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

Initial Chat Template Implementation #901

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions operators/tokenizer/tokenizer_jsconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class TokenJsonConfig final {
bos_token_ = "<s>";
eos_token_ = "</s>";
unk_token_ = "<unk>";
chat_template_ = ""; // can add default chat template
return {};
}

Expand All @@ -90,6 +91,8 @@ class TokenJsonConfig final {
parse_token(json_config, "eos_token", eos_token_);
parse_token(json_config, "unk_token", unk_token_);

parse_token(json_config, "chat_template", chat_template_);

auto pad_iter = json_config.find("pad_token");
if (pad_iter != json_config.end() && pad_iter->is_string()) {
pad_token_ = json_config.value("pad_token", "");
Expand Down Expand Up @@ -244,6 +247,8 @@ class TokenJsonConfig final {
std::string unk_token_;
std::string pad_token_;

std::string chat_template_;

AddedTokenMap added_tokens_;

static AddedToken ParseAddedToken(const json& token) {
Expand Down
Loading