Skip to content

Commit 1709a83

Browse files
authored
Update the oss runner to comptiable the passed tokenizer
Differential Revision: D79732133 Pull Request resolved: #13160
1 parent ec0e4a3 commit 1709a83

File tree

1 file changed

+13
-9
lines changed
  • examples/qualcomm/oss_scripts/llama/runner

1 file changed

+13
-9
lines changed

examples/qualcomm/oss_scripts/llama/runner/runner.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,20 @@ Error Runner::load() {
169169
ET_CHECK_MSG(false, "Unsupported llama evaluation mode");
170170
break;
171171
}
172-
173-
tokenizer_ = load_llama_tokenizer(tokenizer_path_, Version::Default);
174-
if (tokenizer_ == nullptr) {
175-
ET_LOG(Error, "Failed to load tokenizer with %s", tokenizer_path_.c_str());
176-
return Error::Internal;
172+
auto eos_ids = std::make_unique<std::unordered_set<uint64_t>>();
173+
if (tokenizer_ != nullptr) {
174+
eos_ids->insert(tokenizer_->encode("<|eot_id|>", 0, 0).get()[0]);
175+
eos_ids->insert(tokenizer_->encode("<|eot|>", 0, 0).get()[0]);
176+
eos_ids->insert(tokenizer_->encode("<|end_of_text|>", 0, 0).get()[0]);
177+
} else {
178+
tokenizer_ = load_llama_tokenizer(tokenizer_path_, Version::Default);
179+
if (tokenizer_ == nullptr) {
180+
ET_LOG(
181+
Error, "Failed to load tokenizer with %s", tokenizer_path_.c_str());
182+
return Error::Internal;
183+
}
184+
eos_ids->insert(tokenizer_->eos_tok());
177185
}
178-
179-
auto eos_ids = std::make_unique<std::unordered_set<uint64_t>>(
180-
std::unordered_set<uint64_t>{tokenizer_->eos_tok()});
181-
182186
if (decoder_model_version_ == DecoderModelVersion::kLlama3) {
183187
eos_ids->insert(tokenizer_->encode("<|eot_id|>", 0, 0).get()[0]);
184188
}

0 commit comments

Comments
 (0)