Self-improving retrieval orchestration framework with RL-based routing, conditional graph activation, and evaluation-driven learning.
Project description
Adaptive Intelligence
Self-improving retrieval orchestration that learns from every query.
Most RAG systems use static retrieval pipelines — same strategy for every query, no learning, no adaptation. Adaptive Intelligence changes that. It uses reinforcement learning to discover the optimal retrieval strategy for each query type, conditional graph activation to enable relationship reasoning only when needed, and evaluation-driven feedback loops to measurably improve over time.
from adaptive_intelligence import AdaptiveAI
engine = AdaptiveAI()
engine.ingest("./documents")
response = engine.ask("What are the key operational risks?")
print(response.answer) # Synthesized answer
print(response.confidence) # 0.87
print(response.evaluation.display()) # Full quality metrics
Three lines to start. The system handles everything else — and gets better with every query.
What Makes This Different
1. RL-Based Retrieval Routing
Instead of hardcoded rules ("always use hybrid search"), Adaptive Intelligence uses contextual bandits with Thompson Sampling to learn which retrieval strategy works best for which type of query:
- First 15 queries: heuristic defaults (keyword for factual, vector for semantic, hybrid for complex)
- After warmup: the RL policy selects from 6 strategies (vector, keyword, hybrid, table-first, graph-first, graph-hybrid), choosing depth, graph activation, prompt template, and verification level
- Every response is evaluated → evaluation score becomes the RL reward → policy updates
The system discovers patterns like "financial extraction queries work best with keyword search at depth 8" without being told.
2. Conditional Graph Activation
Knowledge graphs are powerful but expensive. Adaptive Intelligence builds an entity-relationship graph from your documents automatically, but only activates graph traversal when the query actually needs relational reasoning. Five signals gate activation:
- Relationship words in query ("connected", "depends on", "affects")
- Entity density (multiple entities that might be related)
- Query complexity (multi-hop reasoning detected)
- Historical success rate (did graph help for this query type before?)
- RL policy recommendation
3. Self-Adaptive Retrieval
The system measurably improves through an evaluation-driven feedback loop:
- Layer 1 (always on): Automatic metrics — faithfulness, relevance, citation accuracy, hallucination risk, retrieval precision/recall
- Layer 2 (when L1 confidence is low): LLM-as-Judge evaluation
- Layer 3 (periodic): Cross-reference consistency checks
The composite evaluation score feeds back as the RL reward signal, closing the loop.
Installation
pip install adaptive-intelligence
For document format support:
# PDF support
pip install adaptive-intelligence[pdf]
# All document formats (PDF, DOCX, XLSX, PPTX)
pip install adaptive-intelligence[all]
# HuggingFace models (local, any model)
pip install adaptive-intelligence[huggingface]
# Development
pip install adaptive-intelligence[dev]
Quick Start
Local LLM (Free, Private)
from adaptive_intelligence import AdaptiveAI
# Uses Ollama by default (install: https://ollama.ai, then: ollama pull llama3.2)
engine = AdaptiveAI()
engine.ingest("./documents")
response = engine.ask("What is the total revenue for Q3?")
Cloud LLM
engine = AdaptiveAI(
llm_backend="openai",
llm_model="gpt-4o",
api_key="sk-...",
)
Domain-Specific
engine = AdaptiveAI(
domain="financial", # financial, legal, healthcare, technical, operational
security_level="high", # standard, high, maximum
)
Three Levels of Access
Level 0 (80% of users) — Three lines, zero configuration:
engine = AdaptiveAI()
engine.ingest("./docs")
response = engine.ask("query")
Level 1 (15%) — Domain, provider, security:
engine = AdaptiveAI(
domain="financial",
llm_backend="openai",
api_key="sk-...",
security_level="high",
)
Level 2 (5%) — Full control over RL, graph, evaluation:
from adaptive_intelligence.core.config import AdaptiveConfig, RLConfig, GraphConfig
config = AdaptiveConfig(
rl=RLConfig(warmup_queries=20, exploration_rate=0.15),
graph=GraphConfig(max_hops=3, conditional_activation=True),
)
engine = AdaptiveAI(config=config)
Supported Formats
| Format | Extension | Required Package |
|---|---|---|
| Text / Markdown | .txt, .md | — |
| CSV | .csv | — |
| JSON | .json | — |
| HTML | .html | — |
| XML | .xml | — |
PyMuPDF or pdfplumber |
||
| Word | .docx | python-docx |
| Excel | .xlsx | openpyxl |
| PowerPoint | .pptx | python-pptx |
| Images (OCR) | .png, .jpg | pytesseract, Pillow |
LLM Providers
| Provider | Backend | Local? | Free? |
|---|---|---|---|
| Ollama | ollama |
✓ | ✓ |
| OpenAI | openai |
✗ | ✗ |
| Azure OpenAI | azure_openai |
✗ | ✗ |
| Groq | groq |
✗ | Free tier |
| Together AI | together |
✗ | Free tier |
| HuggingFace | huggingface |
✓ | ✓ |
| Any OpenAI-compatible | custom |
varies | varies |
Monitoring
Dashboard
print(engine.dashboard())
┌─────────────────────────────────────────────────────────┐
│ ADAPTIVE INTELLIGENCE DASHBOARD │
│ Documents Indexed: 247 │
│ Queries Processed: 38 │
│ Average Accuracy: 82.3% │
│ Improvement Rate: +14.7% │
│ RL Policy: Active │
│ Exploration Rate: 8.2% │
│ Arms Learned: 12 │
│ Graph Nodes: 156 │
│ Graph Edges: 284 │
└─────────────────────────────────────────────────────────┘
Learning Curve
curve = engine.learning_curve()
# [{"query_number": 1, "reward": 0.65, "rolling_avg": 0.65}, ...]
Audit Trail
trail = engine.audit.display_query_trail(response.query_id)
engine.audit.export("audit.json")
Architecture
Query → Trigger Interpreter → RL Policy Decision → Retrieval
↓ ↓
Graph Traversal Vector + Keyword
(conditional) (hybrid RRF)
↓ ↓
Adaptive Prompt ← ────────┘
↓
LLM Generation
↓
Evaluation Engine
↓
┌───────────────┼───────────────┐
↓ ↓ ↓
RL Update Memory Update Prompt Evolution
(reward) (patterns) (template scores)
Citation
If you use Adaptive Intelligence in research:
@software{venkatkumar2026adaptive,
title={Adaptive Intelligence: Self-Improving Retrieval Orchestration via Evaluation-Driven Policy Learning},
author={Venkatkumar, VK},
year={2026},
url={https://github.com/VK-Ant/adaptive-intelligence}
}
License
Apache License 2.0. See LICENSE.
Built by Venkatkumar_VK
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adaptive_intelligence-0.1.0.tar.gz.
File metadata
- Download URL: adaptive_intelligence-0.1.0.tar.gz
- Upload date:
- Size: 63.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d3e9590686e245a3eca2a678a0a379c8d5fdce38bea9ddbaddd90614ad38822
|
|
| MD5 |
d4caf69f18ab823e6c404c2e445fbdda
|
|
| BLAKE2b-256 |
2b1d016f223e1652a3e08205af0774c44f042f9aec35488f42ccaad57d69be28
|
File details
Details for the file adaptive_intelligence-0.1.0-py3-none-any.whl.
File metadata
- Download URL: adaptive_intelligence-0.1.0-py3-none-any.whl
- Upload date:
- Size: 61.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42147e85b90303e5cc04ec7f8137e04599953db6cf1f3f7bec29af5f9b41d27f
|
|
| MD5 |
9d87d4d7d989b38679237b3a2fd04e94
|
|
| BLAKE2b-256 |
f8c332c8d698a28e7ab3a87d8386f60e45e6d0c14fbc02f8b82481aa675e8ac2
|