preserve "prev" length during rollback

This commit is contained in:
l3utterfly 2024-01-31 10:42:28 +09:00
parent a5c3f30cb6
commit d5f4dec935

View file

@ -335,5 +335,9 @@ void llama_sampling_rollback(
rollback_num = ctx_sampling->prev.size();
}
// remove rollback_num elements from the end
ctx_sampling->prev.erase(ctx_sampling->prev.end() - rollback_num, ctx_sampling->prev.end());
// Insert rollback_num zeros at the beginning to preserve the size of prev
ctx_sampling->prev.insert(ctx_sampling->prev.begin(), rollback_num, 0);
}