Hub documentation
Using Stable-Baselines3 at Hugging Face
Single Sign-On (SSO) Audit Logs Storage Regions Data Studio for Private datasets Resource Groups (Access Control) Advanced Compute Options Advanced Security Tokens Management Publisher Analytics Gating Group Collections Network Security Rate Limits Blog Articles
PRO Plan Repositories Getting Started with Repositories Repository Settings Storage Limits Storage Backend (Xet) Local Cache Pull Requests & Discussions Notifications Collections Webhooks GitHub Actions Notebooks Next Steps Licenses
Models The Model Hub Model Cards Eval Results Leaderboard Data Gated Models Uploading Models Downloading Models Integrated Libraries
Datasets Adapters AllenNLP BERTopic Asteroid Diffusers ESPnet fastai Flair Keras TF-Keras (legacy) ML-Agents mlx-image MLX OpenCLIP PaddleNLP peft RL-Baselines3-Zoo Sample Factory Sentence Transformers SetFit spaCy SpanMarker SpeechBrain Stable-Baselines3 Stanza TensorBoard timm Transformers Transformers.js Unity Sentis
Model Widgets Model Inference Models Download Stats Model Release Checklist Local Apps Frequently Asked Questions Advanced Topics Datasets Overview Dataset Cards Gated Datasets Uploading Datasets Uploading Datasets (for LLMs) Downloading Datasets Streaming Datasets Integrated Libraries Data Studio Datasets Download Stats
Spaces Spaces Overview Spaces GPU Upgrades Spaces ZeroGPU Spaces Dev Mode Spaces Disk Usage & Storage Spaces Custom Domain Spaces as MCP servers Spaces as Agent Tools Spaces as API Endpoints Gradio Spaces Streamlit Spaces Static HTML Spaces Docker Spaces Embed your Space Run Spaces with Docker Spaces Configuration Reference Sign-In with HF button Featured Spaces Spaces Changelog Advanced Topics
Storage Buckets new Jobs Jobs Overview Quickstart Pricing and Billing Manage Jobs Configuration Popular Images Examples & Tutorials Schedule Jobs Webhook Automation Reference
Agents Agents Overview Hugging Face CLI for AI Agents Hugging Face MCP Server Hugging Face Agent Skills Building agents with the HF SDK Local Agents with llama.cpp Agent Libraries
Other Using Stable-Baselines3 at Hugging Face
stable-baselines3 is a set of reliable implementations of reinforcement learning algorithms in PyTorch.
Exploring Stable-Baselines3 in the Hub
You can find Stable-Baselines3 models by filtering at the left of the models page.
All models on the Hub come up with useful features:
- An automatically generated model card with a description, a training configuration, and more.
- Metadata tags that help for discoverability.
- Evaluation results to compare with other models.
- A video widget where you can watch your agent performing.
Install the library
To install the stable-baselines3 library, you need to install two packages:
stable-baselines3: Stable-Baselines3 library.huggingface-sb3: additional code to load and upload Stable-baselines3 models from the Hub.
pip install stable-baselines3
pip install huggingface-sb3Using existing models
You can simply download a model from the Hub using the load_from_hub function
checkpoint = load_from_hub(
repo_id="sb3/demo-hf-CartPole-v1",
filename="ppo-CartPole-v1.zip",
)You need to define two parameters:
--repo-id: the name of the Hugging Face repo you want to download.--filename: the file you want to download.
Sharing your models
You can easily upload your models using two different functions:
package_to_hub(): save the model, evaluate it, generate a model card and record a replay video of your agent before pushing the complete repo to the Hub.
package_to_hub(model=model,
model_name="ppo-LunarLander-v2",
model_architecture="PPO",
env_id=env_id,
eval_env=eval_env,
repo_id="ThomasSimonini/ppo-LunarLander-v2",
commit_message="Test commit")You need to define seven parameters:
--model: your trained model.--model_architecture: name of the architecture of your model (DQN, PPO, A2C, SAC…).--env_id: name of the environment.--eval_env: environment used to evaluate the agent.--repo-id: the name of the Hugging Face repo you want to create or update. It’s<your huggingface username>/<the repo name>.--commit-message.--filename: the file you want to push to the Hub.
push_to_hub(): simply push a file to the Hub
push_to_hub(
repo_id="ThomasSimonini/ppo-LunarLander-v2",
filename="ppo-LunarLander-v2.zip",
commit_message="Added LunarLander-v2 model trained with PPO",
)You need to define three parameters:
--repo-id: the name of the Hugging Face repo you want to create or update. It’s<your huggingface username>/<the repo name>.--filename: the file you want to push to the Hub.--commit-message.
Additional resources
- Hugging Face Stable-Baselines3 documentation
- Stable-Baselines3 documentation