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

Not all stop sequences are created equal #534

Closed

Conversation

zacharyblank
Copy link

@zacharyblank zacharyblank commented Jul 20, 2023

This PR fixes some stop sequences not being matched. When generating and decoding tokens, sometimes a single token will generate the stop sequence plus additional characters. This caused if seq.output_text.endswith(stop_str): not to behave as expected.

For example. If a stop sequence is defined as ", and the model generates "," as a single token, as is the case with EleutherAI/gpt-neox-20b, then the stop sequence will not be detected and generation will not stop.

This is a small PR that, instead of checking only the end of the generated sequence, checks the entire sequence for the stop sequence

Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! Can you fix the formatting error with format.sh? In addition, does this change lead to an O(N) string comparison at every iteration, which leads to O(N^2) general complexity? Will this affect the performance of long sequences? Can we somehow just compare stop_str with the newly generated token, instead of the whole sequence?

@claudiosv
Copy link

I believe #1724 is a dupe of this one. Would like to see this merged though.

@hmellor
Copy link
Collaborator

hmellor commented Mar 28, 2024

@zacharyblank is this PR still necessary? If yes, do you still plan to get it merged?

@njhill
Copy link
Member

njhill commented Mar 28, 2024

#3672 is a more complete fix for this.

@hmellor
Copy link
Collaborator

hmellor commented Mar 28, 2024

I'll close this in favour of yours @njhill

@hmellor hmellor closed this Mar 28, 2024
pi314ever pushed a commit to pi314ever/vllm that referenced this pull request Nov 23, 2024
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

Successfully merging this pull request may close these issues.

5 participants