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

llama : set attrs of mislabelled EOT/EOM tokens #9348

Merged

Conversation

bakkot
Copy link
Contributor

@bakkot bakkot commented Sep 7, 2024

Some models (such as the official phi-3-mini-4k-instruct-gguf) have an <|end|> or similar token which is detected as being EOT or EOM but which is not marked as control.

This causes issues where the token will be included in the output when it shouldn't. A complete reproduction is to install the phi-3-mini-4k-instruct-gguf linked above and then run

./llama-cli -m ./models/Phi-3-mini-4k-instruct-q4.gguf --prompt "What kind of thing is a llama? Response: " --no-display-prompt --temp 0 --grammar 'root ::= "animal" | "object"'

which will print animal<|end|>.

In these cases, manually set the token's attr to LLAMA_TOKEN_ATTR_CONTROL so that we know not to print it. That fixes the above repro to correctly print just animal.

Copy link
Collaborator

@compilade compilade left a comment

Choose a reason for hiding this comment

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

Note that reconverting the Phi-3 models since #8228 should mark <|end|> as CONTROL.

But we have no control over the "official" models.

@ggerganov ggerganov merged commit fbb7fcf into ggerganov:master Sep 8, 2024
52 checks passed
@bakkot bakkot deleted the handle-mislabeled-control-tokens branch September 8, 2024 11:59
dsx1986 pushed a commit to dsx1986/llama.cpp that referenced this pull request Oct 29, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 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.

3 participants