Update rl.py
This commit is contained in:
parent
eea3fe103d
commit
5cf02ec21e
1 changed files with 3 additions and 2 deletions
|
|
@ -21,11 +21,12 @@ def PatchRL(FastLanguageModel):
|
|||
|
||||
from trl.models.utils import unwrap_model_for_generation
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
||||
@contextmanager
|
||||
def unsloth_unwrap_model_for_generation(model, *args, **kwargs):
|
||||
FastLanguageModel.for_inference(model)
|
||||
yield unwrap_model_for_generation(model, *args, **kwargs)
|
||||
with unwrap_model_for_generation(model, *args, **kwargs) as unwrapped_model:
|
||||
yield unwrapped_model
|
||||
FastLanguageModel.for_training (model)
|
||||
pass
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue