summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/main.c b/main.c
index 266bc34..bac9c43 100644
--- a/main.c
+++ b/main.c
@@ -53,7 +53,11 @@ static void process_request(struct llama_model *model, const char *user_prompt)
{ "user", user_prompt }
};
- prompt_len = llama_chat_apply_template(NULL, messages, 2, true, NULL, 0);
+ const char *tmpl = llama_model_chat_template(model, NULL);
+ if (!tmpl)
+ fprintf(stderr, "Warning: model has no embedded chat template\n");
+
+ prompt_len = llama_chat_apply_template(tmpl, messages, 2, true, NULL, 0);
if (prompt_len <= 0) {
fprintf(stderr, "Error: failed to calculate chat template size\n");
return;
@@ -87,7 +91,7 @@ static void process_request(struct llama_model *model, const char *user_prompt)
}
n_prompt_tokens = -llama_tokenize(vocab,
- prompt, prompt_len, NULL, 0, true, true);
+ prompt, prompt_len, NULL, 0, false, true);
if (n_prompt_tokens <= 0) {
fprintf(stderr, "Error: tokenization sizing failed\n");
@@ -106,7 +110,7 @@ static void process_request(struct llama_model *model, const char *user_prompt)
prompt_tokens = MALLOC((size_t)n_prompt_tokens * sizeof(llama_token));
if (llama_tokenize(vocab, prompt, prompt_len, prompt_tokens,
- n_prompt_tokens, true, true) < 0) {
+ n_prompt_tokens, false, true) < 0) {
fprintf(stderr, "Error: Tokenization failed\n");
free(prompt);
free(prompt_tokens);