Skip to content

Commit 3fc9147

Browse files
authored
Iterate over tokens that should be biased rather than the entire vocabulary. (ggml-org#851)
1 parent 9c8f4dc commit 3fc9147

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llama_cpp/server/app.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,9 @@ def logit_bias_processor(
601601
input_ids: npt.NDArray[np.intc],
602602
scores: npt.NDArray[np.single],
603603
) -> npt.NDArray[np.single]:
604-
new_scores = [None] * len(scores)
605-
for input_id, score in enumerate(scores):
606-
new_scores[input_id] = score + to_bias.get(input_id, 0.0)
607-
604+
new_scores = np.copy(scores) # Does it make sense to copy the whole array or can we just overwrite the original one?
605+
for input_id, score in to_bias.items():
606+
new_scores[input_id] = score + scores[input_id]
608607
return new_scores
609608

610609
return logit_bias_processor

0 commit comments

Comments
 (0)