CoolFace
Datasetpublic

echodict/llama.cpp

version https://git-lfs.github.com/spec/v1 oid sha256:cfc44b7ba25614df70e6b65e3341cae0310163bd32fd31a6b928a542df433faf size 30786

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes765downloads
lookup-merge.cpp51 linesDownload Raw Back to lookup
1#include "ggml.h"2#include "llama.h"3#include "common.h"4#include "ngram-cache.h"5 6#include <clocale>7#include <cstdint>8#include <cstdio>9#include <fstream>10#include <iostream>11#include <string>12#include <unordered_map>13#include <vector>14 15static void print_usage(char* argv0) {16    fprintf(stderr, "Merges multiple lookup cache files into a single one.\n");17    fprintf(stderr, "Usage: %s [--help] lookup_part_1.bin lookup_part_2.bin ... lookup_merged.bin\n", argv0);18}19 20int main(int argc, char ** argv){21    std::setlocale(LC_NUMERIC, "C");22 23    if (argc < 3) {24        print_usage(argv[0]);25        exit(1);26    }27 28    std::vector<std::string> args;29    args.resize(argc-1);30    for (int i = 0; i < argc-1; ++i) {31        args[i] = argv[i+1];32        if (args[i] == "-h" || args[i] == "--help") {33            print_usage(argv[0]);34            exit(0);35        }36    }37 38    fprintf(stderr, "lookup-merge: loading file %s\n", args[0].c_str());39    common_ngram_cache ngram_cache_merged = common_ngram_cache_load(args[0]);40 41    for (size_t i = 1; i < args.size()-1; ++i) {42        fprintf(stderr, "lookup-merge: loading file %s\n", args[i].c_str());43        common_ngram_cache ngram_cache = common_ngram_cache_load(args[i]);44 45        common_ngram_cache_merge(ngram_cache_merged, ngram_cache);46    }47 48    fprintf(stderr, "lookup-merge: saving file %s\n", args.back().c_str());49    common_ngram_cache_save(ngram_cache_merged, args.back());50}51