Downloads · 30 days
101
20% of all-time downloads
OpenVINO/Qwen3-Reranker-0.6B-seq-cls-fp16-ov
Qwen3-Reranker-0.6B-seq-cls-fp16-ov is a text ranking model from OpenVINO. Use it for the text ranking task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
Model creator: tomaarsen Original model: Qwen3-Reranker-0.6B-seq-cls
Downloads · 30 days
101
20% of all-time downloads
All-time downloads
505
Public
Repo size
2.4 GB
Likes
0
Public
Click a slice to open those files.
.bin1.2 GB · 99%
From the Hugging Face model README
This is Qwen3-Reranker-0.6B-seq-cls model converted to the OpenVINO™ IR (Intermediate Representation) format with weights compressed to FP16.
The provided OpenVINO™ IR model is compatible with:
pip install "git+https://github.com/huggingface/optimum-intel.git" "torch==2.8" --extra-index-url https://download.pytorch.org/whl/cpu
import torch
from transformers import AutoTokenizer
from optimum.intel import OVModelForCausalLM
def format_instruction(instruction, query, doc):
prefix = '<|im_start|>system\nJudge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be "yes" or "no".<|im_end|>\n<|im_start|>user\n'
suffix = "<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n"
if instruction is None:
instruction = (
"Given a web search query, retrieve relevant passages that answer the query"
)
output = f"{prefix}<Instruct>: {instruction}\n<Query>: {query}\n<Document>: {doc}{suffix}"
return output
model_id = "OpenVINO/Qwen3-Reranker-0.6B-seq-cls-fp16-ov"
model = OVModelForCausalLM.from_pretrained(model_id, use_cache=False, export=False)
tokenizer = AutoTokenizer.from_pretrained(model_id, padding_side="left")
# We recommend enabling flash_attention_2 for better acceleration and memory saving.
# model = AutoModelForSequenceClassification.from_pretrained("tomaarsen/Qwen3-Reranker-0.6B-seq-cls", torch_dtype=torch.float16, attn_implementation="flash_attention_2").cuda().eval()
max_length = 8192
task = "Given a web search query, retrieve relevant passages that answer the query"
queries = [
"Which planet is known as the Red Planet?",
"Which planet is known as the Red Planet?",
"Which planet is known as the Red Planet?",
"Which planet is known as the Red Planet?",
]
documents = [
"Venus is often called Earth's twin because of its similar size and proximity.",
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
]
pairs = [format_instruction(task, query, doc) for query, doc in zip(queries, documents)]
inputs = tokenizer(
pairs,
padding=True,
truncation=True,
max_length=max_length,
return_tensors="pt",
)
logits = model(**inputs).logits.squeeze()
print(logits.tolist())
# [-3.109282970428467, 7.120373725891113, -0.37874650955200195, 3.5416228771209717]
scores = logits.sigmoid()
print(scores.tolist())
# [0.04272596165537834, 0.9991921782493591, 0.406429260969162, 0.9718491435050964]
For more examples and possible optimizations, refer to the Inference with Optimum Intel.
1a. Deploy model on Windows using binary package:
mkdir C:\models
ovms.exe --rest_port 8000 --source_model OpenVINO/Qwen3-Reranker-0.6B-seq-cls-fp16-ov --model_repository_path C:\models
1b. Deploy model in a Docker container:
mkdir -p ${HOME}/models
export GPU_ARGS=$(if ls /dev/dri/render* >/dev/null 2>&1; then echo "--device /dev/dri --group-add $(stat -c '%g' /dev/dri/render* | head -n1)"; fi)
docker run -d ${GPU_ARGS} --rm --user $(id -u):$(id -g) -p 8000:8000 -v ${HOME}/models:/models openvino/model_server:latest-gpu --rest_port 8000 --model_repository_path /models --source_model OpenVINO/Qwen3-Reranker-0.6B-seq-cls-fp16-ov
pip install requests "numpy<2"
import requests
prefix = "<|im_start|>system\nJudge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be \"yes\" or \"no\".<|im_end|>\n<|im_start|>user\n"
suffix = "<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n"
instruction = "Given a web search query, retrieve relevant passages that answer the query"
query = "What are the key benefits of machine learning in business?"
documents = [
"Machine learning benefits businesses with better decisions, task automation, customer personalization, and cost savings.",
"Quantum computing uses quantum bits for fast calculations in cryptography and simulations.",
]
query_formatted = f"{prefix}<Instruct>: {instruction}\n<Query>: {query}\n"
doc_formatted = [f"<Document>: {doc}{suffix}" for doc in documents]
response = requests.post(
"http://localhost:8000/v1/rerank",
json={
"model": "OpenVINO/Qwen3-Reranker-0.6B-seq-cls-fp16-ov",
"query": query_formatted,
"documents": doc_formatted,
}
)
print(response.json())
Check the original model card for limitations.
The original model is distributed under Apache License Version 2.0 license. More details can be found in Qwen3-Reranker-0.6B-seq-cls.
Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See Intel’s Global Human Rights Principles. Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights.