yonatangross/orchestkitMIT43 files

RAG Retrieval

Retrieval-Augmented Generation patterns for grounded LLM responses. Use when building RAG pipelines, embedding documents, implementing hybrid search, contextual retrieval, HyDE, agentic RAG, multimodal RAG, query decomposition, reranking, or pgvector search.

Specification
Skill ID
yonatangross/orchestkit/rag-retrieval
Publisher
yonatangross
Repository
orchestkit
Installs
0
Files
43
License
MIT
Requires
Claude Code 2.1.277+.
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

yonatangross/orchestkit/rag-retrievalInstalls these files
  • SKILL.md
  • checklists/rag-quality.md
  • checklists/search-implementation-checklist.md
  • examples/chatbot-with-rag-example.ts
  • metadata.json
  • rules/_sections.md
  • rules/_template.md
  • rules/agentic-adaptive-retrieval.md
  • rules/agentic-corrective-rag.md
  • rules/agentic-knowledge-graph.md
  • rules/agentic-self-rag.md
  • rules/contextual-hybrid.md
  • rules/contextual-pipeline.md
  • rules/contextual-prepend.md
  • rules/core-basic-rag.md
  • rules/core-context-management.md
  • rules/core-hybrid-search.md
  • rules/core-pipeline-composition.md
  • rules/embeddings-advanced.md
  • rules/embeddings-chunking.md
  • rules/embeddings-models.md
  • rules/hyde-fallback.md
  • rules/hyde-generation.md
  • rules/hyde-per-concept.md
  • rules/multimodal-chunking.md
  • rules/multimodal-embeddings.md
  • rules/multimodal-pipeline.md
  • rules/pgvector-hybrid-search.md
  • rules/pgvector-indexing.md
  • rules/pgvector-metadata.md
  • rules/pgvector-schema.md
  • rules/query-decompose.md
  • rules/query-detection.md
  • rules/query-hyde-combo.md
  • rules/reranking-combined.md
  • rules/reranking-cross-encoder.md
  • rules/reranking-llm.md
  • scripts/chunk-repository.py
  • scripts/rag-pipeline-template.ts
  • scripts/scripts/crag-workflow.py
  • scripts/scripts/self-rag-graph.py
  • scripts/search-service.py
  • test-cases.json

What this skill tells the agent

RAG Retrieval

Comprehensive patterns for building production RAG systems. Each category has individual rule files in rules/ loaded on-demand.

House thresholds, fusion ordering, and the latency and quality budgets we assert live in House delta below. Vendor documentation is linked, not restated (see Upstream coverage).

Quick Reference

CategoryRulesImpactWhen to Use
Core RAG4CRITICALBasic RAG, citations, hybrid search, context management
Embeddings3HIGHModel selection, chunking, batch/cache optimization
Contextual Retrieval3HIGHContext-prepending, hybrid BM25+vector, pipeline
HyDE3HIGHVocabulary mismatch, hypothetical document generation
Agentic RAG4HIGHSelf-RAG, CRAG, knowledge graphs, adaptive routing
Multimodal RAG3MEDIUMImage+text retrieval, PDF chunking, cross-modal search
Query Decomposition3MEDIUMMulti-concept queries, parallel retrieval, RRF fusion
Reranking3MEDIUMCross-encoder, LLM scoring, combined signals
PGVector4HIGHPostgreSQL hybrid search, HNSW indexes, schema design

Total: 30 rules across 9 categories

Core RAG

Fundamental patterns for retrieval, generation, and pipeline composition.

RuleFileKey Pattern
Basic RAGrules/core-basic-rag.mdRetrieve + context + generate with citations
Hybrid Searchrules/core-hybrid-search.mdRRF fusion (k=60) for semantic + keyword
Context Managementrules/core-context-management.mdToken budgeting + sufficiency check
Pipeline Compositionrules/core-pipeline-composition.mdComposable Decompose → HyDE → Retrieve → Rerank

Embeddings

Embedding models, chunking strategies, and production optimization.

RuleFileKey Pattern
Models & APIrules/embeddings-models.mdModel selection, batch API, similarity
Chunkingrules/embeddings-chunking.mdSemantic boundary splitting, 512 token sweet spot
Advancedrules/embeddings-advanced.mdRedis cache, Matryoshka dims, batch processing

Contextual Retrieval

Anthropic's context-prepending technique — 67% fewer retrieval failures.

RuleFileKey Pattern
Context Prependingrules/contextual-prepend.mdLLM-generated context + prompt caching
Hybrid Searchrules/contextual-hybrid.md40% BM25 / 60% vector weight split
Complete Pipelinerules/contextual-pipeline.mdEnd-to-end indexing + hybrid retrieval

HyDE

Hypothetical Document Embeddings for bridging vocabulary gaps.

