Fix mirostatv2. (#338)
This commit is contained in:
parent
f036109110
commit
56995caa48
1 changed files with 5 additions and 0 deletions
|
@ -178,6 +178,11 @@ llama_token sample_token_mirostat_v2(llama_token_data_array * candidates, std::m
|
||||||
candidates->size = std::distance(candidates->data, std::find_if(candidates->data, candidates->data + candidates->size, [&](const llama_token_data & candidate) {
|
candidates->size = std::distance(candidates->data, std::find_if(candidates->data, candidates->data + candidates->size, [&](const llama_token_data & candidate) {
|
||||||
return -log2f(candidate.p) > *mu;
|
return -log2f(candidate.p) > *mu;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (candidates->size == 0) {
|
||||||
|
candidates->size = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize the probabilities of the remaining words
|
// Normalize the probabilities of the remaining words
|
||||||
llama_sample_softmax(nullptr, candidates);
|
llama_sample_softmax(nullptr, candidates);
|
||||||
// Sample the next word X from the remaining words
|
// Sample the next word X from the remaining words
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue