Skip to content

[QUESTION] data type #223

Closed
Closed

Description

@Napolitain

I see that it says using float16 float32 mixed precision, but as we are talking about characters, shouldn't it uses char8 ?

Activity

  1. jarcen commented on Mar 17, 2023

    @jarcen

    No. Model doesn't operate on characters. Characters are lumped into tokens and tokens are substituted with vectors as shown here:
    https://github.com/ggerganov/llama.cpp/blob/721311070e31464ac12bef9a4444093eb3eaebf7/main.cpp#L579-L582

  2. Napolitain commented on Mar 17, 2023

    @Napolitain
    Author

    my bad I think it uses int4 which is even surprising

  3. Napolitain commented on Mar 17, 2023

    @Napolitain
    Author

    No. Model doesn't operate on characters. Characters are lumped into tokens and tokens are substituted with vectors as shown here:

    https://github.com/ggerganov/llama.cpp/blob/721311070e31464ac12bef9a4444093eb3eaebf7/main.cpp#L579-L582

    characters in C++ is a number within 1 byte

  4. jarcen commented on Mar 17, 2023

    @jarcen

    Groups of those 1-byte numbers are transformed into 32 bit integers called tokens. This process is called tokenization and not shown here. llama_eval accepts list of tokens. The code I shown demonstrates how each token is substituted with vector known as embedding. Data type of vector elements varies. It can be 32 bit float, it can be 16 bit float, it can be 4 bit quantized number. Theoretically vector components could be bits. It doesn't matter because there's thousands of them in one embedding, plenty to uniquely represent a token that in turn represents bunch of UTF-8 characters.

  5. Napolitain commented on Mar 17, 2023

    @Napolitain
    Author

    mhhh whats the effect of quantization ? less nuance in generation / understanding ?

  6. jarcen commented on Mar 17, 2023

    @jarcen

    Ideally none on the side of behavior. Altered behavior is something we try to minimize by picking efficient quantization schemes. Effects that we want from quantization are smaller memory usage and faster speed. Difference between FP32 and 4 bit models is that first requires supercomputer and second runs on Raspberry Pi.

  7. Napolitain commented on Mar 17, 2023

    @Napolitain
    Author

    Yes... sadly this runs on CPU. Is there any way to do the same (ie. running int4 quantized 7B model) on GPU / NPU ? Not sure the standard models implementations allow that.

    Modern phones typically have pretty good NPU / GPU compared to CPU. Could be interesting for say a on-device autocompletion keyboard.

  8. jarcen commented on Mar 17, 2023

    @jarcen

    This codebase is explicitly created to be run on CPU opposed to prevalent GPU implementations. Because everyone have CPU and RAM is upgradeable but not everyone own Nvidia hardware with sufficient VRAM.

    GPU implementations:

    Original Facebook repo:
    https://github.com/facebookresearch/llama

    Huggingface Transformers apparently support Llama judging by people converting models to hf format:
    https://huggingface.co/decapoda-research

    Getting down to 8-bit:
    https://github.com/tloen/llama-int8

    And 4 bit:
    https://github.com/oobabooga/text-generation-webui/

    There's lots of them, really.

  9. added 3 commits that reference this issue on Jun 26, 2026
  10. 7 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions