Skip to main content
Once you have trained a model with SFTTrainer, DPOTrainer, GRPOTrainer, or any other TRL trainer, you can load it and run inference like any other Transformers model.

Load and generate

If you fine-tuned the model fully (without PEFT/LoRA), load it directly with the standard AutoModelForCausalLM class. Any trainer-specific components such as the value head from PPO training are automatically ignored:
Alternatively, use the pipeline API:

Load and use PEFT adapters

If you trained with LoRA or another PEFT method, load the base model and then apply the adapter on top:
With the adapter loaded, run generation as with a standard model.

Merge LoRA adapters into the base model

Merging adapters into the base model weights produces a single self-contained checkpoint that behaves exactly like a standard Transformers model — no PEFT dependency required at inference time.
Merged checkpoints are significantly larger than adapter-only checkpoints because they include all base model weights.
After merging and saving, load the merged model as any other standard model:

Push to the Hugging Face Hub

TRL trainers support pushing the trained model directly to the Hub at the end of training. Set push_to_hub=True in your training config:
Or push manually after training:
You can also use the standard Transformers API to push a loaded model:

Run an inference server

For production inference, consider running a dedicated inference server. The text-generation-inference library provides optimized serving for Transformers models, including models trained with TRL.