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

How do you calculate Efficacy Score for multi-token words in your counterfact dataset? #24

Closed
Zce1112zslx opened this issue Sep 13, 2022 · 1 comment

Comments

@Zce1112zslx
Copy link

Efficacy score can be calculated by P[o] and P[o*]. The object o can sometimes be tokenized to several sub-words (tokens) and in this case how do you calculate P[o]?

@kmeng01
Copy link
Owner

kmeng01 commented Sep 19, 2022

Hi! You can see how we do this in the eval code. tl;dr we multiply the probabilities, which is equivalent to summing logprobs: $$p(o) = \prod_{i \in o} p(w_i \mid w_{j < i}) = \exp \left( \log \prod_i p(w_i \mid w_{j < i}) \right) = \exp \left( \sum_i \log p(w_i \mid w_{j < i}) \right).$$

You'll notice that, in practice, we use negative log probabilities: $$p(o) = \exp \left( -\sum_i -\log p(w_i \mid w_{j < i}) \right)$$

Given $p(o), p(o^*)$, we can perform a direct comparison.

@kmeng01 kmeng01 closed this as completed Sep 21, 2022
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

No branches or pull requests

2 participants