Instructions to use tencent/EVIE-Preview-4.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ColPali
How to use tencent/EVIE-Preview-4.5B with ColPali:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- sentence-transformers
How to use tencent/EVIE-Preview-4.5B with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("tencent/EVIE-Preview-4.5B") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Integrate with Sentence Transformers via MultiVectorEncoder
Hello @xiaoxiaoshadiao and team!
Congratulations on the big release! I'm quite a fan that you're keeping the dimensionality lower here again, there was a bit of a trend to grow the dimensionality (at huge index costs, obviously), and I think it's important to keep it low to keep these models viable. For context, Sentence Transformers is releasing a MultiVectorEncoder class, planned for around the 18th (so for now the install below pulls from source). I would love to feature this model in that release's blog post and documentation, especially once it loads without the revision pin (that is, once this PR is merged). Your release here is great timing in my opinion!
Heads up, the PR text below was AI-generated and human-reviewed. Here's a summary of the changes as reported by my agent:
Pull Request overview
- Integrate
tencent/EVIE-Preview-4.5Bwith Sentence Transformers as a multi-vector (ColBERT-style late interaction) retriever viaMultiVectorEncoder.
Details
The integration is config-only: no modeling file, no trust_remote_code, and config.json and model.safetensors are untouched. The module pipeline Transformer(feature-extraction) -> Dense(2560->128) -> Normalize -> MultiVectorMask mirrors ColQwen3_5.forward step for step (last hidden state -> custom_text_proj -> L2 normalize -> mask by attention_mask). 1_Dense/model.safetensors is custom_text_proj lifted out of the checkpoint, since AutoModel resolves a bare Qwen3_5Model and would otherwise report those tensors as unexpected. Nothing is retrained.
Bidirectional attention is set through sentence_bert_config.json's config_kwargs (text_config.is_causal=false), which transformers threads into the attention interface, so the 8 full-attention layers become bidirectional while the 24 GatedDeltaNet layers stay recurrent, exactly as enable_bidirectional_attention() intends. A new chat_template.jinja reproduces the two ColQwen3_5Processor prompt formats, and processor_class moves to Qwen3VLProcessor so AutoProcessor resolves without importing colpali-engine. The existing ColQwen3_5 / infer.py / reproduce.py path is untouched and loads the same weights and config as before.
Verified against colpali-engine 0.3.17 in float32: token ids are bit-identical for queries and images, per-item embeddings match at max |diff| 0.0, and the batched MaxSim matrix matches at 0.0.
Unrelated to this PR: model.enable_bidirectional_attention() in your Quick Start does not exist in any released colpali-engine (through 0.3.17), so that snippet raises AttributeError today. Without it the rankings hold but the top-hit MaxSim margins drop by roughly 1.1, so it is worth wiring up.
pip install "sentence-transformers[image] @ git+https://github.com/huggingface/sentence-transformers.git"
from sentence_transformers import MultiVectorEncoder
model = MultiVectorEncoder("tencent/EVIE-Preview-4.5B", revision="refs/pr/1")
queries = [
"What is the variable represented on the y-axis of the graph?",
"Total outlay is maximum in which year?",
]
documents = [
"https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc1.jpg",
"https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc2.jpg",
"https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc3.jpg",
"https://huggingface.co/datasets/sentence-transformers/example-documents/resolve/main/doc4.jpg",
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings[0].shape, document_embeddings[0].shape)
# torch.Size([23, 128]) torch.Size([755, 128])
scores = model.similarity(query_embeddings, document_embeddings)
print(scores)
# tensor([[17.2949, 10.7598, 7.9268, 7.3613],
# [ 6.5547, 13.3711, 6.2627, 6.1104]])
- Tom Aarsen
Hi Tom,
Thanks a lot for this β really nice piece of work, and thanks especially for catching the bidirectional attention issue along the way. That one was on us.
We've pulled your integration in and synced it live. We also cross-checked it against the ColPali path on our side: identical shapes, and the MaxSim scores match to within bfloat16 noise with identical rankings. Your ~1.1 margin drop without bidirectional attention reproduces exactly on our hardware too, so we now ship that fix in the repo β infer.py and reproduce.py work with a plain pip install again.
Two small tweaks we made while merging: we kept ColPali Engine as the first/reference path since all the reported numbers come from it, and fixed the default visual budget to 768 tokens (it drives the input context length; higher is better if you have the memory).
Would love to be featured in the MultiVectorEncoder release post. Thanks again!
Hello!
Thanks a bunch for tackling your very valid concerns re. the default 768 & the location of the ST usage snippet and incorporating this yourself. And as far as I can tell, your method for e.g. using FA2 and updating the visual tokens is exactly right. Awesome!
I'll close this PR as it's integrated now, and then I'll update my blogpost and documentation to show users that they can load this model without any revision or something along those lines. If all goes well, the blogpost should be live on https://huggingface.co/blog in about 1.5 hours!
- Tom Aarsen
Oh @xiaoxiaoshadiao , I just asked my Agent to double-check that everything looks good, and they report that the 1_Dense/model.safetensors is missing! This is MultiVectorEncoder version of the 1.28 MB custom_text_proj (2560 -> 128) projection weights. Can you copy the 1_Dense/model.safetensors from this PR perhaps? Otherwise I'll make a new follow-up PR if that helps. Then we can still mention that it works out of the box without a revision in the blogpost etc.
- Tom Aarsen
Thanks and thanks to your agent too ahhhhh.
Fixed now. The cause is a silent one: our HF repo still carried a .gitignore inherited from the GitHub mirror, with *.safetensors on the first line, and huggingface_hub honours the hosted .gitignore at commit time and skips matching files without failing. So 13 of the 14 files went up and 1_Dense/model.safetensors was quietly dropped while the commit reported success.
shapes: (23, 128) (755, 128)
tensor([[17.3457, 10.8008, 7.8613, 7.3174],
[ 6.5547, 13.3828, 6.2207, 6.0771]])
argmax: [0, 1]
I've removed that .gitignore from the HF repo and re-uploaded the file β it's byte-identical to the one in your PR. Loading without a revision works now, so go ahead with the blogpost.
Thanks for the quick fix! It works great, and my Agent is also happy again π
Exciting!
The release, documentation, and blogpost are now live π€
The blogpost: https://huggingface.co/blog/multi-vector-encoder
- Tom Aarsen