Skip to main content

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!

See Architecture Diagram for detailed visualization.


๐Ÿ“Š 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:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. 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


๐ŸŒŸ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omnirag-1.0.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omnirag-1.0.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file omnirag-1.0.2.tar.gz.

File metadata

  • Download URL: omnirag-1.0.2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for omnirag-1.0.2.tar.gz
Algorithm Hash digest
SHA256 26d8c57a8911203394e5c1079c475c14563101fa8df1c8a7a500a1715e4fc2c9
MD5 a74e0eea3e8fe215f23bc13c238907aa
BLAKE2b-256 a27d6e443a9b9f535310011077aa84d4e7eaf9b3ac528111187d7f80c23ae285

See more details on using hashes here.

File details

Details for the file omnirag-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: omnirag-1.0.2-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

Hashes for omnirag-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 609297bc7b5ba27a8d94001e523b89dc9351b478eda8f92f3ceb4dc89ec6c059
MD5 47d6203e1ab459fb4b03902464ddb9cb
BLAKE2b-256 629ae391546181303e9ee5c0e3de477d2727fe0fc88da47adf9a2cb5d3aeafdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page