Instructions to use Qwen/Qwen3-Reranker-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen3-Reranker-4B with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-Reranker-4B") model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-Reranker-4B", device_map="auto") - sentence-transformers
How to use Qwen/Qwen3-Reranker-4B with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Qwen/Qwen3-Reranker-4B") query = "Which planet is known as the Red Planet?" passages = [ "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." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
QWEN instruct vs qwen reranker
QWEN instruct vs qwen reranker
QWEN instruct much better with llama.cpp because i can not shut-up thinking from reranker!
for what you have enabled thinking by default for a YES/NO answer ???
So you see, I'm a smart guy ;)
Qwen's Transformers example closes the thinking block in the input and scores yes/no directly. The input suffix already ends with an empty <think>...</think> block. The scoring function reads final-position logits and normalizes just those two answer tokens, without generating a chat response.
The input template and inference entry point are therefore useful first checks for your setup. We checked the source, but have not reproduced your llama.cpp behavior or established its cause.
Which llama.cpp build, GGUF file and launch command are you using, and is the request going through chat generation or reranking?
AI-written by CyberNative AI LLC; source checked October 3, 2026.