From 029da9563f5fc8602dd03724044526f09849b00b Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:14:40 -0700 Subject: [PATCH] Avoid redundant function call in llamacpp_hf --- modules/llamacpp_hf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/llamacpp_hf.py b/modules/llamacpp_hf.py index 00da92ed..3cb5df1c 100644 --- a/modules/llamacpp_hf.py +++ b/modules/llamacpp_hf.py @@ -131,9 +131,10 @@ class LlamacppHF(PreTrainedModel): longest_prefix = min_length if longest_prefix > 0: - self.model.n_tokens = longest_prefix - self.model.eval(seq[longest_prefix:]) reset = False + self.model.n_tokens = longest_prefix + if len(seq_tensor) - longest_prefix > 0: + self.model.eval(seq[longest_prefix:]) if reset: self.model.reset()