Tarka-AIR/Tarka-Embedding-30M-V1
026
Tarka Embedding 30M V1
[!NOTE] ## Features - Compressed model by 20x. - Recovered approx. 86% performance on MTEB(Eng, v2) Benchmark
For more details refer the blog post
Results
MTEB(Eng, V2)
Usage
from sentence_transformers import SentenceTransformer
# We recommend enabling flash_attention_2 for better acceleration and memory saving,
model = SentenceTransformer(
"Tarka-AIR/Tarka-Embedding-30M-V1",
trust_remote_code=True,
model_kwargs={
"attn_implementation": "flash_attention_2",
"device_map": "cuda",
"torch_dtype": "bfloat16",
},
tokenizer_kwargs={"padding_side": "left"},
)
# Config the model inference mode ("L","M","S")
model[0].auto_model.configure_subnetwork("L")
# 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.8371, 0.1740],
# [0.2176, 0.6293]])
