Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[winrate callback] remove redundant call to eval and train #2372

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions trl/trainer/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _generate_completions(
batch_size: int = 1,
) -> List[str]:
"""
Generates completions for a list of pre-formatted prompts.
Generates completions for a list of pre-formatted prompts from the given model.

Args:
prompts (List[str]): A list of input prompts for which completions are to be generated.
Expand All @@ -68,7 +68,6 @@ def _generate_completions(
"""
completions = []
with unwrap_model_for_generation(model, accelerator) as unwrapped_model:
unwrapped_model.eval()
for idx in range(0, len(prompts), batch_size):
batch = prompts[idx : idx + batch_size]
tokenized_batch = tokenizer(batch, return_tensors="pt", padding=True, truncation=True).to(model.device)
Expand All @@ -81,7 +80,6 @@ def _generate_completions(
generation = generation[len(prompt) :]
completion = tokenizer.decode(generation, skip_special_tokens=True)
completions.append(completion)
unwrapped_model.train()
return completions


Expand Down
Loading