Skip to main content

Model guide

Qwen3 Embedding 4B

Qwen3-Embedding 4B is a larger retrieval model for applications that can justify the extra model and indexing cost. Compare it with 0.6B using your real queries and relevant passages, not a chat benchmark. Changing the embedding model or vector dimension requires a compatible new index rather than mixing old and new vectors.

4BEmbedding32,768 token contextView the model card →

At a glance

Parameters
4B
Accepts
Text
Returns
Vectors
Published context limit
32,768 tokens
Model format
safetensors · GGUF
Software and download hosts
Ollama · sentence-transformers · TEI. Follow the exact setup below; this list does not establish support for every format, input type or software version.
Suggested compression
Q4_K_M
Model-weight download
Q4_K_M weights · 2.50 GBQwen (model publisher)Qwen3-Embedding-4B-Q4_K_M.gguf
Languages
100+ languages, including programming languages
License
Apache-2.0

Record memory while indexing a batch of your usual passage length. Time one query separately.

Best for

  • Compare retrieval against 0.6B on the questions your index actually receives. Measure the change in relevant top results and indexing time.

Choose something else when

  • The Python example downloads 8.04 GB of native weights, even if you already downloaded the separate GGUF.

Using this model for document search

Select this model for the document-search step in an app that supports it. Keep the model that generates answers separate. Check document chunk length and any required query or document prefixes in the model’s instructions.

Changing the embedding model changes the document vectors. Rebuild the document index rather than mixing vectors from different models.

First setup

The Python workflow loads Qwen/Qwen3-Embedding-4B (8.04 GB for the safetensors weights, plus tokenizer/configuration files). The 2.50 GB Q4_K_M GGUF is a separate download for a compatible GGUF model runner; the Python example does not load it. Loaded memory depends on dtype, input length, batch size and model runner.

Install sentence-transformers with python -m pip install -U sentence-transformers. This example uses CPU and short text.

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Qwen/Qwen3-Embedding-4B", device="cpu")
query = model.encode(["When does the meeting start?"], prompt_name="query", batch_size=1)
documents = model.encode(["The meeting starts at 10:30.", "Lunch is at noon."], batch_size=1)
print(query.shape, documents.shape)
print(model.similarity(query, documents))

Expect one query vector, two document vectors and two similarity values. Check whether the meeting passage ranks above the lunch passage. These values do not establish that a generated answer is correct. Keep query and document prompting consistent when building a real index; rebuild it when changing the model.

Save the Python example as example.py, then run python example.py in the environment where you installed its packages. The first run downloads model files; later local execution still needs the cached files. Start with these short inputs and batch size 1. If loading runs out of memory, close other model processes or use a smaller model; do not interpret missing output as an empty search result. See the publisher model card for the full workflow.

For a 768-dimensional index, add truncate_dim=768 to the SentenceTransformer constructor. Encode both queries and documents with that same instance; rebuild existing document vectors before searching the index.

Other models for this task