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, ...
This commit is contained in:
HanishKVC 2024-04-20 11:44:15 +05:30
parent 0e4802b2ec
commit db6f775c93
2 changed files with 13 additions and 0 deletions

View file

@ -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");

View file

@ -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