Skip to content
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
16 changes: 12 additions & 4 deletions extension/llm/runner/text_llm_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@ Error TextLLMRunner::generate(
/*bos=*/config.num_bos,
/*eos=*/config.num_eos);

ET_CHECK_TK_OK_OR_RETURN_ERROR(
encode_res.error(), "Failed to encode prompt %s", prompt.c_str());
if (!encode_res.ok()) {
ET_LOG(
Error,
"Failed to encode prompt %s. Tokenizers error code %d",
prompt.c_str(),
static_cast<uint32_t>(encode_res.error()));
return Error::InvalidArgument;
}

// encode the (string) prompt into tokens sequence
std::vector<uint64_t> prompt_tokens = encode_res.get();
Expand Down Expand Up @@ -232,8 +238,10 @@ Error TextLLMRunner::generate(

Error TextLLMRunner::warmup(const std::string& prompt, int32_t max_new_tokens) {
// Create a GenerationConfig for warmup
GenerationConfig config{
.echo = false, .max_new_tokens = max_new_tokens, .warming = true};
GenerationConfig config;
config.echo = false;
config.max_new_tokens = max_new_tokens;
config.warming = true;

// Call generate with the warmup config
Error err = generate(prompt, config);
Expand Down
Loading