MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / main

Function main

examples/training/finetune.cpp:17–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#endif
16
17int main(int argc, char ** argv) {
18 std::setlocale(LC_NUMERIC, "C");
19
20 common_params params;
21 params.escape = false;
22
23 common_init();
24
25 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_FINETUNE)) {
26 return 1;
27 }
28
29 if (params.use_mmap) {
30 LOG_INF("%s: force disabling memory mapping because it would result in-read-only pointers to the weights\n",
31 __func__);
32 params.use_mmap = false;
33 }
34 if (params.cache_type_k != GGML_TYPE_F32) {
35 LOG_INF("%s: force changing k cache type to f32 due to a lack of f16 support for OUT_PROD\n", __func__);
36 params.cache_type_k = GGML_TYPE_F32;
37 }
38 if (params.cache_type_v != GGML_TYPE_F32) {
39 LOG_INF("%s: force changing v cache type to f32 due to a lack of f16 support for OUT_PROD\n", __func__);
40 params.cache_type_v = GGML_TYPE_F32;
41 }
42
43 llama_backend_init();
44 llama_numa_init(params.numa);
45 // load the model and apply lora adapter, if any
46 auto llama_init = common_init_from_params(params);
47
48 auto * model = llama_init->model();
49 auto * ctx = llama_init->context();
50
51 if (model == NULL) {
52 LOG_ERR("%s: unable to load model\n", __func__);
53 return 1;
54 }
55
56 // print system information
57 {
58 LOG_INF("\n");
59 LOG_INF("%s\n", common_params_get_system_info(params).c_str());
60 }
61
62 std::vector<llama_token> tokens = common_tokenize(ctx, params.prompt, true);
63 ggml_opt_dataset_t dataset = common_opt_dataset_init(ctx, tokens, llama_n_ctx(ctx) / 2);
64
65 struct lr_opt & lr = params.lr;
66 LOG_INF("-optimizer %s -lr0 %.2g -wd %.2g -lr-min %.2g -min-epochs %.2g -epochs %d -period %.2g -val %.2g\n",
67 ggml_opt_optimizer_name(params.optimizer), (double) lr.lr0, (double) lr.wd, (double) lr.lr_min, (double) lr.decay_epochs,
68 (unsigned) lr.epochs, (double) params.n_batch / params.n_ubatch, (double) params.val_split);
69
70 struct llama_opt_params lopt_params{
71 /*n_ctx_train =*/0,
72 /*param_filter =*/llama_opt_param_filter_all,
73 /*param_filter_ud =*/nullptr,
74 /*get_opt_pars =*/common_opt_lr_pars,

Callers

nothing calls this directly

Calls 15

common_initFunction · 0.85
common_params_parseFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
common_init_from_paramsFunction · 0.85
common_tokenizeFunction · 0.85
common_opt_dataset_initFunction · 0.85
llama_n_ctxFunction · 0.85
ggml_opt_optimizer_nameFunction · 0.85
llama_opt_initFunction · 0.85
ggml_opt_dataset_ndataFunction · 0.85

Tested by

no test coverage detected