Minor update to docs
RAG-Templates is now complete as a reusable framework with all core components delivered:
Documentation: π Full Documentation Index
Quick Links:
# 1. Clone and setup environment git clone cd rag-templates make setup-env # Creates .venv using uv make install # Installs dependencies2. Activate environment
source .venv/bin/activate # Windows: .venv\Scripts\activate
3. Start database
docker-compose up -d
4. Initialize database
make setup-db
make load-data5. Create .env file with API keys
cat > .env << 'EOF'
OPENAI_API_KEY=your-key-here
IRIS_HOST=localhost
IRIS_PORT=1972
EOF6. Try different pipelines
python -c "
from iris_rag import create_pipelineBasic RAG - simplest approach
pipeline = create_pipeline('basic')
result = pipeline.query('What is machine learning?', top_k=5)
print(result['answer'])
"
RAG-Templates uses binary .DAT fixtures for fast, reproducible testing. .DAT fixtures are 100-200x faster than JSON fixtures (0.5-2 seconds vs 39-75 seconds for 100 entities).
# 1. List available fixtures make fixture-listExample output:
Name Version Type Tables Rows Embeddings
----------------------------------------------------------------------------------------------
medical-graphrag-20 1.0.0 dat 3 tables 39 Required
2. Get detailed fixture information
make fixture-info FIXTURE=medical-graphrag-20
3. Load fixture into IRIS database
make fixture-load FIXTURE=medical-graphrag-20
4. Validate fixture integrity
make fixture-validate FIXTURE=medical-graphrag-20
Automatic Loading (Recommended):
import pytest
@pytest.mark.dat_fixture("medical-graphrag-20")
def test_with_fixture():
# Fixture automatically loaded before test
# Database contains 21 entities, 15 relationships, pre-computed embeddings
pipeline = create_pipeline("graphrag")
result = pipeline.query("What are cancer treatment targets?")
assert len(result["retrieved_documents"]) > 0
Manual Loading:
from tests.fixtures.manager import FixtureManagerdef test_manual_fixture_load():
manager = FixtureManager()
result = manager.load_fixture(
fixture_name="medical-graphrag-20",
cleanup_first=True, # Clean database first
validate_checksum=True, # Verify fixture integrity
generate_embeddings=False, # Already included in .DAT
)assert result.success assert result.rows_loaded == 39 # Total rows across all tables
# 1. Populate IRIS with test data (manually or via script) python scripts/load_test_data.py2. Create fixture from current database state
make fixture-create FIXTURE=my-test-data
Interactive mode (recommended for first-time users):
python -m tests.fixtures.cli workflow
Command-line mode:
python -m tests.fixtures.cli create my-fixture
--tables RAG.SourceDocuments,RAG.Entities,RAG.EntityRelationships
--description "My test fixture"
--generate-embeddings
# Full CLI help python -m tests.fixtures.cli --helpCommon commands:
python -m tests.fixtures.cli list # List all fixtures
python -m tests.fixtures.cli info medical-graphrag-20 # Fixture details
python -m tests.fixtures.cli load medical-graphrag-20 # Load fixture
python -m tests.fixtures.cli validate my-fixture # Validate integrity
python -m tests.fixtures.cli snapshot snapshot-20250114 # Quick DB snapshot
All integration and E2E tests with β₯10 entities MUST use .DAT fixtures (see .specify/memory/constitution.md for complete IRIS testing principles).
Decision Tree:
Documentation:
tests/fixtures/README.mdexamples/fixtures/basic_usage.py.specify/memory/constitution.md (Principle II)All pipelines follow a consistent, standardized API:
from iris_rag import create_pipelineAvailable pipeline types:
- "basic" : BasicRAG (vector similarity)
- "basic_rerank" : BasicRAG + cross-encoder reranking
- "crag" : Corrective RAG with self-evaluation
- "graphrag" : HybridGraphRAG (vector + text + graph)
- "pylate_colbert" : ColBERT late interaction
pipeline = create_pipeline(
pipeline_type="basic",
validate_requirements=True, # Auto-validate DB setup
auto_setup=False, # Auto-fix issues if True
)
from iris_rag.core.models import DocumentOption 1: From Document objects
docs = [
Document(
page_content="Python is a programming language...",
metadata={"source": "intro.txt", "author": "John"}
)
]
result = pipeline.load_documents(documents=docs)Option 2: From file path
result = pipeline.load_documents(documents_path="data/docs.json")
Returns: {"documents_loaded": 10, "embeddings_generated": 10, "documents_failed": 0}
# Standard query signature for ALL pipelines result = pipeline.query( query="What is machine learning?", top_k=5, # Number of documents to return (1-100) generate_answer=True, # Generate LLM answer (default: True) include_sources=True, # Include source metadata (default: True) )Standardized response format (LangChain & RAGAS compatible):
{
"query": "What is machine learning?",
"answer": "Machine learning is...", # LLM-generated answer
"retrieved_documents": [Document(...)], # LangChain Document objects
"contexts": ["context 1", "context 2"], # RAGAS-compatible contexts
"sources": [{"source": "file.txt", ...}], # Source references
"execution_time": 0.523,
"metadata": {
"num_retrieved": 5,
"pipeline_type": "basic",
"retrieval_method": "vector",
"context_count": 5,
...
}
}
# BasicRAGReranking - Control reranking behavior pipeline = create_pipeline("basic_rerank") result = pipeline.query(query, top_k=5) # Retrieves rerank_factor*5, returns top 5CRAG - Retrieval evaluation
pipeline = create_pipeline("crag")
result = pipeline.query(query, top_k=5, generate_answer=True)HybridGraphRAG - Multi-modal search
pipeline = create_pipeline("graphrag")
result = pipeline.query(
query_text="cancer targets",
method="rrf", # rrf, hybrid, vector, text, graph
vector_k=30,
text_k=30
)PyLateColBERT - Late interaction retrieval
pipeline = create_pipeline("pylate_colbert")
result = pipeline.query(query, top_k=5) # Uses ColBERT late interaction
The RAG-Templates framework includes comprehensive testing tools to ensure code quality and maintainability:
Coverage Warnings - Automated coverage monitoring without failing builds
.coveragercError Message Validation - Ensures helpful test failure messages
TDD Compliance - Validates Test-Driven Development workflow
# Run all tests with coverage pytest --cov=iris_rag --cov=commonRun specific test categories
pytest tests/unit/ # Unit tests only
pytest tests/integration/ # Integration tests
pytest tests/contract/ # Contract testsValidate TDD compliance
python scripts/validate_tdd_compliance.py
Check requirement-task mapping
python scripts/validate_task_mapping.py --spec specs//spec.md --tasks specs//tasks.md
Install pre-commit hooks for automated quality checks:
pip install pre-commit
pre-commit install
This enables:
| Technique | Original Paper | Key Repository | Additional Resources |
|---|---|---|---|
| Basic RAG | Retrieval-Augmented Generation | Facebook Research | LangChain RAG |
| ColBERT | ColBERT: Efficient and Effective Passage Retrieval | Stanford ColBERT | Pylate Integration |
| CRAG | Corrective Retrieval Augmented Generation | CRAG Implementation | LangGraph CRAG |
| HyDE | Precise Zero-Shot Dense Retrieval | HyDE Official | LangChain HyDE |
| GraphRAG | From Local to Global: A Graph RAG Approach | Microsoft GraphRAG | Neo4j GraphRAG |
| NodeRAG | Hierarchical Text Retrieval | NodeRAG Implementation | Hierarchical Retrieval |
MIT License - see https://github.com/intersystems-community/iris-vector-rag/blob/master/LICENSE file for details.