# Qwen3 Embedding 4B

Qwen3 Embedding 4B is a dual-encoder model with 36 transformer layers and a 2560-dimensional vector space, occupying the quality-efficiency middle ground of the Qwen3 Embedding family for retrieval tasks across text and code in more than 100 languages.

- **Model ID:** `alibaba/qwen3-embedding-4b`
- **Type:** embedding
- **Providers:** deepinfra
- **Context window:** 32,768
- **Maximum output tokens:** 32,768
- **Pricing:** $0.02/1M input tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/qwen3-embedding-4b

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { embed } from 'ai';

const result = await embed({
  model: 'alibaba/qwen3-embedding-4b',
  value: 'Sunny day at the beach',
})
```

## About

Qwen3 Embedding 4B represents the middle tier of the Qwen3 Embedding family, balancing retrieval quality against operational cost. Its 2560-dimensional output space captures richer semantic structure than the 0.6B variant, which translates to measurably better performance on dense retrieval benchmarks and multilingual similarity tasks without reaching the full resource requirements of the 8B model.

The embeddings handle asymmetric retrieval tasks where a short user query must match longer documents, and support user-defined instruction prefixes to adapt the embedding space to a specific domain or retrieval intent. Cross-lingual transfer is stable across the 100+ natural languages and multiple programming languages the Qwen3 Embedding family covers.

The context window of 32.8K tokens allows Qwen3 Embedding 4B to embed substantial passages in one shot, reducing the need for aggressive chunking in document-heavy workflows. Combined with Matryoshka Representation Learning (MRL), dimension counts can be adjusted at query time to trade off storage against precision, giving teams flexibility when scaling a vector index.

## What to consider

Provider selection is most consequential when your use case combines high query volume with data-sovereignty requirements, verify each provider's regional availability before finalizing your architecture.

## When to use

### Best For

- Enterprise search applications that require high multilingual precision but can't justify the full cost of an 8B model
- Semantic similarity scoring and clustering in datasets that span many languages or mix natural-language with code
- RAG pipelines serving diverse user populations where retrieval quality visibly affects answer accuracy
- Cross-lingual document alignment tasks where 2560-dimensional vectors provide better discriminability than smaller alternatives

### Consider Alternatives When

- If throughput and cost efficiency are the dominant constraints and slightly lower recall is acceptable, the 0.6B variant may be sufficient
- If you need the absolute highest retrieval precision for a specialized domain with dense, technical vocabulary, the 8B model may serve better
- Your application requires generative text output rather than vector representations (this model produces embeddings only)

## Best for

- **Enterprise multilingual search:** Applications that require high multilingual precision but can't justify the full cost of an 8B model
- **Semantic similarity and clustering:** Datasets that span many languages or mix natural language with code
- **Quality-sensitive RAG:** Pipelines serving diverse user populations where retrieval quality visibly affects answer accuracy
- **Cross-lingual alignment:** Document alignment tasks where 2560-dimensional vectors provide better discriminability than smaller alternatives

## Consider alternatives

- **Throughput and cost first:** Dominant constraints where slightly lower recall is acceptable make the 0.6B variant sufficient
- **Maximum retrieval precision:** Specialized domains with dense, technical vocabulary may be better served by the 8B model
- **Generative output required:** This model produces embeddings only; use a generative model when you need text output

## Frequently asked questions

### What output dimensionality does Qwen3 Embedding 4B produce?

The model outputs 2560-dimensional vectors by default. Matryoshka Representation Learning allows prefix truncation to smaller sizes if storage or query-speed budgets require it.

### How does the 4B model differ architecturally from the 0.6B and 8B variants?

All three variants use a dual-encoder structure and share the same context window of 32.8K tokens. The 4B model uses 36 layers (compared to 28 in the 0.6B) and produces 2560-dimensional vectors, wider than the 0.6B's 1024 dimensions but narrower than the 8B's 4096.

### What multilingual coverage does Qwen3 Embedding 4B support?

Qwen3 Embedding 4B covers more than 100 natural languages plus multiple programming languages, enabling cross-lingual and code-retrieval tasks within a single embedding space.

### Can instruction prefixes change what the model retrieves?

Yes. The model supports custom instruction prefixes at query time to guide the embedding toward a specific retrieval task, such as legal document search vs. general knowledge retrieval.

### Is this model appropriate for code-retrieval tasks alongside natural language?

Yes. The Qwen3 Embedding models explicitly include code in their language coverage, so hybrid corpora of code and prose can be embedded in the same vector space.

### How does chunking strategy affect retrieval quality at context of 32.8K tokens?

Longer passages embedded as single units can yield better recall for complex queries, but very long inputs near the ceiling of 32.8K tokens may dilute specificity. Experiments with paragraph-level vs. section-level chunking are worthwhile for your specific domain.

## Links

- [Model page](https://vercel.com/ai-gateway/models/qwen3-embedding-4b)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://deepinfra.com/Qwen/Qwen3-Embedding-4B)
- [Provider pricing](https://deepinfra.com/pricing)
