MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / gpt_params_parse

Function gpt_params_parse

external/ggml/examples/common.cpp:24–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
25 for (int i = 1; i < argc; i++) {
26 std::string arg = argv[i];
27
28 if (arg == "-s" || arg == "--seed") {
29 params.seed = std::stoi(get_next_arg(i, argc, argv, arg, params));
30 } else if (arg == "-t" || arg == "--threads") {
31 params.n_threads = std::stoi(get_next_arg(i, argc, argv, arg, params));
32 } else if (arg == "-p" || arg == "--prompt") {
33 params.prompt = get_next_arg(i, argc, argv, arg, params);
34 } else if (arg == "-n" || arg == "--n_predict") {
35 params.n_predict = std::stoi(get_next_arg(i, argc, argv, arg, params));
36 } else if (arg == "-np" || arg == "--n_parallel") {
37 params.n_parallel = std::stoi(get_next_arg(i, argc, argv, arg, params));
38 } else if (arg == "--top_k") {
39 params.top_k = std::stoi(get_next_arg(i, argc, argv, arg, params));
40 } else if (arg == "--top_p") {
41 params.top_p = std::stof(get_next_arg(i, argc, argv, arg, params));
42 } else if (arg == "--temp") {
43 params.temp = std::stof(get_next_arg(i, argc, argv, arg, params));
44 } else if (arg == "--repeat-last-n") {
45 params.repeat_last_n = std::stoi(get_next_arg(i, argc, argv, arg, params));
46 } else if (arg == "--repeat-penalty") {
47 params.repeat_penalty = std::stof(get_next_arg(i, argc, argv, arg, params));
48 } else if (arg == "-b" || arg == "--batch_size") {
49 params.n_batch= std::stoi(get_next_arg(i, argc, argv, arg, params));
50 } else if (arg == "-c" || arg == "--context") {
51 params.n_ctx= std::stoi(get_next_arg(i, argc, argv, arg, params));
52 } else if (arg == "-ngl" || arg == "--gpu-layers" || arg == "--n-gpu-layers") {
53 params.n_gpu_layers = std::stoi(get_next_arg(i, argc, argv, arg, params));
54 } else if (arg == "--ignore-eos") {
55 params.ignore_eos = true;
56 } else if (arg == "-m" || arg == "--model") {
57 params.model = get_next_arg(i, argc, argv, arg, params);
58 } else if (arg == "-i" || arg == "--interactive") {
59 params.interactive = true;
60 } else if (arg == "-ip" || arg == "--interactive-port") {
61 params.interactive = true;
62 params.interactive_port = std::stoi(get_next_arg(i, argc, argv, arg, params));
63 } else if (arg == "-h" || arg == "--help") {
64 gpt_print_usage(argc, argv, params);
65 exit(0);
66 } else if (arg == "-f" || arg == "--file") {
67 get_next_arg(i, argc, argv, arg, params);
68 std::ifstream file(argv[i]);
69 if (!file) {
70 fprintf(stderr, "error: failed to open file '%s'\n", argv[i]);
71 break;
72 }
73 std::copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), back_inserter(params.prompt));
74 if (params.prompt.back() == '\n') {
75 params.prompt.pop_back();
76 }
77 } else if (arg == "-tt" || arg == "--token_test") {
78 params.token_test = get_next_arg(i, argc, argv, arg, params);
79 }
80 else {
81 fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());

Callers 6

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 3

get_next_argFunction · 0.85
gpt_print_usageFunction · 0.85
copyFunction · 0.85

Tested by

no test coverage detected