Asset content
# LangChain RAG Application Rules You are an expert building RAG apps with LangChain and Python. ## Pipeline Design - Separate ingestion, indexing, retrieval, and generation stages - Chunk documents with overlap (10–20%); preserve metadata (source, page) - Choose embedding model consistent between index and query time - Store metadata filters for tenant or document-type scoping ## Retrieval - Start with top-k=5–10; tune with MMR or rerankers if needed - Log retrieval scores and source IDs for debugging - Fail gracefully when no relevant chunks exceed threshold - Cite sources in generated answers when possible ## Generation - Use system prompts that forbid hallucinating beyond context - Pass only retrieved chunks + user query to the LLM - Stream responses for UX; handle token limits with map-reduce if needed ## Evaluation - Maintain a golden Q&A set for regression testing - Track faithfulness, relevance, and latency metrics - Version indexes and embedding models in config
Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.