Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
4.0 KiB
4.0 KiB
More about RAG
On this page
- Before you begin
- What is RAG?
- Set up RAG with R2R
- Configure RAG settings
- How RAG works in R2R
- Best Practices
RAG (Retrieval-Augmented Generation) combines the power of large language models with precise information retrieval from your own documents. When users ask questions, RAG first retrieves relevant information from your document collection, then uses this context to generate accurate, contextual responses. This ensures AI responses are both relevant and grounded in your specific knowledge base.
Before you begin
RAG in R2R has the following requirements:
- A running R2R instance (local or deployed)
- Access to an LLM provider (OpenAI, Anthropic, or local models)
- Documents ingested into your R2R system
- Basic configuration for document processing and embedding generation
What is RAG?
RAG operates in three main steps:
- Retrieval: Finding relevant information from your documents
- Augmentation: Adding this information as context for the AI
- Generation: Creating responses using both the context and the AI's knowledge
Benefits over traditional LLM applications:
- More accurate responses based on your specific documents
- Reduced hallucination by grounding answers in real content
- Ability to work with proprietary or recent information
- Better control over AI outputs
Set up RAG with R2R
To start using RAG in R2R:
- Install and start R2R:
pip install r2r
r2r serve --docker
- Ingest your documents:
r2r documents create --file-paths /path/to/your/documents
- Test basic RAG functionality:
r2r retrieval rag --query="your question here"
Configure RAG settings
R2R offers several ways to customize RAG behavior:
Retrieval Settings
# Using hybrid search (combines semantic and keyword search)
client.retrieval.rag(
query="your question",
vector_search_settings={"use_hybrid_search": True}
)
# Adjusting number of retrieved chunks
client.retrieval.rag(
query="your question",
vector_search_settings={"limit": 30}
)
Generation Settings
# Adjusting response style
client.retrieval.rag(
query="your question",
rag_generation_config={
"temperature": 0.7,
"model": "openai/gpt-4"
}
)
How RAG works in R2R
R2R's RAG implementation uses a sophisticated process:
Document Processing
- Documents are split into semantic chunks
- Each chunk is embedded using AI models
- Chunks are stored with metadata and relationships
Retrieval Process
- Queries are processed using hybrid search
- Both semantic similarity and keyword matching are considered
- Results are ranked by relevance scores
Response Generation
- Retrieved chunks are formatted as context
- The LLM generates responses using this context
- Citations and references can be included
Advanced Features
- GraphRAG for relationship-aware responses
- Multi-step RAG for complex queries
- Agent-based RAG for interactive conversations
Best Practices
Document Processing
- Use appropriate chunk sizes (256-1024 tokens)
- Maintain document metadata
- Consider document relationships
Query Optimization
- Use hybrid search for better retrieval
- Adjust relevance thresholds
- Monitor and analyze search performance
Response Generation
- Balance temperature for creativity vs accuracy
- Use system prompts for consistent formatting
- Implement error handling and fallbacks
Learn More
For more detailed information, explore these resources:
- RAG Configuration Guide - Advanced configuration options
- Search and RAG Documentation - Complete search capabilities
- Quickstart Guide - Get started with R2R
- System Architecture - Understand how RAG fits into R2R