diff --git a/ctransformers/llm.py b/ctransformers/llm.py index 90cdfe2..20395b4 100644 --- a/ctransformers/llm.py +++ b/ctransformers/llm.py @@ -562,6 +562,7 @@ def _stream( stop = [stop] tokens = self.tokenize(prompt) + max_new_tokens = min(max_new_tokens, self.context_length - len(tokens) stop_regex = re.compile("|".join(map(re.escape, stop))) count = 0