OmniRAG: Universal RAG System combining Liquid + Agentic + Chain RAG
Project description
๐ OmniRAG - The Universal RAG System
Intelligent RAG combining Liquid + Agentic + Chain architectures
100% FREE using HuggingFace model (Qwen) + FAISS!
๐ฏ What is OmniRAG?
OmniRAG is an advanced Retrieval-Augmented Generation system that combines three powerful RAG techniques:
๐ Liquid RAG
Automatically adapts answers to user expertise level:
- Beginner: Simple explanations with examples
- Intermediate: Balanced technical content
- Expert: Deep technical details
๐ค Agentic RAG
Intelligently chooses the best information source:
- VectorDB: For local documents
- Web Search: For current information
โ๏ธ Chain RAG
Handles complex multi-part questions:
- Breaks down complex queries
- Answers each part separately
- Synthesizes coherent final answer
โจ Features
โ
PDF Support - Load PDF files directly
โ
Multiple LLM Models - Qwen, Flan-T5, Mistral, Phi-2
โ
FAISS Vector DB - Fast similarity search
โ
Web Search - DuckDuckGo integration (free!)
โ
Smart User Detection - Auto expertise level detection
โ
Query Decomposition - Handles complex questions
โ
Fast Caching - 3x speedup on repeated queries
โ
100% FREE - No API costs!
โ
Works on CPU - No GPU required (but faster with GPU)
๐ฆ Installation
pip install omnirag
From Source
git clone https://github.com/Giri530/omnirag.git
cd omnirag
pip install -e .
๐ Quick Start
from omnirag import OmniRAG
# Initialize with your preferred model
rag = OmniRAG(
model_name="Qwen/Qwen2.5-1.5B-Instruct", # or "google/flan-t5-large"
verbose=True
)
# Load documents
rag.load_from_file("dataset.pdf")
# Query
result = rag.query("What is the main concept?")
print(result['answer'])
That's it! OmniRAG automatically:
- Detects user expertise level
- Retrieves relevant information
- Adapts content to user level
- Generates perfect answer
๐ก Usage Examples
Load Different File Types
# PDF files
rag.load_from_file("research_paper.pdf")
# Text files
rag.load_from_file("notes.txt")
# JSON data
rag.load_from_file("data.json")
# Entire folder
rag.load_from_folder("./documents")
# With chunking for large files
rag.load_from_file("big_file.pdf", chunk_size=500)
# Direct text
rag.add_documents([
"Python is great for ML.",
"Qwen is a powerful language model."
])
Different User Levels
# Auto-detect user level
result = rag.query("What is machine learning?")
# Force specific level
result = rag.query("Explain ML", user_level="expert")
# Get detailed metadata
result = rag.query("Question", return_metadata=True)
print(result['metadata']['user_level'])
print(result['metadata']['sub_queries'])
Complex Queries
# OmniRAG automatically breaks down and answers
result = rag.query("""
Compare Python vs Java for machine learning.
Which is better for beginners?
What are the performance differences?
""")
print(result['answer'])
Enable Web Search
rag = OmniRAG(
model_name="Qwen/Qwen2.5-1.5B-Instruct",
enable_web_search=True # Free DuckDuckGo search
)
# Queries about "latest" or "recent" automatically use web
result = rag.query("Latest AI developments in 2025")
๐จ Supported Models
Qwen Models (Recommended!)
# Fast & Efficient
rag = OmniRAG(model_name="Qwen/Qwen2.5-0.5B-Instruct")
# Balanced (Best Choice!)
rag = OmniRAG(model_name="Qwen/Qwen2.5-1.5B-Instruct")
# High Quality
rag = OmniRAG(model_name="Qwen/Qwen2.5-3B-Instruct")
Flan-T5 Models
# Small & Fast
rag = OmniRAG(model_name="google/flan-t5-base") # 250M params
# Larger & Better
rag = OmniRAG(model_name="google/flan-t5-large") # 780M params
Other Models
# Microsoft Phi
rag = OmniRAG(model_name="microsoft/phi-2") # 2.7B params
# Mistral
rag = OmniRAG(model_name="mistralai/Mistral-7B-Instruct-v0.2") # 7B params
๐๏ธ Architecture
User Query
โ
๐ LIQUID RAG: Detect expertise level
โ
โ๏ธ CHAIN RAG: Break into sub-queries (if complex)
โ
FOR EACH SUB-QUERY:
โ
๐ค AGENTIC RAG: Choose tool (VectorDB or Web)
โ
Retrieve relevant chunks
โ
๐ LIQUID RAG: Transform to user level
โ
Generate sub-answer
โ
โ๏ธ CHAIN RAG: Synthesize all sub-answers
โ
๐ LIQUID RAG: Final polish
โ
โจ Perfect Answer!
๐ Performance
| Model | Size | RAM | Speed | Quality |
|---|---|---|---|---|
| Qwen-0.5B | 0.5B | 1GB | โกโกโก | โญโญ |
| Qwen-1.5B | 1.5B | 2GB | โกโก | โญโญโญ โญ |
| Qwen-3B | 3B | 4GB | โก | โญโญโญโญโญ |
| Flan-T5-Base | 250M | 1GB | โกโกโก | โญโญโญ |
| Flan-T5-Large | 780M | 2GB | โกโก | โญโญโญโญ |
Recommended: Qwen-1.5B for best balance!
๐ง Configuration
rag = OmniRAG(
# LLM Model
model_name="Qwen/Qwen2.5-1.5B-Instruct",
# Embedding Model
embedding_model="all-MiniLM-L6-v2",
# Web Search
enable_web_search=True,
# Verbose Output
verbose=True
)
๐ API Reference
OmniRAG Class
__init__(model_name, embedding_model, enable_web_search, verbose)
Initialize OmniRAG system.
load_from_file(file_path, chunk_size=None)
Load documents from file (.pdf, .txt, .json, .csv, .md).
load_from_folder(folder_path, file_extensions=None, chunk_size=None)
Load all documents from folder.
add_documents(documents)
Add documents directly as list.
query(user_query, user_level=None, max_sources=5, return_metadata=False)
Query the system and get answer.
Returns:
{
'answer': str, # Generated answer
'metadata': { # Optional
'user_level': str,
'sub_queries_count': int,
'sub_queries': list,
'tools_used': list
}
}
get_stats()
Get system statistics.
clear_cache()
Clear query cache.
๐ Use Cases
Research Assistant
rag.load_from_file("research_papers.pdf")
result = rag.query("What are the key findings?")
Document Q&A
rag.load_from_folder("./company_docs")
result = rag.query("What is our refund policy?")
Educational Tool
rag.load_from_file("textbook.pdf")
result = rag.query("Explain photosynthesis simply")
# Auto-detects beginner level!
Code Documentation
rag.load_from_folder("./docs", file_extensions=['.md', '.txt'])
result = rag.query("How do I deploy this?")
๐ ๏ธ Development
Install for Development
git clone https://github.com/Giri530/omnirag.git
cd omnirag
pip install -e ".[dev]"
Run Tests
pytest tests/
Project Structure
omnirag/
โโโ omnirag/
โ โโโ __init__.py
โ โโโ omnirag.py # Main class
โ โโโ liquid_analyzer.py # User level detection
โ โโโ chain_decomposer.py # Query decomposition
โ โโโ agentic_planner.py # Tool selection
โ โโโ content_transformer.py # Content adaptation
โ โโโ vectordb_tool.py # FAISS database
โ โโโ web_search_tool.py # Web search
โ โโโ llm_client.py # LLM wrapper
โ โโโ cache.py # Caching
โโโ examples/
โ โโโ quickstart.py
โโโ setup.py
โโโ requirements.txt
โโโ README.md
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request
๐ Requirements
- Python 3.8+
- 2-4GB RAM (depends on model)
- CPU or GPU (GPU recommended for speed)
Dependencies:
- transformers
- torch
- sentence-transformers
- faiss-cpu
- PyPDF2
- duckduckgo-search
๐ License
MIT License - Free for commercial and personal use!
See LICENSE for details.
๐ Acknowledgments
- HuggingFace for transformers library
- Qwen Team for excellent models
- FAISS for fast vector search
- Sentence Transformers for embeddings
๐ง Contact
- GitHub Issues: Report bugs or request features
- Gmail: girinathv48@gmail.com
๐ Star History
If you find OmniRAG useful, please โญ star the repo!
๐ Citation
@software{omnirag2025,
title={OmniRAG: The Universal RAG System},
author={Girinath V},
year={2025},
url={https://github.com/Giri530/omnirag}
}
๐ฏ Roadmap
- Support for more file formats (DOCX, XLSX)
- Advanced caching strategies
- Multi-language support
- Custom embedding models
- GUI interface
- Cloud deployment guides
Made with โค๏ธ - 100% FREE Forever!
Happy RAG-ing! ๐
Project details
Release history Release notifications | RSS feed
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 omnirag-1.0.3.tar.gz.
File metadata
- Download URL: omnirag-1.0.3.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c924d1452588215770cb11710df6af22bd8dd5cd5515740f014e3cf8d95fa709
|
|
| MD5 |
1032a4a591d48e1321443c5ea9a09934
|
|
| BLAKE2b-256 |
e1b8251420058691771c29feca97d5971ae282d91e17045d78cfc052e54b3350
|
File details
Details for the file omnirag-1.0.3-py3-none-any.whl.
File metadata
- Download URL: omnirag-1.0.3-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76861cb6da1a0152d09336225ca6f18a631bd5fffaa9a4135cd6d77352e9184
|
|
| MD5 |
8c1d9b3f162b33770e923a49e66858ce
|
|
| BLAKE2b-256 |
8ef4bdd5ac28cf9b0ffc75e2962eef0e54dd3198a615746b623badbc409d2153
|