Skip to content

Commit a289d1b

Browse files
kamran-rapidfireAIkbigdelyshabidlabs
authored
docs: Add RapidFire AI integration guide (#414)
Co-authored-by: kamran bigdely <kamranbigdely@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
1 parent 4520576 commit a289d1b

3 files changed

Lines changed: 158 additions & 0 deletions

File tree

docs/source/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
- sections:
3030
- local: transformers_integration
3131
title: Transformers Trainer
32+
- local: rapidfireai_integration
33+
title: RapidFire AI
3234
title: Integration
3335
- sections:
3436
- local: api
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# RapidFire AI Integration
2+
3+
[RapidFire AI](https://github.com/RapidFireAI/rapidfireai) enables rapid experimentation for easier, faster, and more impactful AI customization. It is built for agentic RAG, context engineering, fine-tuning, and post-training of LLMs and other DL models, delivering 16-24x higher throughput without extra resources. It supports two key use cases:
4+
5+
- **Fine-tuning and post-training**: Compare learning rates, LoRA configurations, batch sizes, and other training hyperparameters
6+
- **RAG optimization**: Evaluate chunking strategies, embedding models, retrieval approaches, and reranking settings
7+
8+
When running experiments, you often have many configurations executing simultaneously. RapidFire AI provides native Trackio integration to track and visualize all of these runs with minimal setup.
9+
10+
## Installation
11+
12+
Trackio is included as a dependency of RapidFire AI:
13+
14+
```bash
15+
pip install rapidfireai
16+
```
17+
18+
## Configuration
19+
20+
Enable Trackio as the tracking backend by setting environment variables before importing RapidFire components:
21+
22+
```python
23+
import os
24+
25+
# Enable Trackio as the tracking backend
26+
os.environ["RF_TRACKIO_ENABLED"] = "true"
27+
28+
# Optionally disable other tracking backends for standalone Trackio usage
29+
os.environ["RF_MLFLOW_ENABLED"] = "false"
30+
os.environ["RF_TENSORBOARD_ENABLED"] = "false"
31+
```
32+
33+
You can also set the Trackio project name:
34+
35+
```sh
36+
export TRACKIO_PROJECT_NAME="my-experiment"
37+
```
38+
39+
## Fine-Tuning Example
40+
41+
For complete working examples, see the tutorial notebooks:
42+
- [SFT with Trackio Tutorial](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/trackio/rf-tutorial-sft-trackio.ipynb)
43+
- [SFT with Trackio Tutorial (Colab Version)](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/fine-tuning/trackio/rf-colab-tutorial-sft-trackio.ipynb)
44+
45+
Here's a minimal example of running a fine-tuning experiment with Trackio tracking:
46+
47+
```python
48+
import os
49+
os.environ["RF_TRACKIO_ENABLED"] = "true"
50+
51+
from rapidfireai import Experiment
52+
from rapidfireai.automl import RFGridSearch, RFModelConfig, RFLoraConfig, RFSFTConfig
53+
54+
experiment = Experiment(experiment_name="my-sft-experiment", mode="fit")
55+
56+
config = RFModelConfig(
57+
model_name="TinyLlama/TinyLlama-1.1B-Chat-v1.0",
58+
peft_config=RFLoraConfig(r=8, lora_alpha=16, target_modules=["q_proj", "v_proj"]),
59+
training_args=RFSFTConfig(
60+
learning_rate=1e-4,
61+
max_steps=128,
62+
logging_steps=2,
63+
eval_strategy="steps",
64+
eval_steps=4,
65+
),
66+
model_type="causal_lm",
67+
)
68+
69+
experiment.run_fit(
70+
RFGridSearch(configs=[config], trainer_type="SFT"),
71+
create_model_fn,
72+
train_dataset,
73+
eval_dataset,
74+
num_chunks=4
75+
)
76+
```
77+
78+
## RAG Optimization Example
79+
80+
For complete working examples, see the tutorial notebooks:
81+
- [RAG FiQA with Trackio Tutorial](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/rag-contexteng/trackio/rf-tutorial-rag-fiqa-trackio.ipynb)
82+
- [RAG FiQA with Trackio Tutorial (Colab Version)](https://github.com/RapidFireAI/rapidfireai/blob/main/tutorial_notebooks/rag-contexteng/trackio/rf-colab-tutorial-rag-fiqa-trackio.ipynb)
83+
84+
RapidFire AI also supports RAG pipeline optimization. Enable Trackio tracking the same way:
85+
86+
```python
87+
import os
88+
os.environ["RF_TRACKIO_ENABLED"] = "true"
89+
90+
from rapidfireai import Experiment
91+
from rapidfireai.evals.automl import List, RFGridSearch, RFLangChainRagSpec, RFvLLMModelConfig
92+
93+
experiment = Experiment(experiment_name="my-rag-experiment", mode="evals")
94+
95+
rag_spec = RFLangChainRagSpec(
96+
document_loader=your_document_loader,
97+
text_splitter=your_text_splitter,
98+
embedding_cls=your_embedding_class,
99+
search_kwargs={"k": List([5, 10])}, # 2 retrieval configs to compare
100+
)
101+
102+
config_group = RFGridSearch({
103+
"vllm_config": RFvLLMModelConfig(rag=rag_spec, ...),
104+
"batch_size": 32,
105+
...
106+
})
107+
108+
experiment.run_evals(
109+
config_group=config_group,
110+
dataset=eval_dataset,
111+
num_actors=1,
112+
num_shards=4,
113+
)
114+
```
115+
116+
## What Gets Tracked
117+
118+
RapidFire AI automatically logs the following to Trackio:
119+
120+
**Fine-Tuning Metrics**:
121+
- `loss`, `learning_rate`, `epoch`, `step` - Training progress
122+
- `eval_loss` - Validation loss
123+
- Custom metrics from your `compute_metrics` function (e.g., `rougeL`, `bleu`)
124+
125+
**RAG Evaluation Metrics**:
126+
- Retrieval metrics: `Precision`, `Recall`, `F1 Score`, `NDCG@K`, `MRR`
127+
- Generation metrics: Custom metrics you define (e.g., `Accuracy`)
128+
129+
**Run Configuration**:
130+
- All hyperparameters for each run
131+
- Model settings, LoRA configurations, chunking strategies, etc.
132+
133+
## Viewing the Dashboard
134+
135+
Launch the Trackio dashboard to visualize your experiments:
136+
137+
```bash
138+
trackio show --project "my-sft-experiment"
139+
```
140+
141+
Or from Python:
142+
143+
```python
144+
import trackio
145+
trackio.show(project="my-sft-experiment")
146+
```
147+
148+
The dashboard displays real-time training curves for all your runs, making it easy to compare configurations side-by-side:
149+
150+
![Trackio dashboard showing RapidFire AI fine-tuning metrics](./trackio-screenshot-sft.png)
151+
152+
*Trackio dashboard comparing 4 fine-tuning runs with different hyperparameters. The plots show training loss, validation loss, learning rate schedules, and ROUGE-L scores—making it easy to identify which configuration (Run 4, in orange) achieves the lowest loss and best generation quality.*
153+
154+
**Documentation**:
155+
- [RapidFire AI Documentation](https://oss-docs.rapidfire.ai/) - Getting started guide
156+
- [RapidFire AI GitHub](https://github.com/RapidFireAI/rapidfireai) - Source code and tutorials
327 KB
Loading

0 commit comments

Comments
 (0)