From 864dcb26fb2f74453f223a9cc100768530e7a391 Mon Sep 17 00:00:00 2001 From: Gary Linscott Date: Sun, 2 Apr 2023 20:16:15 -0700 Subject: [PATCH] updates --- examples/perplexity/perplexity.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/perplexity/perplexity.cpp b/examples/perplexity/perplexity.cpp index d8195a1f8..eb456fcfa 100644 --- a/examples/perplexity/perplexity.cpp +++ b/examples/perplexity/perplexity.cpp @@ -34,7 +34,7 @@ void perplexity(llama_context * ctx, const gpt_params & params) { for (int i = 0; i < seq_count; ++i) { int start = i * params.n_ctx; - int end = start + params.n_ctx - 1; + int end = start + params.n_ctx; std::vector logits; int num_batches = (params.n_ctx + params.n_batch - 1) / params.n_batch; @@ -66,8 +66,7 @@ void perplexity(llama_context * ctx, const gpt_params & params) { // Example, we have a context window of 512, we will compute perplexity for each of the // last 256 tokens. Then, we split the input up into context window size chunks to // process the entire prompt. - - for (int j = params.n_ctx / 2; j < params.n_ctx - 1; ++j) { + for (int j = std::min(512, params.n_ctx / 2); j < params.n_ctx - 1; ++j) { // Calculate probability of next token, given the previous ones. std::vector tok_logits( logits.begin() + j * n_vocab,