retriever-optimizer
Skill3 starsChanged 4 months agoMITView on GitHub
Optimize RAG retrieval quality: tune top-k, reranking, query preprocessing, and filtering to maximize recall and precision. Use when working on RAG pipelines, chunking, embeddings, retrieval, or hybrid search.
In this repository59 other files it gives its agents.
- agent-memory-designerSkill
- ai-cost-optimizerSkill
- ai-evaluation-builderSkill
- ai-latency-optimizerSkill
- ai-solution-architectSkill
- ai-workflow-builderSkill
- context-engineeringSkill
- human-in-the-loop-designerSkill
- multi-agent-plannerSkill
- prompt-engineerSkill
- prompt-optimizerSkill
- prompt-reviewerSkill
- adr-generatorSkill
- api-designerSkill
- architecture-reviewSkill
- component-diagram-builderSkill
- container-diagram-builderSkill
- data-flow-analyzerSkill
- integration-plannerSkill
- observability-plannerSkill
- scalability-advisorSkill
- solution-architectureSkill
- system-context-builderSkill
- experiment-designerSkill
- go-to-market-plannerSkill
- pricing-strategy-advisorSkill
- mcp-best-practicesSkill
- mcp-client-generatorSkill
- mcp-security-reviewSkill
- mcp-server-generatorSkill
- mcp-tool-generatorSkill
- acceptance-criteria-generatorSkill
- analytics-instrumentation-plannerSkill
- competitive-analysisSkill
- epic-generatorSkill
- feature-prioritizationSkill
- idea-validatorSkill
- north-star-metric-advisorSkill
- okr-builderSkill
- persona-generatorSkill
- prd-generatorSkill
- problem-statement-builderSkill
- product-discovery-assistantSkill
- product-vision-builderSkill
- sprint-plannerSkill
- story-mappingSkill
- user-story-generatorSkill
- value-proposition-designerSkill
- chunking-strategy-advisorSkill
- embedding-strategy-advisorSkill
- hybrid-search-advisorSkill
- knowledge-ingestion-plannerSkill
- rag-architecture-designerSkill
- ai-governance-advisorSkill
- ai-threat-modelingSkill
- guardrails-builderSkill
- owasp-llm-reviewerSkill
- prompt-injection-detectorSkill
- skill-nameSkill
The file
Files
Retriever Optimizer
Purpose
Optimize RAG retrieval quality: tune top-k, reranking, query preprocessing, and filtering to maximize recall and precision.
Input: RAG architecture, golden query set (optional), current retrieval metrics
Output: Retriever optimization report with parameter recommendations and A/B test plan
Examples: See examples.md for worked input/output.
Workflow
Step 1: Baseline retrieval metrics
Measure on golden set:
| Metric | Current | Target |
| Recall@k | ||
| Precision@k | ||
| MRR | ||
| Latency p95 |
Step 2: Analyze failure modes
Categorize misses:
| Failure type | Count | Example query |
| Wrong chunk retrieved | ||
| Right doc, wrong section | ||
| Query-document vocabulary gap | ||
| Multi-hop not supported |
Step 3: Tune retrieval parameters
| Parameter | Current | Recommended | Rationale |
| top-k initial | |||
| top-k after rerank | |||
| Similarity threshold | |||
| Metadata filters |
Step 4: Recommend enhancements
Options:
- Query expansion / HyDE
- Cross-encoder reranking
- Metadata pre-filtering
- Hypothetical document embedding
- Query decomposition
Prioritize by failure mode analysis.
Step 5: Define A/B test plan
| Variant | Change | Success metric | Sample size |
Step 6: Validate
Run Validation checklist.
Decision Rules
| Condition | Action |
| No golden query set | Create minimum 20 Q&A pairs before tuning |
| Recall low, precision high | Increase k, add query expansion |
| Precision low, recall high | Add reranker, raise similarity threshold |
| Latency exceeds budget | Reduce k, use lighter reranker |
| Vocabulary gap failures dominate | Recommend hybrid-search-advisor |
Validation
- Baseline metrics documented
- Failure modes categorized with examples
- Parameter recommendations with rationale
- Enhancements prioritized by failure type
- A/B test plan defined
- Latency impact estimated per change
- No tuning without measurable success criteria
Anti-patterns
- Random k tuning — changing top-k without measuring.
- Rerank everything — expensive reranker on all queries regardless of need.
- Ignore latency — quality gains that break SLA.
- Overfit golden set — tuning to 5 queries only.
- No baseline — optimizing without before metrics.
Best Practices
- Hold out 20% of golden set for validation.
- Tune one parameter at a time.
- Log retrieval results in production for continuous improvement.
- Pair with hybrid-search-advisor for keyword gaps.
- Re-evaluate after corpus or embedding changes.
Output Structure
# Retriever Optimization: [System Name]
## Baseline
| Metric | Value | Target |
|--------|-------|--------|
## Failure Analysis
| Type | % | Example | Fix |
|------|---|---------|-----|
## Parameter Tuning
| Param | Before | After | Impact |
|-------|--------|-------|--------|
## Recommended Enhancements
| Priority | Enhancement | Addresses |
|----------|-------------|-----------|
## A/B Test Plan
| Variant | Metric | Duration |
|---------|--------|----------|Next Skills
| Outcome | Recommended Skill |
| Add keyword retrieval | rag/hybrid-search-advisor |
| Fix chunking issues | rag/chunking-strategy-advisor |
| Change embeddings | rag/embedding-strategy-advisor |
| Citation validation | rag/citation-validator |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

