]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
Do not crash when it has nothing to say. (#796)
authorSergey Alirzaev <redacted>
Thu, 6 Apr 2023 15:59:11 +0000 (17:59 +0200)
committerGitHub <redacted>
Thu, 6 Apr 2023 15:59:11 +0000 (17:59 +0200)
Otherwise observing this in the interactive mode:
/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_vector.h:1230: reference std::vector<int>::back() [_Tp = int, _Alloc = std::allocator<int>]: Assertion '!this->empty()' failed.

examples/main/main.cpp

index 453450a41d7d4544db8fbab3ada39ffabf4fa7a6..67a34e6677edfa30a84618beeefc277f2d0d9898 100644 (file)
@@ -431,7 +431,7 @@ int main(int argc, char ** argv) {
         }
 
         // end of text token
-        if (embd.back() == llama_token_eos()) {
+        if (!embd.empty() && embd.back() == llama_token_eos()) {
             if (params.instruct) {
                 is_interacting = true;
             } else {