Skip to content

Stop after first EOS post-prompt #2255

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 2 additions & 8 deletions examples/models/llama2/runner/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ Error Runner::generate(
int next; // will store the next token in the sequence
int64_t pos = num_prompt_tokens - 1; // position in the sequence
int token = prompt_tokens[pos]; // prefill starts from 0 to num_prompt_tokens
int eos_counter = 0; // counter to capture EOS
int logits_index = 0; // index of the logits tensor in the output
int k_cache_index = 0;
int v_cache_index = 0;
Expand Down Expand Up @@ -340,13 +339,8 @@ Error Runner::generate(

// data-dependent terminating condition: we have n_eos_ number of EOS
if (pos >= num_prompt_tokens && next == eos_id_) {
eos_counter++;
if (eos_counter == n_eos_) {
ET_LOG(Info, "Reached to the end of generation");
break;
}
} else {
eos_counter = 0;
ET_LOG(Info, "Reached to the end of generation");
break;
}

token = next;
Expand Down