Sentence Similarity
sentence-transformers
Safetensors
Transformers
English
Chinese
qwen2_vl
image-text-to-text
mteb
Qwen2-VL
vidore
custom_code
Eval Results (legacy)
Instructions to use Alibaba-NLP/gme-Qwen2-VL-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Alibaba-NLP/gme-Qwen2-VL-7B-Instruct with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Alibaba-NLP/gme-Qwen2-VL-7B-Instruct", trust_remote_code=True) sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use Alibaba-NLP/gme-Qwen2-VL-7B-Instruct with Transformers:
# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Alibaba-NLP/gme-Qwen2-VL-7B-Instruct", trust_remote_code=True) model = AutoModelForImageTextToText.from_pretrained("Alibaba-NLP/gme-Qwen2-VL-7B-Instruct", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
Use get_input_embeddings() Instead of Accessing .embed_tokens Directly
#8
by Zhenzhao - opened
No description provided.
Problem
Code was previously accessing self.base.model.embed_tokens(input_ids) directly, which works on transformers < 4.51.0, but raises:
AttributeError: 'Qwen2VLModel' object has no attribute 'embed_tokens'
in transformers >= 4.51.0 due to internal API refactoring.
✅ Solution
Switched to the standardized HuggingFace API:
inputs_embeds = self.base.get_input_embeddings()(input_ids)
This makes the code compatible across all transformers >= 4.0, and avoids reliance on internal attributes that may change.
🧪 Tested
- Confirmed working on both
transformers==4.50.0and4.52.3. - No behavior changes, but now forward-compatible.