You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Eval bug: the vector of jina-embeddings-v2-base-zh retrieval result is incorrect. #18452
./build/bin/llama-cli --version
version: 7449 (6853bee)
built with GNU 11.4.0 for Linux x86_64
Operating systems
Linux
GGML backends
CPU
Hardware
AMD EPYC 9K84 96-Core Processor
Models
jina-embeddings-v2-base-zh
Problem description & steps to reproduce
1.Convert HF model to GGUF model:
/app/jczhao/miniconda3/envs/llamacpp/bin/python convert_hf_to_gguf.py
/app/jczhao/jina-embeddings-v2-base-zh
--outfile /app/jczhao/jina-embeddings-v2-base-zh-f32.gguf
--outtype f32
--metadata "general.architecture=encoder"
--metadata "encoder.context_length=8192"
--metadata "general.name=jina-embeddings-v2-base-zh"
--verbose
2.Llama server deployment command:
sudo nohup ./build/bin/llama-server -m /app/jczhao/jina-embeddings-v2-base-zh-f32.gguf -t 24 -c 8192 -b 512 --host 0.0.0.0 --port 7868 --embeddings --cont-batching --no-mmap > llama-server-7.log 2>&1 &
Compared to the official HF model and ONNX model,the vector of jina-embeddings-v2-base-zh gguf model retrieval result is incorrect!
Please help me solve the issue,thanks!
This works correctly for models with ByteLevel pre-tokenizer (like Qwen, LLaMA), where the vocabulary stores byte-encoded tokens (e.g., "ä½łå¥½" → token 108386).
But for Jina, after byte encoding, "你好" becomes "ä½łå¥½", which doesn't exist in the vocabulary, causing fallback to single-byte tokens.
I'm considering adding a GGUF metadata field (set during convert_hf_to_gguf.py) to control ByteLevel encoding, but there might be a cleaner approach.
Hi @CISC, suggestions for a more elegant approach?
Hi @zhaojc001, I've submitted a PR (#18756) for this. The implementation approach might still have some issues, but my current results align with the Python tokenizer. Give it a try if you'd like!
Activity
o7si commentedon Dec 31, 2025
Hi @zhaojc001, Could you provide the cosine similarity score between the embeddings from llama.cpp and the Python implementation?
zhaojc001 commentedon Jan 7, 2026
embedding_similarity_result.json
zhaojc001 commentedon Jan 7, 2026
Hello @o7si Please take a detailed look and fix the issue as soon as possible. let me know if you need any further assistance.
o7si commentedon Jan 8, 2026
This could be a tokenizer issue. Let me take some time to look into it.
zhaojc001 commentedon Jan 9, 2026
o7si commentedon Jan 10, 2026
I've done some investigation on this issue and believe the problem might be related to the tokenizer implementation.
The
jina-embeddings-v2-base-zhmodel uses a simpleWhitespacepre-tokenizer in itstokenizer.json:This means the vocabulary stores tokens as raw Unicode (e.g.,
"你好"→token 49226).However, llama.cpp's BPE tokenizer always applies GPT-2 byte encoding via
unicode_byte_encoding_process()insrc/unicode.cpp:llama.cpp/src/unicode.cpp
Lines 223 to 239 in 9ac2693
This works correctly for models with ByteLevel pre-tokenizer (like Qwen, LLaMA), where the vocabulary stores byte-encoded tokens (e.g.,
"ä½łå¥½"→token 108386).But for
Jina, after byte encoding,"你好"becomes"ä½łå¥½", which doesn't exist in the vocabulary, causing fallback to single-byte tokens.I'm considering adding a GGUF metadata field (set during
convert_hf_to_gguf.py) to control ByteLevel encoding, but there might be a cleaner approach.Hi @CISC, suggestions for a more elegant approach?
o7si commentedon Jan 10, 2026
Expected output (HuggingFace tokenizer)
Actual output (llama.cpp tokenizer)
CISC commentedon Jan 10, 2026
This is technically a very basic, but unsupported tokenizer, perhaps it should just be treated as one (ie, set
tokenizer.ggml.modeltowhitespace)?o7si commentedon Jan 11, 2026
Hi @zhaojc001, I've submitted a PR (#18756) for this. The implementation approach might still have some issues, but my current results align with the Python tokenizer. Give it a try if you'd like!
zhaojc001 commentedon Jan 13, 2026
@o7si Thank you very much.
github-actions commentedon Feb 28, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.