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

fix tokenize_row in xPOTrainer #1683

Closed
wants to merge 1 commit into from
Closed

Conversation

AIR-hl
Copy link
Contributor

@AIR-hl AIR-hl commented May 30, 2024

  • Remove tokenize_row and build_tokenized_answer from DPOTrainer.py, ORPOTrainer.py and CPOTrainer.py;
  • Add tokenize_row and build_tokenized_answer to trainer/utils.py;
  • Modify the codes related to the function in the corresponding files;
  • Modify the parameter max_completion_length to max_target_length in ORPO in order to be consistent with DPO and CPO

Sorry for my multiple pr, I've never done it before, this is my first time contributing to a project. :(

Copy link
Contributor

@vwxyzjn vwxyzjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice refactoring. Thanks. CC @kashif for a check.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@kashif kashif self-requested a review May 30, 2024 13:57
@vwxyzjn
Copy link
Contributor

vwxyzjn commented May 30, 2024

Tests failing. @AIR-hl could you check?

@AIR-hl
Copy link
Contributor Author

AIR-hl commented May 30, 2024

Tests failing. @AIR-hl could you check?

I guess it’s because the default max_length in config is None. Normally, it would be initiated if it is None, but now tokenizer_now is separated, the max_length in args doesn't be initiated, I will try it fix

@kashif
Copy link
Collaborator

kashif commented May 30, 2024

btw the TRL maintainers might have an issue with arg being renamed due to backward compatibility... there is a mechanism i believe for deprecating things

@AIR-hl
Copy link
Contributor Author

AIR-hl commented May 30, 2024

btw the TRL maintainers might have an issue with arg being renamed due to backward compatibility... there is a mechanism i believe for deprecating things

btw the TRL maintainers might have an issue with arg being renamed due to backward compatibility... there is a mechanism i believe for deprecating things

Do I have any good idea? I am just a student who lacks practical experience

@kashif
Copy link
Collaborator

kashif commented May 30, 2024

for now perhaps lets not rename the arguments?

@AIR-hl
Copy link
Contributor Author

AIR-hl commented May 30, 2024

for now perhaps lets not rename the arguments?

max_completion_length in ORPO and max_target_length in DPO and CPO are equivalent in terms of function, is this due to irrational naming by the trl developers?
image
image

Maybe I can add a judgement in tokenize_row , such as:

if hasattr(args, "max_target_length"):
    max_length = object.max_target_length
elif hasattr(args, "max_completion_length"):
    max_length = object.max_completion_length
else:
    raise ValueError(f"You should set 'max_target_length' or 'max_completion_length' when using encode_decoder")

How do you think that?

@winglian
Copy link
Contributor

winglian commented Jun 3, 2024

I'm not sure this is a great change. This makes it near impossible to extend the functionality of tokenize_row. To modify the tokenize_row, a developer has no hooks to do so cleanly with this change, whereas at least a class method allows for this cleanly.

@AIR-hl AIR-hl closed this Jun 4, 2024
@AIR-hl AIR-hl deleted the tokenize_row branch June 18, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants