Principle:AMAP ML SkillClaw Skill Retrieval
| Knowledge Sources | |
|---|---|
| Domains | Information_Retrieval, Skill_Management |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
A skill retrieval mechanism that selects relevant skills from a skill library using either effectiveness-ranked template matching or semantic embedding-based cosine similarity.
Description
Skill retrieval addresses the problem of finding the most relevant skills from a potentially large library to inject into an LLM's context. The template mode ranks skills purely by their historical effectiveness score (injection and PRM-derived metrics), offering zero-latency retrieval. The embedding mode uses SentenceTransformer to encode both skills and the task description, ranking by cosine similarity weighted by effectiveness, with deduplication to avoid similar skills. The result is a compact catalog of skills injected as an XML block into the system message.
Usage
Use this principle when designing systems that need:
- Relevant skill/tool selection from a large library
- Trade-off between latency (template) and semantic accuracy (embedding)
- Effectiveness-based ranking that improves over time
- Lazy-loading skill catalogs (list names, let the model read full content on demand)
Theoretical Basis
Template Mode: Pure effectiveness ranking, O(1) per skill:
Embedding Mode: Cosine similarity weighted by effectiveness:
Where is the embedding vector and effectiveness is a [0, 1] score derived from injection statistics and PRM scores.
# Abstract algorithm (NOT real implementation)
def retrieve_skills(task_description, skills, mode, top_k):
if mode == "template":
ranked = sorted(skills, key=lambda s: s.effectiveness, reverse=True)
elif mode == "embedding":
task_vec = embed(task_description)
for skill in skills:
skill_vec = embed(skill.description)
skill.sim = cosine_similarity(task_vec, skill_vec)
ranked = sorted(skills, key=lambda s: weighted_score(s.sim, s.effectiveness), reverse=True)
return ranked[:top_k]