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

Samplers should know know their own SamplingParameters #1335

Open
dgerlanc opened this issue Dec 12, 2024 · 1 comment
Open

Samplers should know know their own SamplingParameters #1335

dgerlanc opened this issue Dec 12, 2024 · 1 comment

Comments

@dgerlanc
Copy link
Collaborator

What behavior of the library made you think about the improvement?

Since we already have classes for samplers, we should encapsulate the known behaviors of the samplers within that class.

How would you like it to behave?

Currently, the SamplingParameters are processed in conditional statement at line 431 of outlines/generate/api.py

I think we should move the generation of the sampling parameters to the individual sampler classes.

The new code in SequenceGeneratorAdapter would be:

def __init__(self, model, logits_processor, sampler):
    self.model = model
    self.logits_processor = logits_processor
    self.sampling_params = sampler.sampling_params()

And each of these classes would get a sampling_parameters property or method.

  • MultinomialSampler
  • GreedySampler
  • BeamSearchSampler

This will allow us to add new samplers without modifying the code in SequenceGeneratorAdapter

rlouf pushed a commit that referenced this issue Dec 16, 2024
This PR addresses #1335 
I have kept the `SamplingParameters` in `outlines/generate/api.py` cause
its imported at many places and may break examples ig.
Would you want to change that @dgerlanc ??
Otherwise if this looks good, I can make docs changes if needd, lmk.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@dgerlanc and others