翻篇收录说明
翻篇网页快照

Open Source RL Libraries for LLMs | Anyscale

https://www.anyscale.com/blog/open-source-rl-libraries-for-llms

最近抓取:2026-12-05 02:45:57(北京时间)

最近内容变化:2026-12-05 02:45:57(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Explore a technical comparison of leading Reinforcement Learning (RL) libraries for LLMs from Ray. This guide analyzes frameworks like TRL, Verl, and RAGEN to help developers choose the best tools for RLHF, reasoning, and agentic AI.

正文摘录

HomeBlogBlog DetailOpen Source RL Libraries for LLMsBy Tyler Griggs and Philipp Moritz | July 1, 2025The content of this blog post was updated on September 1, 2025 with the latest information for each library and to include the new slime library.Reinforcement learning (RL) has become integral to modern large language model development. Beyond the traditional post-training use of Reinforcement Learning from Human Feedback (RLHF) to align models with human preferences, RL on verifiable rewards has emerged as a powerful technique for extending LLM capabilities. This approach has gained particular importance as high-quality pre-training data becomes increasingly scarce.Recent breakthroughs demonstrate the effectiveness of this paradigm, including OpenAI's reasoning models (o1 and o3) and the openly available DeepSeek R1 models. The latest frontier extends LLM reinforcement learning to multi-turn settings, where models function as agents interacting with environments to solve complex tasks. This represents a significant step toward creating LLMs that can serve as effective agents across diverse domains.Given the potential of reinforcement learning, the open-source ecosystem has experienced rapid growth, with numerous libraries emerging that embody different design principles and optimization choices. This analysis examines the leading RL frameworks from a technical perspective, evaluating their respective advantages and limitations. We conducted this research while developing a reinforcement learning library, systematically analyzing existing solutions to understand the design decisions and architectural trade-offs inherent in each approach. By sharing these insights, we aim to help researchers and practitioners navigate the current landscape more effectively and make informed choices about which tools best suit their specific requirements and use cases.We acknowledge that some of the comparison points can be subjective – we made our best effort to compare the libraries on objective criteria as much as possible, and provide links to the relevant code in the libraries so you can get your own impressions. If you feel something is misrepresented, please let us know. Also, keep in mind that these libraries are evolving at a very fast pace, so always consult the documentation and code of the different libraries for the latest updates.LinkThe Libraries We ComparedWe chose these specific libraries based on their recent activity, relevance to diverse use cases (from RLHF to agentic RL), and their representation of different architectural philosophies in the open-source landscape.TRL: A popular library from Hugging Face, tightly integrated with the Hugging Face ecosystem, focusing on the training aspect of RL.Verl: A popular high-performance, feature-rich RL stack from ByteDance optimized for scalability and support for advanced training techniques.OpenRLHF: One of the earliest popular open-source RLHF libraries, it is both easy to use and high-performance. Similar to Verl, paving the way for many subsequent frameworksRAGEN: A notable extension of Verl that extends its capabilities with a focus on multi-turn conversations and diverse RL environments.Nemo-RL: NVIDIA's comprehensive post-training framework, designed with clean interfaces and a focus on structured data flow, but also with scalability and high performance in mind.ROLL: New library from Alibaba for RLHF, reasoning, and multi-turn agentic training – designed to be flexible for researchers and scalable for large-scale production use.AReaL: RL library from Ant Research with a focus on asynchronous training to improve training throughput and scalability.slime: RL library from Tsinghua and Z.ai that focuses on simplicity and high performance, and makes it easy to integrate arbitrary custom data generation methods.Verifiers: Built on TRL, this framework simplifies the implementation of multi-turn RL with verifiable rewards, prioritizing ease of use.SkyRL: New RL library from Berkeley with a focus on multi-turn agentic training, using a simple and flexible design that allows both high-performance execution and adaptation to a wide variety of scenarios.LinkUse Cases and Components of an RL LibraryReinforcement learning libraries aim to simplify the process of training RL policies that can solve complex problems. Users define their specific problems along with reward functions that measure solution quality, while the library handles the underlying training mechanics to develop effective policies. Common problems to train a policy on include:Coding, where the reward is whether the code is correct (e.g., measured by whether it passes a suite of unit tests),Computer use (i.e., solving tasks with a computer), where the reward is whether the task is solved successfully,Formulating mathematical proofs, where the reward is +1 if the proof is a valid proof for a given proposition and 0 otherwise, andPlaying games, where the reward is the final score achieved in the game, or whether the policy could beat the game.As mentioned in the introduction, there are a number of different use cases for RL libraries for LLMs:Reinforcement Learning from Human Feedback (RLHF): This was the original RL post-training use case and aligns the LLM with human preferences. As part of that, a preference dataset is collected from humans, from which a reward model is learned, which is then used to run RL to adapt the LLM.Reasoning models: This use case uses tasks like solving mathematical or scientific problems or coding to improve the reasoning capabilities of LLMs. Instead of outputting the answer immediately, the LLM learns to output “thinking” tokens first, which can boost the performance of the models. The thinking process is often learned by running RL with verifiable rewards on the problem. Since the LLM gives a single answer at the end of the reasoning process, this is often referred to as “single-step” RL.Agentic and multi-step RL: In this setting, the LLM operates as an autonomous agent within an environment, executing multiple sequential actions to accomplish a task. This represents the most sophisticated configuration and places the highest demands on the supporting library. The library must coordinate both the environment and the LLM, while handling problems that may require very different numbers of steps across various instances.The core of an RL library can be broken down into two fundamental components:The generator that sets the LLM up to interact with an environment to solve problems and compute the rewards.The trainer that updates the model based on reward feedback given during the generation phase.The way a framework is designed and integrates these components reveals its core philosophy and use cases. Some libraries are more focused on RLHF, some are optimized for training reasoning models, and others have more powerful abstractions for generation and environments, which makes them better suited for multi-turn RL and training agents.The architecture of a Reinforcement Learning (RL) library is split into two primary components: Generation and Training. During the generation phase, an LLM Engine performs multi-turn rollouts within an environment to produce data and reward signals. This output is then fed into the training phase to update the model's parameters. This process forms a feedback loop, where the progressively improved model generates the next iteration of data for continuous refinement.Open Source RL Libraries for LLMs GraphWe will first dive a little deeper into the design tradeoffs that can be made in these components.LinkThe GeneratorThe generation phase is often the most expensive part of the computation. It involves running inference on the LLM as well as executing the actions in the environment and computing the rewards. Often, there is a dataset of problems, which might contain initial prompts with the problem statement and/or parameters of the environment that the agent should operate in. In the case of verifiable rewards, there is also a notion of the correct answer to the problem. For each problem, the current policy generates a trajectory, which contains the sequence of tokens produced by the LLM that contain the actions taken in the environment. Different libraries represent these trajectories in different ways, but the OpenAI format is a common choice.The generation can be arbitrarily complex and use techniques such as branching when exploring a larger solution space in a tree-like manner. Libraries that make it easy to define a custom generate function for generating the rollouts enable the maximum amount of flexibility for custom sampling, branching, and searching.The environment is an important part of the Generator. In earlier RL libraries used for RLHF or for training reasoning models, there was often no explicit environment. Instead, each output of the LLM was scored either with a reward model or an explicit reward in the form of a custom reward function. Later, more explicit APIs were added, often similar to OpenAI’s gym interface with init, step, and reset functions. This allows tool use during the trajectory generation, as well as multi-step interactions between the LLM and the environment. In many cases, the actual execution of the environment happens in a separate container/process or on a remote server, so the environment can be isolated.LinkThe TrainerThe trainer is where the core optimization loop resides, which takes the trajectory data collected in the generation phase and produces the new policy. Most libraries have standardized around supporting both the PPO and GRPO training algorithms. In terms of the sharding backend for splitting up the model among different GPUs, there are several different choices, with Hugging Face trainer, FSDP, DeepSpeed, and Megatron being the most popular. FSDP is among the simpler choices with tight PyTorch integration, DeepSpeed has more aggressive parameter and optimizer offloading, and Megatron is the most per