Views
No views yet


jina-embeddings-v5-text-nano-retrieval outperforms existing state-of-the-art models of similar size across diverse embedding benchmarks.| Feature | Value |
|---|---|
| Parameters | 239M |
| Supported Tasks | retrieval |
| Max Sequence Length | 8192 |
| Embedding Dimension | 768 |
| Matryoshka Dimensions | 32, 64, 128, 256, 512, 768 |
| Pooling Strategy | Last-token pooling |
| Base Model | jinaai/jina-embeddings-v5-text-nano |

transformers>=5.1.0torch>=2.8.0peft>=0.15.2vllm==0.15.1sentence-transformers interface, install this package as well.1PUT _inference/text_embedding/jina-v5
2{
3 "service": "elastic",
4 "service_settings": {
5 "model_id": "jina-embeddings-v5-text-nano"
6 }
7}1from sentence_transformers import SentenceTransformer
2import torch
3
4model = SentenceTransformer(
5 "jinaai/jina-embeddings-v5-text-nano-retrieval",
6 trust_remote_code=True,
7 model_kwargs={"dtype": torch.bfloat16}, # Recommended for GPUs
8 config_kwargs={"_attn_implementation": "flash_attention_2"}, # Recommended but optional
9)
10# Optional: set truncate_dim in encode() to control embedding size
11
12query = "Which planet is known as the Red Planet?"
13documents = [
14 "Venus is often called Earth's twin because of its similar size and proximity.",
15 "Mars, known for its reddish appearance, is often referred to as the Red Planet.",
16 "Jupiter, the largest planet in our solar system, has a prominent red spot.",
17 "Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
18]
19
20# Encode query and documents
21query_embeddings = model.encode(sentences=query, prompt_name="query")
22document_embeddings = model.encode(sentences=documents, prompt_name="document")
23print(query_embeddings.shape, document_embeddings.shape)
24# (768,) (4, 768)
25
26similarity = model.similarity(query_embeddings, document_embeddings)
27print(similarity)
28# tensor([[0.5013, 0.7914, 0.6133, 0.5736]])1from vllm import LLM
2from vllm.config.pooler import PoolerConfig
3
4# Initialize model
5name = "jinaai/jina-embeddings-v5-text-nano-retrieval"
6model = LLM(
7 model=name,
8 dtype="float16",
9 runner="pooling",
10 trust_remote_code=True,
11 pooler_config=PoolerConfig(seq_pooling_type="LAST", normalize=True),
12)
13
14# Create text prompts
15query = "Overview of climate change impacts on coastal cities"
16query_prompt = f"Query: {query}"
17
18document = "The impacts of climate change on coastal cities are significant.."
19document_prompt = f"Document: {document}"
20
21# Encode all prompts
22prompts = [query_prompt, document_prompt]
23outputs = model.encode(prompts, pooling_task="embed")
24jinaai/jina-embeddings-v5-text-nano, which is not yet supported by llama.cpp, we provide our own branch of llama.cpp, which implements the necessary changes to support it for now.llama-server \
-hf jinaai/jina-embeddings-v5-text-nano-retrieval:F16 \
--embedding \
--pooling last \
--batch-size 8192 \
--ubatch-size 8192 \
--ctx-size 8192curl -X POST "http://127.0.0.1:8080/v1/embeddings" \
-H "Content-Type: application/json" \
-d '{
"input": [
"Query: A beautiful sunset over the beach",
"Query: Un beau coucher de soleil sur la plage",
"Document: 海滩上美丽的日落",
"Document: 浜辺に沈む美しい夕日",
"Document: Golden sunlight melts into the horizon, painting waves in warm amber and rose, while the sky whispers goodnight to the quiet, endless sea."
]
}'Query: or Document: prefix in front of your input as shown above.optimum library. Make sure you have the required dependencies installed (e.g., pip install optimum[onnxruntime] transformers torch):1from optimum.onnxruntime import ORTModelForFeatureExtraction
2from transformers import AutoTokenizer
3import torch
4
5model_id = "jinaai/jina-embeddings-v5-text-nano-retrieval"
6
7# 1. Load tokenizer and ONNX model
8# We specify the subfolder 'onnx' where the weights are located
9tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
10model = ORTModelForFeatureExtraction.from_pretrained(
11 model_id,
12 subfolder="onnx",
13 file_name="model.onnx",
14 provider="CPUExecutionProvider", # Or "CUDAExecutionProvider" for GPU
15 trust_remote_code=True,
16)
17
18# 2. Prepare input
19texts = ["Query: How do I use Jina ONNX models?", "Document: Information about semantic matching."]
20inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
21
22
23# 4. Inference
24with torch.no_grad():
25 outputs = model(**inputs)
26
27# 5. Pooling (Crucial for Jina-v5)
28# Jina-v5 uses LAST-TOKEN pooling.
29# We take the hidden state of the last non-padding token.
30last_hidden_state = outputs.last_hidden_state
31# Find the indices of the last token (usually the end of the sequence)
32sequence_lengths = inputs.attention_mask.sum(dim=1) - 1
33embeddings = last_hidden_state[torch.arange(last_hidden_state.size(0)), sequence_lengths]
34
35print('embeddings shape:', embeddings.shape)
36print('embeddings:', embeddings)jina-embeddings-v5-text-nano-retrieval useful in your research, please cite the following paper:@misc{akram2026jinaembeddingsv5texttasktargetedembeddingdistillation,
title={jina-embeddings-v5-text: Task-Targeted Embedding Distillation},
author={Mohammad Kalim Akram and Saba Sturua and Nastia Havriushenko and Quentin Herreros and Michael Günther and Maximilian Werk and Han Xiao},
year={2026},
eprint={2602.15547},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2602.15547},
}