Skip to content

Commit b82decf

Browse files
authored
Optimize Installation and Development Doc (agentscope-ai#301)
1 parent f777fb2 commit b82decf

27 files changed

+1910
-1944
lines changed

README.md

Lines changed: 53 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,36 @@
1818

1919
</div>
2020

21-
22-
## 🚀 News
23-
24-
* [2025-09][[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.0)] Trinity-RFT v0.3.0 released: enhanced Buffer, FSDP2 & Megatron support, multi-modal models, and new RL algorithms/examples.
25-
* [2025-08] 🎵 Introducing [CHORD](https://github.com/modelscope/Trinity-RFT/tree/main/examples/mix_chord): dynamic SFT + RL integration for advanced LLM fine-tuning ([paper](https://arxiv.org/pdf/2508.11408)).
26-
* [2025-08] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.2.1)] Trinity-RFT v0.2.1 released.
27-
* [2025-07] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.2.0)] Trinity-RFT v0.2.0 released.
28-
* [2025-07] Technical report (arXiv v2) updated with new features, examples, and experiments: [link](https://arxiv.org/abs/2505.17826).
29-
* [2025-06] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.1.1)] Trinity-RFT v0.1.1 released.
30-
* [2025-05] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.1.0)] Trinity-RFT v0.1.0 released, plus [technical report](https://arxiv.org/abs/2505.17826).
31-
* [2025-04] Trinity-RFT open sourced.
32-
33-
3421
## 💡 What is Trinity-RFT?
3522

36-
Trinity-RFT is a flexible, general-purpose framework for reinforcement fine-tuning (RFT) of large language models (LLMs). It supports a wide range of applications and provides a unified platform for RL research in the [era of experience](https://storage.googleapis.com/deepmind-media/Era-of-Experience%20/The%20Era%20of%20Experience%20Paper.pdf).
23+
Trinity-RFT is a flexible, general-purpose framework for reinforcement fine-tuning (RFT) of large language models (LLMs). It provides three independent modules for users with different needs:
3724

38-
The RFT process is modularized into three core components:
25+
* 🤖 **Explorer**:For agent application developers. [[tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/develop_workflow.html)
26+
- Train an agent application to enhance its ability to complete tasks in a specified environment
27+
- Examples: [Multi-Turn Interaction](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_multi_turn.html), [ReAct Agent](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_react.html)
3928

40-
* **Explorer**: Handles agent-environment interaction
41-
* **Trainer**: Manages model training
42-
* **Buffer**: Manages data storage and processing
29+
* 🧠 **Trainer**: For RL algorithm researchers. [[tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/develop_algorithm.html)
30+
- Design and validate new RL algorithms in compact, plug-and-play classes
31+
- Examples: [Mixture of RL Algorithms](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_mix_algo.html)
4332

33+
* 🗄️ **Buffer**: For data engineers. [[tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/develop_operator.html)
34+
- Design task-specific datasets and build data pipelines for cleaning, augmentation, and human-in-the-loop scenarios
35+
- Examples: [Data Functionalities](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_data_functionalities.html)
4436

45-
<img src="https://img.alicdn.com/imgextra/i2/O1CN01H3UbpF1yP7E1OCLbi_!!6000000006570-2-tps-1334-638.png" alt="The high-level design of Trinity-RFT" width="800" />
4637

47-
48-
49-
## ✨ Key Features
38+
Trinity-RFT unifies the above three modules and provides the following key features:
5039

5140
* **Flexible RFT Modes:**
5241
- Supports synchronous/asynchronous, on-policy/off-policy, and online/offline training. Rollout and training can run separately and scale independently across devices.
5342

5443
<img src="https://img.alicdn.com/imgextra/i3/O1CN01E7NskS1FFoTI9jlaQ_!!6000000000458-2-tps-1458-682.png" alt="RFT modes supported by Trinity-RFT" width="600" />
5544

56-
* **Agent Framework Compatible Workflows:**
57-
- Supports both concatenated and general multi-turn agentic workflows. Automatically collects training data from model API clients (e.g., OpenAI) and is compatible with agent frameworks like AgentScope.
45+
* **General Agentic-RL Support:**
46+
- Supports both concatenated and general multi-turn agentic workflows. Able to directly train agent applications developed using agent frameworks like AgentScope.
5847

5948
<img src="https://img.alicdn.com/imgextra/i1/O1CN01z1i7kk1jlMEVa8ZHV_!!6000000004588-2-tps-1262-695.png" alt="Agentic workflows" width="600" />
6049

61-
* **Powerful Data Pipelines:**
50+
* **Full Lifecycle Data Pipelines:**
6251
- Enables pipeline processing of rollout and experience data, supporting active management (prioritization, cleaning, augmentation) throughout the RFT lifecycle.
6352

6453
<img src="https://img.alicdn.com/imgextra/i2/O1CN01BfeHp61sXSlGjH7zQ_!!6000000005776-2-tps-1734-473.png" alt="Data pipeline design" width="600" />
@@ -69,26 +58,24 @@ The RFT process is modularized into three core components:
6958
<img src="https://img.alicdn.com/imgextra/i1/O1CN01Ti0o4320RywoAuyhN_!!6000000006847-2-tps-3840-2134.png" alt="System architecture" width="600" />
7059

7160

61+
## 🚀 News
7262

63+
* [2025-09][[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.3.0)] Trinity-RFT v0.3.0 released: enhanced Buffer, FSDP2 & Megatron support, multi-modal models, and new RL algorithms/examples.
64+
* [2025-08] 🎵 Introducing [CHORD](https://github.com/modelscope/Trinity-RFT/tree/main/examples/mix_chord): dynamic SFT + RL integration for advanced LLM fine-tuning ([paper](https://arxiv.org/pdf/2508.11408)).
65+
* [2025-08] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.2.1)] Trinity-RFT v0.2.1 released.
66+
* [2025-07] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.2.0)] Trinity-RFT v0.2.0 released.
67+
* [2025-07] Technical report (arXiv v2) updated with new features, examples, and experiments: [link](https://arxiv.org/abs/2505.17826).
68+
* [2025-06] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.1.1)] Trinity-RFT v0.1.1 released.
69+
* [2025-05] [[Release Notes](https://github.com/modelscope/Trinity-RFT/releases/tag/v0.1.0)] Trinity-RFT v0.1.0 released, plus [technical report](https://arxiv.org/abs/2505.17826).
70+
* [2025-04] Trinity-RFT open sourced.
7371

74-
## 🛠️ What can I use Trinity-RFT for?
75-
76-
* **Train agent applications with RL and minimal migration cost** [[Tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/trinity_programming_guide.html#workflows-for-rl-environment-developers)
77-
- Implement agent-environment interaction logic in a single workflow class ([example1](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_multi_turn.html), [example2](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_step_wise.html)),
78-
- Or import workflows from agent frameworks like AgentScope ([example](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_react.html)).
79-
80-
* **Rapid RL algorithm design and validation** [[Tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/trinity_programming_guide.html#algorithms-for-rl-algorithm-developers)
81-
- Develop custom RL algorithms (loss design, sampling strategy, etc.) in compact, plug-and-play classes ([example](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_mix_algo.html)).
82-
83-
* **Custom datasets and data pipelines for RFT** [[Tutorial]](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/trinity_programming_guide.html#operators-for-data-developers)
84-
- Design task-specific datasets and build data pipelines for cleaning, augmentation, and human-in-the-loop scenarios ([example](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_data_functionalities.html)).
8572

8673
---
8774

8875
## Table of contents
8976

9077

91-
- [Getting started](#getting-started)
78+
- [Quick Start](#quick-start)
9279
- [Step 1: installation](#step-1-installation)
9380
- [Step 2: prepare dataset and model](#step-2-prepare-dataset-and-model)
9481
- [Step 3: configurations](#step-3-configurations)
@@ -101,7 +88,7 @@ The RFT process is modularized into three core components:
10188

10289

10390

104-
## Getting started
91+
## Quick Start
10592

10693

10794
> [!NOTE]
@@ -110,18 +97,16 @@ The RFT process is modularized into three core components:
11097

11198
### Step 1: installation
11299

113-
#### Prerequisites
114-
115100
Before installing, make sure your system meets the following requirements:
116101

117102
- **Python**: version 3.10 to 3.12 (inclusive)
118103
- **CUDA**: version 12.4 to 12.8 (inclusive)
119104
- **GPUs**: at least 2 GPUs
120105

121106

122-
#### Option A: Install from Source (Recommended)
107+
#### From Source (Recommended)
123108

124-
This method gives you full control and is best if you plan to customize or contribute to the project.
109+
If you plan to customize or contribute to Trinity-RFT, this is the best option.
125110

126111
##### 1. Clone the Repository
127112

@@ -132,81 +117,71 @@ cd Trinity-RFT
132117

133118
##### 2. Set Up a Virtual Environment
134119

135-
Choose one of the following options to create an isolated environment:
120+
Choose one of the following options:
136121

137122
###### Using Conda
123+
138124
```bash
139125
conda create -n trinity python=3.10
140126
conda activate trinity
127+
128+
pip install -e ".[dev]"
129+
pip install -e ".[flash_attn]"
130+
# if you encounter issues when installing flash-attn, try:
131+
# pip install flash-attn==2.8.1 --no-build-isolation
141132
```
142133

143134
###### Using venv
135+
144136
```bash
145137
python3.10 -m venv .venv
146138
source .venv/bin/activate
147-
```
148139

149-
##### 3. Install the Package
150-
151-
Install in editable mode so you can make changes without reinstalling:
152-
153-
```bash
154140
pip install -e ".[dev]"
141+
pip install -e ".[flash_attn]"
142+
# if you encounter issues when installing flash-attn, try:
143+
# pip install flash-attn==2.8.1 --no-build-isolation
155144
```
156145

157-
##### 4. Install Flash Attention
158-
159-
Flash Attention boosts training speed. It takes a few minutes to compile — please be patient!
160-
161-
```bash
162-
pip install flash-attn==2.8.1
163-
```
146+
###### Using `uv`
164147

165-
If you encounter issues during installation, try this alternative:
148+
[`uv`](https://github.com/astral-sh/uv) is a modern Python package installer.
166149

167150
```bash
168-
pip install flash-attn==2.8.1 --no-build-isolation
151+
uv sync --extra dev --extra flash_attn
169152
```
170153

171154

172-
##### ⚡ Fast Alternative: Use `uv` (Optional)
155+
#### Via PyPI
173156

174-
If you'd like a faster installation, try [`uv`](https://github.com/astral-sh/uv), a modern Python package installer:
157+
If you just want to use the package without modifying the code:
175158

176159
```bash
177-
uv venv
178-
source .venv/bin/activate
179-
180-
uv pip install -e ".[dev]"
181-
uv pip install flash-attn==2.8.1 --no-build-isolation
160+
pip install trinity-rft==0.3.0
161+
pip install flash-attn==2.8.1
182162
```
183163

184-
#### Option B: Install via pip (Quick Start)
185-
186-
If you just want to use the package without modifying the code:
164+
Or with `uv`:
187165

188166
```bash
189-
pip install trinity-rft==0.3.0
190-
pip install flash-attn==2.8.1 # Install Flash Attention separately
191-
192-
# Use uv to install trinity-rft
193-
# uv pip install trinity-rft==0.3.0
194-
# uv pip install flash-attn==2.8.1
167+
uv pip install trinity-rft==0.3.0
168+
uv pip install flash-attn==2.8.1
195169
```
196170

197-
#### Option C: Use Docker
171+
172+
#### Using Docker
198173

199174
We provide a Docker setup for hassle-free environment configuration.
200175

201176
```bash
202177
git clone https://github.com/modelscope/Trinity-RFT
203178
cd Trinity-RFT
204179

205-
## Build the Docker image
180+
# Build the Docker image
206181
## Tip: You can modify the Dockerfile to add mirrors or set API keys
207182
docker build -f scripts/docker/Dockerfile -t trinity-rft:latest .
208183

209-
## Run the container
184+
# Run the container, replacing <path_to_your_data_and_checkpoints> with your actual path
210185
docker run -it \
211186
--gpus all \
212187
--shm-size="64g" \
@@ -216,9 +191,7 @@ docker run -it \
216191
trinity-rft:latest
217192
```
218193

219-
💡 **Note**: Replace `<path_to_your_data_and_checkpoints>` with the actual path on your machine where datasets and model checkpoints are stored.
220-
221-
> If you'd like to integrate with **Megatron-LM**, check out our [example setup guide for Megatron](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_megatron.html).
194+
> For training with **Megatron-LM**, please refer to [Megatron-LM Backend](https://modelscope.github.io/Trinity-RFT/en/main/tutorial/example_megatron.html).
222195
223196
### Step 2: prepare dataset and model
224197

0 commit comments

Comments
 (0)