adaptive-intelligence 4.0.2__tar.gz → 4.0.3__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.
- adaptive_intelligence-4.0.3/PKG-INFO +400 -0
- adaptive_intelligence-4.0.3/README.md +330 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/__init__.py +1 -1
- adaptive_intelligence-4.0.3/adaptive_intelligence.egg-info/PKG-INFO +400 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/pyproject.toml +1 -1
- adaptive_intelligence-4.0.2/PKG-INFO +0 -311
- adaptive_intelligence-4.0.2/README.md +0 -241
- adaptive_intelligence-4.0.2/adaptive_intelligence.egg-info/PKG-INFO +0 -311
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/LICENSE +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/agentic/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/context/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/core/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/core/config.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/core/engine.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/core/response.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/evaluation/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/graph/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/indexes/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/indexes/base.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/indexes/keyword_index.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/indexes/page_index.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/indexes/vector_index.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/ingestion/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/ingestion/chunker.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/ingestion/engine.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/ingestion/parser.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/llm/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/mcp/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/memory/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/memory/persistent.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/prompts/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/query/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/rl/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/rl/multi_query.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/rl/ppo.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/rl/pretrained.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/rl/reranker.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/security/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence/utils/__init__.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence.egg-info/SOURCES.txt +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence.egg-info/dependency_links.txt +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence.egg-info/requires.txt +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/adaptive_intelligence.egg-info/top_level.txt +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/setup.cfg +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_core.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_evaluation.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_graph.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_ingestion.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_query.py +0 -0
- {adaptive_intelligence-4.0.2 → adaptive_intelligence-4.0.3}/tests/test_rl.py +0 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adaptive-intelligence
|
|
3
|
+
Version: 4.0.3
|
|
4
|
+
Summary: Self-improving retrieval framework with RL routing, context engineering, MCP integration, agentic workflow, and persistent memory.
|
|
5
|
+
Author-email: Venkatkumar Rajan <venkatkumarr.vk99@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/VK-Ant/adaptive-intelligence
|
|
8
|
+
Project-URL: Documentation, https://github.com/VK-Ant/adaptive-intelligence#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/VK-Ant/adaptive-intelligence
|
|
10
|
+
Project-URL: Issues, https://github.com/VK-Ant/adaptive-intelligence/issues
|
|
11
|
+
Project-URL: PyPI, https://pypi.org/project/adaptive-intelligence/
|
|
12
|
+
Project-URL: Paper, https://www.researchgate.net/publication/405076088
|
|
13
|
+
Project-URL: Portfolio, https://vk-ant.github.io/Venkatkumar/
|
|
14
|
+
Project-URL: Changelog, https://github.com/VK-Ant/adaptive-intelligence/blob/main/CHANGELOG.md
|
|
15
|
+
Keywords: rag,retrieval,reinforcement-learning,knowledge-graph,document-intelligence,adaptive,self-improving,llm,ai,nlp,evaluation,self-learning,context-engineering,mcp,agentic,memory,tool-use,multi-agent
|
|
16
|
+
Classifier: Development Status :: 4 - Beta
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: Science/Research
|
|
19
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Provides-Extra: vector
|
|
31
|
+
Requires-Dist: chromadb>=0.4.0; extra == "vector"
|
|
32
|
+
Provides-Extra: openai
|
|
33
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
34
|
+
Provides-Extra: huggingface
|
|
35
|
+
Requires-Dist: transformers>=4.35.0; extra == "huggingface"
|
|
36
|
+
Requires-Dist: torch>=2.0.0; extra == "huggingface"
|
|
37
|
+
Provides-Extra: pdf
|
|
38
|
+
Requires-Dist: PyMuPDF>=1.23.0; extra == "pdf"
|
|
39
|
+
Provides-Extra: docx
|
|
40
|
+
Requires-Dist: python-docx>=1.0.0; extra == "docx"
|
|
41
|
+
Provides-Extra: xlsx
|
|
42
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "xlsx"
|
|
43
|
+
Provides-Extra: pptx
|
|
44
|
+
Requires-Dist: python-pptx>=0.6.21; extra == "pptx"
|
|
45
|
+
Provides-Extra: sql
|
|
46
|
+
Requires-Dist: sqlalchemy>=2.0.0; extra == "sql"
|
|
47
|
+
Provides-Extra: rerank
|
|
48
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "rerank"
|
|
49
|
+
Provides-Extra: ocr
|
|
50
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
|
|
51
|
+
Requires-Dist: Pillow>=10.0; extra == "ocr"
|
|
52
|
+
Provides-Extra: all
|
|
53
|
+
Requires-Dist: chromadb>=0.4.0; extra == "all"
|
|
54
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
55
|
+
Requires-Dist: transformers>=4.35.0; extra == "all"
|
|
56
|
+
Requires-Dist: torch>=2.0.0; extra == "all"
|
|
57
|
+
Requires-Dist: PyMuPDF>=1.23.0; extra == "all"
|
|
58
|
+
Requires-Dist: python-docx>=1.0.0; extra == "all"
|
|
59
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "all"
|
|
60
|
+
Requires-Dist: python-pptx>=0.6.21; extra == "all"
|
|
61
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "all"
|
|
62
|
+
Requires-Dist: Pillow>=10.0; extra == "all"
|
|
63
|
+
Requires-Dist: sentence-transformers>=2.2.0; extra == "all"
|
|
64
|
+
Provides-Extra: dev
|
|
65
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
66
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
67
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
68
|
+
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
69
|
+
Dynamic: license-file
|
|
70
|
+
|
|
71
|
+
<div align="center">
|
|
72
|
+
|
|
73
|
+
<img src="https://raw.githubusercontent.com/VK-Ant/adaptive-intelligence/main/docs/images/image_ai.png" alt="adaptive-intelligence" width="100%">
|
|
74
|
+
|
|
75
|
+
# adaptive-intelligence
|
|
76
|
+
|
|
77
|
+
**Self-improving retrieval framework that learns, remembers, and connects tools.**
|
|
78
|
+
|
|
79
|
+
[](https://pypi.org/project/adaptive-intelligence/)
|
|
80
|
+
[](https://pypi.org/project/adaptive-intelligence/)
|
|
81
|
+
[](LICENSE)
|
|
82
|
+
[](https://www.researchgate.net/publication/405076088)
|
|
83
|
+
|
|
84
|
+
[PyPI](https://pypi.org/project/adaptive-intelligence/) · [Paper](https://www.researchgate.net/publication/405076088) · [Portfolio](https://vk-ant.github.io/Venkatkumar/) · [llmevalkit](https://pypi.org/project/llmevalkit/)
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Why adaptive-intelligence?
|
|
91
|
+
|
|
92
|
+
Every RAG system uses the same retrieval strategy for every query. A revenue lookup gets vector search. A multi-document relationship chain gets the same vector search.
|
|
93
|
+
|
|
94
|
+
adaptive-intelligence fixes this. It uses reinforcement learning to select the best retrieval strategy per query type. The system evaluates every response, uses the score as a reward signal, and improves with every query answered.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from adaptive_intelligence import AdaptiveAI
|
|
98
|
+
|
|
99
|
+
engine = AdaptiveAI()
|
|
100
|
+
engine.ingest("./documents")
|
|
101
|
+
response = engine.ask("What are the key risks?")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Install
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install adaptive-intelligence # Zero deps (Ollama, no-LLM mode)
|
|
108
|
+
pip install adaptive-intelligence[vector] # + ChromaDB vector search
|
|
109
|
+
pip install adaptive-intelligence[openai] # + Any OpenAI-compatible API
|
|
110
|
+
pip install adaptive-intelligence[huggingface] # + Local HuggingFace models
|
|
111
|
+
pip install adaptive-intelligence[all] # Everything
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Features
|
|
115
|
+
|
|
116
|
+
### Context Engineering
|
|
117
|
+
Optimizes the entire context window — not just which chunks to retrieve, but what memory to include, how much history to keep, which tool results to add, and how to structure the prompt.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
engine = AdaptiveAI(context_engineering=True)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### MCP Integration
|
|
124
|
+
Connect external tools. Register MCP servers, REST APIs, or Python functions. The RL policy learns which tools to call per query type.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
engine.add_tool("financial", server="http://localhost:8081")
|
|
128
|
+
engine.add_tool("calculator", function=my_calc_function)
|
|
129
|
+
engine.add_tool("search", api_endpoint="https://api.example.com/search")
|
|
130
|
+
|
|
131
|
+
engine.list_tools()
|
|
132
|
+
engine.remove_tool("search")
|
|
133
|
+
|
|
134
|
+
# Serve your retrieval as an MCP server
|
|
135
|
+
engine.serve_mcp(port=8080)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Agentic Workflow
|
|
139
|
+
Multi-round retrieval. The system retrieves, evaluates confidence, refines the query, calls tools, and retrieves again until the answer is sufficient.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
response = engine.ask("Analyze supply chain risks and mitigation", mode="agentic")
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Persistent Memory
|
|
146
|
+
Remembers across sessions. Routing patterns, user preferences, and facts persist to disk.
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
engine.remember("focus_area", "supply chain risk")
|
|
150
|
+
engine.recall("focus_area")
|
|
151
|
+
engine.search_memory("supply chain")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Incremental Learning
|
|
155
|
+
Add new documents anytime. The RL policy, knowledge graph, and memory continue from their current state — no restart needed.
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
engine.ingest("./initial_docs")
|
|
159
|
+
engine.ingest("./quarterly_update.pdf") # System continues, no restart
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### RL-Based Retrieval Routing
|
|
163
|
+
Thompson Sampling or PPO learns which retrieval strategy works best per query type.
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
engine = AdaptiveAI(rl_algorithm="ppo")
|
|
167
|
+
engine = AdaptiveAI(pretrained_policy=True, domain="financial")
|
|
168
|
+
engine.export_policy("learned.json")
|
|
169
|
+
engine.import_policy("learned.json")
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Conditional Graph Activation
|
|
173
|
+
Knowledge graph auto-built during ingestion. A 5-signal gate activates graph traversal only when the query needs relational reasoning. Saves compute on 70% of queries.
|
|
174
|
+
|
|
175
|
+
### Vectorless Mode
|
|
176
|
+
No ChromaDB, no embeddings, zero dependencies. Uses page-level BM25 with page citations.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
engine = AdaptiveAI(vectorless=True)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Structured Output
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
response = engine.ask("Extract metrics", output_format="json")
|
|
186
|
+
response = engine.ask("List items", output_format="csv")
|
|
187
|
+
response = engine.ask("Summarize", output_format="yaml")
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### User Feedback
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
response = engine.ask("What are the risks?")
|
|
194
|
+
engine.feedback(response.query_id, "good") # +0.2 RL reward
|
|
195
|
+
engine.feedback(response.query_id, "bad") # -0.3 RL reward + prompt evolution
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## LLM Providers
|
|
199
|
+
|
|
200
|
+
The library works with any LLM. Zero required dependencies for basic usage.
|
|
201
|
+
|
|
202
|
+
### Free (no credit card needed)
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
# Ollama — local, no extras needed
|
|
206
|
+
engine = AdaptiveAI()
|
|
207
|
+
|
|
208
|
+
# NVIDIA NIM
|
|
209
|
+
engine = AdaptiveAI(api_key="nvapi-...", base_url="https://integrate.api.nvidia.com/v1",
|
|
210
|
+
llm_model="meta/llama-3.1-70b-instruct")
|
|
211
|
+
|
|
212
|
+
# Groq
|
|
213
|
+
engine = AdaptiveAI(api_key="gsk_...", base_url="https://api.groq.com/openai/v1",
|
|
214
|
+
llm_model="llama-3.3-70b-versatile")
|
|
215
|
+
|
|
216
|
+
# Google Gemini
|
|
217
|
+
engine = AdaptiveAI(api_key="...", base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
|
218
|
+
llm_model="gemini-2.0-flash")
|
|
219
|
+
|
|
220
|
+
# Together AI
|
|
221
|
+
engine = AdaptiveAI(api_key="...", base_url="https://api.together.xyz/v1",
|
|
222
|
+
llm_model="meta-llama/Llama-3-70b-chat-hf")
|
|
223
|
+
|
|
224
|
+
# Fireworks AI
|
|
225
|
+
engine = AdaptiveAI(api_key="...", base_url="https://api.fireworks.ai/inference/v1",
|
|
226
|
+
llm_model="accounts/fireworks/models/llama-v3p1-70b-instruct")
|
|
227
|
+
|
|
228
|
+
# HuggingFace local — needs [huggingface] extras
|
|
229
|
+
engine = AdaptiveAI(llm_backend="huggingface", llm_model="Qwen/Qwen2.5-1.5B-Instruct")
|
|
230
|
+
|
|
231
|
+
# No LLM — retrieval only
|
|
232
|
+
engine = AdaptiveAI(llm_backend="none")
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Paid
|
|
236
|
+
|
|
237
|
+
```python
|
|
238
|
+
# OpenAI
|
|
239
|
+
engine = AdaptiveAI(api_key="sk-...", llm_model="gpt-4o")
|
|
240
|
+
|
|
241
|
+
# Grok (xAI)
|
|
242
|
+
engine = AdaptiveAI(api_key="xai-...", base_url="https://api.x.ai/v1")
|
|
243
|
+
|
|
244
|
+
# Azure OpenAI
|
|
245
|
+
engine = AdaptiveAI(azure_endpoint="https://your.openai.azure.com/", api_key="...")
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Self-hosted
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
# vLLM server
|
|
252
|
+
engine = AdaptiveAI(base_url="http://localhost:8000/v1")
|
|
253
|
+
|
|
254
|
+
# Any OpenAI-compatible server
|
|
255
|
+
engine = AdaptiveAI(base_url="http://your-server:8000/v1")
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## How It Works
|
|
259
|
+
|
|
260
|
+
1. **Understand** — Trigger interpreter classifies query type, complexity, domain, entities (no LLM call)
|
|
261
|
+
2. **Decide** — RL policy selects retrieval route, depth, graph activation, tools to call
|
|
262
|
+
3. **Retrieve** — Executes via vector, BM25, or page index with RRF fusion. Graph activates conditionally.
|
|
263
|
+
4. **Generate** — Cross-encoder reranks chunks. Context engineer assembles full context window. LLM generates.
|
|
264
|
+
5. **Learn** — 6 metrics evaluate response. Composite score = RL reward. Policy updates. Next query is better.
|
|
265
|
+
|
|
266
|
+
## Demos
|
|
267
|
+
|
|
268
|
+
### Colab (no setup needed)
|
|
269
|
+
|
|
270
|
+
Run on free T4 GPU with no API key: [`notebooks/adaptive_intelligence_v4_demo.ipynb`](notebooks/adaptive_intelligence_v4_demo.ipynb)
|
|
271
|
+
|
|
272
|
+
### Local demos
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
cd demo_mcp_agenticai
|
|
276
|
+
pip install -r requirements.txt
|
|
277
|
+
python demo_basic.py # Basic usage + incremental learning
|
|
278
|
+
python demo_tools.py # Tool registry + cost optimization
|
|
279
|
+
python demo_agentic.py # Agentic multi-round retrieval
|
|
280
|
+
python demo_mcp_server.py # Serve as MCP server (terminal 1)
|
|
281
|
+
python demo_mcp_client.py # Connect to MCP server (terminal 2)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## FAQ
|
|
285
|
+
|
|
286
|
+
**1. Does it work without an LLM?**
|
|
287
|
+
|
|
288
|
+
Yes. Set `llm_backend="none"` and the system returns relevant document excerpts. RL routing, graph activation, memory, and evaluation all work without an LLM.
|
|
289
|
+
|
|
290
|
+
**2. Does it work without a vector database?**
|
|
291
|
+
|
|
292
|
+
Yes. Set `vectorless=True` for page-level BM25 search with zero dependencies. Same RL routing, same graph, same learning.
|
|
293
|
+
|
|
294
|
+
**3. How many queries before it starts learning?**
|
|
295
|
+
|
|
296
|
+
Default warmup is 15 queries. During warmup, the system uses smart heuristic defaults while collecting RL statistics. After 15 queries, the learned policy takes over. Use `pretrained_policy=True` to skip warmup entirely.
|
|
297
|
+
|
|
298
|
+
**4. Which retrieval strategies does the RL choose from?**
|
|
299
|
+
|
|
300
|
+
Six routes: keyword only, vector only, hybrid (keyword + vector with RRF), table first, graph first, and graph hybrid. The RL also selects retrieval depth and whether to activate the knowledge graph.
|
|
301
|
+
|
|
302
|
+
**5. How is the knowledge graph built?**
|
|
303
|
+
|
|
304
|
+
Automatically during document ingestion from entity co-occurrences. No manual setup. A 5-signal gate decides per-query whether to activate graph traversal.
|
|
305
|
+
|
|
306
|
+
**6. What is context engineering?**
|
|
307
|
+
|
|
308
|
+
Instead of just stuffing retrieved chunks into a prompt, context engineering optimizes the entire context window — system prompt, memory entries, conversation history, tool results, and chunks — with token budget allocation per component.
|
|
309
|
+
|
|
310
|
+
**7. How does agentic mode work?**
|
|
311
|
+
|
|
312
|
+
The system retrieves, evaluates confidence, and if it's below threshold, refines the query and retrieves again. It can also call registered tools between rounds. Maximum 3 rounds by default.
|
|
313
|
+
|
|
314
|
+
**8. Can I add documents after initial ingestion?**
|
|
315
|
+
|
|
316
|
+
Yes. Call `engine.ingest()` again with new documents. The RL policy, knowledge graph, and memory all continue from their current state. No restart needed.
|
|
317
|
+
|
|
318
|
+
**9. What about latency?**
|
|
319
|
+
|
|
320
|
+
The system adds approximately 100-150ms overhead per query (classification, RL decision, evaluation, policy update). The LLM call typically takes 500-3000ms. Overhead is roughly 5-10% of total response time.
|
|
321
|
+
|
|
322
|
+
**10. How does it save cost?**
|
|
323
|
+
|
|
324
|
+
The RL learns optimal retrieval depth per query type. Factual queries get depth 2 (2 chunks), complex queries get depth 8. Fewer chunks = fewer tokens = lower LLM cost. The RL also learns which tools to skip, reducing unnecessary API calls.
|
|
325
|
+
|
|
326
|
+
**11. Is it production-ready?**
|
|
327
|
+
|
|
328
|
+
The library has 99 tests, crash recovery with auto-checkpoint, and graceful shutdown. BM25 is in-memory which works for hundreds of documents. For 50K+ documents, a disk-backed index is planned.
|
|
329
|
+
|
|
330
|
+
**12. How is this different from LangChain or LlamaIndex?**
|
|
331
|
+
|
|
332
|
+
Those are orchestration frameworks with static pipelines. You configure the retrieval strategy once. adaptive-intelligence learns the optimal strategy per query type through reinforcement learning. The system improves with every query answered.
|
|
333
|
+
|
|
334
|
+
## Version History
|
|
335
|
+
|
|
336
|
+
| Version | Focus | Features |
|
|
337
|
+
|---------|-------|----------|
|
|
338
|
+
| v1 | Core Innovation | RL routing, conditional graph, 6-metric evaluation, 15 features |
|
|
339
|
+
| v2 | Production Ready | Vectorless mode, crash recovery, SQL connector, 10+ providers, 28 features |
|
|
340
|
+
| v3 | Intelligence | PPO, reranking, multi-query, pre-trained policies, transfer learning, 44 features |
|
|
341
|
+
| v4 | Context + Agentic | Context engineering, MCP, agentic workflow, persistent memory, incremental learning |
|
|
342
|
+
|
|
343
|
+
## Project Structure
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
adaptive_intelligence/
|
|
347
|
+
core/ # Engine, config, response objects
|
|
348
|
+
ingestion/ # Parser (10+ formats), chunker, ingestion engine
|
|
349
|
+
indexes/ # Vector (ChromaDB), keyword (BM25), page index
|
|
350
|
+
query/ # Trigger interpreter, query classification
|
|
351
|
+
rl/ # Thompson Sampling, PPO, reranker, multi-query, pretrained
|
|
352
|
+
graph/ # Knowledge graph, conditional activation
|
|
353
|
+
prompts/ # Adaptive prompt engine, template evolution
|
|
354
|
+
evaluation/ # 6-metric evaluation engine
|
|
355
|
+
llm/ # LLM providers (Ollama, OpenAI, HuggingFace)
|
|
356
|
+
memory/ # Learning memory, persistent memory
|
|
357
|
+
context/ # Context engineering, token budget
|
|
358
|
+
mcp/ # MCP server, tool registry
|
|
359
|
+
agentic/ # Agentic workflow, multi-round retrieval
|
|
360
|
+
security/ # Audit trail, PII scanning
|
|
361
|
+
utils/ # Logging, timing, ID generation
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Citation
|
|
365
|
+
|
|
366
|
+
If you use adaptive-intelligence in your research, please cite:
|
|
367
|
+
|
|
368
|
+
```bibtex
|
|
369
|
+
@article{rajan2026adaptive,
|
|
370
|
+
title={Adaptive Retrieval Orchestration for Self-Learning Knowledge Systems},
|
|
371
|
+
author={Rajan, Venkatkumar},
|
|
372
|
+
year={2026},
|
|
373
|
+
publisher={ResearchGate},
|
|
374
|
+
url={https://www.researchgate.net/publication/405076088}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Contributing
|
|
379
|
+
|
|
380
|
+
Contributions are welcome.
|
|
381
|
+
|
|
382
|
+
1. Fork the repository
|
|
383
|
+
2. Create a feature branch (`git checkout -b feature/your-feature`)
|
|
384
|
+
3. Add tests for your changes
|
|
385
|
+
4. Run tests (`pytest tests/ -v`)
|
|
386
|
+
5. Submit a pull request
|
|
387
|
+
|
|
388
|
+
## Also by me
|
|
389
|
+
|
|
390
|
+
[**llmevalkit**](https://pypi.org/project/llmevalkit/) — 78 metrics for LLM evaluation with HIPAA, GDPR, DPDP, and EU AI Act compliance modules.
|
|
391
|
+
|
|
392
|
+
adaptive-intelligence was born from llmevalkit. If you can measure LLM quality (llmevalkit), you can use those measurements as a reward signal to improve retrieval (adaptive-intelligence).
|
|
393
|
+
|
|
394
|
+
## Author
|
|
395
|
+
|
|
396
|
+
**Venkatkumar Rajan** · [@VK_Venkatkumar](https://linkedin.com/in/venkatkumarvk) · [Portfolio](https://vk-ant.github.io/Venkatkumar/)
|
|
397
|
+
|
|
398
|
+
## License
|
|
399
|
+
|
|
400
|
+
[Apache License 2.0](LICENSE)
|