TRL

🤗 TRL – Transformer Reinforcement Learning

A library for training language models after pretraining: supervised fine-tuning (SFT), preferences (DPO), and reinforcement learning such as PPO and GRPO.

ActiveAdvancedv1.18.2Apache-2.0Generative AINatural Language Processing & Language Models

Official documentation

Basic information

NameTRL
Full name🤗 TRL – Transformer Reinforcement Learning
CategoryGenerative AI
DeveloperHugging Face
Release yearNot specified
Official websitegithub.com/huggingface/trl
GitHub repositoryhuggingface/trl
Official documentationNot specified
Package on PyPItrl
LicenseApache-2.0 (PyPI license_expression)
Project statusActive Had a release in the last 12 months
Latest version19 November 2026 (version 1.18.2)
Programming languagePython
Operating systemsOS Independent (as declared by the package on PyPI)
Required Python version>=3.11
Difficulty levelAdvanced

Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)

Overview

TRL offers ready trainers (SFTTrainer, DPOTrainer, GRPOTrainer and others) built on Transformers, with PEFT and distributed training support, for alignment and instruction-tuning stages.

It requires an understanding of preference data and training settings, and suitable GPU resources.

When to choose it? Choose it for instruction tuning and alignment once the base model is chosen.

Uses

Main uses

  • Supervised instruction tuning (SFT)
  • Preference training (DPO)
  • Preference training (DPO)
  • Reinforcement learning from rewards
  • Reinforcement learning from rewards

Scientific fields

  • Language models
  • Language models

Suitable project types

  • An Arabic chat model tuned with instructions
  • An Arabic chat model tuned with instructions

Research applications

  • Experiments with alignment and preference methods
  • Experiments with alignment and preference methods

Fine-tuning language modelsLarge language modelsReinforcement Learning

Technical features

A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".

CPU supportPartial or through an add-onOnly possible for very small experiments.
GPU supportSupported
CUDA compatibilitySupported
Distributed training or computingSupported
Automatic differentiation (Autodiff)SupportedThrough PyTorch.
Model deploymentNot applicable
Pre-trained modelsNot applicable
Supported data typesModels, text and datasets
Integration with other librariesHugging Face Transformers, PEFT, Unsloth, vLLM
Flexibility (editorial estimate)High
Performance (editorial estimate)Good
Community (editorial estimate)Large
Documentation quality (editorial estimate)Good documentation

Installation and running

Shell
pip install trl

Compatibility: Python >=3.11 — according to the package data on PyPI, checked on 21 November 2026

Compatibility: Python >=3.11 — according to the package data on PyPI, checked on 21 November 2026

Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.

Pros

  • Ready implementations of modern alignment methods
  • Integration with PEFT

Limitations

  • Requires GPU resources
  • Changes quickly as new methods appear

References and verification

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/trl/

    Checked on: 21 November 2026 — version checked: 1.18.2 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://github.com/huggingface/trl

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/huggingface/trl

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/trl/

    Checked on: 21 November 2026 — version checked: 1.18.2 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://github.com/huggingface/trl

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/huggingface/trl

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

History of verified versions

VersionRelease dateChecked on
1.18.219 November 202621 November 2026

Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.

Report information that needs updating