Qwen3-Embedding 4B
Alibaba (Qwen) · Qwen/Qwen3-Embedding-4B
Weights license: Apache 2.0 · code and components may use other terms
Quality
MTEB (Multilingual, v2)
Mean(task) · 0–100 · higher is better · this model outlined
- Color = publisher
Source: MTEB results dataset (independent runs, CC0) · publisher-reported where the model card is the only source · other benchmarks and versions are not mixed in
| MTEB (Multilingual, v2) | mean(task) · 2560d | 69.45 | independent run |
|---|---|---|---|
| MTEB (eng, v2) | mean(task) · 2560d | 74.60 | independent run |
Reported by the publisher
- Mean (Task)
- 69.45MTEB (Multilingual) · MTEB
- Mean (Type)
- 60.86MTEB (Multilingual) · MTEB
- Bitxt Mining
- 79.36MTEB (Multilingual) · MTEB
- Class.
- 72.33MTEB (Multilingual) · MTEB
- Clust.
- 57.15MTEB (Multilingual) · MTEB
- Inst. Retri.
- 11.56MTEB (Multilingual) · MTEB
- Multi. Class.
- 26.77MTEB (Multilingual) · MTEB
- Pair. Class.
- 85.05MTEB (Multilingual) · MTEB
Every reported result
- Rerank
- 65.08MTEB (Multilingual) · MTEB
- Retri.
- 69.60MTEB (Multilingual) · MTEB
- STS
- 80.86MTEB (Multilingual) · MTEB
- Mean (Task)
- 74.60MTEB (Eng v2) · MTEB
- Mean (Type)
- 68.10MTEB (Eng v2) · MTEB
- Class.
- 89.84MTEB (Eng v2) · MTEB
- Clust.
- 57.51MTEB (Eng v2) · MTEB
- Pair Class.
- 87.01MTEB (Eng v2) · MTEB
- Rerank.
- 50.76MTEB (Eng v2) · MTEB
- Retri.
- 68.46MTEB (Eng v2) · MTEB
- STS
- 88.72MTEB (Eng v2) · MTEB
- Summ.
- 34.39MTEB (Eng v2) · MTEB
- Mean (Task)
- 72.27C-MTEB (MTEB Chinese) · MTEB
- Mean (Type)
- 73.51C-MTEB (MTEB Chinese) · MTEB
- Class.
- 75.46C-MTEB (MTEB Chinese) · MTEB
- Clust.
- 77.89C-MTEB (MTEB Chinese) · MTEB
- Pair Class.
- 83.34C-MTEB (MTEB Chinese) · MTEB
- Rerank.
- 66.05C-MTEB (MTEB Chinese) · MTEB
- Retr.
- 77.03C-MTEB (MTEB Chinese) · MTEB
- STS
- 61.26C-MTEB (MTEB Chinese) · MTEB
Values as printed on the card, with the publisher's own settings (card section: Evaluation › MTEB (Multilingual); Evaluation › MTEB (Eng v2)); column “Qwen3-Embedding-4B”. Not comparable across publishers and not used in any ranking. Model card
Quality × memory
No comparable quality × memory pair
Embedding memory estimates cluster at a few GB, so a quality × memory chart would not separate these models; MTEB is ranked above instead.
Consider Qwen3-Embedding 4B for retrieval and semantic search: it turns text into 2,560-dimension vectors.
The publisher states no memory figure; the hardware list uses a ~7 GB planning estimate, a ceiling and not a measurement. See the prompt format under How to run. PT-BR is confirmed by a source.
Runs on
Fast memory holds it 114
The planning estimate fits the memory the model can use quickly: graphics card VRAM, or unified memory within the macOS GPU share.
Show all 114
One memory tier short 4
The same machines with the next memory size up would hold it in fast memory.
Hardware profiles grouped by the embedding planning estimate (8-bit weights, 20% allowance, 2 GB reserve). Not a measured fit.
Measured speed
No published measurement for this checkpoint
Throughput (texts per second) is shown only when a source publishes it with hardware, build and setup. It is never estimated.
How to run
The planning estimate uses 8-bit weights, 20% working allowance and a 2 GB reserve; it is a ceiling, not a measurement.
- Runs in
- Ollama, Sentence Transformers, Transformerssource
- Query/document prompts
- Queries: prepend a one-sentence task instruction in the form “Instruct: {task} Query: {query}”. Documents: no prefix.
- Languages · PT-BR
- 100+ languages, including programming languages (model card)PT-BR confirmed by a source
Documented ways to run it
Copied as printed in the linked source (read 2026-10-18); not run by this site.
# Requires transformers>=4.51.0
# Requires sentence-transformers>=2.7.0
from sentence_transformers import SentenceTransformer
# Load the model
model = SentenceTransformer("Qwen/Qwen3-Embedding-4B")
# We recommend enabling flash_attention_2 for better acceleration and memory saving,
# together with setting `padding_side` to "left":
# model = SentenceTransformer(
# "Qwen/Qwen3-Embedding-4B",
# model_kwargs={"attn_implementation": "flash_attention_2", "device_map": "auto"},
# tokenizer_kwargs={"padding_side": "left"},
# )
# The queries and documents to embed
queries = [
"What is the capital of China?",
"Explain gravity",
]
documents = [
"The capital of China is Beijing.",
"Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun.",
]
# Encode the queries and documents. Note that queries benefit from using a prompt
# Here we use the prompt called "query" stored under `model.prompts`, but you can
# also pass your own prompt via the `prompt` argument
query_embeddings = model.encode(queries, prompt_name="query")
document_embeddings = model.encode(documents)
# Compute the (cosine) similarity between the query and document embeddings
similarity = model.similarity(query_embeddings, document_embeddings)
print(similarity)
# tensor([[0.7534, 0.1147],
# [0.0320, 0.6258]])# Requires transformers>=4.51.0
import torch
import torch.nn.functional as F
from torch import Tensor
from transformers import AutoTokenizer, AutoModel
def last_token_pool(last_hidden_states: Tensor,
attention_mask: Tensor) -> Tensor:
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
if left_padding:
return last_hidden_states[:, -1]
else:
sequence_lengths = attention_mask.sum(dim=1) - 1
batch_size = last_hidden_states.shape[0]
return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
def get_detailed_instruct(task_description: str, query: str) -> str:
return f'Instruct: {task_description}\nQuery:{query}'
# Each query must come with a one-sentence instruction that describes the task
task = 'Given a web search query, retrieve relevant passages that answer the query'
queries = [
get_detailed_instruct(task, 'What is the capital of China?'),
get_detailed_instruct(task, 'Explain gravity')
]
# No need to add instruction for retrieval documents
documents = [
"The capital of China is Beijing.",
"Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
]
input_texts = queries + documents
tokenizer = AutoTokenizer.from_pretrained('Qwen/Qwen3-Embedding-4B', padding_side='left')
model = AutoModel.from_pretrained('Qwen/Qwen3-Embedding-4B')
# We recommend enabling flash_attention_2 for better acceleration and memory saving.
# model = AutoModel.from_pretrained('Qwen/Qwen3-Embedding-4B', attn_implementation="flash_attention_2", torch_dtype=torch.float16).cuda()
max_length = 8192
# Tokenize the input texts
batch_dict = tokenizer(
input_texts,
padding=True,
truncation=True,
max_length=max_length,
return_tensors="pt",
)
batch_dict.to(model.device)
outputs = model(**batch_dict)
embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
# normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
scores = (embeddings[:2] @ embeddings[2:].T)
print(scores.tolist())
# [[0.7534257769584656, 0.1146894246339798], [0.03198453038930893, 0.6258305311203003]]# Requires vllm>=0.8.5
import torch
import vllm
from vllm import LLM
def get_detailed_instruct(task_description: str, query: str) -> str:
return f'Instruct: {task_description}\nQuery:{query}'
# Each query must come with a one-sentence instruction that describes the task
task = 'Given a web search query, retrieve relevant passages that answer the query'
queries = [
get_detailed_instruct(task, 'What is the capital of China?'),
get_detailed_instruct(task, 'Explain gravity')
]
# No need to add instruction for retrieval documents
documents = [
"The capital of China is Beijing.",
"Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
]
input_texts = queries + documents
model = LLM(model="Qwen/Qwen3-Embedding-4B", task="embed")
outputs = model.embed(input_texts)
embeddings = torch.tensor([o.outputs.embedding for o in outputs])
scores = (embeddings[:2] @ embeddings[2:].T)
print(scores.tolist())
# [[0.7525103688240051, 0.1143278032541275], [0.030893627554178238, 0.6239761114120483]]Technical details
What the source and the catalog store for this checkpoint. Missing fields are left out, never zero.
- Checkpoint / source
- Qwen/Qwen3-Embedding-4B
- Task
- embeddings for search (feature extraction)
- Library in source
- Ollama, Sentence Transformers, Transformers
- Weight license
- Apache 2.0
- Commercial use
- Allowed Apache License 2.0 text (SPDX) · read 2026-10-18license text
- Parameter basis
- Hub safetensors total (4,021,774,336 parameters, read 2026-10-07 from the Hub API); publishers round it in their names.
- Announced
- 2025-06-05
The card states a 32K sequence length and output sizes from 32 to 2560 (“user-defined”), so there is no fixed list of Matryoshka sizes; the model card lists Portuguese nowhere by name, only “100+ languages”. Instructions are recommended in English.
Sources
Identity and published specifications come from the checkpoint page. Benchmark scores belong to the named release and do not measure speed on your computer.
- Publisher model card
- Hugging Face model page / card · 2026-10-07
- Hugging Face API (parameters, licence, library) · 2026-10-07
- Ollama library (availability only) · 2026-10-07
- MTEB results dataset (CC0), scores computed by scripts/ingest-mteb-results.mjs · 2026-10-25
- Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Models | Qwen · 2026-10-09
Curated facts checked: 2026-10-07. Each value cites its source (the publisher's card or the MTEB results dataset); estimates are labelled as estimates, and a value no source states stays empty. A repository commit is not a model release date.





























































