Skip to content

Commit 6595ad8

Browse files
committed
Add field to disable reseting between generations
1 parent 22fa5a6 commit 6595ad8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: llama_cpp/llama.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def generate(
218218
top_p: float,
219219
temp: float,
220220
repeat_penalty: float,
221+
reset: bool = True,
221222
) -> Generator[
222223
llama_cpp.llama_token, Optional[Sequence[llama_cpp.llama_token]], None
223224
]:
@@ -235,12 +236,14 @@ def generate(
235236
top_p: The top-p sampling parameter.
236237
temp: The temperature parameter.
237238
repeat_penalty: The repeat penalty parameter.
239+
reset: Whether to reset the model state.
238240
239241
Yields:
240242
The generated tokens.
241243
"""
242244
assert self.ctx is not None
243-
self.reset()
245+
if reset:
246+
self.reset()
244247
while True:
245248
self.eval(tokens)
246249
token = self.sample(

0 commit comments

Comments
 (0)