Views
No views yet
SR-Emb-0.6B is a compact embedding model for skill retrieval in large LLM-agent skill registries. It is the encoder used in the SkillRouter retrieve-and-rerank pipeline and is fine-tuned from Qwen/Qwen3-Embedding-0.6B for full-text skill routing over approximately 80K skills.Qwen/Qwen3-Embedding-0.6Bname | description | bodyK=20 or K=50.1import torch
2import torch.nn.functional as F
3from transformers import AutoModel, AutoTokenizer
4
5MODEL_ID = "pipizhao/SkillRouter-Embedding-0.6B"
6QUERY_INSTRUCTION = (
7 "Instruct: Given a task description, retrieve the most relevant "
8 "skill document that would help an agent complete the task\nQuery:"
9)
10
11
12def last_token_pool(last_hidden_states: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
13 left_padding = (attention_mask[:, -1].sum() == attention_mask.shape[0])
14 if left_padding:
15 return last_hidden_states[:, -1]
16 seq_lens = attention_mask.sum(dim=1) - 1
17 batch = last_hidden_states.shape[0]
18 return last_hidden_states[torch.arange(batch, device=last_hidden_states.device), seq_lens]
19
20
21def encode(texts, tokenizer, model, max_length=4096):
22 encoded = tokenizer(
23 texts,
24 padding=True,
25 truncation=True,
26 max_length=max_length,
27 return_tensors="pt",
28 )
29 encoded = {k: v.to(model.device) for k, v in encoded.items()}
30 with torch.no_grad():
31 outputs = model(**encoded)
32 embs = last_token_pool(outputs.last_hidden_state, encoded["attention_mask"])
33 embs = F.normalize(embs, p=2, dim=1)
34 return embs
35
36
37tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True, padding_side="left")
38model = AutoModel.from_pretrained(
39 MODEL_ID,
40 trust_remote_code=True,
41 torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
42)
43model = model.eval().to("cuda" if torch.cuda.is_available() else "cpu")
44
45query = QUERY_INSTRUCTION + "Implement a feature branch workflow with PR checks."
46skills = [
47 "moai-foundation-git | Git workflow conventions | # Git Workflow ...",
48 "concurrency-control | Mutex patterns for CI | # Concurrency Control ...",
49]
50
51query_emb = encode([query], tokenizer, model)
52skill_embs = encode(skills, tokenizer, model)
53scores = (query_emb @ skill_embs.T).squeeze(0)
54ranked = torch.argsort(scores, descending=True)
55print(ranked.tolist(), scores[ranked].tolist())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}