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 Preference Loss and Refactor for Readability #484

Merged
merged 6 commits into from
Dec 20, 2024

Conversation

austin362667
Copy link
Collaborator

@austin362667 austin362667 commented Dec 17, 2024

Summary

Thanks to @winglian and @shivam15s noticed and fixed this #481.

This PR suggests negating the preference loss terms to align with the formulas in the docstrings, while maintaining the base preference structure as nll_loss + preference_loss. This would make our loss computations more consistent since both terms would represent losses to be minimized.

[UPDATE: It seems like being addressed now in here]
This PR also tightened the tolerance in case of encountering a similar issue.

Testing Done

  • Hardware Type:
  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence

Comment on lines 62 to 71
losses = -(
F.logsigmoid(self.beta * logits) * (1 - self.label_smoothing)
+ F.logsigmoid(-self.beta * logits) * self.label_smoothing
)
elif self.loss_type == "simpo":
logits = logits - (self.simpo_gamma / self.beta)
losses = (
losses = -(
F.logsigmoid(self.beta * logits) * (1 - self.label_smoothing)
+ F.logsigmoid(-self.beta * logits) * self.label_smoothing
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure! Thank you for reviewing.

Signed-off-by: Austin Liu <austin362667@gmail.com>
Signed-off-by: Austin Liu <austin362667@gmail.com>
@shivam15s shivam15s merged commit 15a2f58 into main Dec 20, 2024
5 checks passed
@shivam15s shivam15s deleted the preference-loss-sign branch December 20, 2024 23:17
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.

4 participants