Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 329297f

Browse filesBrowse files
committed
Bugfix: Missing logits_to_logprobs
1 parent d594892 commit 329297f
Copy full SHA for 329297f

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def _create_completion(
639639
self.detokenize([token]).decode("utf-8", errors="ignore")
640640
for token in all_tokens
641641
]
642-
all_logprobs = [Llama._logits_to_logprobs(row) for row in self.eval_logits]
642+
all_logprobs = [Llama.logits_to_logprobs(list(map(float, row))) for row in self.eval_logits]
643643
for token, token_str, logprobs_token in zip(
644644
all_tokens, all_token_strs, all_logprobs
645645
):
@@ -985,7 +985,7 @@ def token_bos() -> llama_cpp.llama_token:
985985
return llama_cpp.llama_token_bos()
986986

987987
@staticmethod
988-
def logits_to_logprobs(logits: List[llama_cpp.c_float]) -> List[llama_cpp.c_float]:
988+
def logits_to_logprobs(logits: List[float]) -> List[float]:
989989
exps = [math.exp(float(x)) for x in logits]
990990
sum_exps = sum(exps)
991-
return [llama_cpp.c_float(math.log(x / sum_exps)) for x in exps]
991+
return [math.log(x / sum_exps) for x in exps]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.