Repository navigation
Qwen3-Embedding models do not work #611
Copy link
Copy link
Open
Description
Model description
The qwen3 models easily outperform nearly every other open source model for embeddings, however it does not work in infinity due to outdated transformers.
My docker compose file:
version: '3.8'
services:
infinity:
image: michaelf34/infinity:latest
environment:
DO_NOT_TRACK: 1 # Disable telemetry
INFINITY_BETTERTRANSFORMER: True
HF_HOME: /app/data # Use /app/data
INFINITY_MODEL_ID: Qwen/Qwen3-Embedding-4B;Qwen/Qwen3-Reranker-4B # Model(s), semicolon separated
INFINITY_PORT: 7997 # Port
INFINITY_API_KEY: foo # Optional API key
INFINITY_DEVICE: cuda
INFINITY_VECTOR_DISK_CACHE: True
volumes:
- ./infinity:/app/data:rw # Persist /app/data to ./infinity in the current directory
- ./models:/data/models:ro # Mount local models to /data/models in read-only mode
- ./infinity:/data/hf_cache:rw # Mount cache data to /data/hf_cache in read-write mode
ports:
- "7997:7997" # Flexible port mapping
command: v2
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
volumes:
infinity: # Named volume declaration
This results in the error:
infinity-1 | ValueError: The checkpoint you are trying to load has model type `qwen3` but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.
To fix this, you should just be able to update transformers to >4.51.0 as per the qwen documentation.
Open source status & huggingface transformers.
- The model implementation is available on transformers
- The model weights are available on huggingface-hub
- I verified that the model is currently not running in the latest version
pip install infinity_emb[all] --upgrade - I made the authors of the model aware that I want to use it with infinity_emb & check if they are aware of the issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
wirthual commentedon Jun 30, 2025
Hi,
thank you for reporting this. Related issue: #598
Until a new docker image is released, you should be able to build a custom docker image by following the suggestions in the linked issue.
GhostDog98 commentedon Jun 30, 2025
Is there any way to do this without needing to completely rebuild all of the docker containers?
I'm aware I could technically do something like
But that seems really arduous and kind of janky
GhostDog98 commentedon Jun 30, 2025
Okay i found a kinda workaround, if you simply add the following line to your docker-compose it will update those packages every start before starting infinity:
okpedro commentedon Jul 5, 2025
You don't need to run the commands on every start. Just build a custom image where those commands are run when building the image.
Create a "Dockerfile" with the following:
Now change your docker-compose.yaml file from this:
...to this:
Run
docker compose up -dand you're done. Then revert to the original image once it has been patched.GhostDog98 commentedon Jul 6, 2025
I'm aware, however constraints in my current environment mean that injecting the commands is the simplest way to do things, though your approach is better if a user is able to build another image etc.
zengqingfu1442 commentedon Jul 17, 2025
I updated transformers but it still not support Qwen3-reranker-8B model。
Here is my dockerfile:
docker-compose.yml:
After deployed, the rerank api call returns error.
api call command:
errors:
bakongi commentedon Aug 18, 2025
I use this code to run Qwen3 embedding and reranking models:
matfax commentedon Aug 23, 2025
Related: microsoft/onnxruntime#25083 for optimization. Bert should work for the Embedding and Reranking models. The generative Qwen3 models would probably benefit from the Phi optimizer, as they also use GQA and RoPE. The model support is also missing in huggingface/optimum-onnx.
Also will depend on #619 for supporting newer transformers packages.
IlyasMoutawwakil commentedon Oct 6, 2025
@matfax I added a note on the issue you linked ; The qwen3-moe is supported in optimum-onnx, I just think the way it is constrained to be exported (looping over all experts) is suboptimal for inference.
matfax commentedon Oct 6, 2025
Optimum seemed to have issues with Embedding in particular. I couldn't get this running on ONNX/TRT in a non-broken/accurate state. As far as I recall, they use an instruction that breaks the optimization, that's technically not in the opset version. The uploaded ONNX versions on HF either don't seem to work on onnxruntime or they work, but produce inaccurate vectors. There's also a number of other issues with the input mapping and weights that I don't recall. So it's not the export itself, but any attempt to optimize and quantize with optimum or TRT. And without any of these optimizations, GGUF seems to be the better pick. So, while it seems to be possible to run the Embedding and Reranking models, it's just not with any of the benefits one would expect in memory/inference speed.
https://forums.developer.nvidia.com/t/tensorrt-produce-all-zero-output-for-qwen3-embedding-0-6b/337047/4
arnonuem commentedon Nov 13, 2025
When i try to upgrade the transformers, its saying that is then incompatible with the colpali-engine.
I can not get it running with QWEN3-EMBEDDING-0.6B :(
Any ideas?
In the Dockerfile i did this:
and this is the entrypoint.sh
I also wanted to have a model downloader and separate the model from the image itself to make it smaller.
But when i run it i get:
wirthual commentedon Nov 14, 2025
Infinity creates its own virtual environment inside the container, so try to run it from
/app/.venv/bin/python3.10:Working:
ehartford commentedon Jan 25, 2026
i fixed this with a docker-compose.yml like this:
dotmobo commentedon Feb 9, 2026
Hey some news here about a real fix ? I tried to fix poetry dependencies for transformers and colpali-engine but then, i have some mypy errors during the Dockerfile build ...
I'm on OpenShift so i cannot use hack like post install because of permission denied.
This project is still alive or should we migrate on vllm for embedding/reranking ?