Ai Rag Patternsのロゴ

Ai Rag Patterns

コミュニティ
peterbamuhigire
ai-rag-patterns

非公開データ、ドキュメント、ポリシー、または鮮度が重要な情報に関する質問に答える機能を構築するときに使います。RAGアーキテクチャ、チャンク分割、ハイブリッド検索、再ランキング、ベクトルデータベース、評価、エージェント型・マルチモーダルRAG、コンテキストが不足したサブエージェント向けの範囲を限定した反復検索を扱います。

Add to TypingMind

概要

公開者peterbamuhigire
リポジトリchwezi-dev-engine
スキル名ai-rag-patterns
スター
29
フォーク
6
同梱ファイル
8
ライセンスMIT
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 8個の同梱ファイル

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

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

Claude Code — .claude/skills
git clone --depth 1 https://github.com/peterbamuhigire/chwezi-dev-engine.git /tmp/chwezi-dev-engine
mkdir -p .claude/skills
cp -r /tmp/chwezi-dev-engine/skills/ai/ai-rag-patterns .claude/skills/ai-rag-patterns
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

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

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

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

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

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

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

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

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

スキルの指示

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

RAG Patterns — Retrieval-Augmented Generation

Operating contract

Inputs

InputRequiredPurpose
Domain evidenceyesquestion set, authoritative corpus, tenancy and access rules, freshness target, citation needs, and evaluation set

Outputs

  • Produce: retrieval architecture, ingestion/chunking policy, index and filter contract, grounded-answer schema, and evaluation report.

Capability and permission boundaries

Default to read-only analysis. Read only scoped records; redact secrets and regulated data. Writes, execution, network calls, production configuration, customer communication, billing changes, and delegation require explicit authority and an identified owner. Never widen tenant, time-window, or system scope implicitly.

Degraded mode

When required telemetry, evidence, execution, network access, or write authority is unavailable, return a partial result with each unassessed item labelled, preserve the safest existing state, and state the evidence or approval needed to continue. Never convert missing evidence into a pass.

Decision rules

ConditionAction
Scope, owner, or threshold is missingStop the affected decision and request it
Evidence is incomplete but read-only analysis is safeProduce a qualified partial result and gap list
A mutation exceeds authority or tenant boundaryBlock it and route for approval
Evidence meets the stated thresholdIssue the output with provenance and owner

Anti-Patterns

  • Treating absent evidence as success. Fix: mark the check unassessed and name the missing source.
  • Expanding one tenant or workflow to all tenants. Fix: enforce supplied scope at every query and action.
  • Performing a production write during analysis. Fix: emit a reviewed change plan until authority is explicit.
  • Reporting a metric without population, window, or source. Fix: attach all three.
  • Hiding a failed threshold inside an average. Fix: report failure slices and the remediation owner.

Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.

Use When

  • Use when building features that answer questions from private data, documents, policies, or time-sensitive information — RAG architecture, chunking strategies, hybrid search, re-ranking, vector databases, evaluation, agentic RAG, multimodal RAG...

Evidence Produced

CategoryArtifactFormatExample
CorrectnessRAG retrieval evaluation reportMarkdown doc covering recall / precision / answer-quality on a fixed eval setdocs/ai/rag-eval-2026-04-16.md
Data safetyIndex ingestion + tenancy isolation noteMarkdown doc covering chunking, source filtering, and per-tenant index segregationdocs/ai/rag-tenancy-note.md

References

  • Use the references/ directory for deep detail after reading the core workflow below.
  • references/curated-corpus-worked-example.md: small curated corpus with BM25 ranking, per-domain score floors, calibrated abstention and a graded, fingerprinted golden set.

Overview

RAG solves the core LLM limitation: they only know what they were trained on. Use RAG to inject private data (invoices, menus, policies, reports) into every AI response.

Core principle: RAG = look up a database + LLM synthesises the results. The LLM never needs to "know" your data.


When to Use RAG

ConditionAction
Knowledge base < 200K tokens (~500 pages)Include everything in context — no RAG needed
Knowledge base > 200K tokensUse RAG
Data changes frequently (menus, prices, stock)RAG (update documents, not model)
Data is private/confidentialRAG (keeps data out of training pipelines)
Need source citationsRAG (chunks are traceable to source)
Model needs brand voice / domain jargonFine-tune instead

