Std-SFT-Passage-4B
Qwen3-4B passage reranker trained with Std-SFT: the loss is on the teacher's reasoning and the final answer. Code · Eklav version
Results
| BRIGHT nDCG@10 | ▶ Qwen3-4B | Qwen3-8B | GLM-Z1-9B | Qwen3-14B |
|---|---|---|---|---|
| ▶ Std-SFT | ▶ 29.3 | 31.5 | 30.1 | 32.5 |
| Eklav | 31.5 | 34.2 | 33.2 | 34.7 |
Usage
Pointwise reranker in the style of Rank1: the model writes its reasoning, ending in </think> true or </think> false, and relevance is the probability of true at that last token.
from vllm import LLM, SamplingParams
import math
model_id = "AdarshSingh7647/Std-SFT-Passage-4B"
model = LLM(model=model_id, max_model_len=16000)
tokenizer = model.get_tokenizer()
def create_prompt(query: str, passage: str) -> str:
return (
"Determine if the following passage is relevant to the query. "
"Answer only with 'true' or 'false'.\n"
f"Query: {query}\n"
f"Passage: {passage}\n<think>"
)
sampling_params = SamplingParams(
temperature=0,
max_tokens=8192,
logprobs=20,
stop=["</think> true", "</think> false"],
)
def score(query: str, passage: str) -> float:
prompt = create_prompt(query, passage)
output = model.generate([prompt], sampling_params)[0].outputs[0]
# the answer token is usually the second to last logprob step (vLLM's stop
# string match can consume one extra token, e.g. <|im_end|>, after it), but
# scan from the end so this is robust to that off by one
for step in reversed(output.logprobs or []):
true_lp = next((v.logprob for k, v in step.items() if tokenizer.decode([k]).strip().lower() == "true"), None)
false_lp = next((v.logprob for k, v in step.items() if tokenizer.decode([k]).strip().lower() == "false"), None)
if true_lp is not None and false_lp is not None:
true_score, false_score = math.exp(true_lp), math.exp(false_lp)
return true_score / (true_score + false_score)
return 0.5
query = "What causes seasons on Earth?"
passages = [
"Seasons are caused by the tilt of Earth's axis relative to its orbit around the Sun.",
"The Great Wall of China is visible from space, according to popular belief.",
]
ranked = sorted(passages, key=lambda p: score(query, p), reverse=True)
for p in ranked:
print(p)