diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 587fcb036..57cc1e486 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -204,7 +204,7 @@ int main(int argc, char ** argv) { // if we will use the cache for the full prompt without reaching the end of the cache, force // reevaluation of the last token token to recalculate the cached logits - if (embd_inp.size() && n_matching_session_tokens == embd_inp.size() && + if (!embd_inp.empty() && n_matching_session_tokens == embd_inp.size() && session_tokens.size() > embd_inp.size()) { session_tokens.resize(embd_inp.size() - 1); }