This is an
FP8 quantized version of
Qwen/Qwen3-VL-Embedding-8B, optimized for efficient inference with vLLM.
1from vllm import LLM, EngineArgs
2import numpy as np
3
4# Initialize vLLM with pooling runner
5engine_args = EngineArgs(
6 model="RamManavalan/Qwen3-VL-Embedding-8B-FP8",
7 runner="pooling",
8 dtype="bfloat16",
9 trust_remote_code=True,
10)
11llm = LLM(**vars(engine_args))
12
13# Prepare inputs
14tokenizer = llm.get_tokenizer()
15
16def format_input(text, instruction="Represent the user's input."):
17 conversation = [
18 {"role": "system", "content": [{"type": "text", "text": instruction}]},
19 {"role": "user", "content": [{"type": "text", "text": text}]}
20 ]
21 prompt = tokenizer.apply_chat_template(
22 conversation, tokenize=False, add_generation_prompt=True
23 )
24 return {"prompt": prompt}
25
26# Get embeddings
27inputs = [
28 format_input("A woman playing with her dog on the beach."),
29 format_input("Machine learning for image classification."),
30]
31outputs = llm.embed(inputs)
32
33# Extract embeddings
34embeddings = np.array([o.outputs.embedding for o in outputs])
35print(f"Embeddings shape: {embeddings.shape}") # (2, 4096)
36
37# Compute similarity
38similarity = embeddings[0] @ embeddings[1]
39print(f"Similarity: {similarity:.4f}")
1# Start the server
2vllm serve RamManavalan/Qwen3-VL-Embedding-8B-FP8 --task embed
3
4# Query via API
5curl http://localhost:8000/v1/embeddings \
6 -H "Content-Type: application/json" \
7 -d '{"input": "Your text here", "model": "RamManavalan/Qwen3-VL-Embedding-8B-FP8"}'
1import torch
2from transformers import AutoProcessor, Qwen3VLForConditionalGeneration
3
4model = Qwen3VLForConditionalGeneration.from_pretrained(
5 "RamManavalan/Qwen3-VL-Embedding-8B-FP8",
6 dtype=torch.bfloat16,
7 trust_remote_code=True,
8 device_map="auto",
9)
10processor = AutoProcessor.from_pretrained(
11 "RamManavalan/Qwen3-VL-Embedding-8B-FP8",
12 trust_remote_code=True,
13)
14
15# Prepare input
16messages = [
17 {"role": "system", "content": [{"type": "text", "text": "Represent the user's input."}]},
18 {"role": "user", "content": [{"type": "text", "text": "Your text here"}]}
19]
20prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21inputs = processor(text=[prompt], return_tensors="pt", padding=True).to(model.device)
22
23# Get embedding (last-token pooling)
24with torch.no_grad():
25 outputs = model.model(**inputs, output_hidden_states=True)
26 # Get the last non-padding token
27 seq_len = inputs['attention_mask'].sum(dim=1) - 1
28 embedding = outputs.last_hidden_state[0, seq_len[0]]
29 embedding = torch.nn.functional.normalize(embedding, p=2, dim=-1)
30
31print(f"Embedding shape: {embedding.shape}") # (4096,)
1from scripts.qwen3_vl_embedding import Qwen3VLEmbedder
2
3# Initialize
4model = Qwen3VLEmbedder(model_name_or_path="RamManavalan/Qwen3-VL-Embedding-8B-FP8")
5
6# Get embeddings for text, images, or multimodal inputs
7inputs = [
8 {"text": "A dog on the beach"},
9 {"image": "path/to/image.jpg"},
10 {"text": "What is in this image?", "image": "path/to/image.jpg"},
11]
12embeddings = model.process(inputs)
13print(f"Embeddings shape: {embeddings.shape}") # (3, 4096)
This model was quantized using
llm-compressor:
1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from llmcompressor import oneshot
3from llmcompressor.modifiers.quantization import QuantizationModifier
4
5# Load model
6model = Qwen3VLForConditionalGeneration.from_pretrained(
7 "Qwen/Qwen3-VL-Embedding-8B",
8 torch_dtype=torch.bfloat16,
9 trust_remote_code=True,
10 device_map="auto",
11)
12
13# FP8 quantization recipe (data-free)
14recipe = QuantizationModifier(
15 targets="Linear",
16 scheme="FP8_DYNAMIC",
17 ignore=[
18 "lm_head",
19 r"re:model\.visual\..*", # Keep vision encoder in BF16
20 ]
21)
22
23# Apply quantization
24oneshot(model=model, recipe=recipe)
25
26# Save
27model.save_pretrained("Qwen3-VL-Embedding-8B-FP8", save_compressed=True)
1@article{qwen3vlembedding,
2 title={Qwen3-VL-Embedding and Qwen3-VL-Reranker: A Unified Framework for State-of-the-Art Multimodal Retrieval and Ranking},
3 author={Li, Mingxin and Zhang, Yanzhao and Long, Dingkun and Chen, Keqin and Song, Sibo and Bai, Shuai and Yang, Zhibo and Xie, Pengjun and Yang, An and Liu, Dayiheng and Zhou, Jingren and Lin, Junyang},
4 journal={arXiv preprint arXiv:2601.04720},
5 year={2026}
6}