WhoBuilt

Let LLMs Wander: Engineering RL Environments

Apr 8, 2026· 41 min· 8.2K views·Watch on YouTube

Speaker

Stefano Fiorucci, an AI and software engineer at deepset working on Haystack, explains how to build reinforcement learning environments for language model training and evaluation at an AI Engineer talk.

From language model training to verifiable rewards

Fiorucci reviews how agents learn through actions and rewards, then describes how reinforcement learning with verifiable rewards can complement supervised fine-tuning. Tasks with automatically checkable outcomes, such as correct answers, wins, or successful tool calls, can provide training signals without requiring large collections of curated examples.

Building reusable environments with Verifiers

Fiorucci introduces Verifiers, an open-source Python library for building environments for language model evaluation and training. Its components support single-turn, multi-turn, and tool-based interactions, while handling model serving and parallel rollouts. Examples include reversing text, checking a math answer with a follow-up question, and connecting tools.

Designing a tic-tac-toe training environment

Fiorucci builds a game environment that tracks the board, validates moves, applies opponent moves, and rewards outcomes and output formatting. He improves it with a minimax opponent whose difficulty can be varied, penalties that let play continue after invalid moves, and seeded opponent behavior to make rollout comparisons more consistent. Stratified sampling balances opponent difficulty across training batches.

Training a small model into a stronger player

Fiorucci evaluates GPT-5 mini and Liquid AI's LFM2, then uses 200 filtered synthetic examples to fine-tune LFM2 on move formatting and valid moves. Reinforcement learning improves its game performance: it dominates random opponents and draws 85% of games against an optimal opponent. A further run with stronger opponents and adjusted sampling temperature produces a player that beats the teacher model, GPT-5 mini, against an optimal opponent.

Lessons from experiments and next steps

Fiorucci says small batches can make training unstable when games and opponent skill vary, while larger batches tend to train more slowly but steadily. He warns that an opponent algorithm can have a hidden bias that the model memorizes, and recommends inspecting rollouts and testing the trained model on the actual task. He suggests building environments around a few frequently used tools and points to the Wiki Search example in Prime RL.

Takeaways

  • Choose tasks with outcomes your environment can verify automatically, such as a correct answer or a won game.
  • Inspect rollouts and test models on real task behavior, since benchmark scores can hide learned quirks.
  • Control environment randomness so reward differences reflect the model's choices more clearly.
  • Balance opponent difficulty across batches to reduce unstable updates from unusually easy or hard games.
  • Start with a promising base model and use supervised fine-tuning to teach task format before reinforcement learning.

Mentioned in this talk

Search inside this talk

What was claimed 7

Related talks