ragmint 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ragmint-0.2.3.data/data/README.md +284 -0
- ragmint-0.2.3.dist-info/METADATA +312 -0
- {ragmint-0.2.1.dist-info → ragmint-0.2.3.dist-info}/RECORD +7 -5
- ragmint-0.2.3.dist-info/licenses/LICENSE +19 -0
- ragmint-0.2.1.dist-info/METADATA +0 -27
- {ragmint-0.2.1.dist-info/licenses → ragmint-0.2.3.data/data}/LICENSE +0 -0
- {ragmint-0.2.1.dist-info → ragmint-0.2.3.dist-info}/WHEEL +0 -0
- {ragmint-0.2.1.dist-info → ragmint-0.2.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Ragmint
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
**Ragmint** (Retrieval-Augmented Generation Model Inspection & Tuning) is a modular, developer-friendly Python library for **evaluating, optimizing, and tuning RAG (Retrieval-Augmented Generation) pipelines**.
|
|
12
|
+
|
|
13
|
+
It provides a complete toolkit for **retriever selection**, **embedding model tuning**, and **automated RAG evaluation** with support for **Optuna-based Bayesian optimization**, **Auto-RAG tuning**, and **explainability** through Gemini or Claude.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ✨ Features
|
|
18
|
+
|
|
19
|
+
- ✅ **Automated hyperparameter optimization** (Grid, Random, Bayesian via Optuna)
|
|
20
|
+
- 🤖 **Auto-RAG Tuner** — dynamically recommends retriever–embedding pairs based on corpus size
|
|
21
|
+
- 🧠 **Explainability Layer** — interprets RAG performance via Gemini or Claude APIs
|
|
22
|
+
- 🏆 **Leaderboard Tracking** — stores and ranks experiment runs via JSON or external DB
|
|
23
|
+
- 🔍 **Built-in RAG evaluation metrics** — faithfulness, recall, BLEU, ROUGE, latency
|
|
24
|
+
- ⚙️ **Retrievers** — FAISS, Chroma, ElasticSearch
|
|
25
|
+
- 🧩 **Embeddings** — OpenAI, HuggingFace
|
|
26
|
+
- 💾 **Caching, experiment tracking, and reproducibility** out of the box
|
|
27
|
+
- 🧰 **Clean modular structure** for easy integration in research and production setups
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🚀 Quick Start
|
|
32
|
+
|
|
33
|
+
### 1️⃣ Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/andyolivers/ragmint.git
|
|
37
|
+
cd ragmint
|
|
38
|
+
pip install -e .
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> The `-e` flag installs Ragmint in editable (development) mode.
|
|
42
|
+
> Requires **Python ≥ 3.9**.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### 2️⃣ Run a RAG Optimization Experiment
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python ragmint/main.py --config configs/default.yaml --search bayesian
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Example `configs/default.yaml`:
|
|
53
|
+
```yaml
|
|
54
|
+
retriever: faiss
|
|
55
|
+
embedding_model: text-embedding-3-small
|
|
56
|
+
reranker:
|
|
57
|
+
mode: mmr
|
|
58
|
+
lambda_param: 0.5
|
|
59
|
+
optimization:
|
|
60
|
+
search_method: bayesian
|
|
61
|
+
n_trials: 20
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### 3️⃣ Manual Pipeline Usage
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from ragmint.core.pipeline import RAGPipeline
|
|
70
|
+
|
|
71
|
+
pipeline = RAGPipeline({
|
|
72
|
+
"embedding_model": "text-embedding-3-small",
|
|
73
|
+
"retriever": "faiss",
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
result = pipeline.run("What is retrieval-augmented generation?")
|
|
77
|
+
print(result)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🧪 Dataset Options
|
|
83
|
+
|
|
84
|
+
Ragmint can automatically load evaluation datasets for your RAG pipeline:
|
|
85
|
+
|
|
86
|
+
| Mode | Example | Description |
|
|
87
|
+
|------|----------|-------------|
|
|
88
|
+
| 🧱 **Default** | `validation_set=None` | Uses built-in `experiments/validation_qa.json` |
|
|
89
|
+
| 📁 **Custom File** | `validation_set="data/my_eval.json"` | Load your own QA dataset (JSON or CSV) |
|
|
90
|
+
| 🌐 **Hugging Face Dataset** | `validation_set="squad"` | Automatically downloads benchmark datasets (requires `pip install datasets`) |
|
|
91
|
+
|
|
92
|
+
### Example
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from ragmint.tuner import RAGMint
|
|
96
|
+
|
|
97
|
+
ragmint = RAGMint(
|
|
98
|
+
docs_path="data/docs/",
|
|
99
|
+
retrievers=["faiss", "chroma"],
|
|
100
|
+
embeddings=["text-embedding-3-small"],
|
|
101
|
+
rerankers=["mmr"],
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Use built-in default
|
|
105
|
+
ragmint.optimize(validation_set=None)
|
|
106
|
+
|
|
107
|
+
# Use Hugging Face benchmark
|
|
108
|
+
ragmint.optimize(validation_set="squad")
|
|
109
|
+
|
|
110
|
+
# Use your own dataset
|
|
111
|
+
ragmint.optimize(validation_set="data/custom_qa.json")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🧠 Auto-RAG Tuner
|
|
117
|
+
|
|
118
|
+
The **AutoRAGTuner** automatically recommends retriever–embedding combinations
|
|
119
|
+
based on corpus size and average document length.
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from ragmint.autotuner import AutoRAGTuner
|
|
123
|
+
|
|
124
|
+
corpus_stats = {"size": 5000, "avg_len": 250}
|
|
125
|
+
tuner = AutoRAGTuner(corpus_stats)
|
|
126
|
+
recommendation = tuner.recommend()
|
|
127
|
+
print(recommendation)
|
|
128
|
+
# Example output: {"retriever": "Chroma", "embedding_model": "SentenceTransformers"}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🏆 Leaderboard Tracking
|
|
134
|
+
|
|
135
|
+
Track and visualize your best experiments across runs.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from ragmint.leaderboard import Leaderboard
|
|
139
|
+
|
|
140
|
+
lb = Leaderboard("experiments/leaderboard.json")
|
|
141
|
+
lb.add_entry({"trial": 1, "faithfulness": 0.87, "latency": 0.12})
|
|
142
|
+
lb.show_top(3)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🧠 Explainability with Gemini / Claude
|
|
148
|
+
|
|
149
|
+
Compare two RAG configurations and receive natural language insights
|
|
150
|
+
on **why** one performs better.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from ragmint.explainer import explain_results
|
|
154
|
+
|
|
155
|
+
config_a = {"retriever": "FAISS", "embedding_model": "OpenAI"}
|
|
156
|
+
config_b = {"retriever": "Chroma", "embedding_model": "SentenceTransformers"}
|
|
157
|
+
|
|
158
|
+
explanation = explain_results(config_a, config_b, model="gemini")
|
|
159
|
+
print(explanation)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
> Set your API keys in a `.env` file or via environment variables:
|
|
163
|
+
> ```
|
|
164
|
+
> export GOOGLE_API_KEY="your_gemini_key"
|
|
165
|
+
> export ANTHROPIC_API_KEY="your_claude_key"
|
|
166
|
+
> ```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 🧩 Folder Structure
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
ragmint/
|
|
174
|
+
├── core/
|
|
175
|
+
│ ├── pipeline.py
|
|
176
|
+
│ ├── retriever.py
|
|
177
|
+
│ ├── reranker.py
|
|
178
|
+
│ ├── embedding.py
|
|
179
|
+
│ └── evaluation.py
|
|
180
|
+
├── autotuner.py
|
|
181
|
+
├── explainer.py
|
|
182
|
+
├── leaderboard.py
|
|
183
|
+
├── tuner.py
|
|
184
|
+
├── utils/
|
|
185
|
+
├── configs/
|
|
186
|
+
├── experiments/
|
|
187
|
+
├── tests/
|
|
188
|
+
└── main.py
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🧪 Running Tests
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
pytest -v
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
To include integration tests with Gemini or Claude APIs:
|
|
200
|
+
```bash
|
|
201
|
+
pytest -m integration
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## ⚙️ Configuration via `pyproject.toml`
|
|
207
|
+
|
|
208
|
+
Your `pyproject.toml` includes all required dependencies:
|
|
209
|
+
|
|
210
|
+
```toml
|
|
211
|
+
[project]
|
|
212
|
+
name = "ragmint"
|
|
213
|
+
version = "0.1.0"
|
|
214
|
+
dependencies = [
|
|
215
|
+
"numpy",
|
|
216
|
+
"optuna",
|
|
217
|
+
"scikit-learn",
|
|
218
|
+
"faiss-cpu",
|
|
219
|
+
"chromadb",
|
|
220
|
+
"pytest",
|
|
221
|
+
"openai",
|
|
222
|
+
"tqdm",
|
|
223
|
+
"google-generativeai",
|
|
224
|
+
"google-genai",
|
|
225
|
+
]
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 📊 Example Experiment Workflow
|
|
231
|
+
|
|
232
|
+
1. Define your retriever, embedding, and reranker setup
|
|
233
|
+
2. Launch optimization (Grid, Random, Bayesian) or AutoTune
|
|
234
|
+
3. Compare performance with explainability
|
|
235
|
+
4. Persist results to leaderboard for later inspection
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## 🧬 Architecture Overview
|
|
240
|
+
|
|
241
|
+
```mermaid
|
|
242
|
+
flowchart TD
|
|
243
|
+
A[Query] --> B[Embedder]
|
|
244
|
+
B --> C[Retriever]
|
|
245
|
+
C --> D[Reranker]
|
|
246
|
+
D --> E[Generator]
|
|
247
|
+
E --> F[Evaluation]
|
|
248
|
+
F --> G[Optuna / AutoRAGTuner]
|
|
249
|
+
G -->|Best Params| B
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 📘 Example Output
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
[INFO] Starting Bayesian optimization with Optuna
|
|
258
|
+
[INFO] Trial 7 finished: faithfulness=0.83, latency=0.42s
|
|
259
|
+
[INFO] Best parameters: {'lambda_param': 0.6, 'retriever': 'faiss'}
|
|
260
|
+
[INFO] AutoRAGTuner: Suggested retriever=Chroma for medium corpus
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 🧠 Why Ragmint?
|
|
266
|
+
|
|
267
|
+
- Built for **RAG researchers**, **AI engineers**, and **LLM ops**
|
|
268
|
+
- Works with **LangChain**, **LlamaIndex**, or standalone setups
|
|
269
|
+
- Designed for **extensibility** — plug in your own retrievers, models, or metrics
|
|
270
|
+
- Integrated **explainability and leaderboard** modules for research and production
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## ⚖️ License
|
|
275
|
+
|
|
276
|
+
Licensed under the **Apache License 2.0** — free for personal, research, and commercial use.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## 👤 Author
|
|
281
|
+
|
|
282
|
+
**André Oliveira**
|
|
283
|
+
[andyolivers.com](https://andyolivers.com)
|
|
284
|
+
Data Scientist | AI Engineer
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ragmint
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: A modular framework for evaluating and optimizing RAG pipelines.
|
|
5
|
+
Author-email: Andre Oliveira <oandreoliveira@outlook.com>
|
|
6
|
+
License: Apache License 2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/andyolivers/ragmint
|
|
8
|
+
Project-URL: Documentation, https://andyolivers.com
|
|
9
|
+
Project-URL: Issues, https://github.com/andyolivers/ragmint/issues
|
|
10
|
+
Keywords: RAG,LLM,retrieval,optimization,AI,evaluation
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy>=1.23
|
|
15
|
+
Requires-Dist: pandas>=2.0
|
|
16
|
+
Requires-Dist: scikit-learn>=1.3
|
|
17
|
+
Requires-Dist: openai>=1.0
|
|
18
|
+
Requires-Dist: tqdm
|
|
19
|
+
Requires-Dist: pyyaml
|
|
20
|
+
Requires-Dist: chromadb>=0.4
|
|
21
|
+
Requires-Dist: faiss-cpu; sys_platform != "darwin"
|
|
22
|
+
Requires-Dist: optuna>=3.0
|
|
23
|
+
Requires-Dist: pytest
|
|
24
|
+
Requires-Dist: colorama
|
|
25
|
+
Requires-Dist: google-generativeai>=0.8.0
|
|
26
|
+
Requires-Dist: supabase>=2.4.0
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# Ragmint
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
**Ragmint** (Retrieval-Augmented Generation Model Inspection & Tuning) is a modular, developer-friendly Python library for **evaluating, optimizing, and tuning RAG (Retrieval-Augmented Generation) pipelines**.
|
|
40
|
+
|
|
41
|
+
It provides a complete toolkit for **retriever selection**, **embedding model tuning**, and **automated RAG evaluation** with support for **Optuna-based Bayesian optimization**, **Auto-RAG tuning**, and **explainability** through Gemini or Claude.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ✨ Features
|
|
46
|
+
|
|
47
|
+
- ✅ **Automated hyperparameter optimization** (Grid, Random, Bayesian via Optuna)
|
|
48
|
+
- 🤖 **Auto-RAG Tuner** — dynamically recommends retriever–embedding pairs based on corpus size
|
|
49
|
+
- 🧠 **Explainability Layer** — interprets RAG performance via Gemini or Claude APIs
|
|
50
|
+
- 🏆 **Leaderboard Tracking** — stores and ranks experiment runs via JSON or external DB
|
|
51
|
+
- 🔍 **Built-in RAG evaluation metrics** — faithfulness, recall, BLEU, ROUGE, latency
|
|
52
|
+
- ⚙️ **Retrievers** — FAISS, Chroma, ElasticSearch
|
|
53
|
+
- 🧩 **Embeddings** — OpenAI, HuggingFace
|
|
54
|
+
- 💾 **Caching, experiment tracking, and reproducibility** out of the box
|
|
55
|
+
- 🧰 **Clean modular structure** for easy integration in research and production setups
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 Quick Start
|
|
60
|
+
|
|
61
|
+
### 1️⃣ Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/andyolivers/ragmint.git
|
|
65
|
+
cd ragmint
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> The `-e` flag installs Ragmint in editable (development) mode.
|
|
70
|
+
> Requires **Python ≥ 3.9**.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### 2️⃣ Run a RAG Optimization Experiment
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python ragmint/main.py --config configs/default.yaml --search bayesian
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Example `configs/default.yaml`:
|
|
81
|
+
```yaml
|
|
82
|
+
retriever: faiss
|
|
83
|
+
embedding_model: text-embedding-3-small
|
|
84
|
+
reranker:
|
|
85
|
+
mode: mmr
|
|
86
|
+
lambda_param: 0.5
|
|
87
|
+
optimization:
|
|
88
|
+
search_method: bayesian
|
|
89
|
+
n_trials: 20
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### 3️⃣ Manual Pipeline Usage
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from ragmint.core.pipeline import RAGPipeline
|
|
98
|
+
|
|
99
|
+
pipeline = RAGPipeline({
|
|
100
|
+
"embedding_model": "text-embedding-3-small",
|
|
101
|
+
"retriever": "faiss",
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
result = pipeline.run("What is retrieval-augmented generation?")
|
|
105
|
+
print(result)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 🧪 Dataset Options
|
|
111
|
+
|
|
112
|
+
Ragmint can automatically load evaluation datasets for your RAG pipeline:
|
|
113
|
+
|
|
114
|
+
| Mode | Example | Description |
|
|
115
|
+
|------|----------|-------------|
|
|
116
|
+
| 🧱 **Default** | `validation_set=None` | Uses built-in `experiments/validation_qa.json` |
|
|
117
|
+
| 📁 **Custom File** | `validation_set="data/my_eval.json"` | Load your own QA dataset (JSON or CSV) |
|
|
118
|
+
| 🌐 **Hugging Face Dataset** | `validation_set="squad"` | Automatically downloads benchmark datasets (requires `pip install datasets`) |
|
|
119
|
+
|
|
120
|
+
### Example
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from ragmint.tuner import RAGMint
|
|
124
|
+
|
|
125
|
+
ragmint = RAGMint(
|
|
126
|
+
docs_path="data/docs/",
|
|
127
|
+
retrievers=["faiss", "chroma"],
|
|
128
|
+
embeddings=["text-embedding-3-small"],
|
|
129
|
+
rerankers=["mmr"],
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Use built-in default
|
|
133
|
+
ragmint.optimize(validation_set=None)
|
|
134
|
+
|
|
135
|
+
# Use Hugging Face benchmark
|
|
136
|
+
ragmint.optimize(validation_set="squad")
|
|
137
|
+
|
|
138
|
+
# Use your own dataset
|
|
139
|
+
ragmint.optimize(validation_set="data/custom_qa.json")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 🧠 Auto-RAG Tuner
|
|
145
|
+
|
|
146
|
+
The **AutoRAGTuner** automatically recommends retriever–embedding combinations
|
|
147
|
+
based on corpus size and average document length.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from ragmint.autotuner import AutoRAGTuner
|
|
151
|
+
|
|
152
|
+
corpus_stats = {"size": 5000, "avg_len": 250}
|
|
153
|
+
tuner = AutoRAGTuner(corpus_stats)
|
|
154
|
+
recommendation = tuner.recommend()
|
|
155
|
+
print(recommendation)
|
|
156
|
+
# Example output: {"retriever": "Chroma", "embedding_model": "SentenceTransformers"}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 🏆 Leaderboard Tracking
|
|
162
|
+
|
|
163
|
+
Track and visualize your best experiments across runs.
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
from ragmint.leaderboard import Leaderboard
|
|
167
|
+
|
|
168
|
+
lb = Leaderboard("experiments/leaderboard.json")
|
|
169
|
+
lb.add_entry({"trial": 1, "faithfulness": 0.87, "latency": 0.12})
|
|
170
|
+
lb.show_top(3)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 🧠 Explainability with Gemini / Claude
|
|
176
|
+
|
|
177
|
+
Compare two RAG configurations and receive natural language insights
|
|
178
|
+
on **why** one performs better.
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from ragmint.explainer import explain_results
|
|
182
|
+
|
|
183
|
+
config_a = {"retriever": "FAISS", "embedding_model": "OpenAI"}
|
|
184
|
+
config_b = {"retriever": "Chroma", "embedding_model": "SentenceTransformers"}
|
|
185
|
+
|
|
186
|
+
explanation = explain_results(config_a, config_b, model="gemini")
|
|
187
|
+
print(explanation)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
> Set your API keys in a `.env` file or via environment variables:
|
|
191
|
+
> ```
|
|
192
|
+
> export GOOGLE_API_KEY="your_gemini_key"
|
|
193
|
+
> export ANTHROPIC_API_KEY="your_claude_key"
|
|
194
|
+
> ```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 🧩 Folder Structure
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
ragmint/
|
|
202
|
+
├── core/
|
|
203
|
+
│ ├── pipeline.py
|
|
204
|
+
│ ├── retriever.py
|
|
205
|
+
│ ├── reranker.py
|
|
206
|
+
│ ├── embedding.py
|
|
207
|
+
│ └── evaluation.py
|
|
208
|
+
├── autotuner.py
|
|
209
|
+
├── explainer.py
|
|
210
|
+
├── leaderboard.py
|
|
211
|
+
├── tuner.py
|
|
212
|
+
├── utils/
|
|
213
|
+
├── configs/
|
|
214
|
+
├── experiments/
|
|
215
|
+
├── tests/
|
|
216
|
+
└── main.py
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 🧪 Running Tests
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pytest -v
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
To include integration tests with Gemini or Claude APIs:
|
|
228
|
+
```bash
|
|
229
|
+
pytest -m integration
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## ⚙️ Configuration via `pyproject.toml`
|
|
235
|
+
|
|
236
|
+
Your `pyproject.toml` includes all required dependencies:
|
|
237
|
+
|
|
238
|
+
```toml
|
|
239
|
+
[project]
|
|
240
|
+
name = "ragmint"
|
|
241
|
+
version = "0.1.0"
|
|
242
|
+
dependencies = [
|
|
243
|
+
"numpy",
|
|
244
|
+
"optuna",
|
|
245
|
+
"scikit-learn",
|
|
246
|
+
"faiss-cpu",
|
|
247
|
+
"chromadb",
|
|
248
|
+
"pytest",
|
|
249
|
+
"openai",
|
|
250
|
+
"tqdm",
|
|
251
|
+
"google-generativeai",
|
|
252
|
+
"google-genai",
|
|
253
|
+
]
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 📊 Example Experiment Workflow
|
|
259
|
+
|
|
260
|
+
1. Define your retriever, embedding, and reranker setup
|
|
261
|
+
2. Launch optimization (Grid, Random, Bayesian) or AutoTune
|
|
262
|
+
3. Compare performance with explainability
|
|
263
|
+
4. Persist results to leaderboard for later inspection
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## 🧬 Architecture Overview
|
|
268
|
+
|
|
269
|
+
```mermaid
|
|
270
|
+
flowchart TD
|
|
271
|
+
A[Query] --> B[Embedder]
|
|
272
|
+
B --> C[Retriever]
|
|
273
|
+
C --> D[Reranker]
|
|
274
|
+
D --> E[Generator]
|
|
275
|
+
E --> F[Evaluation]
|
|
276
|
+
F --> G[Optuna / AutoRAGTuner]
|
|
277
|
+
G -->|Best Params| B
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📘 Example Output
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
[INFO] Starting Bayesian optimization with Optuna
|
|
286
|
+
[INFO] Trial 7 finished: faithfulness=0.83, latency=0.42s
|
|
287
|
+
[INFO] Best parameters: {'lambda_param': 0.6, 'retriever': 'faiss'}
|
|
288
|
+
[INFO] AutoRAGTuner: Suggested retriever=Chroma for medium corpus
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## 🧠 Why Ragmint?
|
|
294
|
+
|
|
295
|
+
- Built for **RAG researchers**, **AI engineers**, and **LLM ops**
|
|
296
|
+
- Works with **LangChain**, **LlamaIndex**, or standalone setups
|
|
297
|
+
- Designed for **extensibility** — plug in your own retrievers, models, or metrics
|
|
298
|
+
- Integrated **explainability and leaderboard** modules for research and production
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## ⚖️ License
|
|
303
|
+
|
|
304
|
+
Licensed under the **Apache License 2.0** — free for personal, research, and commercial use.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 👤 Author
|
|
309
|
+
|
|
310
|
+
**André Oliveira**
|
|
311
|
+
[andyolivers.com](https://andyolivers.com)
|
|
312
|
+
Data Scientist | AI Engineer
|
|
@@ -31,8 +31,10 @@ ragmint/utils/caching.py,sha256=LPE2JorOQ90BgVf6NUiS0-bdt-FGpNxDy7FnuwEHzy0,1060
|
|
|
31
31
|
ragmint/utils/data_loader.py,sha256=GXU9Nc3o0UWxtBeRwiskD1aCjSiNNuRoAokIUODn7q8,2024
|
|
32
32
|
ragmint/utils/logger.py,sha256=X7hTNb3st3fUeQIzSghuoV5B8FWXzm_O3DRkSfJvhmI,1033
|
|
33
33
|
ragmint/utils/metrics.py,sha256=DR8mrdumHtQerK0VrugwYKIG1oNptEcsFqodXq3i2kY,717
|
|
34
|
-
ragmint-0.2.
|
|
35
|
-
ragmint-0.2.
|
|
36
|
-
ragmint-0.2.
|
|
37
|
-
ragmint-0.2.
|
|
38
|
-
ragmint-0.2.
|
|
34
|
+
ragmint-0.2.3.data/data/LICENSE,sha256=ahkhYfFLI8tGrdxdO2_GaT6OJW2eNwyFT3kYi85QQhc,692
|
|
35
|
+
ragmint-0.2.3.data/data/README.md,sha256=4rubaB58cFz_LhuWk1JUVBAyQAYbTBwXX8eAZFBocoQ,7010
|
|
36
|
+
ragmint-0.2.3.dist-info/licenses/LICENSE,sha256=ahkhYfFLI8tGrdxdO2_GaT6OJW2eNwyFT3kYi85QQhc,692
|
|
37
|
+
ragmint-0.2.3.dist-info/METADATA,sha256=g1ES-pCYCZJUNY01_1jhEkzpW8hqrZ3gwF9kKGPtgec,7948
|
|
38
|
+
ragmint-0.2.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
39
|
+
ragmint-0.2.3.dist-info/top_level.txt,sha256=K2ulzMHuvFm6xayvvJdGABeRJAvKDBn6M3EI-3SbYLw,8
|
|
40
|
+
ragmint-0.2.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
Copyright 2025 André Oliveira
|
|
8
|
+
|
|
9
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
you may not use this file except in compliance with the License.
|
|
11
|
+
You may obtain a copy of the License at
|
|
12
|
+
|
|
13
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
See the License for the specific language governing permissions and
|
|
19
|
+
limitations under the License.
|
ragmint-0.2.1.dist-info/METADATA
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ragmint
|
|
3
|
-
Version: 0.2.1
|
|
4
|
-
Summary: A modular framework for evaluating and optimizing RAG pipelines.
|
|
5
|
-
Author-email: Andre Oliveira <oandreoliveira@outlook.com>
|
|
6
|
-
License: Apache License 2.0
|
|
7
|
-
Project-URL: Homepage, https://github.com/andyolivers/ragmint
|
|
8
|
-
Project-URL: Documentation, https://andyolivers.com
|
|
9
|
-
Project-URL: Issues, https://github.com/andyolivers/ragmint/issues
|
|
10
|
-
Keywords: RAG,LLM,retrieval,optimization,AI,evaluation
|
|
11
|
-
Requires-Python: >=3.9
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: numpy>=1.23
|
|
15
|
-
Requires-Dist: pandas>=2.0
|
|
16
|
-
Requires-Dist: scikit-learn>=1.3
|
|
17
|
-
Requires-Dist: openai>=1.0
|
|
18
|
-
Requires-Dist: tqdm
|
|
19
|
-
Requires-Dist: pyyaml
|
|
20
|
-
Requires-Dist: chromadb>=0.4
|
|
21
|
-
Requires-Dist: faiss-cpu; sys_platform != "darwin"
|
|
22
|
-
Requires-Dist: optuna>=3.0
|
|
23
|
-
Requires-Dist: pytest
|
|
24
|
-
Requires-Dist: colorama
|
|
25
|
-
Requires-Dist: google-generativeai>=0.8.0
|
|
26
|
-
Requires-Dist: supabase>=2.4.0
|
|
27
|
-
Dynamic: license-file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|