Skip to content

BetterRAG: Powerful RAG evaluation toolkit for LLMs. Measure, analyze, and optimize how your AI processes text chunks with precision metrics. Perfect for RAG systems, document processing, and embedding quality assessment.

Notifications You must be signed in to change notification settings

Kaos599/BetterRAG

Repository files navigation

BetterRAG Logo

BetterRAG

πŸš€ Supercharge your RAG pipeline with optimized text chunking

Python 3.8+ License: MIT Contributions Welcome MongoDB Dashboard

✨ Overview

BetterRAG helps you find the optimal text chunking strategy for your Retrieval-Augmented Generation pipeline through rigorous, data-driven evaluation. Stop guessing which chunking method works bestβ€”measure it!

πŸ“Š Compare Strategies βš™οΈ Zero-Code Configuration πŸ“ˆ Interactive Dashboard

πŸ”Ž Why BetterRAG?

Text chunking can make or break your RAG system's performance. Different strategies yield dramatically different results, but the optimal approach depends on your specific documents and use case. BetterRAG provides:

  • Quantitative comparison between chunking strategies
  • Visualized metrics to understand performance differences
  • Clear recommendations based on real data
  • No coding required to evaluate and improve your pipeline

πŸ› οΈ Features

🧩 Multiple Chunking Strategies

  • Fixed-size chunking: Simple token-based splitting
  • Recursive chunking: Follows document hierarchy
  • Semantic chunking: Preserves meaning and context

πŸ€– LLM Integration

  • Azure OpenAI compatibility
  • Google Gemini support
  • Extensible for other models

πŸ“Š Comprehensive Metrics

  • Context precision
  • Token efficiency
  • Answer relevance
  • Latency measurement

πŸ’Ύ Persistent Storage

  • MongoDB integration
  • Reuse embeddings across evaluations
  • Cache results for faster iteration

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • MongoDB (local or remote)
  • API keys for Azure OpenAI and/or Google Gemini

Installation in 3 Steps

# 1. Clone the repository
git clone https://github.com/yourusername/betterrag.git
cd betterrag

# 2. Install dependencies
pip install -r requirements.txt

# 3. Set up your configuration
cp config.template.yaml config.yaml
# Edit config.yaml with your API keys and preferences

Running Your First Evaluation

# Add your documents to data/documents/

# Run the evaluation
python -m app.main

# View the interactive dashboard
# Default: http://127.0.0.1:8050/

πŸ“Š Sample Results

BetterRAG provides clear visual comparisons between chunking strategies:

Comparison Chart

Based on comprehensive metrics, BetterRAG will recommend the most effective chunking approach for your specific documents and queries.

βš™οΈ Configuration Options

BetterRAG uses a single YAML configuration file for all settings:

# Chunking strategies to evaluate
chunking:
  fixed_size:
    enabled: true
    chunk_size: 500
    chunk_overlap: 50
  
  recursive:
    enabled: true
    chunk_size: 1000
    separators: ["\n\n", "\n", " ", ""]
  
  semantic:
    enabled: true
    model: "all-MiniLM-L6-v2"

# API credentials (or use environment variables)
api:
  azure_openai:
    api_key: ${AZURE_OPENAI_API_KEY}
    endpoint: ${AZURE_OPENAI_ENDPOINT}

See config_setup.md for detailed configuration instructions.

πŸ”§ Advanced Usage

# Run dashboard only (using previously processed data)
python -m app.main --dashboard-only

# Reset database before processing
python -m app.main --reset-db

# Use custom config file
python -m app.main --config my_custom_config.yaml

πŸ› οΈ Extending BetterRAG

Adding a New Chunking Strategy

  1. Create a new chunker implementation in app/chunkers/
  2. Register it in app/chunkers/__init__.py
  3. Add configuration parameters in config.yaml

Custom Metrics

Extend the ChunkingEvaluator class in app/evaluation/metrics.py to add new metrics.

🀝 Contributing

Contributions are welcome! Feel free to:

  • Report bugs and issues
  • Suggest new features or enhancements
  • Add support for additional LLM providers
  • Implement new chunking strategies

πŸ“œ License

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


Built with ❀️ for the RAG community

Report Bug Β· Request Feature

About

BetterRAG: Powerful RAG evaluation toolkit for LLMs. Measure, analyze, and optimize how your AI processes text chunks with precision metrics. Perfect for RAG systems, document processing, and embedding quality assessment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages