Skip to main content

Requirements

  • Python 3.10 or later
  • PyTorch (installed automatically as a transitive dependency via Transformers)

Install from PyPI

Install TRL using pip or uv:
This installs TRL along with its core dependencies: transformers, accelerate, and datasets.

Install from source

To use the latest unreleased features, install directly from the GitHub repository:
Alternatively, clone the repository and install in editable mode:

Optional dependencies

TRL provides optional dependency groups for specific use cases. Install them using the extras syntax:
For example, to install TRL with PEFT and quantization support:
For most use cases, start with pip install trl and add optional dependencies as needed. The peft and quantization extras are recommended for training on consumer hardware.

Developer install

If you want to contribute to TRL or run the test suite, install the development dependencies:
The dev extra includes testing tools (pytest, pytest-cov, pytest-xdist), code quality tools (pre-commit, hf-doc-builder), and most optional dependency groups.
vLLM is not included in the dev extra by default due to CUDA compatibility constraints. Install it separately with pip install "trl[vllm]" if needed.
See the contributing guide for more details on setting up a development environment.