Views
No views yet
| MTEB English / Models | Param. | Mean(Task) | Mean(Type) | Class. | Clust. | Pair Class. | Rerank. | Retri. | STS | Summ. |
|---|---|---|---|---|---|---|---|---|---|---|
| multilingual-e5-large-instruct | 0.6B | 65.53 | 61.21 | 75.54 | 49.89 | 86.24 | 48.74 | 53.47 | 84.72 | 29.89 |
| NV-Embed-v2 | 7.8B | 69.81 | 65.00 | 87.19 | 47.66 | 88.69 | 49.61 | 62.84 | 83.82 | 35.21 |
| GritLM-7B | 7.2B | 67.07 | 63.22 | 81.25 | 50.82 | 87.29 | 49.59 | 54.95 | 83.03 | 35.65 |
| gte-Qwen2-1.5B-instruct | 1.5B | 67.20 | 63.26 | 85.84 | 53.54 | 87.52 | 49.25 | 50.25 | 82.51 | 33.94 |
| stella_en_1.5B_v5 | 1.5B | 69.43 | 65.32 | 89.38 | 57.06 | 88.02 | 50.19 | 52.42 | 83.27 | 36.91 |
| gte-Qwen2-7B-instruct | 7.6B | 70.72 | 65.77 | 88.52 | 58.97 | 85.9 | 50.47 | 58.09 | 82.69 | 35.74 |
| gemini-embedding-exp-03-07 | - | 73.3 | 67.67 | 90.05 | 59.39 | 87.7 | 48.59 | 64.35 | 85.29 | 38.28 |
| Qwen3-Embedding-0.6B | 0.6B | 70.70 | 64.88 | 85.76 | 54.05 | 84.37 | 48.18 | 61.83 | 86.57 | 33.43 |
| Qwen3-Embedding-4B | 4B | 74.60 | 68.10 | 89.84 | 57.51 | 87.01 | 50.76 | 68.46 | 88.72 | 34.39 |
| Qwen3-Embedding-8B | 8B | 75.22 | 68.71 | 90.43 | 58.57 | 87.52 | 51.56 | 69.44 | 88.58 | 34.83 |
| Tarka-Embedding-V1-Beta | 0.350M | 65.30 | 59.63 | 84.89 | 53.26 | 74.17 | 45.75 | 51.80 | 79.04 | 28.50 |
1# Requires transformers>=4.51.0
2# Requires sentence-transformers>=2.7.0
3
4from sentence_transformers import SentenceTransformer
5
6# Load the model
7model = SentenceTransformer("Tarka-Labs/Tarka-Embedding-V1-Beta")
8
9# We recommend enabling flash_attention_2 for better acceleration and memory saving,
10# together with setting `padding_side` to "left":
11# model = SentenceTransformer(
12# "Tarka-Labs/Tarka-Embedding-V1-Beta",
13# model_kwargs={"attn_implementation": "flash_attention_2", "device_map": "auto"},
14# tokenizer_kwargs={"padding_side": "left"},
15# )
16
17# The queries and documents to embed
18queries = [
19 "What is the capital of China?",
20 "Explain gravity",
21]
22documents = [
23 "The capital of China is Beijing.",
24 "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.",
25]
26
27# Encode the queries and documents. Note that queries benefit from using a prompt
28# Here we use the prompt called "query" stored under `model.prompts`, but you can
29# also pass your own prompt via the `prompt` argument
30query_embeddings = model.encode(queries, prompt_name="query")
31document_embeddings = model.encode(documents)
32
33# Compute the (cosine) similarity between the query and document embeddings
34similarity = model.similarity(query_embeddings, document_embeddings)
35print(similarity)
36
37# tensor([[0.9079, 0.3945],
38# [0.3406, 0.7091]])1# Requires transformers>=4.51.0
2
3import torch
4import torch.nn.functional as F
5
6from torch import Tensor
7from transformers import AutoTokenizer, AutoModel
8
9
10def last_token_pool(last_hidden_states: Tensor,
11 attention_mask: Tensor) -> Tensor:
12 left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
13 if left_padding:
14 return last_hidden_states[:, -1]
15 else:
16 sequence_lengths = attention_mask.sum(dim=1) - 1
17 batch_size = last_hidden_states.shape[0]
18 return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
19
20
21def get_detailed_instruct(task_description: str, query: str) -> str:
22 return f'Instruct: {task_description}\nQuery:{query}'
23
24# Each query must come with a one-sentence instruction that describes the task
25task = 'Given a web search query, retrieve relevant passages that answer the query'
26
27queries = [
28 get_detailed_instruct(task, 'What is the capital of China?'),
29 get_detailed_instruct(task, 'Explain gravity')
30]
31# No need to add instruction for retrieval documents
32documents = [
33 "The capital of China is Beijing.",
34 "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."
35]
36input_texts = queries + documents
37
38tokenizer = AutoTokenizer.from_pretrained('Tarka-Labs/Tarka-Embedding-V1-Beta', padding_side='left')
39model = AutoModel.from_pretrained('Tarka-Labs/Tarka-Embedding-V1-Beta')
40
41# We recommend enabling flash_attention_2 for better acceleration and memory saving.
42# model = AutoModel.from_pretrained('Tarka-Labs/Tarka-Embedding-V1-Beta', attn_implementation="flash_attention_2", torch_dtype=torch.float16).cuda()
43
44max_length = 8192
45
46# Tokenize the input texts
47batch_dict = tokenizer(
48 input_texts,
49 padding=True,
50 truncation=True,
51 max_length=max_length,
52 return_tensors="pt",
53)
54batch_dict.to(model.device)
55outputs = model(**batch_dict)
56embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
57
58# normalize embeddings
59embeddings = F.normalize(embeddings, p=2, dim=1)
60scores = (embeddings[:2] @ embeddings[2:].T)
61print(scores.tolist())
62# [[0.8379101753234863, 0.2661917507648468], [0.20272496342658997, 0.7120912075042725]]1# Requires vllm>=0.8.5
2import torch
3import vllm
4from vllm import LLM
5
6def get_detailed_instruct(task_description: str, query: str) -> str:
7 return f'Instruct: {task_description}\nQuery:{query}'
8
9# Each query must come with a one-sentence instruction that describes the task
10task = 'Given a web search query, retrieve relevant passages that answer the query'
11
12queries = [
13 get_detailed_instruct(task, 'What is the capital of China?'),
14 get_detailed_instruct(task, 'Explain gravity')
15]
16# No need to add instruction for retrieval documents
17documents = [
18 "The capital of China is Beijing.",
19 "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."
20]
21input_texts = queries + documents
22
23model = LLM(model="Tarka-Labs/Tarka-Embedding-V1-Beta", task="embed")
24
25outputs = model.embed(input_texts)
26embeddings = torch.tensor([o.outputs.embedding for o in outputs])
27scores = (embeddings[:2] @ embeddings[2:].T)
28print(scores.tolist())
29# [[0.8431930541992188, 0.2617242932319641], [0.19912847876548767, 0.6638712286949158]]