Rrf Hybrid Retrievalのロゴ

Rrf Hybrid Retrieval

コミュニティ
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).

概要

公開者AnthonyAlcaraz
リポジトリagentic-graph-rag-skills
スキル名rrf-hybrid-retrieval
スター
29
フォーク
9
同梱ファイル
2
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 2個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    AnthonyAlcarazがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Rrf Hybrid Retrieval」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/rrf-hybrid-retrieval
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでRrf Hybrid Retrievalを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にRrf Hybrid Retrievalを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Rrf Hybrid Retrievalは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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...

TypingMindでRrf Hybrid Retrievalを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Rrf Hybrid Retrievalはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにRrf Hybrid Retrievalをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/memory/rrf-hybrid-retrievalを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Rrf Hybrid Retrievalを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Rrf Hybrid Retrievalで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもRrf Hybrid Retrievalを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Rrf Hybrid Retrieval」は無料ですか?

はい。AnthonyAlcarazがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