Skip to main content

Multi-Language Voice RAG Framework

Project description

OmniRAG

PyPI version Python 3.8+ License: MIT Downloads

Intelligent Retrieval-Augmented Generation with Multi-Language Support and Voice Interface

FeaturesInstallationQuick StartDocumentationExamplesContributing


Overview

OmniRAG is a production-ready RAG (Retrieval-Augmented Generation) framework that combines adaptive learning, intelligent tool selection, and native multi-language capabilities. Unlike traditional RAG systems, OmniRAG translates outputs after retrieval, preserving semantic quality while supporting 27+ languages with built-in voice interface.

Key Capabilities

  • Adaptive Intelligence: Automatically adjusts response complexity based on user expertise level
  • Multi-Language Translation: Native support for 27+ languages including Tamil, Hindi, Spanish, and more
  • Voice Interface: Built-in speech-to-text and text-to-speech capabilities
  • Intelligent Tool Selection: Automatically chooses between local knowledge base and web search
  • Production Ready: Optimized for real-world applications with caching and error handling

Features

Core Features

  • 🌊 Liquid RAG: Adapts responses to user expertise (beginner, intermediate, expert)
  • 🤖 Agentic RAG: Intelligently selects optimal information sources
  • ⛓️ Chain RAG: Decomposes and handles complex multi-part queries
  • 📄 Document Processing: Native support for PDF, TXT, JSON, and more
  • 🔍 Vector Search: High-performance FAISS-based similarity search
  • 💾 Smart Caching: Automatic response caching for improved performance

v2.0 New Features

  • 🌍 Post-Retrieval Translation

    • Preserves embedding quality by maintaining original language documents
    • Significantly more storage efficient than pre-translation approaches
    • Supports full language names ("Spanish" vs "es") for better usability
  • 🎤 Native Voice Interface

    • Built-in speech recognition and synthesis
    • No external API dependencies
    • Multi-language voice support
    • Works offline
  • 🔧 Production Enhancements

    • UTF-8 encoding support for non-Latin scripts
    • Improved error handling and logging
    • Comprehensive documentation and examples

Installation

Basic Installation

pip install omnirag

With Voice Input Support

Voice output is enabled by default. For voice input (speech recognition), install additional dependencies:

Windows

pip install pipwin
pipwin install pyaudio
pip install omnirag[voice-input]

macOS

brew install portaudio
pip install omnirag[voice-input]

Linux

sudo apt-get install portaudio19-dev python3-pyaudio
pip install omnirag[voice-input]

From Source

git clone https://github.com/Giri530/omnirag.git
cd omnirag
pip install -e .

Quick Start

Basic Usage

from omnirag import OmniRAG

# Initialize with your preferred model
rag = OmniRAG(model_name="google/flan-t5-small")

# Add documents
rag.add_documents([
    "Python is a high-level programming language.",
    "It emphasizes code readability and simplicity."
])

# Query the system
result = rag.query("What is Python?")
print(result['answer'])

Multi-Language Translation

from omnirag import OmniRAG

# Initialize with target language
rag = OmniRAG(
    model_name="google/flan-t5-small",
    output_language="Spanish"
)

# Add English documents
rag.add_documents([
    "Artificial Intelligence enables machines to learn from experience.",
    "Machine Learning is a subset of AI."
])

# Query in any language, receive Spanish response
result = rag.query("What is AI?")
print(result['answer'])
# Output: "La Inteligencia Artificial permite a las máquinas aprender de la experiencia."

Voice-Enabled RAG

from omnirag import OmniRAG

# Initialize with voice support
rag = OmniRAG(
    enable_voice=True,
    output_language="Tamil"
)

rag.add_documents(["Quantum computing uses quantum mechanics principles."])

# Text query with spoken response
result = rag.query("Explain quantum computing", speak_answer=True)

# Full voice interaction (requires microphone)
result = rag.voice_query()

Supported Languages

OmniRAG supports 27+ languages with both full names and ISO codes:

Indian Languages: Tamil, Hindi, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Bengali

European Languages: Spanish, French, German, Italian, Portuguese, Russian, Polish, Dutch, Turkish

Asian Languages: Chinese (Simplified), Japanese, Korean, Vietnamese, Thai, Indonesian, Malay

Other: Arabic, English


