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

compute perplexity from cross entropy #269

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

winglian
Copy link
Collaborator

@winglian winglian commented Jul 8, 2023

No description provided.

@winglian winglian marked this pull request as draft July 8, 2023 16:16
@casper-hansen
Copy link
Collaborator

casper-hansen commented Oct 17, 2023

If we want this to match other libraries, we probably want to do something like

ppl = exp(sum(loss_all_batches) / num_of_batch)

Huggingface also has its own. I think you can set batch_size=512

from evaluate import load
perplexity = load("perplexity", module_type="metric")

def compute_metrics(eval_pred):
    logits, labels = eval_pred
    predictions = np.argmax(logits, axis=-1)
    return perplexity.compute(predictions=predictions, model_id='llama')

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.

None yet

2 participants