Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Qwen (Alibaba) - Open weights - verified

Qwen3-Embedding-4B embeddings

Qwen3-Embedding-4B is a current embedding model from Qwen (Alibaba), with open weights on Hugging Face at Qwen/Qwen3-Embedding-4B. It returns 2,560-dimension vectors by default and accepts up to 32,768 input tokens, for text and code input. There is no API price: the weights download from Hugging Face under Apache 2.0, and you pay for the compute you run them on.

CurrentModel id: Qwen/Qwen3-Embedding-4B- weights: Qwen/Qwen3-Embedding-4B

Default dims
2,560
Max input
32,768 tok
Price / 1M
Self-hosted
Inputs
Text, Code

Dimensions

Flexible output size
  • 2,560default

Default output: 2,560 dimensions.

Qwen (Alibaba) documents shorter output vectors for this model (Matryoshka-style), so you can store smaller embeddings by asking for fewer dimensions instead of re-embedding with another model.

Pricing

No API price: the weights are on Hugging Face and you run them on your own hardware or host.

Open weights

Hugging Face repo
Qwen/Qwen3-Embedding-4B
License
Apache 2.0apache-2.0
Commercial use
Commercial use allowedCommercial use is allowed, per the license.
Parameters
4.02B (4,021,774,336)

Worth knowing

The card supports user-defined output dimensions from 32 to 2560 (MRL), a 32k context, 100+ languages, and recommends a task instruction on the query side only.

Released . Multilingual: yes.

Usage

Copied verbatim from the page linked below. Placeholders such as project ids and API keys are the source's own.

Python
# 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)

Source: huggingface.co/Qwen/Qwen3-Embedding-4B

FAQ

How many dimensions does Qwen3-Embedding-4B output?

Default output: 2,560 dimensions. Qwen (Alibaba) documents shorter output vectors for this model (Matryoshka-style), so you can store smaller embeddings by asking for fewer dimensions instead of re-embedding with another model.

What is the max input length of Qwen3-Embedding-4B?

32,768 tokens per input, per the model card. Longer text has to be chunked before you embed it.

Can I use Qwen3-Embedding-4B commercially?

Qwen3-Embedding-4B is released under Apache 2.0, and commercial use is allowed. The license text is at https://www.apache.org/licenses/LICENSE-2.0.

What can Qwen3-Embedding-4B embed?

Text and code input, per the provider. It is documented as multilingual.

Sources

Last verified from the pages below.

More Qwen (Alibaba) embedding models

Default dimensions, max input tokens and list price per 1M tokens.

Alibaba Cloud (Qwen) API modelsPrices per 1M tokens, context windows and specs for every Alibaba Cloud (Qwen) model in the API registry.

All embedding models - Open-weight embedding models

Newsletter

New models, every week

One email per week. New model releases, embedding and retrieval updates and what they mean for what you build.