ggml-org/llama.cpp

Include `eos_token` and `bos_token` from `tokenizer_config.json` for chat templating

Open

#5,040 创建于 2024年1月19日

在 GitHub 查看
 (12 评论) (4 反应) (0 负责人)C++ (18,202 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (110,169 star)
PR 合并指标
 (平均合并 6天 8小时) (30 天内合并 389 个 PR)

描述

Feature Description

Include (at minimum) eos_token and bos_token keys the huggingface tokenizer_config.json as gguf metadata keys.

Motivation

For chat models these differ from the normal eos and bos tokens and are required to stop the model generating user message tokens.

For example to correctly stop generation of chatml chat models you need to watch for the <|im_end|> token specified in the tokenizer_config.json below.

https://huggingface.co/mlabonne/NeuralBeagle14-7B/blob/main/tokenizer_config.json

however the gguf metadata doesn't include this token

image

using the chat_format alone without the eos_token causes generation to continue incorrectly past the end of the assistant respone.

image

Possible Implementation

I'm not too familiar with the gguf-py package but I think adding these to the SpecialVocab class and updating the _try_load_from_tokenizer_json would be a start. Not sure what the correct gguf key should be for these so as to not create confusion.

贡献者指南