8000 Move workaround to new sample method · coderonion/llama-cpp-python@353e18a · GitHub
[go: up one dir, main page]

Skip to content

Commit 353e18a

Browse files
committed
Move workaround to new sample method
1 parent a4a1bbe commit 353e18a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llama_cpp/llama.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ def sample(
169169
The sampled token.
170170
"""
171171
assert self.ctx is not None
172+
# Temporary workaround for https://github.com/ggerganov/llama.cpp/issues/684
173+
if temp == 0.0:
174+
temp = 1.0
175+
top_p = 0.0
176+
top_k = 1
172177
return llama_cpp.llama_sample_top_p_top_k(
173178
ctx=self.ctx,
174179
last_n_tokens_data=(llama_cpp.llama_token * self.last_n_tokens_size)(
@@ -209,11 +214,6 @@ def generate(
209214
Yields:
210215
The generated tokens.
211216
"""
212-
# Temporary workaround for https://github.com/ggerganov/llama.cpp/issues/684
213-
if temp == 0.0:
214-
temp = 1.0
215-
top_p = 0.0
216-
top_k = 1
217217
assert self.ctx is not None
218218
self.reset()
219219
while True:

0 commit comments

Comments
 (0)
0