From db6f775c93848a56ccee8d53b0eaaaa76e53e409 Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Sat, 20 Apr 2024 11:44:15 +0530 Subject: [PATCH] Common:ChatOn: Add arguments for chaton user needs to pass --chaton TEMPLATE_ID TEMPLATE_ID will be one of the predefined chat templates already in llama.cpp's llama_chat_apply_template_internal and related like chatml, llama2, llama3, ... --- common/common.cpp | 11 +++++++++++ common/common.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/common/common.cpp b/common/common.cpp index cf69535e2..b704d6f1f 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -868,6 +868,15 @@ bool gpt_params_find_arg(int argc, char ** argv, const std::string & arg, gpt_pa params.chatml = true; return true; } + if (arg == "--chaton") { + params.chaton = true; + if (++i >= argc) { + invalid_param = true; + return true; + } + params.chaton_template_id = argv[i]; + return true; + } if (arg == "--infill") { params.infill = true; return true; @@ -1378,6 +1387,8 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) { printf(" --version show version and build info\n"); printf(" -i, --interactive run in interactive mode\n"); printf(" --interactive-first run in interactive mode and wait for input right away\n"); + printf(" --chaton TEMPLATE_ID allow the interactive mode to apply the specified chat template before sending user input to model (you need to specify -i also)\n"); + printf(" TEMPLATE_ID could be chatml, llama3, ...\n"); printf(" -ins, --instruct run in instruction mode (use with Alpaca models)\n"); printf(" -cml, --chatml run in chatml mode (use with ChatML-compatible models)\n"); printf(" --multiline-input allows you to write or paste multiple lines without ending each in '\\'\n"); diff --git a/common/common.h b/common/common.h index cca44268e..931317c83 100644 --- a/common/common.h +++ b/common/common.h @@ -139,6 +139,8 @@ struct gpt_params { bool use_color = false; // use color to distinguish generations and inputs bool interactive = false; // interactive mode bool chatml = false; // chatml mode (used for models trained on chatml syntax) + bool chaton = false; // chaton mode (used to chat with models which have been trained for chat and or instruct operation) + std::string chaton_template_id = ""; // the internal chat template to use bool prompt_cache_all = false; // save user input and generations to prompt cache bool prompt_cache_ro = false; // open the prompt cache read-only and do not update it