Skip to main content

A modular framework for evaluating and optimizing RAG pipelines.

Project description

Ragmint

Python License Tests Optuna Status

Ragmint (Retrieval-Augmented Generation Model Inspection & Tuning) is a modular, developer-friendly Python library for evaluating, optimizing, and tuning RAG (Retrieval-Augmented Generation) pipelines.

It provides a complete toolkit for retriever selection, embedding model tuning, and automated RAG evaluation with support for Optuna-based Bayesian optimization.


✨ Features

  • Automated hyperparameter optimization (Grid, Random, Bayesian via Optuna)
  • 🔍 Built-in RAG evaluation metrics — faithfulness, recall, BLEU, ROUGE, latency
  • ⚙️ Retrievers — FAISS, Chroma, ElasticSearch
  • 🧩 Embeddings — OpenAI, HuggingFace
  • 🧠 Rerankers — MMR, CrossEncoder (extensible via plugin interface)
  • 💾 Caching, experiment tracking, and reproducibility out of the box
  • 🧰 Clean modular structure for easy integration in research and production setups

🚀 Quick Start

1️⃣ Installation

git clone https://github.com/andyolivers/ragmint.git
cd ragmint
pip install -e .

The -e flag installs Ragmint in editable (development) mode.
Requires Python ≥ 3.9.


2️⃣ Run a RAG Optimization Experiment

python ragmint/main.py --config configs/default.yaml --search bayesian

Example configs/default.yaml:

retriever: faiss
embedding_model: text-embedding-3-small
reranker:
  mode: mmr
  lambda_param: 0.5
optimization:
  search_method: bayesian
  n_trials: 20

3️⃣ Manual Pipeline Usage

from ragmint.core.pipeline import RAGPipeline

pipeline = RAGPipeline({
    "embedding_model": "text-embedding-3-small",
    "retriever": "faiss",
})

result = pipeline.run("What is retrieval-augmented generation?")
print(result)

🧩 Folder Structure

ragmint/
├── core/
│   ├── pipeline.py         # RAGPipeline implementation
│   ├── retriever.py        # Retriever logic (FAISS, Chroma)
│   ├── reranker.py         # MMR + CrossEncoder rerankers
│   └── embedding.py        # Embedding backends
├── tuner.py                # Grid, Random, Bayesian optimization (Optuna)
├── utils/                  # Metrics, logging, caching helpers
├── configs/                # Default experiment configs
├── experiments/            # Saved experiment results
├── tests/                  # Unit tests for all components
├── main.py                 # CLI entrypoint for tuning
└── pyproject.toml          # Project dependencies & build metadata

🧪 Running Tests

To verify your setup:

pytest -v

Or to test a specific component (e.g., reranker):

pytest tests/test_reranker.py -v

All tests are designed for Pytest and run with lightweight mock data.


⚙️ Configuration via pyproject.toml

Your pyproject.toml automatically includes:

[project]
name = "ragmint"
version = "0.1.0"
dependencies = [
    "numpy",
    "optuna",
    "scikit-learn",
    "faiss-cpu",
    "chromadb",
    "pytest",
    "openai",
    "tqdm",
]

📊 Example Experiment Workflow

  1. Define your retriever and reranker configuration in YAML
  2. Launch an optimization search (Grid, Random, or Bayesian)
  3. Ragmint evaluates combinations automatically and reports top results
  4. Export best parameters for production pipelines

🧬 Architecture Overview

flowchart TD
    A[Query] --> B[Embedder]
    B --> C[Retriever]
    C --> D[Reranker]
    D --> E[Generator]
    E --> F[Evaluation]
    F --> G[Optuna Tuner]
    G -->|Best Params| B

📘 Example Output

[INFO] Starting Bayesian optimization with Optuna
[INFO] Trial 7 finished: recall=0.83, latency=0.42s
[INFO] Best parameters: {'lambda_param': 0.6, 'retriever': 'faiss'}

🧠 Why Ragmint?

  • Built for RAG researchers, AI engineers, and LLM ops
  • Works with LangChain, LlamaIndex, or standalone RAG setups
  • Designed for extensibility — plug in your own models, retrievers, or metrics

⚖️ License

Licensed under the Apache License 2.0 — free for personal, research, and commercial use.


👤 Author

André Oliveira
andyolivers.com
Data Scientist | AI Engineer

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

ragmint-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

ragmint-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file ragmint-0.1.0.tar.gz.

File metadata

  • Download URL: ragmint-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for ragmint-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bc377c107f31efdf633e4a3c61792b8d48560e16897d20587d0c8ddd0a101419
MD5 75915eb9ab72ffd658661c670bab3178
BLAKE2b-256 80a4b337591c888cf049152d1c6479fba86a39c4a8de456f419b4ccb5a3cf6ba

See more details on using hashes here.

File details

Details for the file ragmint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragmint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for ragmint-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17d6dcc7f2194ccc8c551c356a8422cae68bbc774ca421c7ed55862d3065541f
MD5 1026ad0419c7abee6ab60b67fcb3cc39
BLAKE2b-256 680768a0963536c4d0a9f867d31de6c3e3f77a70dbc66811718d963205caed38

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