Rrf Hybrid Retrieval logo

Rrf Hybrid Retrieval

Community
AnthonyAlcaraz
rrf-hybrid-retrieval

Reciprocal Rank Fusion (RRF) hybrid retrieval across 4 parallel channels — semantic / keyword / graph-traversal / temporal — followed by cross-encoder rerank and token-budget filter (HINDSIGHT, Latimer et al. 2025, cited in Ch4). Rank-based fusion means scores don't need calibration across channels; absent items contribute nothing; items high in multiple lists surface naturally. Use when memory must answer queries that mix conceptual / exact-id / connected-entity / recent-event facets. NOT for single-channel retrieval (just use that channel), NOT for systems where one channel dominates (the fusion is overhead).

Overview

PublisherAnthonyAlcaraz
Repositoryagentic-graph-rag-skills
Skill namerrf-hybrid-retrieval
Stars
29
Forks
9
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by AnthonyAlcaraz on GitHub. Read the source before you install it.

Installation

Install the Rrf Hybrid Retrieval AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/rrf-hybrid-retrieval
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills.git /tmp/agentic-graph-rag-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-graph-rag-skills/skills/memory/rrf-hybrid-retrieval .claude/skills/rrf-hybrid-retrieval
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rrf Hybrid Retrieval in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rrf Hybrid Retrieval on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rrf Hybrid Retrieval is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

RRF Hybrid Retrieval

Overview

A DevOps incident query like "latency spike in checkout related to recent deploy" needs four kinds of retrieval:

  • Semantic: conceptually similar past incidents (vector similarity)
  • Keyword: exact identifiers (checkout-api, deploy-v3.5.0)
  • Graph traversal: connected entities (services that depend on checkout-api; deploys that touched it)
  • Temporal: recent events (last 24h, by deploy timestamp)

Any single channel misses; semantic loses exact identifiers, keyword misses synonyms, graph misses isolated nodes, temporal misses the "happened before 24h ago but matters" cases. The fusion is the point.

Reciprocal Rank Fusion (Cormack et al. 2009):

RRF(item) = sum over channels c of: 1 / (k + rank_c(item))

Where k=60 is the standard. Rank-based — no score calibration needed. Items missing from a channel contribute zero from that channel. Items ranked high across multiple channels naturally rise to the top.

After fusion, run a cross-encoder reranker over the top-N for precision, then apply a token-budget filter so the result fits the downstream LLM's context window. Per HINDSIGHT (Latimer et al. 2025, cited in Ch4): "After RRF, a neural cross-encoder reranker refines precision on top candidates, then token budget filtering ensures results fit the downstream LLM's context window."

When to Use

  • Memory queries that span multiple retrieval-channel "shapes" (conceptual
    • exact + connected + recent)
  • Production DevOps incident-investigation, customer-support resolution, research-synthesis agents
  • When you need to combine heterogeneous retrieval methods and don't want to calibrate scores across them

Phrases: "hybrid retrieval", "RRF", "reciprocal rank fusion", "multi- channel search", "combine semantic and keyword", "cross-encoder rerank".

When NOT to Use

  • Single-channel retrieval is sufficient (e.g. keyword-only ID lookup)
  • One channel dominates and the others contribute noise
  • Real-time hot path where the cross-encoder rerank exceeds latency budget (~50-200ms typical) — fall back to RRF without rerank

Process

StepInputActionOutputVerification
1query + 4 channel rankings (each a list of doc_ids in rank order)lib.rrf_fuse(channels, k=60)List of (doc_id, fusion_score) sorted descendingdoc_ids in multiple channels rank higher than doc_ids in one
2top-N from fusion + querylib.cross_encoder_rerank(top_n, query)Reranked top-Nreranker can re-order but does not introduce or drop items
3reranked list + token-count fn + budgetlib.token_budget_filter(items, get_tokens, budget)Filtered list fitting under budgetsum(tokens) <= budget
4full pipelinelib.hybrid_retrieve(query, channel_callables, ...)Final result listeach item has fusion_score + rerank_score + token_count

Rationalizations

Agent rationalizationDocumented rebuttal
"I'll just use vector search and call it a day."Vector search misses exact identifiers ("incident INC-1043" — the embedding for "INC-1043" is noise). Exact identifiers are graph-traversal + keyword's job. The 4-channel composition exists because no single channel is sufficient.
"I'll combine scores from each channel — RRF is overkill."Score scales differ across channels (cosine 0-1, BM25 0-100+, graph hop-count 1-10). Combining requires calibration. RRF sidesteps this by using ranks. The Ch4 anchor names this exact advantage.
"Cross-encoder rerank is slow — skip it."Skip it when latency budget is tight, document the choice. The rerank produces measurable precision lift on the top-5; without it, top-5 is fusion-only and can include "popular but wrong" items.
"Token budget filter loses information."Yes — that's the point. The downstream LLM's context is bounded. Either you filter, or the LLM truncates blindly. Filtering with intent (drop the lowest-rerank-score) beats truncation by accident.

Red Flags

  • RRF score distribution is flat (top-10 all very close). Channels are redundant — they're returning the same items. The fusion is buying nothing; either trim channels or check that each channel is exercising a different shape.
  • Cross-encoder rerank changes top-10 by > 80%. Either the fusion is bad or the cross-encoder is mis-tuned for this domain.
  • Token budget filter drops > 50% of reranked items. Budget is too small for the query complexity — either widen the budget or write multiple narrower queries.

Non-Negotiable Verification

  1. Run the benchmark battery. python cli.py benchmark must report:
    • RRF formula matches Cormack et al. 2009 reference
    • items in multiple channels rank above items in one
    • token-budget filter respects the budget bound
    • full pipeline produces results with all four score fields
  2. Verify CLI help. Exits 0 and prints SKILL.md description.

Security Posture

  • Prompt injection. Retrieved items are untrusted content headed straight for an LLM context - fusion and rerank order them, they do not sanitize them. An adversarial document that ranks in multiple channels gets RRF-amplified into the budget-filtered prompt; run an injection filter between retrieval and prompt assembly.
  • Data exfiltration. Fusion aggregates across four channels with no ACL of its own - a broad query can pull sensitive items from any channel into one context. Enforce access control per channel BEFORE fusion; the skill itself makes no network calls and writes no files.
  • Privilege escalation. No shell invocation, no eval. The influence vector is rank manipulation: content stuffed with exact identifiers plus synonyms to score across channels and dominate the token budget. Cross-encoder rerank helps but is not a security control.

Source Attribution

Distilled from Agentic GraphRAG (O'Reilly, by Anthony Alcaraz and Sam Julien) Ch4 — Retrieval section. RRF formula: Cormack et al. 2009 (Reciprocal Rank Fusion outperforms Condorcet and individual rank learning methods). HINDSIGHT 4-channel application: Latimer et al. 2025.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Rrf Hybrid Retrieval AI skill do?

Reciprocal Rank Fusion (RRF) hybrid retrieval across 4 parallel channels — semantic / keyword / graph-traversal / temporal — followed by cross-encoder rerank and token-budget filter (HINDSIGHT, Latimer et al. 2025, cited in Ch4). Rank-based fusion means scores don't need calibration across channels; absent items contribute nothing; items high in multiple lists surface naturally. Use when memory must answer queries that mix conceptual / exact-id / connected-entity / recent-event facets. NOT for single-channel retrieval (just use that channel), NOT for systems where one channel dominates (the...

Why use Rrf Hybrid Retrieval on TypingMind?

Because you install it once and use it with any model. Rrf Hybrid Retrieval is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rrf Hybrid Retrieval in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/rrf-hybrid-retrieval. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Rrf Hybrid Retrieval?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rrf Hybrid Retrieval?

As many as you like. As long as a model supports skills, you can use Rrf Hybrid Retrieval with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rrf Hybrid Retrieval AI skill free?

Yes. It is published on GitHub by AnthonyAlcaraz under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