Views
No views yet
Official code and evaluation toolkit: github.com/donghong1/SkillReason Released inference adapter, benchmark evaluation scripts, and reproducibility instructions are available in the repository.
| Property | Value |
|---|---|
| Parameters | 0.6B |
| Primary use | Agent skill retrieval |
| Pooling | Final non-padding token |
| Similarity | Cosine similarity over L2-normalized embeddings |
| Recommended dtype | BF16 on supported GPUs |
| Recommended maximum length | 4096 tokens |
1git clone https://github.com/donghong1/SkillReason.git
2cd SkillReason
3pip install -e .
4
5skillreason-download --artifact retriever-0.6b --output-dir artifacts
6
7skillreason-retrieve \
8 --model artifacts/models/SkillReason-embedding-0.6b \
9 --backend hf_last_token \
10 --corpus examples/skills.jsonl \
11 --queries examples/queries.jsonl \
12 --output-dir outputs/retrieval \
13 --corpus-cache outputs/cache/skills.npy \
14 --query-prefix official \
15 --devices 0 \
16 --max-length 4096 \
17 --top-k 10name | description | body without the query instruction.1import torch
2import torch.nn.functional as F
3from transformers import AutoModel, AutoTokenizer
4
5model_id = "donghongjiang/SkillReason-embedding-0.6b"
6query_instruction = (
7 "Instruct: Given a task description, retrieve the most relevant skill "
8 "document that would help an agent complete the task\nQuery: "
9)
10
11tokenizer = AutoTokenizer.from_pretrained(
12 model_id,
13 padding_side="left",
14)
15model = AutoModel.from_pretrained(
16 model_id,
17 torch_dtype=torch.bfloat16,
18 device_map="auto",
19).eval()
20
21if tokenizer.pad_token_id is None:
22 tokenizer.pad_token = tokenizer.eos_token
23
24
25def last_token_pool(hidden_states, attention_mask):
26 positions = torch.arange(attention_mask.shape[1], device=attention_mask.device)
27 final_positions = (attention_mask.long() * positions).max(dim=1).values
28 rows = torch.arange(hidden_states.shape[0], device=hidden_states.device)
29 return hidden_states[rows, final_positions]
30
31
32@torch.no_grad()
33def encode(texts, max_length=4096):
34 batch = tokenizer(
35 texts,
36 padding=True,
37 truncation=True,
38 max_length=max_length,
39 return_tensors="pt",
40 ).to(model.device)
41 output = model(**batch, use_cache=False)
42 embeddings = last_token_pool(output.last_hidden_state, batch["attention_mask"])
43 # Match the released evaluation protocol: normalize in the model dtype,
44 # then convert the normalized vectors to FP32 for exact cosine search.
45 return F.normalize(embeddings, p=2, dim=1).float()
46
47
48queries = [query_instruction + "<YOUR_USER_REQUEST>"]
49skills = [
50 "<SKILL_NAME_1> | <SKILL_DESCRIPTION_1> | <SKILL_DOCUMENT_1>",
51 "<SKILL_NAME_2> | <SKILL_DESCRIPTION_2> | <SKILL_DOCUMENT_2>",
52]
53
54scores = encode(queries) @ encode(skills).T
55print(scores)1DOWNLOAD=1 \
2MODEL_SIZE=0.6b \
3BENCHMARK=skillreason \
4DEVICES=0,1,2,3,4,5,6,7 \
5bash scripts/evaluate_benchmark.sh1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "donghongjiang/SkillReason-embedding-0.6b"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(
7 model_id,
8 torch_dtype=torch.bfloat16,
9 device_map="auto",
10).eval()
11
12prompt = """Analyze the user query for skill retrieval. Write a concise query analysis that describes what kinds of relevant skill capabilities are needed, especially when multiple skills may be required.
13
14User query:
15<YOUR_USER_REQUEST>
16
17Query analysis:
18"""
19inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
20outputs = model.generate(**inputs, max_new_tokens=96, do_sample=False)
21print(tokenizer.decode(outputs[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))1@misc{jiang2026skillreasonreasoningenhancedagentskill,
2 title = {SkillReason: Reasoning-Enhanced Agent Skill Retrieval for Implicit User Requests},
3 author = {Donghong Jiang and Endian Lin and Luoping Cui and Hanqing Liu and Mingjie Liu and Fan Yang and Hong Wang and Zhao Yang and Chuang Zhu},
4 year = {2026},
5 eprint = {2608.08640},
6 archivePrefix = {arXiv},
7 primaryClass = {cs.AI},
8 url = {https://arxiv.org/abs/2608.08640}
9}