Skip to content

Commit 8a1974a

Browse files
tarceymounta11n
authored andcommitted
llama : fix typical sampling (ggml-org#4261)
Typical sampling was broken because after copying new_candidates into canditates, the "sorted" bool is left at "true", but the new data is no longer sorted according to probability. Patch to set "sorted" to false. Test: Generating with temp=0.0001 (approx. argmax) should generate the same sequence at typical>=1.0 and typical=0.9999 (approx. disabled, but enters the typical sampling codepath).
1 parent e2d614f commit 8a1974a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llama.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -7034,6 +7034,7 @@ void llama_sample_typical(struct llama_context * ctx, llama_token_data_array * c
70347034
// Replace the data in candidates with the new_candidates data
70357035
std::copy(new_candidates.begin(), new_candidates.end(), candidates->data);
70367036
candidates->size = new_candidates.size();
7037+
candidates->sorted = false;
70377038

70387039
if (ctx) {
70397040
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;

0 commit comments

Comments
 (0)