agentleFS
asmamestasmamest/Nexus-Skills/skills/ai-engineering/advanced-retrieval-reranking/SKILL.md

advanced-retrieval-reranking

Skill1 starsChanged 17 days agoMITView on GitHub

Improve search relevance with hybrid retrieval, query rewriting, metadata filtering, reranking, and measurable retrieval experiments for RAG and agent tools.

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Choose a retrieval method: Use lexical search for exact terms/identifiers, dense retrieval for semantic similarity, and hybrid fusion when …

    line 15
  2. Distinctive:

    Preserve diversity and provenance: Avoid many near-duplicate chunks from one source.

    line 18
  3. Distinctive:

    Use source freshness and authority as explicit ranking signals when the task requires them.

    line 27
  4. Distinctive:

    Avoid scoring the same model's output with a circular metric without calibration or human spot checks.

    line 28

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Advanced Retrieval and Reranking

Goal

Improve retrieval quality through controlled experiments. Choose retrieval complexity based on observed failure patterns, not trend-following.

Workflow

  1. Build a query set. Include common, rare, ambiguous, multi-hop, typo-heavy, multilingual, and unanswerable queries. Label relevant documents or passages.
  2. Measure a baseline. Record recall@k, precision@k, MRR or nDCG as appropriate, latency, index cost, and query cost.
  3. Diagnose the failure. Distinguish missing corpus coverage, bad parsing, chunk-boundary loss, lexical mismatch, semantic mismatch, stale data, and ACL filtering mistakes.
  4. Choose a retrieval method. Use lexical search for exact terms/identifiers, dense retrieval for semantic similarity, and hybrid fusion when both matter. Keep filters server-side and authorization-aware.
  5. Try query transformations. Rewrite unclear queries, generate alternate queries, or decompose multi-part questions only when evaluations show benefit. Keep original query and transformations in traces.
  6. Rerank candidates. Retrieve a sufficiently broad candidate set, rerank with a cross-encoder or model-based ranker when useful, then pass a small evidence set to generation.
  7. Preserve diversity and provenance. Avoid many near-duplicate chunks from one source. Keep source IDs and exact evidence spans.
  8. Test failure handling. Include no-result, conflicting-source, stale-source, and permission-filtered cases.
  9. Ship behind an evaluation gate. Compare to the baseline on a held-out set before replacing the production strategy.

Practical considerations

  • Tune top-k and chunk sizes jointly; they are not independent knobs.
  • Query expansion can increase recall but also introduce drift and latency.
  • Rerankers can improve ordering but cannot recover documents that initial retrieval never found.
  • Metadata filters must not be removed merely to increase recall.
  • Use source freshness and authority as explicit ranking signals when the task requires them.
  • Avoid scoring the same model's output with a circular metric without calibration or human spot checks.

Deliverable

Summarize baseline, diagnosed error classes, experiments, metric deltas, latency/cost tradeoffs, security constraints, and the chosen configuration.

References

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.