Skip to content

Stable Baselines3

A Python library of reliable reinforcement learning algorithms built on PyTorch.

Stars
14k
Forks
2.2k
Licence
MIT
Language
Python
Last update
11 days ago
Type
Library

What it is

Stable Baselines3 (SB3) is a Python library that provides tested implementations of common reinforcement learning algorithms, which are methods for training software agents to make decisions by trial and reward. It is written in PyTorch and offers a consistent interface so researchers and engineers can train, compare, and build on these algorithms without writing them from scratch. The README notes that it assumes some prior knowledge of reinforcement learning.

  • Train a PPO agent on the CartPole-v1 environment using the example in the README
  • Compare a new RL approach against established algorithms using a common interface
  • Track experiments with Weights & Biases or share trained models via Hugging Face, per the integrations section
  • Use the companion RL Baselines3 Zoo to tune hyperparameters and record videos of trained agents

Great for

  • Researchers who want a reliable baseline to compare a new method against
  • Engineers prototyping an RL agent for a task with a Gymnasium-style environment
  • Students with some RL background who want readable, tested implementations
  • Users who want to train PPO on a simple environment such as CartPole with a few lines of code

Not ideal for

  • Complete beginners with no reinforcement learning background, since the README says the library assumes some RL knowledge
  • Projects that need the newest experimental algorithms, which the README says are placed in the separate SB3-Contrib repository
  • Users who need the fastest possible training, since the README mentions the separate SBX (JAX) variant as faster but with fewer features
Step-by-step guide: how to use Stable Baselines3Install, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python 3.10+ · PyTorch >= 2.8

    Install with optional extras (Tensorboard, OpenCV, ale-py, pandas, matplotlib)

    pip install 'stable-baselines3[extra]'

    Install core package without extras

    pip install stable-baselines3
  2. 2

    Run it

    • Install the package with pip as shown in the installation section
    • Save the README's PPO CartPole example to a Python file
    • Run the script to train PPO for 10,000 timesteps and render the environment
    • Read the documentation at stable-baselines3.readthedocs.io for more examples
  3. 3

    Get the most out of it

    • Use the RL Baselines3 Zoo for training scripts, hyperparameter tuning, plotting, and video recording
    • Log experiments with Weights & Biases or TensorBoard using the integrations described in the docs
    • Add custom environments and custom policies, both listed as supported in the feature table
    • Explore SB3-Contrib for experimental algorithms such as Recurrent PPO and Maskable PPO

Downloads

Strengths

  • Provides a common, consistent interface across algorithms, as described in the feature table
  • Includes documentation, custom environment and policy support, TensorBoard support, and type hints per the README
  • Has an active CI pipeline and is documented as a successor to Stable Baselines

Trade-offs

  • The README says development is now focused on bug fixes and maintenance, with no major changes planned
  • Requires some reinforcement learning knowledge to use effectively
  • Newer or experimental features live in separate repositories, so a full toolset means installing several projects

How it compares

ProjectStarsTypeLevelUpdatedBest for
stable-baselines3 (this)14kLibraryintermediate11 days agoResearchers who want a reliable baseline to compare a new method against
tianshou11kLibraryadvanced7 months agoResearchers who want to implement or modify reinforcement learning algorithms in PyTorch
annotated_deep_learning_paper_implementations67.6kLearning resourceintermediate4 days agoStudents learning how transformers, GANs, or optimizers work internally
FinGPT21.5kAI model / agentadvanced12 days agoDevelopers who want to experiment with finance-tuned LLMs for sentiment analysis
wandb11.3kLibrarybeginner4 days agoMachine learning engineers who want to compare training runs over time
Gymnasium12.8kLibraryintermediate7 days agoResearchers comparing reinforcement learning algorithms on the same environments

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.