RAG vs Fine-Tuning

FactorRAGFine-Tuning
Up-to-date content✅ Yes (add docs anytime)❌ Stale until retrained
Hallucinations✅ Lower (document-grounded)❌ Higher
Source citations✅ Yes❌ No
Brand voice control❌ Weak✅ Strong
Domain jargon❌ Weak✅ Strong
Up-front cost✅ Lower❌ High

Default: start with RAG. Fine-tune only when RAG + prompt engineering cannot deliver the required tone or vocabulary.


Additional Guidance

Guidance is split across two reference files so this entrypoint stays compact.

references/skill-deep-dive.md — architecture, chunking, retrieval, schema:

  • Pipeline Architecture
  • Chunking Strategies
  • Embedding Model Selection
  • Vector Database Selection
  • Retrieval Algorithms
  • Re-Ranking
  • Full RAG Query Algorithm
  • Query Rewriting (Multi-Turn)
  • RAG Schema (Multi-Tenant)
  • Evaluation Framework
  • Production Patterns
  • Agentic RAG
  • Multimodal RAG, Edge Cases, Cost Optimisation, Sources

references/production-rag.md — the progression from draft to production and the gates before shipping:

  • RAG Maturity Model — Naive → Advanced → Modular
  • Query Transformation — HyDE, Multi-Query, Step-Back
  • Contextual Compression
  • Self-RAG
  • RAGAS Evaluation — 4 metrics with production thresholds
  • Embedding Pipeline — batching, upserts, re-embed triggers, $/1M-token table
  • Cost Management Decision Tree — concrete dollar figures per branch
  • Failure Mode Playbook — empty, irrelevant, hallucinated, stale
  • Gates Before Shipping

references/iterative-retrieval.md — load when a context-starved subagent must explore a codebase or workspace before working: bounded DISPATCH-EVALUATE-REFINE-LOOP (max 3 cycles), relevance banding, explicit gap lists, and terminology learning.

Load the production file when building a RAG system that has to pass evaluation gates, survive multi-tenant review, or hit a cost budget under load.

When answers depend on structured records about a specific customer, order or account (not documents), or when embedding, prompt and model versions must be managed like an ML system, load python-ml-predictive reference ml-system-architecture-fti.md (feature/training/inference pipelines, entity-keyed retrieval, version coupling).

Multi-Tenant Addendum

This skill describes RAG patterns in general. When the RAG feature ships inside a multi-tenant SaaS, the production answer is ai-rag-multi-tenant — per-tenant ingestion pipelines, vector store partitioning, tier-specific chunking and embedding models, defence-in-depth retrieval security, and citation grounding tied to live sources.

Cross-references:

  • ai-rag-multi-tenant — multi-tenant RAG end-to-end.
  • ai-tenant-isolation-patterns — vector-store partitioning tradeoffs and data-bleed tests.
  • ai-on-saas-architecture — KB service as a control-plane service.
  • ai-hallucination-slo-and-grounding — citation grounding + faithfulness SLO.
  • ai-model-gateway — gateway-mediated retrieval calls.
  • saas-tenant-data-portability-and-erasure — KB erasure cascade for embeddings.
  • Catalog metadata for AI — load when retrieval or an agent draws on data-catalog or data-contract metadata: classification-first filtering, ODCS context block, provenance.

Consolidated Child References

同梱ファイル

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

よくある質問

AIスキル「Ai Rag Patterns」では何ができますか?

非公開データ、ドキュメント、ポリシー、または鮮度が重要な情報に関する質問に答える機能を構築するときに使います。RAGアーキテクチャ、チャンク分割、ハイブリッド検索、再ランキング、ベクトルデータベース、評価、エージェント型・マルチモーダルRAG、コンテキストが不足したサブエージェント向けの範囲を限定した反復検索を扱います。

TypingMindでAi Rag Patternsを使うメリットは何ですか?

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

TypingMindにAi Rag Patternsをインストールするにはどうすればよいですか?

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

Ai Rag Patternsを使えるAIモデルはどれですか?

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

Ai Rag Patternsで使えるAIモデルの数に制限はありますか?

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

AIスキル「Ai Rag Patterns」は無料ですか?

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

AIスキルとは何ですか?

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

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

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

すべて見る

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

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