Update rl.py

This commit is contained in:
Daniel Han 2025-02-05 06:41:37 -08:00
commit eed2ac7329

View file

@ -41,8 +41,8 @@ def PatchRL(FastLanguageModel):
# Must use for_inference to allow inference in Unsloth
FastLanguageModel.for_inference(model)
try:
unwrapped_model = unwrap_model_for_generation(model, *args, **kwargs)
yield unwrapped_model
with unwrap_model_for_generation(model, *args, **kwargs) as unwrapped_model:
yield unwrapped_model
finally:
# Finally return back training
FastLanguageModel.for_training(model)