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

Stop the generation when <|eom_id|> token is encountered (needed for llama 3.1 tool call support) #8858

Merged
merged 5 commits into from
Aug 5, 2024

Conversation

fairydreaming
Copy link
Collaborator

@fairydreaming fairydreaming commented Aug 4, 2024

This PR adds support for <|eom_id|> token introduced by llama 3.1 models. It adds the EOM token to the list of tokens that stop the generation. This is necessary to allow proper tool call support, see https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1/ for more details.

Note that it doesn't add any tool call support in llama.cpp, it only stops the generation after <|eom_id|> to allow implementation of tool calls in other software that uses llama.cpp for inference.

I don't feel confident enough to tinker with LlamaModel::set_vocab() in convert_hf_to_gguf.py script to explicitly set the EOM token value during conversion, so it's currently found during vocabulary loading like EOT tokens.

I created a simple script allowing to test the llama 3.1 tool calling with llama-server: https://github.com/fairydreaming/tlcl

@github-actions github-actions bot added the python python script changes label Aug 4, 2024
@fairydreaming fairydreaming merged commit d3f0c71 into ggerganov:master Aug 5, 2024
54 checks passed
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Aug 7, 2024
… Llama 3.1 tool call support (ggerganov#8858)

* gguf-py, llama : add constants and methods related to Llama-3.1 <|eom_id|> token

* llama : find Llama-3.1 <|eom_id|> token id during vocab loading

* llama-vocab : add Llama-3.1 <|eom_id|> token to the set of tokens stopping the generation

---------

Co-authored-by: Stanisław Szymczyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python python script changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants