RAG Implementation

Implement robust Retrieval-Augmented Generation for ChromaDB and Postgres.

xiangteng007 f9fc9d3 892 B Updated

File contents

RAG Implementation Guidelines

Hybrid Search Strategy

  • Pure vector search fails on precise terminology (e.g., specific steel grades or project IDs).
  • Mandatory Mix: Always combine Dense Vector Search (ChromaDB) with Sparse Keyword Search (PostgreSQL + pg_trgm / BM25).

Context Window Optimization

  • Chunking: Break documents down by semantic boundaries (headers, paragraphs), not arbitrary character limits.
  • Reranking: Use a lightweight Cross-Encoder model locally or via API to rerank the top 20 retrieved chunks down to the top 5 most relevant before feeding to the Agent prompt.
  • Metadata Filtering: Always use structured filters (Date >= X, Source = Y) before performing exact k-NN vector distance matches to drastically improve speed.

xiangteng007/XXT-AGENT/tree/main/.agents/skills/rag-implementation commit f9fc9d3227

Frequently asked questions

npx skillmds add xiangteng007/rag-implementation