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

Top-p version of the TokenProposal #51

Open
benlebrun opened this issue Jul 16, 2024 · 1 comment
Open

Top-p version of the TokenProposal #51

benlebrun opened this issue Jul 16, 2024 · 1 comment

Comments

@benlebrun
Copy link
Collaborator

Modify the top K TokenProposal to lazily materialize the set of most probable tokens with cumulative probability less than probability p.

@timvieira
Copy link
Collaborator

timvieira commented Jul 17, 2024

We might need to be more specific about which probability is covered up to p.

The key method in the TokenProposal is traverse_trie(context, p_llm), which returns an iterator over the possible next tokens token and their raw score p_llm(token | context) * p_guide(token | context). The challenge in defining the set of top-p tokens is that we cannot compute the normalization constant Z(context) = sum_{token} p_llm(token | context) * p_guide(token | context) without materializing the complete distribution.

Thus, for efficiency, the top-p set would need to be defined on the sum of p_llm(token | context) * p_guide(token | context). which could be really small if the llm and the guide disagree. However, if we rescaled it by Z(context) it would not be because we'd rescale it by the total agreement.

What did you have in mind @benlebrun ?

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