Skip to content

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

Merged
ggerganov merged 1 commit intoggml-org:masterfrom
bakkot:handle-mislabeled-control-tokens
Sep 8, 2024
Merged

llama : set attrs of mislabelled EOT/EOM tokens#9348
ggerganov merged 1 commit intoggml-org:masterfrom
bakkot:handle-mislabeled-control-tokens

Conversation

@bakkot
Copy link
Copy Markdown
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
Copy Markdown
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 ggml-org:master Sep 8, 2024
@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
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
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