Skip to content

Handle null bos and eos token #66

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

Merged
merged 1 commit into from
May 1, 2025
Merged
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
11 changes: 9 additions & 2 deletions src/hf_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ Error HFTokenizer::load(const std::string& path) {

// Pull out the token strings
try {
const std::string bos_token = parsed_config_json.at("bos_token");
const std::string eos_token = parsed_config_json.at("eos_token");
const std::string bos_token =
parsed_config_json.contains("bos_token") && !parsed_config_json["bos_token"].is_null()
? parsed_config_json["bos_token"].get<std::string>()
: "";

const std::string eos_token =
parsed_config_json.contains("eos_token") && !parsed_config_json["eos_token"].is_null()
? parsed_config_json["eos_token"].get<std::string>()
: "";
const auto bos_res = special_token_map_->tryGetInteger(bos_token);
const auto eos_res = special_token_map_->tryGetInteger(eos_token);
if (!bos_res) {
Expand Down