rLLM
repository·main·Indexed 26 days ago
https://github.com/rllm-org/rllmAn open-source framework for training language agents using reinforcement learning. rLLM allows developers to wrap agent harnesses or sandboxes and switch between multiple training backends, including verl, tinker, and fireworks. The framework includes cookbooks for specific agents such as Deepcoder, FinQA, and FrozenLake, and provides CLI tools for dataset management, agent evaluation, and training.
What's inside rLLM
- Experiential Reinforcement Learning is a training paradigm where agents learn through an experience-reflection-consolidation loop. This method is built on top of the rLLM training infrastructure and is described in the paper arXiv:2602.13949.
Overview of SETA (Scaling Environment for Terminal Agents)
mainSETA, developed by CAMEL-AI, provides scalable environment infrastructure specifically designed for training terminal agents using rLLM. It is used to create diverse and reproducible terminal environments necessary for Reinforcement Learning (RL) training at scale.Overview of V1: Parallel Self-Verification
mainV1 is a framework designed to improve model performance during inference by unifying generation and pairwise self-verification. Instead of scoring individual solution candidates in isolation, V1 uses a pairwise approach where the model compares two candidates head-to-head. This is combined with a tournament-based ranking algorithm to optimize the allocation of verification compute. The framework is designed to jointly develop generation and verification capabilities, which has shown improvements of up to 10% on math reasoning and code generation benchmarks.Overview of LLM-in-Sandbox
mainLLM-in-Sandbox is a research project focused on building general-purpose agents by running Large Language Models (LLMs) inside sandboxed virtual computer environments. It leveragesrLLMto perform Reinforcement Learning (RL) training for agents that interact with full desktop and terminal interfaces.Use Terminal-Bench-RL for long-horizon terminal agent training
mainTerminal-Bench-RL is a benchmark and training framework designed for long-horizon task completion within terminal environments. It provides a suite of tasks specifically for evaluating and training terminal agents using the rLLM reinforcement learning (RL) pipeline.FinQA Agent Flow Pattern
mainThe FinQA agent follows a multi-turn ReAct-style loop (up to 20 turns). It uses native OpenAI function calling to dispatch tools.
Termination: The loop breaks when the model emits a
FINAL ANSWER:block without tool calls, or when the maximum number of turns is reached.Artifacts: The resulting
Episodecontains:answer: The full text response.accessed_tables: A list of tables accessed during the run (used for table-access bonuses).turns: The number of steps taken.
Geo3K Agent Architecture and Pattern
mainThe Geo3K agent is a single-turn vision-language agent (VLM) that solves geometry problems using the AgentFlow protocol.
Pattern Details
- Loop shape: Single-turn (one VLM call per task).
- Tools: None; the answer is parsed directly from the model response.
- Inputs: Multimodal (text question + base64-encoded diagram image).
- Termination: The single LLM call returns, and the evaluator extracts the answer using
\boxed{...}. - Reward shape:
1.0if the boxed answer matches the ground truth (symbolic math), otherwise0.0.
Multimodal Content-Block Pattern
When implementing similar agents in AgentFlow, the
messageslist should use the multimodal content-block pattern, including animage_urlblock with a base64-encoded string:# Example pattern for multimodal messages messages = [ {"type": "system", "content": "system_prompt"}, { "role": "user", "content": [ {"type": "text", "text": "question_text"}, { "type": "image_url", "image_url": {"url": f"data:image/png;base64,{base64_string}"} } ] } ]Compare rLLM training backends: verl vs tinker
mainrLLM provides two training backends depending on your scale and complexity requirements:
- verl: A distributed, production-ready backend designed for large-scale training. It uses a Ray-based architecture, supports multi-node/multi-GPU clusters, and is suitable for Vision-Language Models (VLM) and advanced distributed training (FSDP, tensor parallel).
- tinker: An async-first, service-based backend designed for rapid development and prototyping. It is best suited for single-node training, LoRA fine-tuning, and has a gentler learning curve with simpler configuration.
Understand the rLLM data model: Step, Trajectory, and Episode
mainThe solver-judge workflow relies on three nested data structures:
Step: The atomic unit representing a single LLM interaction. It captures input messages, generated output, token IDs, log-probabilities, and a parsedaction.Trajectory: An ordered list ofSteps from a single role (e.g.,"solver"or"judge"). Thenameattribute is used by the trainer to group trajectories for advantage computation.Episode: The top-level container returned by anAgentFlow. It bundles all trajectories from a single rollout execution along with metadata likeis_correctandartifacts.
Understand the rLLM Trainer Capability Matrix
mainrLLM uses a
UnifiedTrainerthat supports different backends, launch methods, execution flows, and dataset types. Capabilities are not uniform across these dimensions.Key Dimensions:
- Backend:
tinker(single-machine, LoRA-only, async-native) vsverl(Ray-distributed, multi-GPU/node, FSDP/Megatron). - Launch Method:
rllm trainCLI (a strict subset of features, hardcoded totinkerbackend) vs Python script/Hydra (full surface, supportsverland all config keys). - Execution Flow:
regular,sandboxed, orremote runtime(decides if gateway, hooks, and sandbox warm pool engage). - Dataset Type:
rLLM-native rowsvsharbor task dirs(decides how rows becomeTasks).
Critical Rule: The CLI is a subset of the Python API. If a feature is not available via
rllm trainflags, you must use a Python script withAgentTrainerto access it.- Backend:
Understand rLLM Cookbooks
mainA cookbook is a self-contained Python package that bundles an
AgentFlowand anEvaluatortogether. It includes data preparation scripts (prepare_data.py) and training scripts (train_tinker.shfor single-machine LoRA ortrain_verl.shfor distributed multi-GPU training). Cookbooks are discovered by the rLLM CLI via Python entry points, allowing you to run evaluations and training using simple CLI commands.Each cookbook's
AgentFlowis an async function that calls an OpenAI-compatible endpoint and returns anEpisodeobject.Understand the rLLM execution pipeline
mainThe rLLM training workflow follows a four-step pipeline:
- Run Agent: The agent runs as-is; rLLM's SDK intercepts LLM calls.
- Collect Traces: LLM calls are structured into Episodes (one task), Trajectories (one agent run), and Steps (one LLM call).
- Compute Rewards: A reward function scores the results.
- Update Model: An RL algorithm (such as GRPO, REINFORCE, or RLOO) updates the model weights.
Internal components involved:
- Workflow Engine: Runs parallel agent instances for rollouts.
- LiteLLM Proxy: Routes requests and captures token IDs and logprobs.
- Transform Pipeline: Groups trajectories for advantage computation.
- Training Backend: (
verlortinker) executes the policy update.