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 min_p #680

Open
carterprince opened this issue Feb 11, 2025 · 4 comments
Open

Add min_p #680

carterprince opened this issue Feb 11, 2025 · 4 comments
Assignees
Labels
component:api Issues related to the API, not the SDK. status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement

Comments

@carterprince
Copy link

carterprince commented Feb 11, 2025

Description of the feature request:

Add the min_p sampler as an option in generation_config. See https://arxiv.org/abs/2407.01082

What problem are you trying to solve with this feature?

This sampler effectively solves the problem of incoherent outputs at high temperatures, allowing for better model creativity and stability with temperatures well above 1.0.

Image

Any other information you'd like to share?

No response

@gmKeshari gmKeshari added type:feature request New feature request/enhancement status:triaged Issue/PR triaged to the corresponding sub-team component:python sdk Issue/PR related to Python SDK labels Feb 13, 2025
@MarkDaoust MarkDaoust added component:api Issues related to the API, not the SDK. and removed component:python sdk Issue/PR related to Python SDK labels Feb 18, 2025
@demoncoder-crypto
Copy link

Is this issue about Api limitation? if not can I try to solve it?

@bhakarboy01
Copy link

Well, there is no direct parameter specified in gemini api documentation for setting min_p. Now, we could have calculated min_p using dynamic truncation as shown in the paper above, but that would also require the top_k tokens(and their probabilities), which are not given in the response generated. So, any other ideas to implement it?

@demoncoder-crypto
Copy link

So, the Google GenAI Python library doesn’t yet support something called min_p sampling, which is a function that helps the model stay creative and avoid making dull or repetitive responses, especially when using a higher temperature (which controls randomness). The idea is to filter out the really unlikely next-word options before the model picks one, but since the library doesn’t have this built-in yet, you’d have to work around it. That means making multiple API calls just to get the probability of each next word, then doing some calculations (based on a recent research paper) to adjust those probabilities manually. It’s definitely a bit heavy on resources and not super efficient, but it is possible if you really want to experiment with it. Hopefully, Google adds it natively soon to make this easier.

@demoncoder-crypto
Copy link

#724 You can see implementation here. Although very vague

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:api Issues related to the API, not the SDK. status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement
Projects
None yet
Development

No branches or pull requests

6 participants