Views
No views yet
Qwen3ForCausalLM
(Qwen3MoeForCausalLM for MoE). The relevance score of a (query, passage) pair
is the yes/no log-odds at the final prompt token:score = logit(" yes") − logit(" no")"\nIs the passage relevant to the query?".
The prompt is "query: {{query}} passage: {{title}} {{text}}\nIs the passage relevant to the query?"
and no EOS token is appended.This differs from the HF sequence-classification rerankers in this release (*-hf,*-lora-hf), which score a single regression logit at EOS.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4name = "brutusxu/tevatron3-reranker-30b-a3b-contrastive-lora"
5tok = AutoTokenizer.from_pretrained(name)
6model = AutoModelForCausalLM.from_pretrained(name, dtype=torch.bfloat16).cuda().eval()
7yes_id = tok.encode(" yes", add_special_tokens=False)[-1]
8no_id = tok.encode(" no", add_special_tokens=False)[-1]
9prompt = ("query: what is the capital of france "
10 "passage: Paris is the capital of France.\n"
11 "Is the passage relevant to the query?")
12ids = tok(prompt, return_tensors="pt").to("cuda")
13with torch.no_grad():
14 logits = model(**ids).logits[0, -1]
15print((logits[yes_id] - logits[no_id]).item())