Skip to content

Official BitNet-b1.58-2B-4T GGUF has no tokenizer.ggml.pre: llama.cpp falls back to the default pre-tokenizer and tokenizes differently from the official tokenizer #684

Open

Description

@will3g

Summary

The official GGUF microsoft/bitnet-b1.58-2B-4T-gguf (ggml-model-i2_s.gguf, HF revision a1f2f1c, still the current one) has no tokenizer.ggml.pre key. When it loads, llama.cpp falls back to the default pre-tokenizer and logs:

missing pre-tokenizer type, using: 'default'
GENERATION QUALITY WILL BE DEGRADED!

The model uses the LLaMA 3 tokenizer, which needs the llama-bpe pre-tokenizer. With default, numbers, $ and contractions are split differently from the official tokenizer.json.

Reproduction

Setup: bitnet.cpp 404980e, built with setup_env.py -q i2_s, on an Apple M1 (macOS). The official GGUF above was used unchanged.

Sentence: In 1999, 1234567 people paid $3.50 each; it's 2,560 x 6912.

Tokenization Token ids
HF tokenizer.json (microsoft/bitnet-b1.58-2B-4T rev 04c3b9a) 128000, 644, 220, 2550, 24, 11, 220, 4513, 10961, 22, 1274, 7318, 400, 18, 13, 1135, 1855, 26, 433, 596, 220, 17, 11, 17698, 865, 220, 25168, 17, 13 (29)
bitnet.cpp, GGUF as distributed (llama-cli --verbose-prompt) … 1274, 7318, 220, 3, 18, 13, 1135, 1855, 26, 433, 6, 82, 220, … (31): $3 and it's split differently
bitnet.cpp with --override-kv tokenizer.ggml.pre=str:llama-bpe identical to HF (29)

On the whole WikiText-2 test set (wiki.test.raw):

Effect on perplexity

Protocol: WikiText-2, first 40 chunks of 512 tokens, llama-perplexity protocol, bitnet.cpp 404980e.

Setup PPL
GGUF as distributed 16.74
GGUF with --override-kv tokenizer.ggml.pre=str:llama-bpe 14.963
HF transformers reference, fp32, HF tokens 14.968

The first number scores a different token sequence, so it is not directly comparable per token. Still, with the right pre-tokenizer bitnet.cpp matches the reference within 0.04%.

Suggested fix

Add tokenizer.ggml.pre = "llama-bpe" to the published GGUF, and to whatever pipeline produces it. Until then, passing --override-kv tokenizer.ggml.pre=str:llama-bpe restores the official tokenization.

Activity

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