Model reference · open weights
gme-Qwen2-VL is an open-weight embedding model from Alibaba-NLP. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Maker | Alibaba-NLP |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 2.2B |
| Context | 32k tokens |
| Runs with | sentence-transformers |
| Based on | Qwen/Qwen2-VL-2B-Instruct |
| Released | 2024-12-21 |
| Popularity | 18k downloads / month |
| Licence | Open weights |
About
We are excited to present GME-Qwen2VL series of unified multimodal embedding models,
which are based on the advanced Qwen2-VL multimodal large language models (MLLMs).
The GME models support three types of input: text, image, and image-text pair, all of which can produce universal vector representations and have powerful retrieval performance.
Key Enhancements of GME Models:
Qwen2-VL and our training data, GME models support dynamic resolution image input.Developed by: Tongyi Lab, Alibaba Group
Paper: GME: Improving Universal Multimodal Retrieval by Multimodal LLMs
| Models | Model Size | Max Seq. Length | Dimension | MTEB-en | MTEB-zh | UMRB |
|---|---|---|---|---|---|---|
gme-Qwen2-VL-2B | 2.21B | 32768 | 1536 | 65.27 | 66.92 | 64.45 |
gme-Qwen2-VL-7B | 8.29B | 32768 | 3584 | 67.48 | 69.73 | 67.44 |
Transformers
The remote code has some issues with transformers>=4.52.0, please downgrade or use sentence_transformers
from transformers import AutoModel
from transformers.utils.versions import require_version
require_version(
"transformers<4.52.0",
"The remote code has some issues with transformers>=4.52.0, please downgrade: pip install transformers==4.51.3"
)
t2i_prompt = 'Find an image that matches the given text.'
texts = [
"The Tesla Cybertruck is a battery electric pickup truck built by Tesla, Inc. since 2023.",
"Alibaba office.",
]
images = [
'https://upload.wikimedia.org/wikipedia/commons/e/e9/Tesla_Cybertruck_damaged_window.jpg',
'https://upload.wikimedia.org/wikipedia/commons/e/e0/TaobaoCity_Alibaba_Xixi_Park.jpg',
]
gme = AutoModel.from_pretrained(
"Alibaba-NLP/gme-Qwen2-VL-2B-Instruct",
torch_dtype="float16", device_map='cuda', trust_remote_code=True
)
# Single-modal embedding
e_text = gme.get_text_embeddings(texts=texts)
e_image = gme.get_image_embeddings(images=images)
print('Single-modal', (e_text @ e_image.T).tolist())
## Single-modal [[0.359619140625, 0.0655517578125], [0.04180908203125, 0.374755859375]]
# How to set embedding instruction
e_query = gme.get_text_embeddings(texts=texts, instruction=t2i_prompt)
# If is_query=False, we always use the default instruction.
e_corpus = gme.get_image_embeddings(images=images, is_query=False)
print('Single-modal with instruction', (e_query @ e_corpus.T).tolist())
## Single-modal with instruction [[0.429931640625, 0.11505126953125], [0.049835205078125, 0.409423828125]]
# Fused-modal embedding
e_fused = gme.get_fused_embeddings(texts=texts, images=images)
print('Fused-modal', (e_fused @ e_fused.T).tolist())
## Fused-modal [[1.0, 0.05511474609375], [0.05511474609375, 1.0]]
sentence_transformers
The encode function accept str or dict with key(s) in {'text', 'image', 'prompt'}.
Do not pass prompt as the argument to encode, pass as the input as a dict with a prompt key.
from sentence_transformers import SentenceTransformer
t2i_prompt = 'Find an image that matches the given text.'
texts = [
"The Tesla Cybertruck is a battery electric pickup truck built by Tesla, Inc. since 2023.",
"Alibaba office.",
]
images = [
'https://upload.wikimedia.org/wikipedia/commons/e/e9/Tesla_Cybertruck_damaged_window.jpg',
'https://upload.wikimedia.org/wikipedia/commons/e/e0/TaobaoCity_Alibaba_Xixi_Park.jpg',
]
gme_st = SentenceTransformer("Alibaba-NLP/gme-Qwen2-VL-2B-Instruct")
# Single-modal embedding
e_text = gme_st.encode(texts, convert_to_tensor=True)
e_image = gme_st.encode([dict(image=i) for i in images], convert_to_tensor=True)
print('Single-modal', (e_text @ e_image.T).tolist())
## Single-modal [[0.356201171875, 0.06536865234375], [0.041717529296875, 0.37890625]]
# How to set embedding instruction
e_query = gme_st.encode([dict(text=t, prompt=t2i_prompt) for t in texts], convert_to_tensor=True)
# If no prompt, we always use the default instruction.
e_corpus = gme_st.encode([dict(image=i) for i in images], convert_to_tensor=True)
print('Single-modal with instruction', (e_query @ e_corpus.T).tolist())
## Single-modal with instruction [[0.425537109375, 0.1158447265625], [0.049835205078125, 0.413818359375]]
# Fused-modal embedding
e_fused = gme_st.encode([dict(text=t, image=i) for t, i in zip(texts, images)], convert_to_tensor=True)
print('Fused-modal', (e_fused @ e_fused.T).tolist())
## Fused-modal [[0.99951171875, 0.0556640625], [0.0556640625, 0.99951171875]]
We validated the performance on our universal multimodal retrieval benchmark (UMRB, see Release UMRB) among others.
| | | Single-modal |
From the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| STS | MTEB AFQMC | cos_sim_pearson | 61.032 |
| STS | MTEB AFQMC | cos_sim_spearman | 67.549 |
| STS | MTEB AFQMC | euclidean_pearson | 65.390 |
| STS | MTEB AFQMC | euclidean_spearman | 67.549 |
| STS | MTEB AFQMC | manhattan_pearson | 65.253 |
| STS | MTEB AFQMC | manhattan_spearman | 67.342 |
| STS | MTEB ATEC | cos_sim_pearson | 50.838 |
| STS | MTEB ATEC | cos_sim_spearman | 54.032 |
| STS | MTEB ATEC | euclidean_pearson | 55.207 |
| STS | MTEB ATEC | euclidean_spearman | 54.032 |
| STS | MTEB ATEC | manhattan_pearson | 55.052 |
| STS | MTEB ATEC | manhattan_spearman | 53.813 |
| Classification | MTEB AmazonCounterfactualClassification (en) | accuracy | 72.552 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap | 35.015 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1 | 66.441 |
| Classification | MTEB AmazonPolarityClassification | accuracy | 96.758 |
| Classification | MTEB AmazonPolarityClassification | ap | 95.510 |
| Classification | MTEB AmazonPolarityClassification | f1 | 96.757 |
| Classification | MTEB AmazonReviewsClassification (en) | accuracy | 61.972 |
| Classification | MTEB AmazonReviewsClassification (en) | f1 | 60.507 |
| Classification | MTEB AmazonReviewsClassification (zh) | accuracy | 53.490 |
| Classification | MTEB AmazonReviewsClassification (zh) | f1 | 51.577 |
| Retrieval | MTEB ArguAna | map_at_1 | 36.273 |
| Retrieval | MTEB ArguAna | map_at_10 | 52.782 |
Using it via the API
Once AxForge deploys gme-qwen2-vl for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (gme-qwen2-vl below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gme-qwen2-vl","input":"text to embed"}'
Create an account — your API key is available in the console. 5M tokens/month currently included with every new account at launch.