Views
No views yet
1QuantizationModifier(
2 targets="Linear",
3 scheme="FP8_DYNAMIC",
4 ignore=['re:visual.*'] # Preserve visual layer quality
5)| Property | Value |
|---|---|
| Text Layers | 28 layers (FP8 quantized) |
| Visual Layers | 24 blocks (bfloat16, full precision) |
| Default Embedding Dim | 2048 |
| Matryoshka Dimensions | 64 - 2048 |
| Model Size | ~2.8 GB (vs ~4.6 GB bfloat16) |
1vllm serve Qwen3-VL-Embedding-2B-FP8-DYNAMIC \
2 --runner pooling \
3 --convert embed \
4 --hf-overrides '{"is_matryoshka": true}' \
5 --quantization compressed-tensors \--runner pooling: Enables embedding mode--convert embed: Extract embeddings from model output--quantization compressed-tensors: Load FP8 quantized weights--hf-overrides '{"is_matryoshka": true}': Enable Matryoshka embedding support1from openai import OpenAI
2
3client = OpenAI(
4 api_key="EMPTY",
5 base_url="http://localhost:8000/v1"
6)
7
8# Default 2048 dimensions
9response = client.embeddings.create(
10 model="Qwen3-VL-Embedding-2B-FP8-DYNAMIC",
11 input="Your text here",
12 encoding_format="float"
13)
14
15embedding = response.data[0].embedding # List[float] with 2048 dims1# Request smaller embedding for efficiency
2response = client.embeddings.create(
3 model="Qwen3-VL-Embedding-2B-FP8-DYNAMIC",
4 input="Your text here",
5 encoding_format="float",
6 dimensions=512 # Options: 128, 256, 512, 1024, 2048
7)
8
9embedding = response.data[0].embedding # List[float] with 512 dims1texts = [
2 "First document to embed",
3 "Second document to embed",
4 "Third document to embed"
5]
6
7response = client.embeddings.create(
8 model="Qwen3-VL-Embedding-2B-FP8-DYNAMIC",
9 input=texts,
10 encoding_format="float",
11 dimensions=256
12)
13
14# Access each embedding
15for i, data in enumerate(response.data):
16 embedding = data.embedding
17 print(f"Document {i+1}: {len(embedding)} dimensions")1import base64
2
3def encode_image(image_path):
4 with open(image_path, "rb") as f:
5 return base64.b64encode(f.read()).decode("utf-8")
6
7# Image only
8messages = [{
9 "role": "user",
10 "content": [{
11 "type": "image_url",
12 "image_url": {"url": f"data:image/jpeg;base64,{encode_image('image.jpg')}"}
13 }]
14}]
15
16# Text + Image
17messages = [{
18 "role": "user",
19 "content": [
20 {"type": "text", "text": "Describe this image"},
21 {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{encode_image('image.jpg')}"}}
22 ]
23}]
24
25# Call embeddings endpoint
26response = client.post(
27 "/embeddings",
28 body={
29 "messages": messages,
30 "model": "Qwen3-VL-Embedding-2B-FP8-DYNAMIC",
31 "encoding_format": "float",
32 "dimensions": 512
33 },
34 cast_to=object
35)
36
37embedding = response.data[0].embedding1from llmcompressor import oneshot
2from llmcompressor.modifiers.quantization import QuantizationModifier
3from transformers import AutoModel, AutoTokenizer
4
5# Load base model
6model = AutoModel.from_pretrained(
7 "Qwen/Qwen3-VL-Embedding-2B",
8 trust_remote_code=True,
9 dtype="bfloat16"
10)
11tokenizer = AutoTokenizer.from_pretrained(
12 "Qwen/Qwen3-VL-Embedding-2B",
13 trust_remote_code=True
14)
15
16# Configure quantization
17recipe = QuantizationModifier(
18 targets="Linear",
19 scheme="FP8_DYNAMIC",
20 ignore=['re:visual.*'] # Preserve visual layers
21)
22
23# Apply quantization
24oneshot(
25 model=model,
26 recipe=recipe,
27 output_dir="Qwen3-VL-Embedding-2B-FP8-DYNAMIC"
28)
29
30# Save
31model.save_pretrained("Qwen3-VL-Embedding-2B-FP8-DYNAMIC")
32tokenizer.save_pretrained("Qwen3-VL-Embedding-2B-FP8-DYNAMIC")