A framework for optimizing DSPy programs with RL.
Install Arbor via uv (recommended) or pip:
uv pip install -U arbor-ai
# or: pip install -U arbor-ai
Optionally, you c
8000
an also install flash attention to speed up inference.
This can take 15+ minutes to install on some setups:
uv pip install flash-attn --no-build-isolation
# or: pip install flash-attn --no-build-isolation
import arbor
import dspy
import random
# Start Arbor server (auto-detects GPUs, starts in background)
arbor.init()
# Sample classification data
data = [
dspy.Example(text="I want to transfer money", label="transfer").with_inputs("text"),
dspy.Example(text="What is my balance?", label="balance").with_inputs("text"),
dspy.Example(text="I lost my credit card", label="card_issues").with_inputs("text"),
# ... more examples
]
# Split into train/validation
random.Random(42).shuffle(data)
trainset, valset = data[:6], data[6:]
# Define classification task
CLASSES = ["transfer", "balance", "card_issues", "pin_change"]
classify = dspy.ChainOfThought(f"text -> label: Literal{CLASSES}")
# Set up DSPy with Arbor backend
from arbor import ArborProvider
provider = ArborProvider()
student_lm = dspy.LM(
model="openai/arbor:Qwen/Qwen2-0.5B-Instruct",
provider=provider,
api_base="http://127.0.0.1:7453/v1/",
api_key="arbor"
)
student_classify = classify.deepcopy()
student_classify.set_lm(student_lm)
# Optimize with Arbor's GRPO trainer (requires 2+ GPUs)
from arbor import ArborGRPO
compiler = ArborGRPO(
metric=lambda x, y: x.label == y.label,
)
# Run optimization
optimized_classify = compiler.compile(
student=student_classify,
trainset=trainset,
valset=valset
)
# Your classifier is now optimized with RL! π
For remote servers or custom configurations, use the CLI approach:
1. Create config at ~/.arbor/config.yaml
:
storage_path: ~/.arbor/storage
The server will automatically detect available GPUs at startup.
2. Start server:
uv run arbor serve
3. Connect from remote:
from openai import OpenAI
client = OpenAI(base_url="http://your-server:7453/v1", api_key="not-needed")
Docker deployment:
docker run --gpus all -p 7453:7453 -v ~/.arbor:/root/.arbor arbor-ai
For advanced distributed training setups, you can specify a custom Hugging Face Accelerate config in your ~/.arbor/config.yaml
:
accelerate_config: "/path/to/your/accelerate_config.yaml"
NCCL Errors Certain GPU setups, particularly with newer GPUs, seem to have issues with NCCL that cause Arbor to crash. Often times of these can be fixed with the following environment variables:
export NCCL_P2P_DISABLE=1
export NCCL_IB_DISABLE=1
NVCC If you run into issues, double check that you have nvcc installed:
nvcc --version
If you don't have admin permissions, you can often install nvcc using conda.
- Join our Discord for help, updates, and discussion: DSPy Discord
- Arbor-specific channel in the DSPy Discord: Arbor Channel
To avoid merge surprises, make sure the dev
branch is rebased on the
latest main
history before integrating feature work. A quick sanity
check is to fetch the remote main
ref and merge it locally:
git fetch origin main
git checkout dev
git merge origin/main
Only proceed with your feature merges once the commands above succeed.
Arbor builds on the shoulders of great work. We extend our thanks to:
If you use this code in your research, please cite:
@article{ziems2025multi,
title={Multi-module GRPO: Composing policy gradients and prompt optimization for language model programs},
author={Ziems, Noah and Soylu, Dilara and Agrawal, Lakshya A and Miller, Isaac and Lai, Liheng and Qian, Chen and Song, Kaiqiang and Jiang, Meng and Klein, Dan and Zaharia, Matei and others},
journal={arXiv preprint arXiv:2508.04660},
year={2025}
}
@article{agrawal2025gepa,
title={GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning},
author={Agrawal, Lakshya A and Tan, Shangyin and Soylu, Dilara and Ziems, Noah and Khare, Rishi and Opsahl-Ong, Krista and Singhvi, Arnav and Shandilya, Herumb and Ryan, Michael J and Jiang, Meng and others},
journal={arXiv preprint arXiv:2507.19457},
year={2025}
}