iris-vector-rag 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iris_vector_rag-0.2.0/PKG-INFO +504 -0
- iris_vector_rag-0.2.0/README.md +404 -0
- iris_vector_rag-0.2.0/adapters/rag_templates_bridge.py +578 -0
- iris_vector_rag-0.2.0/common/__init__.py +1 -0
- iris_vector_rag-0.2.0/common/batch_utils.py +294 -0
- iris_vector_rag-0.2.0/common/config.py +58 -0
- iris_vector_rag-0.2.0/common/connection_manager.py +242 -0
- iris_vector_rag-0.2.0/common/connection_pool.py +445 -0
- iris_vector_rag-0.2.0/common/database.py +141 -0
- iris_vector_rag-0.2.0/common/database_schema_manager.py +289 -0
- iris_vector_rag-0.2.0/common/db_init_with_indexes.py +181 -0
- iris_vector_rag-0.2.0/common/db_vector_utils.py +181 -0
- iris_vector_rag-0.2.0/common/environment_manager.py +220 -0
- iris_vector_rag-0.2.0/common/huggingface_utils.py +206 -0
- iris_vector_rag-0.2.0/common/iris_client.py +92 -0
- iris_vector_rag-0.2.0/common/iris_connection_manager.py +411 -0
- iris_vector_rag-0.2.0/common/iris_connection_pool.py +360 -0
- iris_vector_rag-0.2.0/common/iris_connector.py +71 -0
- iris_vector_rag-0.2.0/common/iris_dbapi_connector.py +323 -0
- iris_vector_rag-0.2.0/common/iris_index_utils.py +195 -0
- iris_vector_rag-0.2.0/common/iris_sql_utils.py +704 -0
- iris_vector_rag-0.2.0/common/iris_stream_reader.py +166 -0
- iris_vector_rag-0.2.0/common/llm_cache_config.py +308 -0
- iris_vector_rag-0.2.0/common/llm_cache_iris.py +671 -0
- iris_vector_rag-0.2.0/common/llm_cache_manager.py +911 -0
- iris_vector_rag-0.2.0/common/utils.py +559 -0
- iris_vector_rag-0.2.0/common/vector_sql_utils.py +584 -0
- iris_vector_rag-0.2.0/evaluation_framework/__init__.py +66 -0
- iris_vector_rag-0.2.0/evaluation_framework/biomedical_question_generator.py +826 -0
- iris_vector_rag-0.2.0/evaluation_framework/comparative_analysis_system.py +1173 -0
- iris_vector_rag-0.2.0/evaluation_framework/empirical_reporting.py +1298 -0
- iris_vector_rag-0.2.0/evaluation_framework/evaluation_orchestrator.py +1123 -0
- iris_vector_rag-0.2.0/evaluation_framework/execute_production_evaluation.py +382 -0
- iris_vector_rag-0.2.0/evaluation_framework/pmc_data_pipeline.py +1332 -0
- iris_vector_rag-0.2.0/evaluation_framework/production_evaluation_config.py +353 -0
- iris_vector_rag-0.2.0/evaluation_framework/ragas_metrics_framework.py +1013 -0
- iris_vector_rag-0.2.0/evaluation_framework/real_production_evaluation.py +544 -0
- iris_vector_rag-0.2.0/evaluation_framework/run_10k_evaluation.py +175 -0
- iris_vector_rag-0.2.0/evaluation_framework/simple_test.py +364 -0
- iris_vector_rag-0.2.0/evaluation_framework/statistical_evaluation_methodology.py +1016 -0
- iris_vector_rag-0.2.0/evaluation_framework/test_framework.py +281 -0
- iris_vector_rag-0.2.0/evaluation_framework/test_iris_connectivity.py +244 -0
- iris_vector_rag-0.2.0/evaluation_framework/test_small_scale_evaluation.py +432 -0
- iris_vector_rag-0.2.0/evaluation_framework/true_e2e_evaluation.py +639 -0
- iris_vector_rag-0.2.0/evaluation_framework/visualization_engine.py +585 -0
- iris_vector_rag-0.2.0/iris_rag/__init__.py +284 -0
- iris_vector_rag-0.2.0/iris_rag/config/default_config.yaml +295 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/PKG-INFO +504 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/SOURCES.txt +71 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/dependency_links.txt +1 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/entry_points.txt +2 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/not-zip-safe +1 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/requires.txt +71 -0
- iris_vector_rag-0.2.0/iris_vector_rag.egg-info/top_level.txt +4 -0
- iris_vector_rag-0.2.0/pyproject.toml +243 -0
- iris_vector_rag-0.2.0/setup.cfg +4 -0
- iris_vector_rag-0.2.0/setup.py +134 -0
- iris_vector_rag-0.2.0/tests/test_comprehensive_pipeline_validation_e2e.py +459 -0
- iris_vector_rag-0.2.0/tests/test_comprehensive_pipeline_validation_e2e_fixed.py +528 -0
- iris_vector_rag-0.2.0/tests/test_enterprise_storage.py +515 -0
- iris_vector_rag-0.2.0/tests/test_entity_extraction_service.py +291 -0
- iris_vector_rag-0.2.0/tests/test_hybrid_graphrag_functional.py +394 -0
- iris_vector_rag-0.2.0/tests/test_index_ensure.py +298 -0
- iris_vector_rag-0.2.0/tests/test_mcp_integration.py +256 -0
- iris_vector_rag-0.2.0/tests/test_mcp_server_integration.py +738 -0
- iris_vector_rag-0.2.0/tests/test_ontology_loader.py +555 -0
- iris_vector_rag-0.2.0/tests/test_ontology_support.py +804 -0
- iris_vector_rag-0.2.0/tests/test_performance_monitor_comprehensive.py +485 -0
- iris_vector_rag-0.2.0/tests/test_performance_monitor_working.py +341 -0
- iris_vector_rag-0.2.0/tests/test_pylate_colbert_pipeline.py +913 -0
- iris_vector_rag-0.2.0/tests/test_schema_manager_bugs.py +370 -0
- iris_vector_rag-0.2.0/tests/test_temporal_manager.py +507 -0
- iris_vector_rag-0.2.0/tests/test_vector_safe_helpers.py +252 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iris-vector-rag
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Dead-simple library for building RAG applications with InterSystems IRIS
|
|
5
|
+
Home-page: https://github.com/intersystems/rag-templates
|
|
6
|
+
Author: InterSystems
|
|
7
|
+
Author-email: InterSystems <support@intersystems.com>
|
|
8
|
+
Maintainer-email: Thomas Dyar <thomas.dyar@intersystems.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/intersystems/rag-templates
|
|
11
|
+
Project-URL: Documentation, https://github.com/intersystems/rag-templates/docs
|
|
12
|
+
Project-URL: Repository, https://github.com/intersystems/rag-templates
|
|
13
|
+
Project-URL: Bug Tracker, https://github.com/intersystems/rag-templates/issues
|
|
14
|
+
Project-URL: Changelog, https://github.com/intersystems/rag-templates/blob/main/CHANGELOG.md
|
|
15
|
+
Keywords: rag,retrieval-augmented-generation,intersystems,iris,vector-database,llm,ai,machine-learning,nlp,embeddings,semantic-search,mcp,model-context-protocol
|
|
16
|
+
Classifier: Development Status :: 4 - Beta
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Topic :: Database
|
|
27
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
28
|
+
Requires-Python: >=3.8
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
Requires-Dist: openai>=1.0.0
|
|
31
|
+
Requires-Dist: anthropic>=0.25.0
|
|
32
|
+
Requires-Dist: sentence-transformers>=2.2.0
|
|
33
|
+
Requires-Dist: numpy>=1.21.0
|
|
34
|
+
Requires-Dist: pandas>=1.3.0
|
|
35
|
+
Requires-Dist: pyyaml>=6.0
|
|
36
|
+
Requires-Dist: requests>=2.28.0
|
|
37
|
+
Requires-Dist: tqdm>=4.64.0
|
|
38
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
39
|
+
Requires-Dist: psutil>=7.0.0
|
|
40
|
+
Requires-Dist: intersystems-irispython>=5.1.2
|
|
41
|
+
Requires-Dist: langchain-openai>=0.3.24
|
|
42
|
+
Requires-Dist: langchain>=0.3.25
|
|
43
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
44
|
+
Requires-Dist: matplotlib>=3.10.3
|
|
45
|
+
Requires-Dist: ragas>=0.2.15
|
|
46
|
+
Requires-Dist: seaborn>=0.13.2
|
|
47
|
+
Requires-Dist: plotly>=6.1.2
|
|
48
|
+
Requires-Dist: jaydebeapi>=1.2.3
|
|
49
|
+
Requires-Dist: docker>=6.1.3
|
|
50
|
+
Requires-Dist: tiktoken>=0.5.0
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: uv>=0.1.0; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
55
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
56
|
+
Requires-Dist: pytest-dotenv>=0.5.2; extra == "dev"
|
|
57
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
58
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
59
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
60
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
61
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
62
|
+
Requires-Dist: build>=0.10.0; extra == "dev"
|
|
63
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
64
|
+
Provides-Extra: mcp
|
|
65
|
+
Requires-Dist: mcp>=0.1.0; extra == "mcp"
|
|
66
|
+
Requires-Dist: fastapi>=0.100.0; extra == "mcp"
|
|
67
|
+
Requires-Dist: uvicorn>=0.23.0; extra == "mcp"
|
|
68
|
+
Requires-Dist: websockets>=11.0.0; extra == "mcp"
|
|
69
|
+
Provides-Extra: api
|
|
70
|
+
Requires-Dist: fastapi>=0.104.0; extra == "api"
|
|
71
|
+
Requires-Dist: uvicorn[standard]>=0.24.0; extra == "api"
|
|
72
|
+
Requires-Dist: python-multipart>=0.0.6; extra == "api"
|
|
73
|
+
Requires-Dist: websockets>=12.0; extra == "api"
|
|
74
|
+
Requires-Dist: redis>=5.0.0; extra == "api"
|
|
75
|
+
Requires-Dist: bcrypt>=4.0.0; extra == "api"
|
|
76
|
+
Requires-Dist: python-jose[cryptography]>=3.3.0; extra == "api"
|
|
77
|
+
Provides-Extra: all
|
|
78
|
+
Requires-Dist: uv>=0.1.0; extra == "all"
|
|
79
|
+
Requires-Dist: pytest>=7.0.0; extra == "all"
|
|
80
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "all"
|
|
81
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
|
|
82
|
+
Requires-Dist: black>=23.0.0; extra == "all"
|
|
83
|
+
Requires-Dist: isort>=5.12.0; extra == "all"
|
|
84
|
+
Requires-Dist: flake8>=6.0.0; extra == "all"
|
|
85
|
+
Requires-Dist: mypy>=1.0.0; extra == "all"
|
|
86
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "all"
|
|
87
|
+
Requires-Dist: build>=0.10.0; extra == "all"
|
|
88
|
+
Requires-Dist: twine>=4.0.0; extra == "all"
|
|
89
|
+
Requires-Dist: mcp>=0.1.0; extra == "all"
|
|
90
|
+
Requires-Dist: fastapi>=0.104.0; extra == "all"
|
|
91
|
+
Requires-Dist: uvicorn[standard]>=0.24.0; extra == "all"
|
|
92
|
+
Requires-Dist: websockets>=12.0; extra == "all"
|
|
93
|
+
Requires-Dist: python-multipart>=0.0.6; extra == "all"
|
|
94
|
+
Requires-Dist: redis>=5.0.0; extra == "all"
|
|
95
|
+
Requires-Dist: bcrypt>=4.0.0; extra == "all"
|
|
96
|
+
Requires-Dist: python-jose[cryptography]>=3.3.0; extra == "all"
|
|
97
|
+
Dynamic: author
|
|
98
|
+
Dynamic: home-page
|
|
99
|
+
Dynamic: requires-python
|
|
100
|
+
|
|
101
|
+
# IRIS Vector RAG Templates
|
|
102
|
+
|
|
103
|
+
**Production-ready Retrieval-Augmented Generation (RAG) pipelines powered by InterSystems IRIS Vector Search**
|
|
104
|
+
|
|
105
|
+
Build intelligent applications that combine large language models with your enterprise data using battle-tested RAG patterns and native vector search capabilities.
|
|
106
|
+
|
|
107
|
+
[](LICENSE)
|
|
108
|
+
[](https://www.python.org/downloads/)
|
|
109
|
+
[](https://www.intersystems.com/products/intersystems-iris/)
|
|
110
|
+
|
|
111
|
+
## Why IRIS Vector RAG?
|
|
112
|
+
|
|
113
|
+
🚀 **Production-Ready** - Six proven RAG architectures ready to deploy, not research prototypes
|
|
114
|
+
|
|
115
|
+
⚡ **Blazing Fast** - Native IRIS vector search with HNSW indexing, no external vector databases needed
|
|
116
|
+
|
|
117
|
+
🔧 **Unified API** - Swap between RAG strategies with a single line of code
|
|
118
|
+
|
|
119
|
+
📊 **Enterprise-Grade** - ACID transactions, connection pooling, and horizontal scaling built-in
|
|
120
|
+
|
|
121
|
+
🎯 **100% Compatible** - Works seamlessly with LangChain, RAGAS, and your existing ML stack
|
|
122
|
+
|
|
123
|
+
🧪 **Fully Validated** - Comprehensive test suite with automated contract validation
|
|
124
|
+
|
|
125
|
+
## Available RAG Pipelines
|
|
126
|
+
|
|
127
|
+
| Pipeline Type | Use Case | Retrieval Method | When to Use |
|
|
128
|
+
|---------------|----------|------------------|-------------|
|
|
129
|
+
| **basic** | Standard retrieval | Vector similarity | General Q&A, getting started, baseline comparisons |
|
|
130
|
+
| **basic_rerank** | Improved precision | Vector + cross-encoder reranking | Higher accuracy requirements, legal/medical domains |
|
|
131
|
+
| **crag** | Self-correcting | Vector + evaluation + web search fallback | Dynamic knowledge, fact-checking, current events |
|
|
132
|
+
| **graphrag** | Knowledge graphs | Vector + text + graph + RRF fusion | Complex entity relationships, research, medical knowledge |
|
|
133
|
+
| **multi_query_rrf** | Multi-perspective | Query expansion + reciprocal rank fusion | Complex queries, comprehensive coverage needed |
|
|
134
|
+
| **pylate_colbert** | Fine-grained matching | ColBERT late interaction embeddings | Nuanced semantic understanding, high precision |
|
|
135
|
+
|
|
136
|
+
## Quick Start
|
|
137
|
+
|
|
138
|
+
### 1. Install
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Clone repository
|
|
142
|
+
git clone https://github.com/intersystems-community/iris-rag-templates.git
|
|
143
|
+
cd iris-rag-templates
|
|
144
|
+
|
|
145
|
+
# Setup environment (requires uv package manager)
|
|
146
|
+
make setup-env
|
|
147
|
+
make install
|
|
148
|
+
source .venv/bin/activate
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 2. Start IRIS Database
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Start IRIS with Docker Compose
|
|
155
|
+
docker-compose up -d
|
|
156
|
+
|
|
157
|
+
# Initialize database schema
|
|
158
|
+
make setup-db
|
|
159
|
+
|
|
160
|
+
# Optional: Load sample medical data
|
|
161
|
+
make load-data
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 3. Configure API Keys
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cat > .env << 'EOF'
|
|
168
|
+
OPENAI_API_KEY=your-key-here
|
|
169
|
+
ANTHROPIC_API_KEY=your-key-here # Optional, for Claude models
|
|
170
|
+
IRIS_HOST=localhost
|
|
171
|
+
IRIS_PORT=1972
|
|
172
|
+
IRIS_NAMESPACE=USER
|
|
173
|
+
IRIS_USERNAME=_SYSTEM
|
|
174
|
+
IRIS_PASSWORD=SYS
|
|
175
|
+
EOF
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 4. Run Your First Query
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from iris_rag import create_pipeline
|
|
182
|
+
|
|
183
|
+
# Create pipeline with automatic validation
|
|
184
|
+
pipeline = create_pipeline('basic', validate_requirements=True)
|
|
185
|
+
|
|
186
|
+
# Load your documents
|
|
187
|
+
from iris_rag.core.models import Document
|
|
188
|
+
|
|
189
|
+
docs = [
|
|
190
|
+
Document(
|
|
191
|
+
page_content="RAG combines retrieval with generation for accurate AI responses.",
|
|
192
|
+
metadata={"source": "rag_basics.pdf", "page": 1}
|
|
193
|
+
),
|
|
194
|
+
Document(
|
|
195
|
+
page_content="Vector search finds semantically similar content using embeddings.",
|
|
196
|
+
metadata={"source": "vector_search.pdf", "page": 5}
|
|
197
|
+
)
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
pipeline.load_documents(documents=docs)
|
|
201
|
+
|
|
202
|
+
# Query with LLM-generated answer
|
|
203
|
+
result = pipeline.query(
|
|
204
|
+
query="What is RAG?",
|
|
205
|
+
top_k=5,
|
|
206
|
+
generate_answer=True
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
print(f"Answer: {result['answer']}")
|
|
210
|
+
print(f"Sources: {result['sources']}")
|
|
211
|
+
print(f"Retrieved: {len(result['retrieved_documents'])} documents")
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Unified API Across All Pipelines
|
|
215
|
+
|
|
216
|
+
**Switch RAG strategies with one line** - all pipelines share the same interface:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from iris_rag import create_pipeline
|
|
220
|
+
|
|
221
|
+
# Try different strategies instantly
|
|
222
|
+
for pipeline_type in ['basic', 'basic_rerank', 'crag', 'multi_query_rrf', 'graphrag']:
|
|
223
|
+
pipeline = create_pipeline(pipeline_type)
|
|
224
|
+
|
|
225
|
+
result = pipeline.query(
|
|
226
|
+
query="What are the latest cancer treatment approaches?",
|
|
227
|
+
top_k=5,
|
|
228
|
+
generate_answer=True
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
print(f"\n{pipeline_type.upper()}:")
|
|
232
|
+
print(f" Answer: {result['answer'][:150]}...")
|
|
233
|
+
print(f" Retrieved: {len(result['retrieved_documents'])} docs")
|
|
234
|
+
print(f" Confidence: {result['metadata'].get('confidence', 'N/A')}")
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Standardized Response Format
|
|
238
|
+
|
|
239
|
+
**100% LangChain & RAGAS compatible** responses:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
{
|
|
243
|
+
"query": "What is diabetes?",
|
|
244
|
+
"answer": "Diabetes is a chronic metabolic condition...", # LLM answer
|
|
245
|
+
"retrieved_documents": [Document(...)], # LangChain Documents
|
|
246
|
+
"contexts": ["context 1", "context 2"], # RAGAS contexts
|
|
247
|
+
"sources": ["medical.pdf p.12", "diabetes.pdf p.3"], # Source citations
|
|
248
|
+
"execution_time": 0.523,
|
|
249
|
+
"metadata": {
|
|
250
|
+
"num_retrieved": 5,
|
|
251
|
+
"pipeline_type": "basic",
|
|
252
|
+
"retrieval_method": "vector",
|
|
253
|
+
"generated_answer": True,
|
|
254
|
+
"processing_time": 0.523
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Pipeline Deep Dives
|
|
260
|
+
|
|
261
|
+
### CRAG: Self-Correcting Retrieval
|
|
262
|
+
|
|
263
|
+
Automatically evaluates retrieval quality and falls back to web search when needed:
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
from iris_rag import create_pipeline
|
|
267
|
+
|
|
268
|
+
pipeline = create_pipeline('crag')
|
|
269
|
+
|
|
270
|
+
# CRAG evaluates retrieved documents and uses web search if quality is low
|
|
271
|
+
result = pipeline.query(
|
|
272
|
+
query="What happened in the 2024 Olympics opening ceremony?",
|
|
273
|
+
top_k=5,
|
|
274
|
+
generate_answer=True
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
# Check which retrieval method was used
|
|
278
|
+
print(f"Method: {result['metadata']['retrieval_method']}") # 'vector' or 'web_search'
|
|
279
|
+
print(f"Confidence: {result['metadata']['confidence']}") # 0.0 - 1.0
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### HybridGraphRAG: Multi-Modal Search
|
|
283
|
+
|
|
284
|
+
Combines vector search, text search, and knowledge graph traversal:
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
pipeline = create_pipeline('graphrag')
|
|
288
|
+
|
|
289
|
+
result = pipeline.query(
|
|
290
|
+
query_text="cancer treatment targets",
|
|
291
|
+
method="rrf", # Reciprocal Rank Fusion across all methods
|
|
292
|
+
vector_k=30, # Top 30 from vector search
|
|
293
|
+
text_k=30, # Top 30 from text search
|
|
294
|
+
graph_k=10, # Top 10 from knowledge graph
|
|
295
|
+
generate_answer=True
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Rich metadata includes entities and relationships
|
|
299
|
+
print(f"Entities: {result['metadata']['entities']}")
|
|
300
|
+
print(f"Relationships: {result['metadata']['relationships']}")
|
|
301
|
+
print(f"Graph depth: {result['metadata']['graph_depth']}")
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### MultiQueryRRF: Multi-Perspective Retrieval
|
|
305
|
+
|
|
306
|
+
Expands queries into multiple perspectives and fuses results:
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
pipeline = create_pipeline('multi_query_rrf')
|
|
310
|
+
|
|
311
|
+
# Automatically generates query variations and combines results
|
|
312
|
+
result = pipeline.query(
|
|
313
|
+
query="How does machine learning work?",
|
|
314
|
+
top_k=10,
|
|
315
|
+
generate_answer=True
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
# See the generated query variations
|
|
319
|
+
print(f"Query variations: {result['metadata']['generated_queries']}")
|
|
320
|
+
print(f"Fusion method: {result['metadata']['fusion_method']}") # 'rrf'
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Enterprise Features
|
|
324
|
+
|
|
325
|
+
### Production-Ready Database
|
|
326
|
+
|
|
327
|
+
**IRIS provides everything you need in one database:**
|
|
328
|
+
|
|
329
|
+
- ✅ Native vector search (no external vector DB needed)
|
|
330
|
+
- ✅ ACID transactions (your data is safe)
|
|
331
|
+
- ✅ SQL + NoSQL + Vector in one platform
|
|
332
|
+
- ✅ Horizontal scaling and clustering
|
|
333
|
+
- ✅ Enterprise-grade security and compliance
|
|
334
|
+
|
|
335
|
+
### Connection Pooling
|
|
336
|
+
|
|
337
|
+
**Automatic concurrency management:**
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from iris_rag.storage import IRISVectorStore
|
|
341
|
+
|
|
342
|
+
# Connection pool handles concurrency automatically
|
|
343
|
+
store = IRISVectorStore()
|
|
344
|
+
|
|
345
|
+
# Safe for multi-threaded applications
|
|
346
|
+
# Pool manages connections, no manual management needed
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Automatic Schema Management
|
|
350
|
+
|
|
351
|
+
**Database schema created and migrated automatically:**
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
pipeline = create_pipeline('basic', validate_requirements=True)
|
|
355
|
+
# ✅ Checks database connection
|
|
356
|
+
# ✅ Validates schema exists
|
|
357
|
+
# ✅ Migrates to latest version if needed
|
|
358
|
+
# ✅ Reports validation results
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### RAGAS Evaluation Built-In
|
|
362
|
+
|
|
363
|
+
**Measure your RAG pipeline performance:**
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# Evaluate all pipelines on your data
|
|
367
|
+
make test-ragas-sample
|
|
368
|
+
|
|
369
|
+
# Generates detailed metrics:
|
|
370
|
+
# - Answer Correctness
|
|
371
|
+
# - Faithfulness
|
|
372
|
+
# - Context Precision
|
|
373
|
+
# - Context Recall
|
|
374
|
+
# - Answer Relevance
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Model Context Protocol (MCP) Support
|
|
378
|
+
|
|
379
|
+
**Expose RAG pipelines as MCP tools** for use with Claude Desktop and other MCP clients:
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Start MCP server
|
|
383
|
+
python -m iris_rag.mcp
|
|
384
|
+
|
|
385
|
+
# Available MCP tools:
|
|
386
|
+
# - rag_basic
|
|
387
|
+
# - rag_basic_rerank
|
|
388
|
+
# - rag_crag
|
|
389
|
+
# - rag_multi_query_rrf
|
|
390
|
+
# - rag_graphrag
|
|
391
|
+
# - rag_hybrid_graphrag
|
|
392
|
+
# - health_check
|
|
393
|
+
# - list_tools
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Configure in Claude Desktop:
|
|
397
|
+
|
|
398
|
+
```json
|
|
399
|
+
{
|
|
400
|
+
"mcpServers": {
|
|
401
|
+
"iris-rag": {
|
|
402
|
+
"command": "python",
|
|
403
|
+
"args": ["-m", "iris_rag.mcp"],
|
|
404
|
+
"env": {
|
|
405
|
+
"OPENAI_API_KEY": "your-key"
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Architecture Overview
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
iris_rag/
|
|
416
|
+
├── core/ # Abstract base classes (RAGPipeline, VectorStore)
|
|
417
|
+
├── pipelines/ # Pipeline implementations
|
|
418
|
+
│ ├── basic.py # BasicRAG
|
|
419
|
+
│ ├── basic_rerank.py # Reranking pipeline
|
|
420
|
+
│ ├── crag.py # Corrective RAG
|
|
421
|
+
│ ├── multi_query_rrf.py # Multi-query with RRF
|
|
422
|
+
│ ├── graphrag.py # Graph-based RAG
|
|
423
|
+
│ └── hybrid_graphrag.py # Hybrid multi-modal
|
|
424
|
+
├── storage/ # Vector store implementations
|
|
425
|
+
│ ├── vector_store_iris.py # IRIS vector store
|
|
426
|
+
│ └── schema_manager.py # Schema management
|
|
427
|
+
├── mcp/ # Model Context Protocol server
|
|
428
|
+
├── api/ # Production REST API
|
|
429
|
+
├── services/ # Business logic (entity extraction, etc.)
|
|
430
|
+
├── config/ # Configuration management
|
|
431
|
+
└── validation/ # Pipeline contract validation
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Documentation
|
|
435
|
+
|
|
436
|
+
📚 **Comprehensive documentation for every use case:**
|
|
437
|
+
|
|
438
|
+
- **[User Guide](docs/USER_GUIDE.md)** - Complete installation and usage
|
|
439
|
+
- **[API Reference](docs/API_REFERENCE.md)** - Detailed API documentation
|
|
440
|
+
- **[Pipeline Guide](docs/PIPELINE_GUIDE.md)** - When to use each pipeline
|
|
441
|
+
- **[MCP Integration](docs/MCP_INTEGRATION.md)** - Model Context Protocol setup
|
|
442
|
+
- **[Production Deployment](docs/PRODUCTION_DEPLOYMENT.md)** - Deployment checklist
|
|
443
|
+
- **[Development Guide](docs/DEVELOPMENT.md)** - Contributing and testing
|
|
444
|
+
|
|
445
|
+
## Performance Benchmarks
|
|
446
|
+
|
|
447
|
+
**Native IRIS vector search delivers:**
|
|
448
|
+
|
|
449
|
+
- 🚀 **50-100x faster** than traditional solutions for hybrid search
|
|
450
|
+
- ⚡ **Sub-second queries** on millions of documents
|
|
451
|
+
- 📊 **Linear scaling** with IRIS clustering
|
|
452
|
+
- 💾 **10x less memory** than external vector databases
|
|
453
|
+
|
|
454
|
+
## Testing & Quality
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
# Run comprehensive test suite
|
|
458
|
+
make test
|
|
459
|
+
|
|
460
|
+
# Test specific categories
|
|
461
|
+
pytest tests/unit/ # Unit tests (fast)
|
|
462
|
+
pytest tests/integration/ # Integration tests (with IRIS)
|
|
463
|
+
pytest tests/contract/ # API contract validation
|
|
464
|
+
|
|
465
|
+
# Run with coverage
|
|
466
|
+
pytest --cov=iris_rag --cov-report=html
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**For detailed testing documentation**, see [DEVELOPMENT.md](docs/DEVELOPMENT.md)
|
|
470
|
+
|
|
471
|
+
## Research & References
|
|
472
|
+
|
|
473
|
+
This implementation is based on peer-reviewed research:
|
|
474
|
+
|
|
475
|
+
- **Basic RAG**: Lewis et al., [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401), NeurIPS 2020
|
|
476
|
+
- **CRAG**: Yan et al., [Corrective Retrieval Augmented Generation](https://arxiv.org/abs/2401.15884), arXiv 2024
|
|
477
|
+
- **GraphRAG**: Edge et al., [From Local to Global: A Graph RAG Approach](https://arxiv.org/abs/2404.16130), arXiv 2024
|
|
478
|
+
- **ColBERT**: Khattab & Zaharia, [ColBERT: Efficient and Effective Passage Search](https://arxiv.org/abs/2004.12832), SIGIR 2020
|
|
479
|
+
|
|
480
|
+
## Contributing
|
|
481
|
+
|
|
482
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
|
|
483
|
+
|
|
484
|
+
- Development setup
|
|
485
|
+
- Testing guidelines
|
|
486
|
+
- Code style and standards
|
|
487
|
+
- Pull request process
|
|
488
|
+
|
|
489
|
+
## Community & Support
|
|
490
|
+
|
|
491
|
+
- 💬 **Discussions**: [GitHub Discussions](https://github.com/intersystems-community/iris-rag-templates/discussions)
|
|
492
|
+
- 🐛 **Issues**: [GitHub Issues](https://github.com/intersystems-community/iris-rag-templates/issues)
|
|
493
|
+
- 📖 **Documentation**: [Full Documentation](docs/)
|
|
494
|
+
- 🏢 **Enterprise Support**: [InterSystems Support](https://www.intersystems.com/support/)
|
|
495
|
+
|
|
496
|
+
## License
|
|
497
|
+
|
|
498
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
**Built with ❤️ by the InterSystems Community**
|
|
503
|
+
|
|
504
|
+
*Powering intelligent applications with enterprise-grade RAG*
|