Model Support

Recommended Models

Model Parameters RAM Speed Quality Use Case
google/flan-t5-small 80M 0.5GB ⚡⚡⚡ ⭐⭐ Development, Testing
google/flan-t5-base 250M 1GB ⚡⚡⚡ ⭐⭐⭐ Production (Balanced)
Qwen/Qwen2.5-0.5B-Instruct 500M 1GB ⚡⚡ ⭐⭐⭐ High Quality
Qwen/Qwen2.5-1.5B-Instruct 1.5B 2GB ⚡⚡ ⭐⭐⭐⭐ Best Quality
Qwen/Qwen2.5-3B-Instruct 3B 4GB ⭐⭐⭐⭐⭐ Maximum Quality

Advanced Configuration

rag = OmniRAG(
    model_name="google/flan-t5-base",      # LLM model
    embedding_model="all-MiniLM-L6-v2",    # Embedding model
    enable_web_search=True,                 # Enable web search
    output_language="Tamil",                # Target language
    enable_voice=True,                      # Voice interface
    use_4bit=False,                         # 4-bit quantization
    verbose=True                            # Debug logging
)

Examples

Document Q&A System

# Load documents from various sources
rag.load_from_file("company_handbook.pdf")
rag.load_from_folder("./policy_documents")

# Query with automatic source attribution
result = rag.query("What is the remote work policy?")
print(f"Answer: {result['answer']}")
print(f"Sources: {result['sources']}")

Multi-Language Customer Support

# Initialize for Hindi-speaking users
support_rag = OmniRAG(
    output_language="Hindi",
    enable_voice=True
)

support_rag.load_from_file("product_manual.pdf")

# Customer query with voice response
result = support_rag.query(
    "How do I reset my password?",
    speak_answer=True
)

Educational Assistant

# Initialize for students
edu_rag = OmniRAG(model_name="google/flan-t5-base")

edu_rag.load_from_file("physics_textbook.pdf")

# Automatically adapts to user level
beginner_result = rag.query("Explain photosynthesis")  # Simple explanation
expert_result = rag.query("Explain quantum entanglement")  # Technical detail

Complex Query Handling

# Automatically decomposes complex queries
result = rag.query("""
Compare the advantages and disadvantages of solar and wind energy.
Which is more cost-effective for residential use?
What are the environmental impacts of each?
""")

API Reference

Core Methods

__init__(**kwargs)

Initialize OmniRAG with configuration parameters.

Parameters:

  • model_name (str): HuggingFace model identifier
  • embedding_model (str): Sentence transformer model
  • enable_web_search (bool): Enable web search capability
  • output_language (str): Target language for responses
  • enable_voice (bool): Enable voice interface
  • use_4bit (bool): Use 4-bit quantization for memory efficiency
  • verbose (bool): Enable detailed logging

query(user_query, output_language=None, speak_answer=False)

Submit a query to the RAG system.

Parameters:

  • user_query (str): The question or prompt
  • output_language (str, optional): Override default output language
  • speak_answer (bool): Enable voice response

Returns: Dictionary containing:

  • answer (str): Generated response
  • sources (list): Retrieved source documents
  • user_level (str): Detected expertise level
  • output_language (str): Language code of response

add_documents(documents)

Add documents to the knowledge base.

Parameters:

  • documents (list): List of text strings or file paths

load_from_file(file_path, chunk_size=None)

Load and process a document file.

Parameters:

  • file_path (str): Path to document file
  • chunk_size (int, optional): Character limit per chunk

voice_query(output_language=None)

Process voice input and provide voice output.

Parameters:

  • output_language (str, optional): Override default output language

Returns: Same structure as query()


Architecture

┌─────────────┐
│ User Query  │
└──────┬──────┘
       │
       ▼
┌─────────────────────┐
│  Liquid Analyzer    │  ← Detect user expertise level
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Chain Decomposer   │  ← Break complex queries
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Agentic Planner    │  ← Select tools (Vector DB / Web)
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Information        │
│  Retrieval          │  ← Fetch relevant chunks
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Content            │
│  Transformation     │  ← Adapt to user level
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  LLM Generation     │  ← Generate response
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Smart Translator   │  ← Translate (if needed)
└──────┬──────────────┘
       │
       ▼
