Skip to content

Commit b7676d1

Browse files
Fixed some typos and added small details about trackio to docs (#3965)
1 parent 515e9eb commit b7676d1

13 files changed

+29
-29
lines changed

docs/source/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Training customization
22

3-
TRL is designed with modularity in mind so that users to be able to efficiently customize the training loop for their needs. Below are some examples on how you can apply and test different techniques. Note: Although these examples use the DPOTrainer, the customization applies to most (if not all) trainers.
3+
TRL is designed with modularity in mind so that users are able to efficiently customize the training loop for their needs. Below are some examples on how you can apply and test different techniques. Note: Although these examples use the DPOTrainer, the customization applies to most (if not all) trainers.
44

55

66

docs/source/detoxifying_a_lm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The evaluation script can be found [here](https://github.com/huggingface/trl/blo
174174

175175
### Discussions
176176

177-
The results are quite promising, as we can see that the models are able to reduce the toxicity score of the generated text by an interesting margin. The gap is clear for `gpt-neo-2B` model but we less so for the `gpt-j-6B` model. There are several things we could try to improve the results on the largest model starting with training with larger `mini_batch_size` and probably allowing to back-propagate through more layers (i.e. use less shared layers).
177+
The results are quite promising, as we can see that the models are able to reduce the toxicity score of the generated text by an interesting margin. The gap is clear for `gpt-neo-2B` model but we see less so for the `gpt-j-6B` model. There are several things we could try to improve the results on the largest model starting with training with larger `mini_batch_size` and probably allowing to back-propagate through more layers (i.e. use less shared layers).
178178

179179
To sum up, in addition to human feedback this could be a useful additional signal when training large language models to ensure their outputs are less toxic as well as useful.
180180

docs/source/distributing_training.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ Having one model per GPU can lead to high memory usage, which may not be feasibl
5555

5656
</Tip>
5757

58-
## Multi-Nodes Training
58+
## Multi-Node Training
5959

6060
We're working on a guide for multi-node training. Stay tuned! 🚀

docs/source/how_to_train.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To address this, we recommend focusing on two key metrics first:
99
**Mean Reward**: The primary goal is to maximize the reward achieved by the model during RL training.
1010
**Objective KL Divergence**: KL divergence (Kullback-Leibler divergence) measures the dissimilarity between two probability distributions. In the context of RL training, we use it to quantify the difference between the current model and a reference model. Ideally, we want to keep the KL divergence between 0 and 10 to ensure the model's generated text remains close to what the reference model produces.
1111

12-
However, there are more metrics that can be useful for debugging, checkout the [logging section](logging).
12+
However, there are more metrics that can be useful for debugging, check out the [logging section](logging).
1313

1414
## Why Do We Use a Reference Model, and What's the Purpose of KL Divergence?
1515

@@ -26,7 +26,7 @@ To address this issue, we add a penalty to the reward function based on the KL d
2626

2727
## What Is the Concern with Negative KL Divergence?
2828

29-
If you generate text by purely sampling from the model distribution things work fine in general. But when you use the `generate` method there are a few caveats because it does not always purely sample depending on the settings which can cause KL-divergence to go negative. Essentially when the active model achieves `log_p_token_active < log_p_token_ref` we get negative KL-div. This can happen in a several cases:
29+
If you generate text by purely sampling from the model distribution things work fine in general. But when you use the `generate` method there are a few caveats because it does not always purely sample depending on the settings which can cause KL-divergence to go negative. Essentially when the active model achieves `log_p_token_active < log_p_token_ref` we get negative KL-div. This can happen in several cases:
3030

3131
- **top-k sampling**: the model can smooth out the probability distribution causing the top-k tokens having a smaller probability than those of the reference model but they still are selected
3232
- **min_length**: this ignores the EOS token until `min_length` is reached. thus the model can assign a very low log prob to the EOS token and very high probs to all others until min_length is reached
@@ -50,7 +50,7 @@ generation_kwargs = {
5050
}
5151
```
5252

53-
With these settings we usually don't encounter any issues. You can also experiments with other settings but if you encounter issues with negative KL-divergence try to go back to these and see if they persist.
53+
With these settings we usually don't encounter any issues. You can also experiment with other settings but if you encounter issues with negative KL-divergence try to go back to these and see if they persist.
5454

5555
## How can debug your own use-case?
5656

@@ -60,6 +60,6 @@ Debugging the RL pipeline can be challenging due to its complexity. Here are som
6060
- **Start small, scale later**: Training large models can be very slow and take several hours or days until you see any improvement. For debugging this is not a convenient timescale so try to use small model variants during the development phase and scale up once that works. That being said you sometimes have to be careful as small models might not have the capacity to solve a complicated task either.
6161
- **Start simple**: Try to start with a minimal example and build complexity from there. Your use-case might require for example a complicated reward function consisting of many different rewards - try to use one signal first and see if you can optimize that and then add more complexity after that.
6262
- **Inspect the generations**: It's always a good idea to inspect what the model is generating. Maybe there is a bug in your post-processing or your prompt. Due to bad settings you might cut-off generations too soon. These things are very hard to see on the metrics but very obvious if you look at the generations.
63-
- **Inspect the reward model**: If you reward is not improving over time maybe there's an issue with the reward model. You can look at extreme cases to see if it does what it should: e.g. in the sentiment case you can check if simple positive and negative examples really get different rewards. And you can look at the distribution of your dataset. Finally, maybe the reward is dominated by the query which the model can't affect so you might need to normalize this (e.g. reward of query+response minus reward of the query).
63+
- **Inspect the reward model**: If your reward is not improving over time maybe there's an issue with the reward model. You can look at extreme cases to see if it does what it should: e.g. in the sentiment case you can check if simple positive and negative examples really get different rewards. And you can look at the distribution of your dataset. Finally, maybe the reward is dominated by the query which the model can't affect so you might need to normalize this (e.g. reward of query+response minus reward of the query).
6464

6565
These are just a few tips that we find helpful - if you have more useful tricks feel free to open a PR to add them as well!

docs/source/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Install the library with pip or [uv](https://docs.astral.sh/uv/):
77
<hfoptions id="install">
88
<hfoption id="uv">
99

10-
uv is a fast Rust-based Python package and project manager. Refer to [Installation](https://docs.astral.sh/uv/getting-started/installation/) for installation instructions), .
10+
uv is a fast Rust-based Python package and project manager. Refer to [Installation](https://docs.astral.sh/uv/getting-started/installation/) for installation instructions).
1111

1212
```bash
1313
uv pip install trl

docs/source/logging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Logging
22

33
As reinforcement learning algorithms are historically challenging to debug, it's important to pay careful attention to logging.
4-
By default, TRL trainers like [`PPOTrainer`] and [`GRPOTrainer`] save a lot of relevant information to supported experiment trackers like Weights & Biases (wandb) or TensorBoard.
4+
By default, TRL trainers like [`PPOTrainer`] and [`GRPOTrainer`] save a lot of relevant information to supported experiment trackers like Trackio, Weights & Biases (wandb) or TensorBoard.
55

66
Upon initialization, pass the `report_to` argument to the respective configuration object (e.g., [`PPOConfig`] for `PPOTrainer`, or [`GRPOConfig`] for `GRPOTrainer`):
77

88
```python
99
# For PPOTrainer
1010
ppo_config = PPOConfig(
1111
# ...,
12-
report_to="wandb" # or "tensorboard"
12+
report_to="trackio" # or "wandb" or "tensorboard"
1313
)
1414

1515
# For GRPOTrainer
16-
grpc_config = GRPOConfig(
16+
grpo_config = GRPOConfig(
1717
# ...,
18-
report_to="wandb" # or "tensorboard"
18+
report_to="trackio" # or "wandb" or "tensorboard"
1919
)
2020
```
2121

docs/source/paper_index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ from trl import GRPOConfig
1818
training_args = GRPOConfig(
1919
importance_sampling_level="sequence",
2020
loss_type="grpo",
21-
beta=0.0, # GSPO set kl regularization to zero: https://github.com/volcengine/verl/pull/2775#issuecomment-3131807306
21+
beta=0.0, # GSPO set KL regularization to zero: https://github.com/volcengine/verl/pull/2775#issuecomment-3131807306
2222
epsilon=3e-4, # GSPO paper (v2), section 5.1
2323
epsilon_high=4e-4, # GSPO paper (v2), section 5.1
2424
gradient_accumulation_steps=1,
@@ -30,7 +30,7 @@ training_args = GRPOConfig(
3030

3131
**📜 Paper**: https://huggingface.co/papers/2503.14476
3232

33-
The DAPO algorithm, includes 5 key components:
33+
The DAPO algorithm includes 5 key components:
3434

3535
- Overlong Filtering
3636
- Clip-Higher
@@ -165,7 +165,7 @@ training_args = GRPOConfig(
165165
temperature=0.99,
166166
num_completions=8, # = num_return_sequences in the paper
167167
num_iterations=1, # = ppo_epochs in the paper
168-
per_device_train_batch_size=4
168+
per_device_train_batch_size=4,
169169
gradient_accumulation_steps=32,
170170
steps_per_generation=8, # (rollout_batch_size*num_return_sequences) / (per_device_train_batch_size*gradient_accumulation_steps)
171171
)

docs/source/peft_integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Examples of using peft with trl to finetune 8-bit models with Low Rank Adaption (LoRA)
22

3-
The notebooks and scripts in this examples show how to use Low Rank Adaptation (LoRA) to fine-tune models in a memory efficient manner. Most of PEFT methods supported in peft library but note that some PEFT methods such as Prompt tuning are not supported.
3+
The notebooks and scripts in these examples show how to use Low Rank Adaptation (LoRA) to fine-tune models in a memory efficient manner. Most of PEFT methods supported in peft library but note that some PEFT methods such as Prompt tuning are not supported.
44
For more information on LoRA, see the [original paper](https://huggingface.co/papers/2106.09685).
55

66
Here's an overview of the `peft`-enabled notebooks and scripts in the [trl repository](https://github.com/huggingface/trl/tree/main/examples):

docs/source/quickstart.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ trl dpo --model_name_or_path Qwen/Qwen2.5-0.5B-Instruct \
6969

7070
### 📚 Learn More
7171

72-
- [SFT Trainer](https://huggingface.co/docs/trl/sft_trainer) - Complete SFT guide
73-
- [DPO Trainer](https://huggingface.co/docs/trl/dpo_trainer) - Preference alignment
74-
- [GRPO Trainer](https://huggingface.co/docs/trl/grpo_trainer) - Group relative policy optimization
75-
- [Training FAQ](https://huggingface.co/docs/trl/how_to_train) - Common questions
72+
- [SFT Trainer](sft_trainer) - Complete SFT guide
73+
- [DPO Trainer](dpo_trainer) - Preference alignment
74+
- [GRPO Trainer](grpo_trainer) - Group relative policy optimization
75+
- [Training FAQ](how_to_train) - Common questions
7676

7777
### 🚀 Scale Up
7878

79-
- [Distributed Training](https://huggingface.co/docs/trl/distributing_training) - Multi-GPU setups
80-
- [Memory Optimization](https://huggingface.co/docs/trl/reducing_memory_usage) - Efficient training
81-
- [PEFT Integration](https://huggingface.co/docs/trl/peft_integration) - LoRA and QLoRA
79+
- [Distributed Training](distributing_training) - Multi-GPU setups
80+
- [Memory Optimization](reducing_memory_usage) - Efficient training
81+
- [PEFT Integration](peft_integration) - LoRA and QLoRA
8282

8383
### 💡 Examples
8484

8585
- [Example Scripts](https://github.com/huggingface/trl/tree/main/examples) - Production-ready code
86-
- [Community Tutorials](https://huggingface.co/docs/trl/community_tutorials) - External guides
86+
- [Community Tutorials](community_tutorials) - External guides
8787

8888
## Troubleshooting
8989

@@ -122,4 +122,4 @@ Try adjusting the learning rate:
122122
training_args = SFTConfig(learning_rate=2e-5) # Good starting point
123123
```
124124

125-
For more help, see our [Training FAQ](how_to_train.md) or open an [issue on GitHub](https://github.com/huggingface/trl/issues).
125+
For more help, see our [Training FAQ](how_to_train) or open an [issue on GitHub](https://github.com/huggingface/trl/issues).

docs/source/reducing_memory_usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Packing, introduced in [Raffel et al., 2020](https://huggingface.co/papers/1910.
8888
<img src="https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/packing_2.png" alt="Packing" width="600"/>
8989
</div>
9090

91-
Packing reduces padding by merging several sequences in one row when possible. We use an advanced method to be near-optimal in the way we pack the dataset. To enable packing, use `packing=True` and in the [`SFTConfig`].
91+
Packing reduces padding by merging several sequences in one row when possible. We use an advanced method to be near-optimal in the way we pack the dataset. To enable packing, use `packing=True` in the [`SFTConfig`].
9292

9393
<Tip>
9494

0 commit comments

Comments
 (0)