mirror of
https://git.adityakumar.xyz/llama.cpp.git
synced 2024-11-09 15:29:43 +00:00
Define non-positive temperature behavior (#720)
This commit is contained in:
parent
a0c0516416
commit
cd7fa95690
1 changed files with 14 additions and 0 deletions
14
llama.cpp
14
llama.cpp
|
@ -1194,6 +1194,20 @@ static llama_vocab::id llama_sample_top_p_top_k(
|
||||||
const auto & logits = lctx.logits;
|
const auto & logits = lctx.logits;
|
||||||
const auto * plogits = logits.data() + logits.size() - n_logits;
|
const auto * plogits = logits.data() + logits.size() - n_logits;
|
||||||
|
|
||||||
|
if (temp <= 0) {
|
||||||
|
// select the token with the highest logit directly
|
||||||
|
float max_logit = plogits[0];
|
||||||
|
llama_vocab::id max_id = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i < n_logits; ++i) {
|
||||||
|
if (plogits[i] > max_logit) {
|
||||||
|
max_logit = plogits[i];
|
||||||
|
max_id = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max_id;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::pair<float, llama_vocab::id>> logits_id;
|
std::vector<std::pair<float, llama_vocab::id>> logits_id;
|
||||||
logits_id.reserve(n_logits);
|
logits_id.reserve(n_logits);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue