echodict/llama.cpp
version https://git-lfs.github.com/spec/v1 oid sha256:cfc44b7ba25614df70e6b65e3341cae0310163bd32fd31a6b928a542df433faf size 30786
0773
1#include "arg.h"2#include "common.h"3#include "ngram-cache.h"4#include "llama.h"5 6#include <clocale>7#include <string>8#include <vector>9 10int main(int argc, char ** argv){11 std::setlocale(LC_NUMERIC, "C");12 13 common_params params;14 15 common_init();16 17 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_LOOKUP)) {18 return 1;19 }20 21 // init llama.cpp22 llama_backend_init();23 llama_numa_init(params.numa);24 25 // load the model26 auto llama_init = common_init_from_params(params);27 28 auto * model = llama_init->model();29 auto * ctx = llama_init->context();30 31 GGML_ASSERT(model != nullptr);32 33 // tokenize the prompt34 std::vector<llama_token> inp;35 inp = common_tokenize(ctx, params.prompt, true, true);36 fprintf(stderr, "%s: tokenization done\n", __func__);37 38 common_ngram_cache ngram_cache;39 common_ngram_cache_update(ngram_cache, LLAMA_NGRAM_STATIC, LLAMA_NGRAM_STATIC, inp, inp.size(), true);40 fprintf(stderr, "%s: hashing done, writing file to %s\n", __func__, params.speculative.lookup_cache_static.c_str());41 42 common_ngram_cache_save(ngram_cache, params.speculative.lookup_cache_static);43 44 return 0;45}46 