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 beam search #258

Closed
cartazio opened this issue Aug 22, 2023 · 5 comments · Fixed by #618
Closed

Add beam search #258

cartazio opened this issue Aug 22, 2023 · 5 comments · Fixed by #618
Labels
enhancement transformers Linked to the `transformers` integration

Comments

@cartazio
Copy link

Hello! I'm trying to understand the capabilities of the current interface, and it seems like kwargs aren't passed to the underlying models, are they? I'd like to do stuff like beam search so i can get useful structured queries that are "good quality"

@cartazio
Copy link
Author

to be clear: i'm also happy to write a patch for it if thats feasible

@brandonwillard
Copy link
Member

to be clear: i'm also happy to write a patch for it if thats feasible

Patches/PRs are always welcome! In cases of large or complicated changes, we do prefer to have high-level discussions first, though, so that we make the best use of contributors' time.

@mattkindy
Copy link
Contributor

Did anything come of this discussion privately?

@brandonwillard
Copy link
Member

Did anything come of this discussion privately?

We've been working on improving the performance of the basic sampling steps recently and will start addressing alternative approaches soon after.

@rlouf rlouf changed the title is there support for beam search? Add beam search Nov 6, 2023
@rlouf rlouf added the transformers Linked to the `transformers` integration label Jan 26, 2024
@rlouf
Copy link
Member

rlouf commented Feb 6, 2024

Now that #416 has been merged we can consider implementing Beam Search in Outlines.

The samplers currently return next token ids. We will now need them to return the next token ids, as well as the "ancestor" of these token ids, i.e. the sequences to which they need to be appended. The list of ancestors will allow to update:

  1. The sequences by adding new token ids to the ancestors; `token_ids = update_token_ids(token_ids, next_token_ids, ancestors)
  2. The cumulative log-probability of the sequences: `logprobs = update_logprobs(logprobs, token_ids, logits, ancestors)
  3. The KV-cache kv_cache = update_kv_cache(kv_cache, ancestors)
  4. The FSMs and FSM states

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement transformers Linked to the `transformers` integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants