Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 546938d

Browse filesBrowse files
JohannesGaesslertybalex
authored andcommitted
lookup: complement data from context with general text statistics (ggml-org#5479)
* lookup: evaluation tools, use corpus/previous gens * fixup! lookup: evaluation tools, use corpus/previous gens * fixup! lookup: evaluation tools, use corpus/previous gens * fixup! lookup: evaluation tools, use corpus/previous gens * fixup! lookup: evaluation tools, use corpus/previous gens
1 parent 83bad30 commit 546938d
Copy full SHA for 546938d

File tree

Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+29
-0
lines changed

‎examples/lookup/lookup.cpp

Copy file name to clipboardExpand all lines: examples/lookup/lookup.cpp
+29Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,35 @@ int main(int argc, char ** argv){
7474
t_draft_flat_us += ggml_time_us() - t_start_draft_us;
7575
}
7676

77+
llama_ngram_cache ngram_cache_context;
78+
llama_ngram_cache ngram_cache_dynamic;
79+
llama_ngram_cache ngram_cache_static;
80+
int64_t t_draft_flat_us = 0;
81+
int64_t t_draft_us = 0;
82+
83+
{
84+
// Fill up context ngram cache with tokens from user input:
85+
const int64_t t_start_draft_us = ggml_time_us();
86+
llama_ngram_cache_update(ngram_cache_context, LLAMA_NGRAM_MIN, LLAMA_NGRAM_MAX, inp, inp.size(), false);
87+
88+
if (!params.lookup_cache_static.empty()) {
89+
try {
90+
ngram_cache_static = llama_ngram_cache_load(params.lookup_cache_static);
91+
} catch (std::ifstream::failure const &) {
92+
fprintf(stderr, "error: failed to open static lookup cache: %s", params.lookup_cache_static.c_str());
93+
exit(1);
94+
}
95+
}
96+
97+
if (!params.lookup_cache_dynamic.empty()) {
98+
try {
99+
ngram_cache_dynamic = llama_ngram_cache_load(params.lookup_cache_dynamic);
100+
} catch (std::ifstream::failure const &) {} // if the file does not exist it will simply be created at the end of the program
101+
}
102+
103+
t_draft_flat_us += ggml_time_us() - t_start_draft_us;
104+
}
105+
77106
const int max_context_size = llama_n_ctx(ctx);
78107
const int max_tokens_list_size = max_context_size - 4;
79108

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.