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

Adjust better score reporting #2191

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

vince62s
Copy link
Member

@vince62s vince62s commented Sep 6, 2022

Behavior before this PR:
if length_penalty = none
AVG SCORE = total logprobs of all sentences / total nb of words ===> ("average per word log prob")
PPL = exp(above) ===> ("average per word perplexity" even if not really relevant)
if length_penalty = avg (or wu)
AVG SCORE and PPL are completely wrong since scores were normalized twice.

Behavior after this PR:
if length_penalty = none
SCORE = total logprobs of all sentences / number of sentences ===> (gives an average score per sentence, but again not 100% precise, we would need to report scores at the sentence level and then average)
PPL = exp (above) ===> Approx of a per sentence perplexity
if length_penalty = avg (or wu)
SCORE = total normalized logprob (per token) / number of sentences ===> average normalized log prob
PPL = exp(above) ===> Approx 'average per word perplexity' similar to the case none before this PR.

msg = "%s AVG SCORE: %.4f, %s PPL: %.4f" % (
score = score_total / nb_sentences
ppl = np.exp(-score_total.item() / nb_sentences)
msg = "%s SCORE: %.4f, %s PPL: %.2f NB SENTENCES: %d" % (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the change.
Can we just add a comment that the ppl might contain a length penalty term, even if it was already the case before.

I think you forget the file with the length_penalty and alpha

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you forget the file with the length_penalty and alpha

another PR is better.

Can we just add a comment that the ppl might contain a length penalty term, even if it was already the case before.

I think the comments in the code are good enough.

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry, I missed the comments

@francoishernandez francoishernandez merged commit dcca072 into OpenNMT:master Sep 6, 2022
@vince62s vince62s deleted the reportscore branch September 6, 2022 17: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.

3 participants