Skip to main content

RAG pipelines with InterSystems IRIS as the vector database. Six strategies (basic, rerank, CRAG, GraphRAG, multi-query RRF, ColBERT), unified API, RAGAS evaluation.

Project description

IRIS Vector RAG

Production-ready RAG (Retrieval-Augmented Generation) pipelines powered by InterSystems IRIS vector search.

Author: Thomas Dyar (thomas.dyar@intersystems.com)

Quick Start

# 1. Clone and install
git clone https://github.com/intersystems-community/iris-vector-rag.git
cd iris-vector-rag
pip install -e .

# 2. Start IRIS
docker compose up -d

# 3. Configure
cp .env.example .env
# Edit .env — add your OPENAI_API_KEY

# 4. Query
python -c "
from iris_vector_rag import create_pipeline
from iris_vector_rag.core.models import Document

pipeline = create_pipeline('basic')
pipeline.load_documents(documents=[
    Document(page_content='RAG combines retrieval with generation for accurate AI.', metadata={'source': 'intro.pdf'}),
    Document(page_content='Vector search finds similar content using embeddings.', metadata={'source': 'vectors.pdf'}),
])
result = pipeline.query('What is RAG?', top_k=5, generate_answer=True)
print(result['answer'])
"

Pipelines

All pipelines share the same interface — switch with one line:

from iris_vector_rag import create_pipeline

pipeline = create_pipeline('basic')           # Vector similarity search
pipeline = create_pipeline('basic_rerank')    # + cross-encoder reranking
pipeline = create_pipeline('crag')            # + self-correction + web fallback
pipeline = create_pipeline('graphrag')        # + knowledge graph + entity reasoning
pipeline = create_pipeline('multi_query_rrf') # + query expansion + rank fusion
pipeline = create_pipeline('pylate_colbert')  # + ColBERT late interaction
Pipeline Method Best For
basic Vector similarity General Q&A, getting started
basic_rerank Vector + reranking Higher accuracy, medical/legal
crag Vector + evaluation + web Fact-checking, current events
graphrag Vector + text + graph + RRF Complex relationships, research
multi_query_rrf Query expansion + fusion Comprehensive coverage
pylate_colbert ColBERT embeddings Fine-grained matching

Response Format

All pipelines return the same structure (LangChain/RAGAS compatible):

result = pipeline.query("What is diabetes?", top_k=5)

result["answer"]                # LLM-generated answer
result["retrieved_documents"]   # List[Document]
result["contexts"]              # List[str] — for RAGAS evaluation
result["sources"]               # Source citations
result["metadata"]              # Timing, pipeline type, method used

Configuration

Environment variables (loaded automatically from .env):

OPENAI_API_KEY=sk-...          # Required for answer generation
IRIS_HOST=localhost             # IRIS SuperServer host
IRIS_PORT=1972                  # IRIS SuperServer port
IRIS_NAMESPACE=USER             # IRIS namespace
IRIS_USERNAME=_SYSTEM           # IRIS username
IRIS_PASSWORD=SYS               # IRIS password

Evaluate with RAGAS

Compare pipelines side-by-side using real RAGAS metrics:

python examples/compare_pipelines.py --pipelines basic,basic_rerank

Or in code:

from iris_vector_rag import create_pipeline
from ragas import evaluate, EvaluationDataset, SingleTurnSample
from ragas.metrics import faithfulness, context_precision, context_recall

pipeline = create_pipeline('basic')
pipeline.load_documents(documents=docs)
result = pipeline.query("What is diabetes?", top_k=3, generate_answer=True)

sample = SingleTurnSample(
    user_input="What is diabetes?",
    response=result["answer"],
    retrieved_contexts=result["contexts"],
    reference="Diabetes is a chronic condition...",
)
scores = evaluate(EvaluationDataset(samples=[sample]),
                  metrics=[faithfulness, context_precision, context_recall])

Optional Extras

pip install iris-vector-rag[colbert]     # ColBERT/PyLate support
pip install iris-vector-rag[dspy]        # DSPy prompt optimization
pip install iris-vector-rag[evaluation]  # RAGAS evaluation framework
pip install iris-vector-rag[api]         # REST API server (FastAPI + Redis)

MCP Server

Use as an AI tool server via Model Context Protocol:

docker build -f Dockerfile.mcp -t iris-vector-rag-mcp .
docker run -p 3000:3000 --env-file .env iris-vector-rag-mcp

Development

pip install -e ".[dspy,evaluation]"
pytest tests/unit/                    # Fast, no IRIS needed
pytest tests/unit/ tests/contract/    # Full suite, needs IRIS running

Architecture

iris_vector_rag/
├── pipelines/      # 6 RAG implementations (basic, crag, graphrag, etc.)
├── core/           # Base classes, models, connection management
├── storage/        # IRIS vector store, schema management
├── embeddings/     # Embedding generation and caching
├── services/       # Entity extraction, storage adapters
├── config/         # Configuration management
├── mcp/            # MCP server implementation
└── api/            # Optional REST API (FastAPI)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iris_vector_rag-0.11.2.tar.gz (348.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iris_vector_rag-0.11.2-py3-none-any.whl (377.0 kB view details)

Uploaded Python 3

File details

Details for the file iris_vector_rag-0.11.2.tar.gz.

File metadata

  • Download URL: iris_vector_rag-0.11.2.tar.gz
  • Upload date:
  • Size: 348.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for iris_vector_rag-0.11.2.tar.gz
Algorithm Hash digest
SHA256 80373b2776c318e5626a5dabed967c23b8d573a43be209f251931821df39542f
MD5 6fc853c2eb1bf40f464a00a38e841d8a
BLAKE2b-256 dbeb3c41b026418b7ff7a949b25be161a29ef948de37cb3ea9c303e6c7d9f0e2

See more details on using hashes here.

File details

Details for the file iris_vector_rag-0.11.2-py3-none-any.whl.

File metadata

File hashes

Hashes for iris_vector_rag-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 84c41fd5e03ee64e46425597596e282a05dc0ba00758d18fb1ba3f5015e6e3d1
MD5 fab46bffa7aba3567b40bb92b97e45b4
BLAKE2b-256 0e9013941eabd60a10668e3ccc29fb802edd775d5c0801662f84a59320d38622

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page