Views
No views yet
SR-Rank-0.6B is a fine-tuned cross-encoder reranker for skill routing. It is designed to score a small candidate set of retrieved skills against a task query and select the single most relevant skill for an LLM agent.Qwen/Qwen3-Reranker-0.6Blogit(yes) - logit(no)SR-Emb-0.6BSR-Rank-0.6B after a first-stage retriever has already narrowed a large corpus to a candidate set, for example:pipizhao/SkillRouter-Embedding-0.6B.pipizhao/SkillRouter-Reranker-0.6B.yes - no score.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4MODEL_ID = "pipizhao/SkillRouter-Reranker-0.6B"
5
6
7def format_rerank_prompt(name, desc, body, query_text, desc_max=500, body_max=2000):
8 instruction = (
9 "Given a task description, judge whether the skill document "
10 "is relevant and useful for completing the task"
11 )
12 doc_text = f"{name} | {desc[:desc_max]} | {body[:body_max]}"
13 return (
14 f"<Instruct>: {instruction}\n\n"
15 f"<Query>: {query_text}\n\n"
16 f"<Document>: {doc_text}"
17 )
18
19
20def build_qwen_reranker_inputs(tokenizer, prompt, max_length=4096):
21 prefix = (
22 '<|im_start|>system\nJudge whether the Document meets the requirements '
23 'based on the Query and the Instruct provided. Note that the answer can '
24 'only be "yes" or "no".<|im_end|>\n<|im_start|>user\n'
25 )
26 suffix = '<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n'
27 prefix_tokens = tokenizer.encode(prefix, add_special_tokens=False)
28 suffix_tokens = tokenizer.encode(suffix, add_special_tokens=False)
29 tokens = tokenizer(
30 prompt,
31 padding=False,
32 truncation=True,
33 max_length=max_length - len(prefix_tokens) - len(suffix_tokens),
34 return_attention_mask=False,
35 )["input_ids"]
36 input_ids = prefix_tokens + tokens + suffix_tokens
37 return input_ids
38
39
40tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, padding_side="left")
41model = AutoModelForCausalLM.from_pretrained(
42 MODEL_ID,
43 torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
44)
45model = model.eval().to("cuda" if torch.cuda.is_available() else "cpu")
46
47token_yes = tokenizer.convert_tokens_to_ids("yes")
48token_no = tokenizer.convert_tokens_to_ids("no")
49
50query = "Implement a feature branch workflow with PR checks."
51candidates = [
52 {
53 "name": "moai-foundation-git",
54 "desc": "Git workflow conventions",
55 "body": "# Git Workflow ...",
56 },
57 {
58 "name": "concurrency-control",
59 "desc": "Mutex patterns for CI",
60 "body": "# Concurrency Control ...",
61 },
62]
63
64scores = []
65for cand in candidates:
66 prompt = format_rerank_prompt(cand["name"], cand["desc"], cand["body"], query)
67 input_ids = build_qwen_reranker_inputs(tokenizer, prompt)
68 input_ids = torch.tensor([input_ids], device=model.device)
69 attention_mask = torch.ones_like(input_ids)
70 with torch.no_grad():
71 logits = model(input_ids=input_ids, attention_mask=attention_mask).logits[:, -1, :]
72 score = (logits[:, token_yes] - logits[:, token_no]).item()
73 scores.append(score)
74
75best_idx = max(range(len(scores)), key=lambda i: scores[i])
76print(best_idx, scores)1@misc{zheng2026skillrouterskillroutingllm,
2 title={SkillRouter: Skill Routing for LLM Agents at Scale},
3 author={YanZhao Zheng and ZhenTao Zhang and Chao Ma and YuanQiang Yu and JiHuai Zhu and Yong Wu and Tianze Xu and Baohua Dong and Hangcheng Zhu and Ruohui Huang and Gang Yu},
4 year={2026},
5 eprint={2603.22455},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/2603.22455},
9}