OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Textrl

Textrl is a Python library built on Hugging Face TRL that configures and trains text-generation models with reinforcement-learning, preference-learning and reward-model methods.

Independent OpenViST project profile, based on linked sources.

Textrl — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Textrl when a text-generation project needs a documented trainer interface for reinforcement-learning or preference-based training, and you can provide the model, training data and reward or feedback signals required by the selected method.

Who it is for

  • Developers building or fine-tuning text-generation models with Python and Hugging Face Transformers.
  • Researchers and practitioners working with reinforcement learning from feedback or preference datasets.

Documented uses

  • Configure online reinforcement-learning trainers such as GRPO, RLOO and REINFORCE++.
  • Train with preference methods including DPO and KTO using their required data formats.
  • Define callable reward functions for generated completions or train a pairwise reward model.
  • Use PEFT in a text-generation reinforcement-learning workflow.
Before you choose

Requirements & limits

The repository is public and lists an MIT license.

  • Choose the training method based on available data: prompt-only for online methods, chosen/rejected pairs for pairwise preference training, or prompt/completion/label for KTO.
  • The README identifies vLLM rollout as a GRPO option and says distributed training can be launched with Accelerate.
  • The project documents support for PEFT, but does not specify all supported methods or configurations.
  • PPO, OnlineDPO, ORPO, CPO, SimPO and binary BCO are listed as unsupported with TRL 0.29 and later.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Set up a GRPO training workflow with a callable reward

Configure and start a text-generation training run using GRPO and a custom reward function.

Before you start

  • Python environment with Textrl installed.
  • A supported Hugging Face Transformers generation model and tokenizer.
  • Prompt-only training data, such as a list of prompts.

Steps

  1. Install the core package with the command below.

    Documented command
    pip install textrl
  2. Define a reward callable that accepts prompts and completions and returns a list of scores; decorate it with @reward_fn.

  3. Load a model with load_model, configure TextRLConfig with algo="grpo", and create an OnlineTrainer with the model, tokenizer, reward and prompt dataset.

  4. Call trainer.train() to start training.

Expected outcome

A GRPO training run configured to optimize generated text against the supplied callable reward.

Guide limitations

  • The project says specific model and algorithm compatibility should be checked.
  • The example uses PEFT with LoRA, but does not specify hardware requirements.
  • The README lists vLLM rollout for GRPO as an optional additional setup.
Source-based practical guide

Configure DPO training with preference data

Set up a preference-learning run using DPO and a pairwise preference dataset.

Before you start

  • Python environment with Textrl installed.
  • A supported Hugging Face Transformers model.
  • Preference data with prompt, chosen and rejected fields.

Steps

  1. Install the core package with the command below.

    Documented command
    pip install textrl
  2. Load the policy model, tokenizer and reference model with load_model.

  3. Set TextRLConfig to algo="dpo" and create a PreferenceTrainer with the models, tokenizer and preference dataset.

  4. Call trainer.train() to start training.

Expected outcome

A DPO training run configured to learn from chosen and rejected responses.

Guide limitations

  • The README’s example uses a dataset from the Hugging Face Hub and 4-bit quantization, but does not specify hardware requirements.
  • Specific model and algorithm compatibility should be checked.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
voidful/TextRL · Official homepage title · retained in its source language