Model reference · open weights
gte-Qwen2 is an open-weight embedding model from Alibaba. gte-Qwen2-1.5B-instruct (FP32) weighs 3.6 GB; the smallest configuration that runs it is RTX 3060 12 GB.
Summary of the Alibaba-NLP/gte-Qwen2-1.5B-instruct model card, 2026-10-01
What it is
| Released by | Alibaba |
|---|---|
| Released | 2024-06-29 |
| Parameters | 1.8B |
| VRAM | 3.6 GB for the weights |
What it runs on
| Card | Runs | Memory |
|---|---|---|
| RTX 3060 12 GB | fits | 11.6 GB |
| RTX 4060 Ti 16 GB | fits | 15.4 GB |
| RTX 3090 24 GB | fits | 23.4 GB |
| RTX 4090 24 GB | fits | 23.4 GB |
| RTX 5090 32 GB | fits | 31.0 GB |
| L40S 48 GB | fits | 44.0 GB |
| A100 80 GB | fits | 78.2 GB |
| H100 80 GB | fits | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | fits | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | fits | 107 GB |
| H200 141 GB | fits | 138 GB |
| B200 180 GB | fits | 176 GB |
Builds
| Build | Params | Precision | Weights | Smallest setup |
|---|---|---|---|---|
| gte-Qwen2-1.5B-instruct (above) ↗ | 1.8B | FP32 | 3.6 GB | RTX 3060 12 GB |
| gte-Qwen2-7B-instruct ↗ | 7.6B | FP32 | 15.2 GB | RTX 4090 24 GB |
From the model card
gte-Qwen2-1.5B-instruct is the latest model in the gte (General Text Embedding) model family. The model is built on Qwen2-1.5B LLM model and use the same training data and strategies as the gte-Qwen2-7B-instruct model.
The model incorporates several key advancements:
transformers>=4.39.2
flash_attn>=2.5.6
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Alibaba-NLP/gte-Qwen2-1.5B-instruct", trust_remote_code=True)
# In case you want to reduce the maximum length:
model.max_seq_length = 8192
queries = [
"how much protein should a female eat",
"summit define",
]
documents = [
"As a general guideline, the CDC's average requirement of protein for women ages 19 to 70 is 46 grams per day. But, as you can see from this chart, you'll need to increase that if you're expecting or training for a marathon. Check out the chart below to see how much protein you should be eating each day.",
"Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments.",
]
query_embeddings = model.encode(queries, prompt_name="query")
document_embeddings = model.encode(documents)
scores = (query_embeddings @ document_embeddings.T) * 100
print(scores.tolist())
Observe the config_sentence_transformers.json to see all pre-built prompt names. Otherwise, you can use model.encode(queries, prompt="Instruct: ...\nQuery: " to use a custom prompt of your choice.
import torch
import torch.nn.functional as F
from torch import Tensor
from transformers import AutoTokenizer, AutoModel
def last_token_pool(last_hidden_states: Tensor,
attention_mask: Tensor) -> Tensor:
left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
if left_padding:
return last_hidden_states[:, -1]
else:
sequence_lengths = attention_mask.sum(dim=1) - 1
batch_size = last_hidden_states.shape[0]
return last_hidden_states[torch.arange(batch_size, device=last_hidden_states.device), sequence_lengths]
def get_detailed_instruct(task_description: str, query: str) -> str:
return f'Instruct: {task_description}\nQuery: {query}'
# Each query must come with a one-sentence instruction that describes the task
task = 'Given a web search query, retrieve relevant passages that answer the query'
queries = [
get_detailed_instruct(task, 'how much protein should a female eat'),
get_detailed_instruct(task, 'summit define')
]
# No need to add instruction for retrieval documents
documents = [
"As a general guideline, the CDC's average requirement of protein for women ages 19 to 70 is 46 grams per day. But, as you can see from this chart, you'll need to increase that if you're expecting or training for a marathon. Check out the chart below to see how much protein you should be eating each day.",
"Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments."
]
input_texts = queries + documents
tokenizer = AutoTokenizer.from_pretrained('Alibaba-NLP/gte-Qwen2-1.5B-instruct', trust_remote_code=True)
model = AutoModel.from_pretrained('Alibaba-NLP/gte-Qwen2-1.5B-instruct', trust_remote_code=True)
max_length = 8192
# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=max_length, padding=True, truncation=True, return_tensors='pt')
outputs = model(**batch_dict)
embeddings = last_token_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
# normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
scores = (embeddings[:2] @ embeddings[2:].T) * 100
print(scores.tolist())
Usage via infinity, MIT Licensed.
docker run \
--gpus "0" -p "7997":"7997" \
michaelf34/infinity:0.0.68-trt-onnx \
v2 --model-id Alibaba-NLP/gte-Qwen2-1.5B-instruct --revision "refs/pr/20" --dtype bfloat16 --batch-size 16 --device cuda --engine torch --port 7997 --no-bettertransformer
You can use the scripts/eval_mteb.py to reproduce the following result of gte-Qwen2-1.5B-instruct on MTEB(English)/C-MTEB(Chinese):
| Model Name | MTEB(56) | C-MTEB(35) | MTEB-fr(26) | MTEB-pl(26) |
|---|---|---|---|---|
| bge-base-en-1.5 | 64.23 | - | - | - |
| bge-large-en-1.5 | 63.55 | - | - | - |
| gte-large-en-v1.5 | 65.39 | - | - | - |
| gte-base-en-v1.5 | 64.11 | - | - | - |
| mxbai-embed-large-v1 | 64.68 | - | - | - |
| [acge_text_embedding](https://hug |
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.
Benchmarks
As published on the model card: the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| Classification | MTEB AmazonCounterfactualClassification (en) | accuracy | 83.985 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap | 50.930 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1 | 78.504 |
| Classification | MTEB AmazonPolarityClassification | accuracy | 96.611 |
| Classification | MTEB AmazonPolarityClassification | ap | 94.892 |
| Classification | MTEB AmazonPolarityClassification | f1 | 96.609 |
| Classification | MTEB AmazonReviewsClassification (en) | accuracy | 55.614 |
| Classification | MTEB AmazonReviewsClassification (en) | f1 | 54.906 |
| Retrieval | MTEB ArguAna | map_at_1 | 45.164 |
| Retrieval | MTEB ArguAna | map_at_10 | 61.519 |
| Retrieval | MTEB ArguAna | map_at_100 | 61.769 |
| Retrieval | MTEB ArguAna | map_at_1000 | 61.769 |
| Retrieval | MTEB ArguAna | map_at_3 | 57.444 |
| Retrieval | MTEB ArguAna | map_at_5 | 60.058 |
| Retrieval | MTEB ArguAna | mrr_at_1 | 46.088 |
| Retrieval | MTEB ArguAna | mrr_at_10 | 61.861 |
| Retrieval | MTEB ArguAna | mrr_at_100 | 62.118 |
| Retrieval | MTEB ArguAna | mrr_at_1000 | 62.118 |
| Retrieval | MTEB ArguAna | mrr_at_3 | 57.729 |
| Retrieval | MTEB ArguAna | mrr_at_5 | 60.392 |
| Retrieval | MTEB ArguAna | ndcg_at_1 | 45.164 |
| Retrieval | MTEB ArguAna | ndcg_at_10 | 69.720 |
| Retrieval | MTEB ArguAna | ndcg_at_100 | 70.719 |
| Retrieval | MTEB ArguAna | ndcg_at_1000 | 70.719 |