Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add min_tokens argument #240

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

Closed
wants to merge 1 commit into from
Closed

Add min_tokens argument #240

wants to merge 1 commit into from

Conversation

Yard1
Copy link

@Yard1 Yard1 commented May 18, 2023

This PR adds a min_tokens argument to complement max_tokens. When set, the EOS token will be discarded until min_tokens have been generated.

Signed-off-by: Antoni Baum <[email protected]>
@Yard1
Copy link
Author

Yard1 commented May 19, 2023

@abetlen, could you review when you have a moment? Thank you!

@gjmulder gjmulder added enhancement New feature or request high-priority labels May 23, 2023
@abetlen
Copy link
Owner

abetlen commented May 26, 2023

Hey @Yard1 sorry to take so long on this reply. The issue I see with this at the moment is that the stop token is still being generated and appended to the eval_logits and eval_tokens internally. This will probably cause some kind of issue in generation, what you really want is a min_tokens inside of generate or something that essentially ignores / sets the eos token probability to 0 until a certain number of tokens are generated.

Also, it should probably be noted that fewer than min_tokens may be returned if e.g. another stop criteria like a stop sequence is encountered.

@abetlen
Copy link
Owner

abetlen commented May 26, 2023

The proposed change would be:

  • Add ignore_eos to sample
  • Move min_tokens check to generate and where the returned tokens is less than min_tokens set ignore_eos=True

@Yard1
Copy link
Author

Yard1 commented Jun 2, 2023

Got it, thanks! Let me take a look at this.

@Yard1
Copy link
Author

Yard1 commented Jun 2, 2023

Hmm, now that I think about it, this can be easily implemented through a LogitsProcessor. Therefore, we don't need a separate argument (and by extension, this PR). Let me know if that makes sense - we can close this PR then.

xaptronic pushed a commit to xaptronic/llama-cpp-python that referenced this pull request Jun 13, 2023
Also start adding prompts in "./prompts"
xaptronic pushed a commit to xaptronic/llama-cpp-python that referenced this pull request Jun 13, 2023
@IkariDevGIT
Copy link

any updates on this?

@abetlen abetlen force-pushed the main branch 2 times, most recently from 8c93cf8 to cc0fe43 Compare November 14, 2023 20:24
@twaka twaka mentioned this pull request Apr 8, 2024
@abetlen
Copy link
Owner

abetlen commented May 14, 2024

@Yard1 we've added the parameter to the server and it's available in the python API via a new MinTokensLogitProcessor

@abetlen abetlen closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high-priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants