You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trinity-RFT is a general-purpose, flexible and scalable framework designed for reinforcement fine-tuning (RFT) of large language models (LLM).
12
-
Built with a decoupled architecture, seamless integration for agentic workflows, and systematic data processing pipelines, Trinity-RFT can be easily adapted for diverse application scenarios, and serve as a platform for exploring advanced reinforcement learning (RL) paradigms.
13
12
14
13
14
+
**Trinity-RFT is a general-purpose, flexible and scalable framework designed for reinforcement fine-tuning (RFT) of large language models (LLM).**
15
15
16
16
17
+
Built with a decoupled design, seamless integration for agentic workflows, and systematic data processing pipelines, Trinity-RFT can be easily adapted for diverse application scenarios, and serve as a platform for exploring advanced reinforcement learning (RL) paradigms.
17
18
18
-
**Vision of this project:**
19
19
20
20
21
-
Current RFT approaches, such as RLHF (Reinforcement Learning from Human Feedback) with proxy reward models or training long-CoT reasoning LLMs with rule-based rewards, are limited in their ability to handle dynamic, real-world learning.
22
-
Trinity-RFT envisions a future where AI agents learn by interacting directly with environments, collecting delayed or complex reward signals, and continuously refining their behavior through advanced RL paradigms.
23
-
For example, imagine an AI scientist that designs an experiment, executes it via interacting with the environment, waits for feedback (while working on some other tasks concurrently), and iteratively updates itself based on true environmental rewards when the experiment is finally finished.
21
+
22
+
23
+
## Vision of this project
24
+
25
+
26
+
Current RFT approaches, such as RLHF (Reinforcement Learning from Human Feedback) with proxy reward models or training long-CoT reasoning models with rule-based rewards, are limited in their ability to handle dynamic, real-world learning.
27
+
28
+
Trinity-RFT envisions a future where AI agents learn by interacting directly with environments, collecting delayed or complex reward signals, and continuously refining their behavior through RL.
29
+
30
+
31
+
For example, imagine an AI scientist that designs an experiment, executes it, waits for feedback (while working on other tasks concurrently), and iteratively updates itself based on true environmental rewards when the experiment is finally finished.
32
+
33
+
24
34
Trinity-RFT offers a path into this future by addressing critical gaps in existing solutions.
25
35
26
36
27
37
28
38
29
39
30
-
**Key features of Trinity-RFT:**
40
+
## Key features
31
41
32
42
33
43
34
44
+**Unified RFT modes & algorithm support.**
35
-
Trinity-RFT unifies and generalizes existing RFT methodologies into a flexible and configurable framework, supporting synchronous/asynchronous and on-policy/off-policy/offline training, as well as hybrid modes that combine the above seamlessly into a single learning process (e.g., incorporating expert trajectories or high-quality SFT data to accelerate an online RL process).
45
+
Trinity-RFT unifies and generalizes existing RFT methodologies into a flexible and configurable framework, supporting synchronous/asynchronous and on-policy/off-policy/offline training, as well as hybrid modes that combine them seamlessly into a single learning process.
46
+
36
47
37
48
+**Agent-environment interaction as a first-class citizen.**
38
-
Trinity-RFT natively models the challenges of RFT with real-world agent-environment interactions. It allows delayed rewards in multi-step and/or time-lagged feedback loops, handles long-tailed latencies and environment/agent failures gracefully, and supports distributed deployment where explorers (i.e., the rollout agents) and trainers (i.e., the policy model trained by RL) can operate across separate clusters or devices (e.g., explorers on edge devices, trainers in cloud clusters) and scale up independently.
49
+
Trinity-RFT allows delayed rewards in multi-step/time-lagged feedback loops, handles long-tailed latencies and environment/agent failures gracefully, and supports distributed deployment where explorers and trainers can operate across separate devices and scale up independently.
50
+
51
+
39
52
40
53
+**Data processing pipelines optimized for RFT with diverse/messy data.**
41
-
These include converting raw datasets to prompt/task sets for RL, cleaning/filtering/prioritizing experiences stored in the replay buffer, synthesizing data for tasks and experiences, offering user interfaces for RFT with human in the loop, managing the task and experience buffers (e.g., supporting collection of lagged reward signals), among others.
54
+
These include converting raw datasets to prompt/task sets for RL, cleaning/filtering/prioritizing experiences stored in the replay buffer, synthesizing data for tasks and experiences, offering user interfaces for human in the loop, etc.
55
+
<!-- managing the task and experience buffers (e.g., supporting collection of lagged reward signals) -->
42
56
43
57
44
58
@@ -59,40 +73,40 @@ These include converting raw datasets to prompt/task sets for RL, cleaning/filte
59
73
The overall design of Trinity-RFT exhibits a trinity:
60
74
+ RFT-core;
61
75
+ agent-environment interaction;
62
-
+ data processing pipelines tailored to RFT.
76
+
+ data processing pipelines tailored to RFT;
63
77
64
-
65
-
66
-
In particular, the design of RFT-core also exhibits a trinity:
78
+
and the design of RFT-core also exhibits a trinity:
67
79
+ explorer;
68
80
+ trainer;
69
81
+ manager & buffer.
70
82
71
83
72
84
73
-
The explorer, powered by the rollout model, interacts with the environment and generates rollout trajectories to be stored in the experience buffer.
74
-
The trainer, powered by the policy model, samples batches of experiences from the buffer and updates the policy via RL algorithms.
75
-
These two can be completely decoupled and act asynchronously, except that they share the same experience buffer, and their model weights are synchronized once in a while (according to a schedule specified by user configurations).
85
+
The *explorer*, powered by the rollout model, interacts with the environment and generates rollout trajectories to be stored in the experience buffer.
86
+
87
+
The *trainer*, powered by the policy model, samples batches of experiences from the buffer and updates the policy via RL algorithms.
76
88
89
+
These two can be completely decoupled and act asynchronously, except that they share the same experience buffer, and their model weights are synchronized once in a while.
90
+
Such a decoupled design is crucial for making the aforementioned features of Trinity-RFT possible.
77
91
78
-
Such a decoupled design is crucial for making the aforementioned features of Trinity-RFT possible,
79
-
e.g., flexible and configurable RFT modes (on-policy/off-policy, synchronous/asynchronous, immediate/lagged rewards),
fault tolerance for failures of explorer (agent/environment) or trainer,
81
94
high efficiency in the presence of long-tailed rollout latencies,
82
95
data processing pipelines and human in the loop of RFT (e.g., via acting on the experience buffer, which is implemented as a persistent database),
83
-
among others.
96
+
among others.-->
84
97
85
98
86
99
87
100
Meanwhile, Trinity-RFT has done the dirty work for ensuring high efficiency in every component of the framework,
88
-
e.g., utilizing NCCL (when feasible) for model weight synchronization, sequence concatenation with proper masking for multi-turn conversations and ReAct workflows, pipeline parallelism for the synchronous RFT mode, among many others.
101
+
e.g., utilizing NCCL (when feasible) for model weight synchronization, sequence concatenation with proper masking for multi-turn conversations and ReAct-style workflows, pipeline parallelism for the synchronous RFT mode, among many others.
89
102
90
103
91
104
92
105
## Getting started
93
106
94
107
95
-
*Note: this project is currently under active development; comments and suggestions are welcome!*
108
+
> [!NOTE]
109
+
> This project is currently under active development. Comments and suggestions are welcome!
96
110
97
111
98
112
@@ -218,7 +232,7 @@ ray start --address=<master_address>
218
232
219
233
220
234
221
-
Optionally, we can login into wandb to monitor the RFT process. More details of wandb can be found in its [docs](https://docs.wandb.ai/quickstart/).
235
+
Optionally, we can login into [wandb](https://docs.wandb.ai/quickstart/) to better monitor the RFT process:
222
236
223
237
```shell
224
238
export WANDB_API_KEY=<your_api_key>
@@ -247,7 +261,7 @@ More example config files can be found in `scripts/config`.
247
261
248
262
249
263
250
-
For more detailed examples about how to use Trinity-RFT, please refer to the following documents:
264
+
For more detailed examples about how to use Trinity-RFT, please refer to the following tutorials:
251
265
+ [A quick example with GSM8k](./docs/sphinx_doc/source/tutorial/example_reasoning_basic.md);
252
266
+ [Off-policy / asynchronous modes of RFT](./docs/sphinx_doc/source/tutorial/example_reasoning_advanced.md);
Copy file name to clipboardExpand all lines: docs/sphinx_doc/source/tutorial/example_data_functionalities.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,8 +137,9 @@ All config items in the `data` section can be found [here](trinity_configs.md).
137
137
138
138
139
139
140
-
> [!NOTE]
141
-
> Only when one of `dj_process_desc` and `dj_config_path` is provided, the data module and the data active iterator will be activated. Otherwise, this part will be skipped and it will enter into the exploring stage directly.
140
+
```{note}
141
+
Only when one of `dj_process_desc` and `dj_config_path` is provided, the data module and the data active iterator will be activated. Otherwise, this part will be skipped and it will enter into the exploring stage directly.
142
+
```
142
143
143
144
### Exploring & Training
144
145
After preparing the config files of Trinity-RFT, you can start your ray cluster and run the RFT process including the data active iterator part with the following commands:
0 commit comments