-
Notifications
You must be signed in to change notification settings - Fork 126
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
Automatically calculate perplexity metrics for model supportability #1008
base: main
Are you sure you want to change the base?
Conversation
targets = np.roll(input_ids, -1, axis=1) | ||
|
||
# Use LogSoftMax here | ||
log_probs = torch.nn.functional.log_softmax(torch.tensor(logits), dim=1).numpy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_probs = torch.nn.functional.log_softmax(torch.tensor(logits), dim=1).numpy() | ||
|
||
batch_size, seq_length = targets.shape | ||
target_log_probs = log_probs[np.arange(batch_size)[:, None], np.arange(seq_length), targets] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_log_probs = 0 | ||
total_token_count = 0 | ||
|
||
for batch in dataset: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
logits = generator.compute_logits("logits") | ||
|
||
targets = np.roll(input_ids, -1, axis=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR aims to enhance our model validation process by automatically calculating the perplexity metrics if the model has the corresponding dataset. This will allow us to generate a strong report on the model's supportability, providing valuable insights into its performance and reliability.