]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Work around for recalculating logits in cached prompts (Fixes #1585) (#1609)
authorDannyDaemonic <redacted>
Mon, 29 May 2023 12:13:40 +0000 (05:13 -0700)
committerGitHub <redacted>
Mon, 29 May 2023 12:13:40 +0000 (05:13 -0700)
* Work around for recalculating logits in cached prompts

examples/main/main.cpp

index c7c591537419c5631dde017958edac71799852b6..6131f5b4673041f60082355fccb7d6a650f5da38 100644 (file)
@@ -360,6 +360,12 @@ int main(int argc, char ** argv) {
                     }
                 }
                 if (i > 0) {
+                    // check if we've used up all the prompt but not all cached tokens
+                    if (embd.size() == i && n_session_consumed < (int) session_tokens.size()) {
+                        // force revaluation of the last token to recalculate logits
+                        i--;
+                        n_past--;
+                    }
                     embd.erase(embd.begin(), embd.begin() + i);
                 }
             }