Image-Text-to-Text
Transformers
Safetensors
qwen3_vl
vision-language
image-classification
calibrated-probabilities
structured-outputs
typed-questions
jev-inspired
qwen3-vl
conversational
Instructions to use MeerDevelopment/Qevi-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MeerDevelopment/Qevi-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="MeerDevelopment/Qevi-2B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("MeerDevelopment/Qevi-2B") model = AutoModelForMultimodalLM.from_pretrained("MeerDevelopment/Qevi-2B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MeerDevelopment/Qevi-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MeerDevelopment/Qevi-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MeerDevelopment/Qevi-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/MeerDevelopment/Qevi-2B
- SGLang
How to use MeerDevelopment/Qevi-2B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MeerDevelopment/Qevi-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MeerDevelopment/Qevi-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MeerDevelopment/Qevi-2B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MeerDevelopment/Qevi-2B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use MeerDevelopment/Qevi-2B with Docker Model Runner:
docker model run hf.co/MeerDevelopment/Qevi-2B
Bundle the qevi inference engine in-repo
Browse files- qevi/__init__.py +58 -0
qevi/__init__.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Qevi: answer typed questions about an image in one forward pass, without generating text.
|
| 2 |
+
|
| 3 |
+
A normal vision-language model answers a question by decoding tokens one at a time, and
|
| 4 |
+
re-encodes the image for every question you ask. When the answer is known to be one of a small
|
| 5 |
+
fixed set ("Yes"/"No", "A"/"B"/"C"/"D", "Poor"/"Fair"/"Good"), both of those costs are waste.
|
| 6 |
+
|
| 7 |
+
Qevi instead encodes the image once, packs every question into a single sequence behind a
|
| 8 |
+
block-diagonal attention mask that keeps the questions provably isolated from each other, runs
|
| 9 |
+
one forward pass, and reads the model's own LM-head logits at the position where it would have
|
| 10 |
+
started writing each answer. Softmax over just that question's candidate tokens gives a
|
| 11 |
+
calibrated probability.
|
| 12 |
+
|
| 13 |
+
from transformers import AutoProcessor, Qwen3VLForConditionalGeneration
|
| 14 |
+
from qevi import build_readouts, noul_question, forward_logits, softmax
|
| 15 |
+
|
| 16 |
+
model = Qwen3VLForConditionalGeneration.from_pretrained(MODEL, dtype="bfloat16").cuda()
|
| 17 |
+
processor = AutoProcessor.from_pretrained(MODEL)
|
| 18 |
+
|
| 19 |
+
specs = [(noul_question("There is a ladder in this image."), ["Yes", "No"])]
|
| 20 |
+
readouts = build_readouts(processor.tokenizer, specs)
|
| 21 |
+
logits = forward_logits(model, processor, image, readouts)
|
| 22 |
+
print(softmax(logits[0], T=2.45)) # -> [0.97, 0.03]
|
| 23 |
+
|
| 24 |
+
Everything here works with a stock Qwen3-VL checkpoint. The fine-tuned weights are simply more
|
| 25 |
+
accurate through the same path; no custom architecture and no trust_remote_code is involved.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
from .core import (
|
| 29 |
+
Readout,
|
| 30 |
+
build_readouts,
|
| 31 |
+
forward_logits,
|
| 32 |
+
softmax,
|
| 33 |
+
unwrap,
|
| 34 |
+
wrap_turn,
|
| 35 |
+
noul_question,
|
| 36 |
+
choice_question,
|
| 37 |
+
choice_question_generic,
|
| 38 |
+
score_question,
|
| 39 |
+
score_question_generic,
|
| 40 |
+
NOUL_TEMPLATE,
|
| 41 |
+
LETTERS,
|
| 42 |
+
PREFIX_PRE,
|
| 43 |
+
PREFIX_POST,
|
| 44 |
+
)
|
| 45 |
+
from .pack import Question, PackedBatch, Segment, build_packed_batch, permute_questions
|
| 46 |
+
|
| 47 |
+
__version__ = "0.1.0"
|
| 48 |
+
|
| 49 |
+
DEFAULT_TEMPERATURES = {"noul": 2.45, "choice": 1.9, "score": 3.0}
|
| 50 |
+
|
| 51 |
+
__all__ = [
|
| 52 |
+
"Readout", "build_readouts", "forward_logits", "softmax", "unwrap", "wrap_turn",
|
| 53 |
+
"noul_question", "choice_question", "choice_question_generic",
|
| 54 |
+
"score_question", "score_question_generic",
|
| 55 |
+
"NOUL_TEMPLATE", "LETTERS", "PREFIX_PRE", "PREFIX_POST",
|
| 56 |
+
"Question", "PackedBatch", "Segment", "build_packed_batch", "permute_questions",
|
| 57 |
+
"DEFAULT_TEMPERATURES", "__version__",
|
| 58 |
+
]
|