| name | ultimate-rag |
| description | Hybrid Corrective RAG + Self-RAG implementation with Lyapunov-proven convergence for hallucination-free retrieval. |
| license | MIT |
| compatibility | claude-code, codex, cursor |
| metadata | [object Object] |
Ultimate RAG (Hybrid CRAG + Self-RAG)
Advanced retrieval-augmented generation combining Corrective RAG and Self-RAG techniques with mathematical convergence guarantees.
Architecture
Query → [Vector Search] → [Relevance Check] → [Self-Critique] → [Corrective Loop] → Answer
↓ ↓
[Web Search] [Regenerate]
↓ ↓
[Knowledge Graph] ← [Lyapunov Check]
Features
Corrective RAG (CRAG)
- Relevance scoring with threshold-based correction
- Automatic web search fallback for low-confidence retrievals
- Knowledge graph augmentation for entity relationships
Self-RAG
- Self-critique mechanism for answer validation
- Iterative refinement with convergence tracking
- Hallucination detection and prevention
Lyapunov Convergence
- Mathematical proof of answer stability
- Guaranteed convergence within N iterations
- Quantifiable improvement metrics
Usage
from AFO.rag import UltimateRAG
rag = UltimateRAG(top_k=5, max_iterations=10)
result = rag.query("What is the Trinity Score philosophy?")
# Result includes confidence and convergence metrics
print(f"Answer: {result.answer}")
print(f"Confidence: {result.confidence}")
print(f"Iterations: {result.iterations}")
print(f"Lyapunov Delta: {result.lyapunov_delta}")
Parameters
| Parameter |
Type |
Default |
Description |
| query |
string |
required |
User question |
| top_k |
int |
5 |
Number of documents to retrieve |
| max_iterations |
int |
10 |
Maximum self-correction iterations |
| relevance_threshold |
float |
0.7 |
Minimum relevance score |
Philosophy Alignment
- 眞 (Truth): Lyapunov-proven retrieval accuracy
- 善 (Goodness): No hallucinations, stable answers
- 美 (Beauty): Clean retrieval pipeline
- 孝 (Serenity): Auto-converges without user intervention