adaptive-intelligence 1.0.2__tar.gz → 2.0.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.
- adaptive_intelligence-2.0.0/PKG-INFO +468 -0
- adaptive_intelligence-2.0.0/README.md +406 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence/__init__.py +32 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/core/config.py +1 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence/core/engine.py +775 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/core/response.py +1 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/graph/__init__.py +57 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/indexes/__init__.py +1 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/indexes/keyword_index.py +33 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence/indexes/page_index.py +59 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/ingestion/__init__.py +2 -2
- adaptive_intelligence-2.0.0/adaptive_intelligence/ingestion/chunker.py +356 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence/ingestion/engine.py +307 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence/ingestion/parser.py +866 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/memory/__init__.py +10 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/rl/__init__.py +2 -0
- adaptive_intelligence-2.0.0/adaptive_intelligence.egg-info/PKG-INFO +468 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence.egg-info/SOURCES.txt +1 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence.egg-info/requires.txt +3 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/pyproject.toml +2 -1
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_core.py +2 -2
- adaptive_intelligence-1.0.2/PKG-INFO +0 -336
- adaptive_intelligence-1.0.2/README.md +0 -276
- adaptive_intelligence-1.0.2/adaptive_intelligence/__init__.py +0 -23
- adaptive_intelligence-1.0.2/adaptive_intelligence/core/engine.py +0 -612
- adaptive_intelligence-1.0.2/adaptive_intelligence/ingestion/chunker.py +0 -200
- adaptive_intelligence-1.0.2/adaptive_intelligence/ingestion/engine.py +0 -122
- adaptive_intelligence-1.0.2/adaptive_intelligence/ingestion/parser.py +0 -436
- adaptive_intelligence-1.0.2/adaptive_intelligence.egg-info/PKG-INFO +0 -336
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/LICENSE +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/core/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/evaluation/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/indexes/base.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/indexes/vector_index.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/llm/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/prompts/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/query/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/security/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence/utils/__init__.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence.egg-info/dependency_links.txt +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/adaptive_intelligence.egg-info/top_level.txt +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/setup.cfg +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_evaluation.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_graph.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_ingestion.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_query.py +0 -0
- {adaptive_intelligence-1.0.2 → adaptive_intelligence-2.0.0}/tests/test_rl.py +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adaptive-intelligence
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Self-improving retrieval orchestration framework with RL-based routing, conditional graph activation, and evaluation-driven learning.
|
|
5
|
+
Author-email: Venkatkumar Rajan <venkatkumarr.vk99@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://pypi.org/project/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: Portfolio, https://vk-ant.github.io/Venkatkumar/
|
|
13
|
+
Keywords: rag,retrieval,reinforcement-learning,knowledge-graph,document-intelligence,adaptive,self-improving,llm,ai,nlp,evaluation,self-learning
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: chromadb>=0.4.0
|
|
29
|
+
Provides-Extra: openai
|
|
30
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
31
|
+
Provides-Extra: groq
|
|
32
|
+
Requires-Dist: openai>=1.0.0; extra == "groq"
|
|
33
|
+
Provides-Extra: pdf
|
|
34
|
+
Requires-Dist: PyMuPDF>=1.23.0; extra == "pdf"
|
|
35
|
+
Provides-Extra: docx
|
|
36
|
+
Requires-Dist: python-docx>=1.0.0; extra == "docx"
|
|
37
|
+
Provides-Extra: xlsx
|
|
38
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "xlsx"
|
|
39
|
+
Provides-Extra: pptx
|
|
40
|
+
Requires-Dist: python-pptx>=0.6.21; extra == "pptx"
|
|
41
|
+
Provides-Extra: sql
|
|
42
|
+
Requires-Dist: sqlalchemy>=2.0.0; extra == "sql"
|
|
43
|
+
Provides-Extra: ocr
|
|
44
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
|
|
45
|
+
Requires-Dist: Pillow>=10.0; extra == "ocr"
|
|
46
|
+
Provides-Extra: huggingface
|
|
47
|
+
Requires-Dist: transformers>=4.35.0; extra == "huggingface"
|
|
48
|
+
Requires-Dist: torch>=2.0.0; extra == "huggingface"
|
|
49
|
+
Provides-Extra: all
|
|
50
|
+
Requires-Dist: PyMuPDF>=1.23.0; extra == "all"
|
|
51
|
+
Requires-Dist: python-docx>=1.0.0; extra == "all"
|
|
52
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "all"
|
|
53
|
+
Requires-Dist: python-pptx>=0.6.21; extra == "all"
|
|
54
|
+
Requires-Dist: pytesseract>=0.3.10; extra == "all"
|
|
55
|
+
Requires-Dist: Pillow>=10.0; extra == "all"
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
58
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
59
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
60
|
+
Requires-Dist: mypy>=1.5; extra == "dev"
|
|
61
|
+
Dynamic: license-file
|
|
62
|
+
|
|
63
|
+
# adaptive-intelligence
|
|
64
|
+
|
|
65
|
+
Self-improving retrieval orchestration framework for document intelligence. Drop documents, ask questions, the system learns how to retrieve better over time.
|
|
66
|
+
|
|
67
|
+
RL-based retrieval routing, conditional graph activation, evaluation-driven learning, vectorless mode, and zero-configuration architecture. Works with any LLM.
|
|
68
|
+
|
|
69
|
+
[](https://colab.research.google.com/github/VK-Ant/adaptive-intelligence/blob/main/notebooks/traditional_rag_vs_adaptive_intelligence.ipynb)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## Install
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
pip install adaptive-intelligence
|
|
76
|
+
pip install adaptive-intelligence[pdf] # PDF support
|
|
77
|
+
pip install adaptive-intelligence[sql] # SQL connector
|
|
78
|
+
pip install adaptive-intelligence[all] # all document formats
|
|
79
|
+
pip install adaptive-intelligence[huggingface] # local HuggingFace models
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Quick Start
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from adaptive_intelligence import AdaptiveAI
|
|
88
|
+
|
|
89
|
+
# Zero config — defaults to Ollama (free, local, private)
|
|
90
|
+
engine = AdaptiveAI()
|
|
91
|
+
engine.ingest("./documents")
|
|
92
|
+
response = engine.ask("What are the key operational risks?")
|
|
93
|
+
|
|
94
|
+
print(response.answer)
|
|
95
|
+
print(f"Confidence: {response.confidence:.0%}")
|
|
96
|
+
print(response.evaluation.display())
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Vectorless mode — no embeddings, no ChromaDB, zero dependencies
|
|
101
|
+
engine = AdaptiveAI(vectorless=True)
|
|
102
|
+
engine.ingest("./documents")
|
|
103
|
+
response = engine.ask("Revenue details?")
|
|
104
|
+
print(response.citations[0].page) # Page number citation
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# Structured output
|
|
109
|
+
response = engine.ask("Extract vendors", output_format="json")
|
|
110
|
+
print(response.structured) # Parsed dict
|
|
111
|
+
|
|
112
|
+
# User feedback → RL reward
|
|
113
|
+
engine.feedback(response.query_id, "good")
|
|
114
|
+
engine.feedback(response.query_id, "bad", reason="Missing data")
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## What Makes This Different
|
|
120
|
+
|
|
121
|
+
| | Traditional RAG | Adaptive Intelligence |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| Retrieval | Static vector similarity | RL-learned routing (6+ strategies) |
|
|
124
|
+
| Graph | None | Conditional activation (5-signal gate) |
|
|
125
|
+
| Prompts | Fixed template | Domain-adaptive, evolving |
|
|
126
|
+
| Learning | Same performance forever | Improves with each query |
|
|
127
|
+
| Evaluation | Manual | Automatic 6-metric + RL reward |
|
|
128
|
+
| Vector DB | Required | Optional (vectorless mode) |
|
|
129
|
+
| Output | Text only | JSON, CSV, YAML, DataFrame |
|
|
130
|
+
| Feedback | None | Thumbs up/down → RL update |
|
|
131
|
+
| Crash recovery | None | Auto-checkpoint + graceful shutdown |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Three Core Innovations
|
|
136
|
+
|
|
137
|
+
### 1. RL Policy Engine
|
|
138
|
+
|
|
139
|
+
Contextual bandits with Thompson Sampling learn which retrieval strategy works best for each query type. First 15 queries use heuristic defaults, then RL takes over. No hardcoded rules.
|
|
140
|
+
|
|
141
|
+
### 2. Conditional Graph Activation
|
|
142
|
+
|
|
143
|
+
Knowledge graph built automatically during ingestion. Activated only when the query needs relational reasoning — not wasted on simple factual lookups. Five signals gate activation.
|
|
144
|
+
|
|
145
|
+
### 3. Self-Adaptive Retrieval
|
|
146
|
+
|
|
147
|
+
Every response evaluated on 6 metrics. Composite score becomes RL reward. System measurably improves over queries.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## v2 Features
|
|
152
|
+
|
|
153
|
+
### Vectorless Mode
|
|
154
|
+
|
|
155
|
+
No embeddings. No ChromaDB. No vector DB at all. Pure Python BM25 + knowledge graph + RL routing.
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
engine = AdaptiveAI(vectorless=True)
|
|
159
|
+
# Page-level BM25 index, page citations, zero dependencies
|
|
160
|
+
# RL + graph + evaluation still fully active
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Output Formats
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
response = engine.ask("Extract vendors", output_format="json")
|
|
167
|
+
response = engine.ask("List items", output_format="csv")
|
|
168
|
+
response = engine.ask("Show data", output_format="yaml")
|
|
169
|
+
response = engine.ask("Revenue breakdown", output_format="dataframe")
|
|
170
|
+
|
|
171
|
+
# Custom schema
|
|
172
|
+
response = engine.ask("Contract details", output_format="json",
|
|
173
|
+
schema={"parties": ["str"], "value": "float", "date": "str"})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### User Feedback
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
engine.feedback(response.query_id, "good") # RL reward boost
|
|
180
|
+
engine.feedback(response.query_id, "bad", reason="Wrong data") # RL penalty + prompt evolution
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Incremental Ingestion
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
engine.ingest("./new_report.pdf") # Add
|
|
187
|
+
engine.remove("old_report.pdf") # Remove
|
|
188
|
+
engine.update("./updated_report.pdf") # Re-index
|
|
189
|
+
|
|
190
|
+
# Parallel
|
|
191
|
+
engine.ingest("./docs/", parallel=True, workers=4)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### SQL Connector
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
engine.ingest("sqlite:///data.db")
|
|
198
|
+
engine.ingest("postgresql://user:pass@host/db", tables=["invoices", "vendors"])
|
|
199
|
+
engine.ingest("mysql://user:pass@host/db", query="SELECT * FROM orders WHERE year=2025")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Crash Recovery
|
|
203
|
+
|
|
204
|
+
Auto-checkpoint every 5 minutes. BM25, graph, RL policy, and memory all persist to disk. Graceful shutdown on SIGTERM/SIGINT. Auto-recovery on startup.
|
|
205
|
+
|
|
206
|
+
### Hardened Ingestion
|
|
207
|
+
|
|
208
|
+
Handles every edge case: corrupted PDFs, password-protected files, scanned images (auto-OCR), Excel merged cells, hidden sheets, formula evaluation, CSV wrong delimiters, mixed encodings, malformed rows.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Supported Formats
|
|
213
|
+
|
|
214
|
+
| S.No. | Format | Extension | Required Package |
|
|
215
|
+
|-------|--------|-----------|-----------------|
|
|
216
|
+
| 1 | Text / Markdown | .txt, .md | — |
|
|
217
|
+
| 2 | CSV / TSV | .csv, .tsv | — |
|
|
218
|
+
| 3 | JSON | .json | — |
|
|
219
|
+
| 4 | HTML | .html | — |
|
|
220
|
+
| 5 | XML | .xml | — |
|
|
221
|
+
| 6 | PDF | .pdf | `PyMuPDF` or `pdfplumber` |
|
|
222
|
+
| 7 | Word | .docx | `python-docx` |
|
|
223
|
+
| 8 | Excel | .xlsx | `openpyxl` |
|
|
224
|
+
| 9 | PowerPoint | .pptx | `python-pptx` |
|
|
225
|
+
| 10 | Images (OCR) | .png, .jpg | `pytesseract`, `Pillow` |
|
|
226
|
+
| 11 | SQL databases | — | `sqlalchemy` |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Providers — Copy, Paste, Run
|
|
231
|
+
|
|
232
|
+
### Free Providers
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
# Ollama (default, local, free)
|
|
236
|
+
engine = AdaptiveAI()
|
|
237
|
+
|
|
238
|
+
# Ollama specific model
|
|
239
|
+
engine = AdaptiveAI(llm_model="llama3.2")
|
|
240
|
+
|
|
241
|
+
# NVIDIA NIM (free)
|
|
242
|
+
engine = AdaptiveAI(api_key="nvapi-...",
|
|
243
|
+
base_url="https://integrate.api.nvidia.com/v1",
|
|
244
|
+
llm_model="meta/llama-3.1-70b-instruct")
|
|
245
|
+
|
|
246
|
+
# Groq (free tier)
|
|
247
|
+
engine = AdaptiveAI(api_key="gsk_...",
|
|
248
|
+
base_url="https://api.groq.com/openai/v1",
|
|
249
|
+
llm_model="llama-3.3-70b-versatile")
|
|
250
|
+
|
|
251
|
+
# Google Gemini (free tier)
|
|
252
|
+
engine = AdaptiveAI(api_key="...",
|
|
253
|
+
base_url="https://generativelanguage.googleapis.com/v1beta/openai",
|
|
254
|
+
llm_model="gemini-2.0-flash")
|
|
255
|
+
|
|
256
|
+
# HuggingFace (local, any model)
|
|
257
|
+
engine = AdaptiveAI(llm_backend="huggingface", llm_model="microsoft/phi-2")
|
|
258
|
+
|
|
259
|
+
# Together AI (free tier)
|
|
260
|
+
engine = AdaptiveAI(api_key="...",
|
|
261
|
+
base_url="https://api.together.xyz/v1",
|
|
262
|
+
llm_model="meta-llama/Llama-3-70b-chat-hf")
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Paid Providers
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
# OpenAI
|
|
269
|
+
engine = AdaptiveAI(api_key="sk-...", llm_model="gpt-4o")
|
|
270
|
+
|
|
271
|
+
# Grok (xAI)
|
|
272
|
+
engine = AdaptiveAI(api_key="xai-...",
|
|
273
|
+
base_url="https://api.x.ai/v1", llm_model="grok-3-mini")
|
|
274
|
+
|
|
275
|
+
# Azure OpenAI
|
|
276
|
+
engine = AdaptiveAI(llm_backend="azure_openai", api_key="...",
|
|
277
|
+
azure_endpoint="https://your-resource.openai.azure.com",
|
|
278
|
+
deployment_name="gpt-4o")
|
|
279
|
+
|
|
280
|
+
# AWS Bedrock (via gateway)
|
|
281
|
+
engine = AdaptiveAI(api_key="...",
|
|
282
|
+
base_url="https://your-bedrock-gateway/v1",
|
|
283
|
+
llm_model="anthropic.claude-v2")
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### No LLM
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
# Retrieval only — returns ranked excerpts
|
|
290
|
+
engine = AdaptiveAI(llm_backend="none")
|
|
291
|
+
|
|
292
|
+
# Full zero-dependency mode
|
|
293
|
+
engine = AdaptiveAI(llm_backend="none", vectorless=True)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Code Examples
|
|
299
|
+
|
|
300
|
+
### Inspect the Full Pipeline
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
response = engine.ask("Compare Q2 and Q3 revenue")
|
|
304
|
+
|
|
305
|
+
# What did the system understand?
|
|
306
|
+
print(response.query_analysis)
|
|
307
|
+
|
|
308
|
+
# What strategy did the RL policy choose?
|
|
309
|
+
pd = response.policy_decision
|
|
310
|
+
print(f"Route: {pd.retrieval_route}")
|
|
311
|
+
print(f"Graph: {pd.graph_activation}")
|
|
312
|
+
print(f"Explored: {pd.was_exploration}")
|
|
313
|
+
|
|
314
|
+
# Evaluation scores
|
|
315
|
+
print(response.evaluation.display())
|
|
316
|
+
|
|
317
|
+
# Citations with page numbers
|
|
318
|
+
for c in response.citations:
|
|
319
|
+
print(f" {c.source_document}, Page {c.page} ({c.confidence:.0%})")
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Dashboard and Monitoring
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
print(engine.dashboard())
|
|
326
|
+
|
|
327
|
+
stats = engine.rl.get_stats()
|
|
328
|
+
print(f"Warmup: {stats['is_warmup']}")
|
|
329
|
+
print(f"Arms learned: {stats['total_arms']}")
|
|
330
|
+
|
|
331
|
+
curve = engine.learning_curve()
|
|
332
|
+
print(engine.memory.get_learning_summary())
|
|
333
|
+
|
|
334
|
+
engine.audit.export("audit.json")
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### System Prompt
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
# Set at init
|
|
341
|
+
engine = AdaptiveAI(system_prompt="You are a financial analyst. Cite page numbers.")
|
|
342
|
+
|
|
343
|
+
# Override per query
|
|
344
|
+
response = engine.ask("Risks?",
|
|
345
|
+
system_prompt="You are a risk specialist. Rate each HIGH/MEDIUM/LOW.")
|
|
346
|
+
|
|
347
|
+
# Update anytime
|
|
348
|
+
engine.set_system_prompt("You are a legal reviewer. Flag violations.")
|
|
349
|
+
engine.set_system_prompt(None) # Reset to default
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Advanced Configuration
|
|
353
|
+
|
|
354
|
+
```python
|
|
355
|
+
from adaptive_intelligence.core.config import (
|
|
356
|
+
AdaptiveConfig, RLConfig, GraphConfig, EvaluationConfig,
|
|
357
|
+
LLMBackend, Domain, SecurityLevel,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
config = AdaptiveConfig(
|
|
361
|
+
llm_backend=LLMBackend.OLLAMA,
|
|
362
|
+
llm_model="llama3.2",
|
|
363
|
+
domain=Domain.FINANCIAL,
|
|
364
|
+
security_level=SecurityLevel.HIGH,
|
|
365
|
+
rl=RLConfig(warmup_queries=20, exploration_rate=0.15),
|
|
366
|
+
graph=GraphConfig(conditional_activation=True, max_hops=3),
|
|
367
|
+
evaluation=EvaluationConfig(faithfulness_weight=0.35, enable_llm_judge=True),
|
|
368
|
+
)
|
|
369
|
+
engine = AdaptiveAI(config=config)
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Why This Exists
|
|
373
|
+
|
|
374
|
+
The world has 500+ LLMs. Every cloud provider (Azure, AWS, GCP), every platform (HuggingFace, Ollama), every company (NVIDIA, Meta, Google, xAI) is producing models. Many are free.
|
|
375
|
+
|
|
376
|
+
But every LLM has the same problem: garbage in, garbage out.
|
|
377
|
+
|
|
378
|
+
adaptive-intelligence is the layer that learns WHAT to feed the LLM. The LLM is replaceable. The retrieval intelligence is not.
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## FAQ
|
|
383
|
+
|
|
384
|
+
**Q: How does ingestion handle mixed content (text + tables) from PDFs?**
|
|
385
|
+
|
|
386
|
+
Tables are extracted with structure preserved (`is_table=True`) and indexed into the same indexes as text. The RL policy learns to use the `table_first` retrieval route for structured queries. Separation happens at retrieval time via learned routing, not at ingestion time.
|
|
387
|
+
|
|
388
|
+
**Q: How is this different from just using ChatGPT / Claude?**
|
|
389
|
+
|
|
390
|
+
adaptive-intelligence is not an LLM — it's the retrieval layer that decides what context to feed TO the LLM. It uses ChatGPT, Claude, Grok, or Ollama as backends. The system learns which retrieval strategy works best for each query type on YOUR specific documents.
|
|
391
|
+
|
|
392
|
+
**Q: What is vectorless mode?**
|
|
393
|
+
|
|
394
|
+
No ChromaDB. No embeddings. No vector DB. Pure Python BM25 keyword search over full pages + knowledge graph + RL routing. Everything still learns and improves — just without vector similarity. Best for financial/legal/medical documents with standardized terminology, or air-gapped environments.
|
|
395
|
+
|
|
396
|
+
**Q: Does the RL policy persist across sessions?**
|
|
397
|
+
|
|
398
|
+
Yes. RL state, BM25 index, knowledge graph, and learning memory all persist to disk. Auto-checkpoint every 5 minutes. Auto-recovery on startup.
|
|
399
|
+
|
|
400
|
+
**Q: Can I use this without an LLM (offline)?**
|
|
401
|
+
|
|
402
|
+
Yes. `AdaptiveAI(llm_backend="none")` returns ranked source excerpts directly. RL, graph, and evaluation still work.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Roadmap
|
|
407
|
+
|
|
408
|
+
### v2.0 (Current)
|
|
409
|
+
- [x] RL policy engine (Thompson Sampling)
|
|
410
|
+
- [x] Conditional graph activation (5-signal gate)
|
|
411
|
+
- [x] 6-metric evaluation → RL reward loop
|
|
412
|
+
- [x] Vectorless mode (page BM25, zero dependencies)
|
|
413
|
+
- [x] Output formats (JSON, CSV, YAML, DataFrame)
|
|
414
|
+
- [x] User feedback → RL reward
|
|
415
|
+
- [x] Crash recovery (auto-checkpoint, graceful shutdown)
|
|
416
|
+
- [x] Hardened ingestion (every PDF/Excel/CSV edge case)
|
|
417
|
+
- [x] SQL connector (PostgreSQL, MySQL, SQLite)
|
|
418
|
+
- [x] Incremental ingestion (add/remove/update)
|
|
419
|
+
- [x] Parallel ingestion
|
|
420
|
+
- [x] Chunk quality scoring + deduplication
|
|
421
|
+
- [x] Custom system prompt support
|
|
422
|
+
- [x] 10+ providers copy-paste ready
|
|
423
|
+
- [x] Page-number citations
|
|
424
|
+
|
|
425
|
+
### v3.0 — Intelligence Upgrades
|
|
426
|
+
- [ ] PPO/DQN alongside Thompson Sampling
|
|
427
|
+
- [ ] GraphSAGE embeddings replacing BFS
|
|
428
|
+
- [ ] Cross-encoder reranking
|
|
429
|
+
- [ ] Multi-query decomposition
|
|
430
|
+
- [ ] Pre-trained domain policies (financial, legal, healthcare)
|
|
431
|
+
- [ ] Transfer learning across deployments
|
|
432
|
+
- [ ] llmevalkit compliance integration
|
|
433
|
+
- [ ] Multi-modal ingestion (images, charts, audio)
|
|
434
|
+
- [ ] Enterprise connectors (S3, Notion, Confluence)
|
|
435
|
+
- [ ] Plugin API for community connectors
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Also by the Author
|
|
440
|
+
|
|
441
|
+
- **[llmevalkit](https://pypi.org/project/llmevalkit/)** — LLM evaluation, hallucination detection, compliance, and 61 metrics
|
|
442
|
+
- **[Responsible AI Series](https://medium.com/@VK_Venkatkumar/list/responsible-ai-engineer-series-4d9565c82bd2)** — HIPAA, GDPR, NIST AI RMF, CoSAI, EU AI Act
|
|
443
|
+
|
|
444
|
+
## Citation
|
|
445
|
+
|
|
446
|
+
```bibtex
|
|
447
|
+
@article{venkatkumar2026adaptive,
|
|
448
|
+
title={Adaptive Retrieval Orchestration for Self-Learning Knowledge Systems},
|
|
449
|
+
author={Venkatkumar, Rajan},
|
|
450
|
+
year={2026},
|
|
451
|
+
url={https://www.researchgate.net/publication/405076088},
|
|
452
|
+
note={Available at ResearchGate and GitHub: github.com/VK-Ant/adaptive-intelligence}
|
|
453
|
+
}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
## License
|
|
457
|
+
|
|
458
|
+
Apache License 2.0
|
|
459
|
+
|
|
460
|
+
## Author
|
|
461
|
+
|
|
462
|
+
Venkatkumar Rajan
|
|
463
|
+
|
|
464
|
+
- LinkedIn: https://linkedin.com/in/venkatkumarvk
|
|
465
|
+
- GitHub: https://github.com/VK-Ant
|
|
466
|
+
- Portfolio: https://vk-ant.github.io/Venkatkumar/
|
|
467
|
+
- PyPI: https://pypi.org/project/adaptive-intelligence/
|
|
468
|
+
- ResearchGate: https://www.researchgate.net/publication/405076088
|