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

Function main

examples/retrieval/retrieval.cpp:115–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115int main(int argc, char ** argv) {
116 std::setlocale(LC_NUMERIC, "C");
117
118 common_params params;
119
120 common_init();
121
122 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_RETRIEVAL, print_usage)) {
123 return 1;
124 }
125
126 // For BERT models, batch size must be equal to ubatch size
127 params.n_ubatch = params.n_batch;
128 params.embedding = true;
129
130 if (params.chunk_size <= 0) {
131 LOG_ERR("chunk_size must be positive\n");
132 return 1;
133 }
134 if (params.context_files.empty()) {
135 LOG_ERR("context_files must be specified\n");
136 return 1;
137 }
138
139 LOG_INF("processing files:\n");
140 for (auto & context_file : params.context_files) {
141 LOG_INF("%s\n", context_file.c_str());
142 }
143
144 std::vector<chunk> chunks;
145 for (auto & context_file : params.context_files) {
146 std::vector<chunk> file_chunk = chunk_file(context_file, params.chunk_size, params.chunk_separator);
147 chunks.insert(chunks.end(), file_chunk.begin(), file_chunk.end());
148 }
149 LOG_INF("Number of chunks: %zu\n", chunks.size());
150
151 llama_backend_init();
152 llama_numa_init(params.numa);
153
154 // load the model
155 auto llama_init = common_init_from_params(params);
156
157 auto * model = llama_init->model();
158 auto * ctx = llama_init->context();
159
160 if (model == NULL) {
161 LOG_ERR("%s: unable to load model\n", __func__);
162 return 1;
163 }
164
165 const llama_vocab * vocab = llama_model_get_vocab(model);
166
167 const int n_ctx_train = llama_model_n_ctx_train(model);
168 const int n_ctx = llama_n_ctx(ctx);
169
170 const enum llama_pooling_type pooling_type = llama_pooling_type(ctx);
171 if (pooling_type == LLAMA_POOLING_TYPE_NONE) {
172 LOG_ERR("%s: pooling type NONE not supported\n", __func__);

Callers

nothing calls this directly

Calls 15

common_initFunction · 0.85
common_params_parseFunction · 0.85
chunk_fileFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
common_init_from_paramsFunction · 0.85
llama_model_get_vocabFunction · 0.85
llama_model_n_ctx_trainFunction · 0.85
llama_n_ctxFunction · 0.85
common_tokenizeFunction · 0.85
llama_vocab_eosFunction · 0.85

Tested by

no test coverage detected