┌─────────────────────┐
│  Voice Processor    │  ← Synthesize speech (if enabled)
└──────┬──────────────┘
       │
       ▼
┌─────────────┐
│   Response  │
└─────────────┘

Use Cases

Enterprise Applications

  • Customer Support: Multi-language support with voice interface
  • Internal Knowledge Base: Quick access to company documentation
  • Training Systems: Adaptive content delivery based on employee expertise

Education

  • Study Assistants: Personalized explanations for students
  • Language Learning: Cross-language practice and translation
  • Accessibility: Voice interface for visually impaired students

Research

  • Literature Review: Query across multiple papers and documents
  • Data Analysis: Natural language interface to research data
  • Collaborative Tools: Multi-language research team support

Performance Optimization

Memory Management

# Use 4-bit quantization for large models
rag = OmniRAG(
    model_name="Qwen/Qwen2.5-3B-Instruct",
    use_4bit=True  # Reduces memory usage by ~75%
)

Caching

# Automatic caching of frequent queries
result1 = rag.query("What is Python?")  # ~2s
result2 = rag.query("What is Python?")  # <10ms (from cache)

# Clear cache when needed
rag.clear_cache()

Batch Processing

questions = [
    "What is machine learning?",
    "What is deep learning?",
    "What is neural network?"
]

results = [rag.query(q) for q in questions]

Comparison with Other Frameworks

Feature LangChain LlamaIndex OmniRAG
Built-in Translation*
Built-in Voice I/O*
Adaptive Responses ⚠️ Manual ⚠️ Manual ✅ Auto
Indian Languages ⚠️ External ⚠️ External ✅ Native
Beginner Friendly ⚠️ Complex ⚠️ Complex ✅ Simple
Open Source
Free to Use

* Built-in = Native implementation without external APIs or services


Troubleshooting

Common Issues

Import Errors

# Ensure proper installation
pip install --upgrade omnirag

# Verify installation
python -c "from omnirag import OmniRAG; print('Success!')"

Voice Input Issues

# Windows
pipwin install pyaudio

# macOS
brew install portaudio && pip install pyaudio

# Linux
sudo apt-get install portaudio19-dev python3-pyaudio

Out of Memory

# Use smaller model or enable quantization
rag = OmniRAG(
    model_name="google/flan-t5-small",  # Smaller model
    use_4bit=True  # Enable quantization
)

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Commit changes (git commit -m 'Add amazing feature')
  6. Push to branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Setup

git clone https://github.com/Giri530/omnirag.git
cd omnirag
pip install -e ".[dev]"
pytest tests/  # Run tests

License

This project is licensed under the MIT License - see the LICENSE file for details.


Citation

If you use OmniRAG in your research or project, please cite:

@software{omnirag2025,
  title={OmniRAG: Intelligent Multi-Language RAG Framework},
  author={Girinath V},
  year={2025},
  version={2.0.0},
  url={https://github.com/Giri530/omnirag},
  license={MIT}
}

Acknowledgments

Built with these excellent open-source projects:


Support


Roadmap

v2.0 (Current)

  • ✅ Multi-language translation
  • ✅ Voice interface
  • ✅ UTF-8 support

v2.1 (Planned)

  • DOCX and XLSX support
  • Custom translation models
  • Voice language selection
  • Web UI

v3.0 (Future)

  • Multi-modal support (images, audio)
  • Real-time translation
  • Cloud deployment templates
  • REST API server

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-2.0.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

omnirag-2.0.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for omnirag-2.0.2.tar.gz
Algorithm Hash digest
SHA256 ae3aa76a6cc1ead9ece05afa419b9c9081e37fae1c92d94c44fd343cd6024791
MD5 8b816a7f6e6b649db8576b4826ed0e7d
BLAKE2b-256 b08fe2ad4d0866d5a7784223593a3d5b6e79dce03752bcbcb28d0db5981a6355

See more details on using hashes here.

File details

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

File metadata

  • Download URL: omnirag-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for omnirag-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 95529607e9eac3afba0d37a077c5a2c11cbc350510d4c172bd67f930a12304ca
MD5 dca7eec2edb5b5cc7dbae9252853e584
BLAKE2b-256 ca087be3b8477a2456b137e5f153c0c388221e27ff14f9a4ae8acb1c2bcdb85e

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