Skip to content

Commit 2483676

Browse files
Work around for recalculating logits in cached prompts (Fixes #1585) (#1609)
* Work around for recalculating logits in cached prompts
1 parent 0e730dd commit 2483676

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/main/main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ int main(int argc, char ** argv) {
360360
}
361361
}
362362
if (i > 0) {
363+
// check if we've used up all the prompt but not all cached tokens
364+
if (embd.size() == i && n_session_consumed < (int) session_tokens.size()) {
365+
// force revaluation of the last token to recalculate logits
366+
i--;
367+
n_past--;
368+
}
363369
embd.erase(embd.begin(), embd.begin() + i);
364370
}
365371
}

0 commit comments

Comments
 (0)