]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
examples : fix is_first logic for tokenization (#14329)
authorGeorgi Gerganov <redacted>
Sun, 22 Jun 2025 17:10:07 +0000 (20:10 +0300)
committerGitHub <redacted>
Sun, 22 Jun 2025 17:10:07 +0000 (20:10 +0300)
ggml-ci

examples/simple-chat/simple-chat.cpp
tools/run/run.cpp

index 2aee0a919e60dda1e1b5dbcf2a5529a19587139e..cf1178043d8d1b7b7b957c4029769c09930a472b 100644 (file)
@@ -98,7 +98,7 @@ int main(int argc, char ** argv) {
     auto generate = [&](const std::string & prompt) {
         std::string response;
 
-        const bool is_first = llama_memory_seq_pos_max(llama_get_memory(ctx), 0) == 0;
+        const bool is_first = llama_memory_seq_pos_max(llama_get_memory(ctx), 0) == -1;
 
         // tokenize the prompt
         const int n_prompt_tokens = -llama_tokenize(vocab, prompt.c_str(), prompt.size(), NULL, 0, is_first, true);
index c65afd61e023cb24d38fcaa4379a9213e03f59bd..b8556515564a693cc71155eeb575d4e9ff07e0d6 100644 (file)
@@ -939,7 +939,7 @@ static int apply_chat_template(const struct common_chat_templates * tmpls, Llama
 // Function to tokenize the prompt
 static int tokenize_prompt(const llama_vocab * vocab, const std::string & prompt,
                            std::vector<llama_token> & prompt_tokens, const LlamaData & llama_data) {
-    const bool is_first = llama_memory_seq_pos_max(llama_get_memory(llama_data.context.get()), 0) == 0;
+    const bool is_first = llama_memory_seq_pos_max(llama_get_memory(llama_data.context.get()), 0) == -1;
 
     const int n_prompt_tokens = -llama_tokenize(vocab, prompt.c_str(), prompt.size(), NULL, 0, is_first, true);
     prompt_tokens.resize(n_prompt_tokens);