A comprehensive framework for fine-tuning Small Language Models (SLMs) on agentic tasks and benchmarking them using state-of-the-art evaluation suites. This repository demonstrates the complete workflow from supervised fine-tuning (SFT) with LoRA adapters to deployment with vLLM and evaluation on OpenThoughts and Terminal Bench 2.0.
This project provides an end-to-end pipeline for:

# Install core dependencies
pip install vllm harbor-ai torch transformers
# Clone the repository
git clone https://github.com/your-org/benchmark-agentic-SLMs.git
cd benchmark-agentic-SLMs
1. Serve a Model
cd serve/vLLM
# Configure your model in config.yaml
python serve.py
# Server starts at http://localhost:8000
2. Run Benchmarks
cd ../../benchmarks/terminal_bench
./run_benchmark_lora.sh
3. Fine-Tune & Improve
cd ../../SFT-recipes/trl
# Configure training in train.yaml
./train_multi_gpu.sh
This repository uses vLLM for high-performance model serving with OpenAI-compatible APIs. vLLM provides:
Getting Started:
cd serve/vLLM
python serve.py
The server provides:
/v1/chat/completions/v1/completions/v1/modelshttp://localhost:8000/docsExample Request:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy"
)
response = client.chat.completions.create(
model="mistralai/Devstral-Small-2-24B-Instruct-2512",
messages=[
{"role": "user", "content": "Write a bash script to process logs"}
],
max_tokens=512
)
Supported Models:
Configuration:
Configure models in serve/vLLM/config.yaml
Detailed Documentation: Serving Guide
vLLM supports loading multiple LoRA adapters without restarting the server:
Enable Dynamic Loading:
export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True
python serve.py
Load Adapter at Runtime:
curl -X POST http://localhost:8000/v1/load_lora_adapter \
-H "Content-Type: application/json" \
-d '{
"lora_name": "my-adapter",
"lora_path": "username/adapter-repo"
}'
Use the Adapter:
response = client.chat.completions.create(
model="my-adapter", # Specify adapter name
messages=[{"role": "user", "content": "Hello!"}]
)
This enables:
OpenThoughts is a community-driven initiative for creating high-quality datasets and benchmarks for agentic AI systems. This repository includes OpenThoughts-TB-Dev, a 70-task benchmark designed to evaluate model performance on terminal-based agentic tasks.
What is OpenThoughts?
Dataset Used:
Running the Benchmark:
cd benchmarks/openthoughts
./benchmark_openthoughts.sh
The script:
./benchmark_results/Evaluation Framework: Uses Harbor for standardized task execution:
Expected Metrics:
Detailed Documentation: Benchmark Guide
Terminal Bench 2.0 is a comprehensive benchmark suite for evaluating AI agents' capabilities in terminal-based and shell command environments.
What is Terminal Bench 2.0?
Key Features:
Running the Benchmark:
cd benchmarks/terminal_bench
./benchmark_terminalbench.sh
With LoRA Adapter:
./run_benchmark_lora.sh
Benchmark Configuration:
# benchmarks/terminal_bench/config.yaml
model_information:
model_config:
model_id: "mistralai/Devstral-Small-2-24B-Instruct-2512"
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts"
Performance Improvements: Models fine-tuned on OpenThoughts-SFT show significant gains:
Leaderboard: Terminal Bench 2.0 Results
TRL (Transformer Reinforcement Learning) is HuggingFace's library for training language models with reinforcement learning, including supervised fine-tuning.
Features:
Training Setup:
cd SFT-recipes/trl
# Configure training parameters
vim train.yaml
# Single-GPU training
python train_sft.py
# Multi-GPU training (recommended)
./train_multi_gpu.sh
Training Configuration:
# SFT-recipes/trl/train.yaml
model:
name: "mistralai/Devstral-Small-2-24B-Instruct-2512"
quantization: "4bit" # For memory efficiency
dataset:
name: "open-thoughts/OpenThoughts-Agent-v1-SFT"
split: "train"
training:
output_dir: "./outputs/devstral-sft"
num_train_epochs: 7
learning_rate: 4e-5
per_device_train_batch_size: 1
gradient_accumulation_steps: 16
lora:
r: 16 # LoRA rank
lora_alpha: 32
target_modules: ["q_proj", "k_proj", "v_proj", "o_proj"]
Multi-GPU Training:
# Automatic detection of available GPUs
./train_multi_gpu.sh
Detailed Documentation: SFT Guide - TRL Section
Unsloth provides optimized training for LLMs with 2x faster training and 80% less memory usage.
Features:
Training Setup:
cd SFT-recipes/unsloth
# Configure and train
vim train.yaml
./train_multi_gpu.sh
When to Use Unsloth:
The OpenThoughts-Agent-v1-SFT dataset contains 15,209 high-quality training traces for agentic behavior.
Dataset Characteristics:
Training Process:
Expected Training Time:
Post-Training: After fine-tuning on OpenThoughts-SFT, models show:
LoRA (Low-Rank Adaptation) enables efficient fine-tuning by training only a small set of parameters:
Advantages:
Training Configuration:
lora:
r: 16 # Rank (controls adapter size)
lora_alpha: 32 # Scaling factor
lora_dropout: 0.05
target_modules: # Which layers to adapt
- q_proj
- k_proj
- v_proj
- o_proj
bias: "none"
Training Command:
cd SFT-recipes/trl
./train_multi_gpu.sh
Output:
./outputs/devstral-sft/adapter_model.safetensors, adapter_config.jsonAfter training, you can merge the LoRA adapter with the base model or push it separately.
Option 1: Push LoRA Adapter Only (Recommended)
cd SFT-recipes/trl
python push_to_hf.py \
--hf-repo-id "your-username/model-name-LoRA" \
--mode adapter \
--adapter-path "./outputs/devstral-sft" \
--hf-token "your_hf_token"
Benefits:
Option 2: Merge Then Push Full Model
# Merge LoRA with base model
python merge_lora.py \
--base-model "mistralai/Devstral-Small-2-24B-Instruct-2512" \
--adapter-path "./outputs/devstral-sft" \
--output-path "./outputs/merged-devstral"
# Push merged model
python push_to_hf.py \
--hf-repo-id "your-username/model-name-merged" \
--mode existing \
--model-path "./outputs/merged-devstral" \
--hf-token "your_hf_token"
Benefits:
Example: Our Devstral adapter is available at: Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts
Once LoRA adapters are pushed to HuggingFace, they can be loaded dynamically during serving:
Configure vLLM:
# serve/vLLM/config.yaml
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts"
max_loras: 2
max_lora_rank: 16
Start Server:
cd serve/vLLM
python serve.py
Use in Benchmarking:
cd ../../benchmarks/terminal_bench
# Benchmarks automatically use the configured LoRA adapter
./run_benchmark_lora.sh
Runtime Loading (Without Restart):
# Enable dynamic updates
export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True
# Load new adapter
curl -X POST http://localhost:8000/v1/load_lora_adapter \
-d '{"lora_name": "experiment-1", "lora_path": "user/adapter-repo"}'
# Run benchmark with new adapter
# (update model name in benchmark config to "experiment-1")
This workflow enables:
This section demonstrates the complete workflow using Devstral-Small-2-24B-Instruct-2512 as an example.
First, benchmark the base model on Terminal Bench 2.0:
# Start vLLM server with base model
cd serve/vLLM
# Set model_id in config.yaml to "mistralai/Devstral-Small-2-24B-Instruct-2512"
# Set enable_lora to false
python serve.py
# In another terminal, run benchmark
cd ../../benchmarks/terminal_bench
./benchmark_terminalbench.sh
Expected Result: ~0.7% success rate (baseline)
Train a LoRA adapter on the OpenThoughts-Agent-v1-SFT dataset:
cd ../../SFT-recipes/trl
# Configure training
cat > train.yaml <<EOF
model:
name: "mistralai/Devstral-Small-2-24B-Instruct-2512"
dataset:
name: "open-thoughts/OpenThoughts-Agent-v1-SFT"
training:
output_dir: "./outputs/devstral-sft"
num_train_epochs: 7
lora:
r: 16
lora_alpha: 32
EOF
# Train (8x GPUs recommended)
./train_multi_gpu.sh
Training Time: ~3 hours on 8x A100 GPUs
python push_to_hf.py \
--hf-repo-id "your-username/Devstral-SFT-LoRA-OpenThoughts" \
--mode adapter \
--adapter-path "./outputs/devstral-sft" \
--hf-token "your_hf_token"
Update vLLM configuration to use the adapter:
# serve/vLLM/config.yaml
model_information:
model_config:
model_id: "mistralai/Devstral-Small-2-24B-Instruct-2512"
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "your-username/Devstral-SFT-LoRA-OpenThoughts"
Restart server and benchmark:
cd serve/vLLM
python serve.py
# In another terminal
cd ../../benchmarks/terminal_bench
./run_benchmark_lora.sh
Expected Result: ~15.7% success rate (22x improvement!)
# View detailed results
cd benchmarks/terminal_bench/benchmark_results
cat latest_results.json | jq '.metrics'
# Identify failure patterns
# Adjust training data or hyperparameters
# Repeat from Step 2
| Model | Terminal Bench 2.0 | Improvement |
|---|---|---|
| Devstral-24B (Base) | 0.7% | Baseline |
| Devstral-24B + OpenThoughts-SFT | 15.7% | 22x |
OpenThoughts:
Terminal Bench 2.0:
harbor run -d "terminal-bench@2.0"Harbor Framework:
pip install harbor-aiharbor --helpvLLM:
Training Frameworks:
Minimum:
Recommended:
Model-Specific Requirements:
| Model Size | VRAM (Inference) | VRAM (Training) | GPUs |
|---|---|---|---|
| 7-8B | 16GB | 24GB | 1-2 |
| 20-24B | 48GB | 80GB | 2-4 |
| 30-34B | 80GB | 160GB | 4-8 |
# Core dependencies
pip install vllm torch transformers accelerate
pip install trl peft bitsandbytes
pip install harbor-ai datasets
# Optional: Unsloth for optimized training
pip install unsloth
# Optional: Development tools
pip install jupyter ipython black ruff
This repository is released under the MIT License. See LICENSE for details.
Model and Dataset Licenses:
Citation: If you use this repository or OpenThoughts datasets in your research, please cite:
@misc{openthoughts-agent,
author = {Team, OpenThoughts-Agent},
title = {{OpenThoughts-Agent}},
month = {Dec},
year = {2025},
howpublished = {\url{https://open-thoughts.ai/agent}}
}
Contributions are welcome! Please:
For major changes, please open an issue first to discuss proposed modifications.
This project builds on excellent work from:
Special thanks to the open-source AI community for advancing accessible AI research and development
3 commits
Python
77.6%
Shell
22.4%
A comprehensive framework for fine-tuning Small Language Models (SLMs) on agentic tasks and benchmarking them using state-of-the-art evaluation suites. This repository demonstrates the complete workflow from supervised fine-tuning (SFT) with LoRA adapters to deployment with vLLM and evaluation on OpenThoughts and Terminal Bench 2.0.
This project provides an end-to-end pipeline for:

# Install core dependencies
pip install vllm harbor-ai torch transformers
# Clone the repository
git clone https://github.com/your-org/benchmark-agentic-SLMs.git
cd benchmark-agentic-SLMs
1. Serve a Model
cd serve/vLLM
# Configure your model in config.yaml
python serve.py
# Server starts at http://localhost:8000
2. Run Benchmarks
cd ../../benchmarks/terminal_bench
./run_benchmark_lora.sh
3. Fine-Tune & Improve
cd ../../SFT-recipes/trl
# Configure training in train.yaml
./train_multi_gpu.sh
This repository uses vLLM for high-performance model serving with OpenAI-compatible APIs. vLLM provides:
Getting Started:
cd serve/vLLM
python serve.py
The server provides:
/v1/chat/completions/v1/completions/v1/modelshttp://localhost:8000/docsExample Request:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy"
)
response = client.chat.completions.create(
model="mistralai/Devstral-Small-2-24B-Instruct-2512",
messages=[
{"role": "user", "content": "Write a bash script to process logs"}
],
max_tokens=512
)
Supported Models:
Configuration:
Configure models in serve/vLLM/config.yaml
Detailed Documentation: Serving Guide
vLLM supports loading multiple LoRA adapters without restarting the server:
Enable Dynamic Loading:
export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True
python serve.py
Load Adapter at Runtime:
curl -X POST http://localhost:8000/v1/load_lora_adapter \
-H "Content-Type: application/json" \
-d '{
"lora_name": "my-adapter",
"lora_path": "username/adapter-repo"
}'
Use the Adapter:
response = client.chat.completions.create(
model="my-adapter", # Specify adapter name
messages=[{"role": "user", "content": "Hello!"}]
)
This enables:
OpenThoughts is a community-driven initiative for creating high-quality datasets and benchmarks for agentic AI systems. This repository includes OpenThoughts-TB-Dev, a 70-task benchmark designed to evaluate model performance on terminal-based agentic tasks.
What is OpenThoughts?
Dataset Used:
Running the Benchmark:
cd benchmarks/openthoughts
./benchmark_openthoughts.sh
The script:
./benchmark_results/Evaluation Framework: Uses Harbor for standardized task execution:
Expected Metrics:
Detailed Documentation: Benchmark Guide
Terminal Bench 2.0 is a comprehensive benchmark suite for evaluating AI agents' capabilities in terminal-based and shell command environments.
What is Terminal Bench 2.0?
Key Features:
Running the Benchmark:
cd benchmarks/terminal_bench
./benchmark_terminalbench.sh
With LoRA Adapter:
./run_benchmark_lora.sh
Benchmark Configuration:
# benchmarks/terminal_bench/config.yaml
model_information:
model_config:
model_id: "mistralai/Devstral-Small-2-24B-Instruct-2512"
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts"
Performance Improvements: Models fine-tuned on OpenThoughts-SFT show significant gains:
Leaderboard: Terminal Bench 2.0 Results
TRL (Transformer Reinforcement Learning) is HuggingFace's library for training language models with reinforcement learning, including supervised fine-tuning.
Features:
Training Setup:
cd SFT-recipes/trl
# Configure training parameters
vim train.yaml
# Single-GPU training
python train_sft.py
# Multi-GPU training (recommended)
./train_multi_gpu.sh
Training Configuration:
# SFT-recipes/trl/train.yaml
model:
name: "mistralai/Devstral-Small-2-24B-Instruct-2512"
quantization: "4bit" # For memory efficiency
dataset:
name: "open-thoughts/OpenThoughts-Agent-v1-SFT"
split: "train"
training:
output_dir: "./outputs/devstral-sft"
num_train_epochs: 7
learning_rate: 4e-5
per_device_train_batch_size: 1
gradient_accumulation_steps: 16
lora:
r: 16 # LoRA rank
lora_alpha: 32
target_modules: ["q_proj", "k_proj", "v_proj", "o_proj"]
Multi-GPU Training:
# Automatic detection of available GPUs
./train_multi_gpu.sh
Detailed Documentation: SFT Guide - TRL Section
Unsloth provides optimized training for LLMs with 2x faster training and 80% less memory usage.
Features:
Training Setup:
cd SFT-recipes/unsloth
# Configure and train
vim train.yaml
./train_multi_gpu.sh
When to Use Unsloth:
The OpenThoughts-Agent-v1-SFT dataset contains 15,209 high-quality training traces for agentic behavior.
Dataset Characteristics:
Training Process:
Expected Training Time:
Post-Training: After fine-tuning on OpenThoughts-SFT, models show:
LoRA (Low-Rank Adaptation) enables efficient fine-tuning by training only a small set of parameters:
Advantages:
Training Configuration:
lora:
r: 16 # Rank (controls adapter size)
lora_alpha: 32 # Scaling factor
lora_dropout: 0.05
target_modules: # Which layers to adapt
- q_proj
- k_proj
- v_proj
- o_proj
bias: "none"
Training Command:
cd SFT-recipes/trl
./train_multi_gpu.sh
Output:
./outputs/devstral-sft/adapter_model.safetensors, adapter_config.jsonAfter training, you can merge the LoRA adapter with the base model or push it separately.
Option 1: Push LoRA Adapter Only (Recommended)
cd SFT-recipes/trl
python push_to_hf.py \
--hf-repo-id "your-username/model-name-LoRA" \
--mode adapter \
--adapter-path "./outputs/devstral-sft" \
--hf-token "your_hf_token"
Benefits:
Option 2: Merge Then Push Full Model
# Merge LoRA with base model
python merge_lora.py \
--base-model "mistralai/Devstral-Small-2-24B-Instruct-2512" \
--adapter-path "./outputs/devstral-sft" \
--output-path "./outputs/merged-devstral"
# Push merged model
python push_to_hf.py \
--hf-repo-id "your-username/model-name-merged" \
--mode existing \
--model-path "./outputs/merged-devstral" \
--hf-token "your_hf_token"
Benefits:
Example: Our Devstral adapter is available at: Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts
Once LoRA adapters are pushed to HuggingFace, they can be loaded dynamically during serving:
Configure vLLM:
# serve/vLLM/config.yaml
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "Madhurprash/Devstral-Small-2-24B-Instruct-2512-SFT-LoRA-OpenThoughts"
max_loras: 2
max_lora_rank: 16
Start Server:
cd serve/vLLM
python serve.py
Use in Benchmarking:
cd ../../benchmarks/terminal_bench
# Benchmarks automatically use the configured LoRA adapter
./run_benchmark_lora.sh
Runtime Loading (Without Restart):
# Enable dynamic updates
export VLLM_ALLOW_RUNTIME_LORA_UPDATING=True
# Load new adapter
curl -X POST http://localhost:8000/v1/load_lora_adapter \
-d '{"lora_name": "experiment-1", "lora_path": "user/adapter-repo"}'
# Run benchmark with new adapter
# (update model name in benchmark config to "experiment-1")
This workflow enables:
This section demonstrates the complete workflow using Devstral-Small-2-24B-Instruct-2512 as an example.
First, benchmark the base model on Terminal Bench 2.0:
# Start vLLM server with base model
cd serve/vLLM
# Set model_id in config.yaml to "mistralai/Devstral-Small-2-24B-Instruct-2512"
# Set enable_lora to false
python serve.py
# In another terminal, run benchmark
cd ../../benchmarks/terminal_bench
./benchmark_terminalbench.sh
Expected Result: ~0.7% success rate (baseline)
Train a LoRA adapter on the OpenThoughts-Agent-v1-SFT dataset:
cd ../../SFT-recipes/trl
# Configure training
cat > train.yaml <<EOF
model:
name: "mistralai/Devstral-Small-2-24B-Instruct-2512"
dataset:
name: "open-thoughts/OpenThoughts-Agent-v1-SFT"
training:
output_dir: "./outputs/devstral-sft"
num_train_epochs: 7
lora:
r: 16
lora_alpha: 32
EOF
# Train (8x GPUs recommended)
./train_multi_gpu.sh
Training Time: ~3 hours on 8x A100 GPUs
python push_to_hf.py \
--hf-repo-id "your-username/Devstral-SFT-LoRA-OpenThoughts" \
--mode adapter \
--adapter-path "./outputs/devstral-sft" \
--hf-token "your_hf_token"
Update vLLM configuration to use the adapter:
# serve/vLLM/config.yaml
model_information:
model_config:
model_id: "mistralai/Devstral-Small-2-24B-Instruct-2512"
vllm_engine_config:
enable_lora: true
lora_modules:
devstral-sft: "your-username/Devstral-SFT-LoRA-OpenThoughts"
Restart server and benchmark:
cd serve/vLLM
python serve.py
# In another terminal
cd ../../benchmarks/terminal_bench
./run_benchmark_lora.sh
Expected Result: ~15.7% success rate (22x improvement!)
# View detailed results
cd benchmarks/terminal_bench/benchmark_results
cat latest_results.json | jq '.metrics'
# Identify failure patterns
# Adjust training data or hyperparameters
# Repeat from Step 2
| Model | Terminal Bench 2.0 | Improvement |
|---|---|---|
| Devstral-24B (Base) | 0.7% | Baseline |
| Devstral-24B + OpenThoughts-SFT | 15.7% | 22x |
OpenThoughts:
Terminal Bench 2.0:
harbor run -d "terminal-bench@2.0"Harbor Framework:
pip install harbor-aiharbor --helpvLLM:
Training Frameworks:
Minimum:
Recommended:
Model-Specific Requirements:
| Model Size | VRAM (Inference) | VRAM (Training) | GPUs |
|---|---|---|---|
| 7-8B | 16GB | 24GB | 1-2 |
| 20-24B | 48GB | 80GB | 2-4 |
| 30-34B | 80GB | 160GB | 4-8 |
# Core dependencies
pip install vllm torch transformers accelerate
pip install trl peft bitsandbytes
pip install harbor-ai datasets
# Optional: Unsloth for optimized training
pip install unsloth
# Optional: Development tools
pip install jupyter ipython black ruff
This repository is released under the MIT License. See LICENSE for details.
Model and Dataset Licenses:
Citation: If you use this repository or OpenThoughts datasets in your research, please cite:
@misc{openthoughts-agent,
author = {Team, OpenThoughts-Agent},
title = {{OpenThoughts-Agent}},
month = {Dec},
year = {2025},
howpublished = {\url{https://open-thoughts.ai/agent}}
}
Contributions are welcome! Please:
For major changes, please open an issue first to discuss proposed modifications.
This project builds on excellent work from:
Special thanks to the open-source AI community for advancing accessible AI research and development
3 commits
Python
77.6%
Shell
22.4%