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

Add top_p_size step fn, StepFunctionArgs class #206

Merged
merged 2 commits into from
Jul 26, 2023
Merged

Add top_p_size step fn, StepFunctionArgs class #206

merged 2 commits into from
Jul 26, 2023

Conversation

gsarti
Copy link
Member

@gsarti gsarti commented Jul 26, 2023

Description

This PR adds the following capabilities to the Inseq library:

  • A new top_p_size_fn (identifier: "top_p_size") step function returning the number of tokens needed to reach probability p for a specific generation step (e.g. 5 with p=0.95 means that the top 5 tokens in the probability distribution over the vocabulary are needed to reach a CDF of 95%)

  • The kl_divergence step function now supports a new parameter top_p: float defined in [0,1] (default 1, full distribution) to preserve only tokens in the top p of either the original or the contrastive output distributions before computing the KL divergence between the two.

🔥 Breaking change: This PR introduces a new StepFunctionArgs to better structure the inputs to step function methods. This doesn't change anything in the usage of pre-registered functions, but functions that were previously registered with explicit default params (attribution_model, forward_output, encoder_input_ids, etc.) will now break, and should be converted to use StepFunctionArgs. The step function registration tutorial will be updated accordingly.

@gsarti gsarti merged commit 5ad7a7d into main Jul 26, 2023
4 checks passed
@gsarti gsarti deleted the step-fn-top-p branch July 26, 2023 11:09
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

1 participant