Skip to content

Commit

Permalink
Fixed wrong trigger for warning (#971)
Browse files Browse the repository at this point in the history
func.__code__.co_varnames was used to count the function arguments for formatting_func. This code actually counted the function variables rather than function parameters.
  • Loading branch information
zabealbe authored Nov 15, 2023
1 parent e140d22 commit 28bdb6a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions trl/trainer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,7 @@ def __init__(
self.formatting_func = formatting_func

if formatting_func is not None:
formatting_func_signature = formatting_func.__code__.co_varnames
if len(formatting_func_signature) > 1:
if formatting_func.__code__.co_argcount > 1:
warnings.warn(
"The passed formatting_func has more than one argument. Usually that function should have a single argument `example`"
" which corresponds to the dictionary returned by each element of the dataset. Make sure you know what you are doing."
Expand Down

0 comments on commit 28bdb6a

Please sign in to comment.