RuleFileKey Pattern
Generationrules/hyde-generation.mdEmbed hypothetical doc, not query
Per-Conceptrules/hyde-per-concept.mdParallel HyDE for multi-topic queries
Fallbackrules/hyde-fallback.md2-3s timeout → direct embedding fallback

Agentic RAG

Self-correcting retrieval with LLM-driven decision making.

RuleFileKey Pattern
Self-RAGrules/agentic-self-rag.mdBinary document grading for relevance
Corrective RAGrules/agentic-corrective-rag.mdCRAG workflow with web fallback
Knowledge Graphrules/agentic-knowledge-graph.mdKG + vector hybrid for entity-rich domains
Adaptive Retrievalrules/agentic-adaptive-retrieval.mdQuery routing to optimal strategy

Multimodal RAG

Image + text retrieval with cross-modal search.

RuleFileKey Pattern
Embeddingsrules/multimodal-embeddings.mdCLIP, SigLIP 2, Voyage multimodal-3
Chunkingrules/multimodal-chunking.mdPDF extraction preserving images
Pipelinerules/multimodal-pipeline.mdDedup + hybrid retrieval + generation

Query Decomposition

Breaking complex queries into concepts for parallel retrieval.

RuleFileKey Pattern
Detectionrules/query-detection.mdHeuristic indicators (<1ms fast path)
Decompose + RRFrules/query-decompose.mdLLM concept extraction + parallel retrieval
HyDE Comborules/query-hyde-combo.mdDecompose + HyDE for maximum coverage

Reranking

Post-retrieval re-scoring for higher precision.

RuleFileKey Pattern
Cross-Encoderrules/reranking-cross-encoder.mdms-marco-MiniLM (~50ms, free)
LLM Rerankingrules/reranking-llm.mdBatch scoring + Cohere API
Combinedrules/reranking-combined.mdMulti-signal weighted scoring

PGVector

Production hybrid search with PostgreSQL.

RuleFileKey Pattern
Schemarules/pgvector-schema.mdHNSW index + pre-computed tsvector
Hybrid Searchrules/pgvector-hybrid-search.mdSQLAlchemy RRF with FULL OUTER JOIN
Indexingrules/pgvector-indexing.mdHNSW (17x faster) vs IVFFlat
Metadatarules/pgvector-metadata.mdFiltering, boosting, Redis 8 comparison

Quick Start Example

from openai import OpenAI

client = OpenAI()

async def rag_query(question: str, top_k: int = 5) -> dict:
    """Basic RAG with citations."""
    docs = await vector_db.search(question, limit=top_k)
    context = "\n\n".join([f"[{i+1}] {doc.text}" for i, doc in enumerate(docs)])

    response = await llm.chat([
        {"role": "system", "content": "Answer with inline citations [1], [2]. Use ONLY provided context."},
        {"role": "user", "content": f"Context:\n{context}\n\nQuestion: {question}"}
    ])

    return {"answer": response.content, "sources": [d.metadata['source'] for d in docs]}

Key Decisions

DecisionRecommendation
Embedding modeltext-embedding-3-small (general), voyage-3.5 (production)
Chunk size256-1024 tokens (512 typical)
Hybrid weight40% BM25 / 60% vector
Top-k3-10 documents
Temperature0.1-0.3 (factual)
Context budget4K-8K tokens
RerankingRetrieve 50, rerank to 10
Vector indexHNSW (production), IVFFlat (high-volume)
HyDE timeout2-3 seconds with fallback
Query decompositionHeuristic first, LLM only if multi-concept

Upstream coverage (do not restate)

Fetch these from the source instead of restating them here. Where a row says the house subset stays, that named file carries only the tuned values and the reason, not a tutorial.

TopicSource
pgvector install, operators, index build syntax, "why isn't my index used"https://github.com/pgvector/pgvector; house subset (HNSW m=16, ef_construction=64, halfvec, binary quantize) stays in rules/pgvector-indexing.md and rules/pgvector-schema.md
Postgres full-text search: tsvector, tsquery, GIN, ts_rank_cdhttps://www.postgresql.org/docs/current/textsearch.html; house subset (generated STORED column) stays in rules/pgvector-schema.md
Reading query plans, confirming an index is used, VACUUM/ANALYZEhttps://www.postgresql.org/docs/current/using-explain.html
RRF mechanics: rank constant, rank window size, tie handlinghttps://www.elastic.co/docs/reference/elasticsearch/rest-apis/reciprocal-rank-fusion; house subset (k=60, 3x fetch) stays in rules/core-hybrid-search.md and rules/pgvector-hybrid-search.md
Field-weighted boosting and scoring profiles as a concepthttps://learn.microsoft.com/en-us/azure/search/index-add-scoring-profiles; our boost factors and their ordering are in House delta and rules/pgvector-metadata.md

Use this skill in a project

Open any RiverX project, search the Skills panel for yonatangross/orchestkit/rag-retrieval, and install it in one click.

Use this skill