Skip to content

Commit d008733

Browse files
committed
examples : utilize new llama_get_logits_ith()
1 parent 4c72ab1 commit d008733

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

common/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ llama_token llama_sample_token(
905905

906906
llama_token id = 0;
907907

908-
float * logits = llama_get_logits(ctx) + idx * n_vocab;
908+
float * logits = llama_get_logits_ith(ctx, idx);
909909

910910
// Apply params.logit_bias map
911911
for (auto it = params.logit_bias.begin(); it != params.logit_bias.end(); it++) {

common/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ std::string llama_detokenize_bpe(
183183
// - ctx_guidance: context to use for classifier-free guidance, ignore if NULL
184184
// - grammar: grammar to use for sampling, ignore if NULL
185185
// - last_tokens: needed for repetition penalty, ignore if empty
186-
// - idx: sample from llama_get_logits(ctx) + idx * n_vocab
186+
// - idx: sample from llama_get_logits_ith(ctx, idx)
187187
//
188188
// returns:
189189
// - token: sampled token

examples/simple/simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int main(int argc, char ** argv) {
150150
}
151151

152152
auto n_vocab = llama_n_vocab(ctx);
153-
auto logits = llama_get_logits(ctx) + i_batch[i] * n_vocab;
153+
auto logits = llama_get_logits_ith(ctx, i_batch[i]);
154154

155155
std::vector<llama_token_data> candidates;
156156
candidates.reserve(n_vocab);

0 commit comments

Comments
 (0)