MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / common_params_parser_init

Function common_params_parser_init

subprojects/llama.cpp/common/arg.cpp:981–3788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979}
980
981common_params_context common_params_parser_init(common_params & params, llama_example ex, void(*print_usage)(int, char **)) {
982 // per-example default params
983 // we define here to make sure it's included in llama-gen-docs
984 if (ex == LLAMA_EXAMPLE_COMPLETION) {
985 params.use_jinja = false; // disable jinja by default
986
987 } else if (ex == LLAMA_EXAMPLE_MTMD) {
988 params.use_jinja = false; // disable jinja by default
989 params.sampling.temp = 0.2; // lower temp by default for better quality
990
991 } else if (ex == LLAMA_EXAMPLE_SERVER) {
992 params.n_parallel = -1; // auto by default
993 }
994
995 params.use_color = tty_can_use_colors();
996
997 // load dynamic backends
998 ggml_backend_load_all();
999
1000 common_params_context ctx_arg(params);
1001 ctx_arg.print_usage = print_usage;
1002 ctx_arg.ex = ex;
1003
1004 std::string sampler_type_chars;
1005 std::string sampler_type_names;
1006 for (const auto & sampler : params.sampling.samplers) {
1007 sampler_type_chars += common_sampler_type_to_chr(sampler);
1008 sampler_type_names += common_sampler_type_to_str(sampler) + ";";
1009 }
1010 if (!sampler_type_names.empty()) {
1011 sampler_type_names.pop_back(); // remove last semicolon
1012 }
1013
1014
1015 /**
1016 * filter options by example
1017 * rules:
1018 * - all examples inherit options from LLAMA_EXAMPLE_COMMON
1019 * - if LLAMA_EXAMPLE_* is set (other than COMMON), we only show the option in the corresponding example
1020 * - if both {LLAMA_EXAMPLE_COMMON, LLAMA_EXAMPLE_*,} are set, we will prioritize the LLAMA_EXAMPLE_* matching current example
1021 */
1022 auto add_opt = [&](common_arg arg) {
1023 if ((arg.in_example(ex) || arg.in_example(LLAMA_EXAMPLE_COMMON)) && !arg.is_exclude(ex)) {
1024 ctx_arg.options.push_back(std::move(arg));
1025 }
1026 };
1027
1028
1029 add_opt(common_arg(
1030 {"-h", "--help", "--usage"},
1031 "print usage and exit",
1032 [](common_params & params) {
1033 params.usage = true;
1034 }
1035 ));
1036 add_opt(common_arg(
1037 {"--version"},
1038 "show version and build info",

Callers 5

mainFunction · 0.85
common_preset_contextMethod · 0.85
arg.cppFile · 0.85
common_params_to_mapFunction · 0.85
common_params_parseFunction · 0.85

Calls 15

tty_can_use_colorsFunction · 0.85
ggml_backend_load_allFunction · 0.85
common_argClass · 0.85
parse_cpu_maskFunction · 0.85
parse_cpu_rangeFunction · 0.85
parse_csv_rowFunction · 0.85

Tested by 1

mainFunction · 0.68