llama : cont

ggml-ci
This commit is contained in:
Georgi Gerganov 2025-01-13 14:56:52 +02:00
parent f78b396ee7
commit e4550fbafc
No known key found for this signature in database
GPG key ID: 449E073F9DC10735
19 changed files with 128 additions and 79 deletions

View file

@ -88,6 +88,8 @@ int main(int argc, char ** argv) {
return 1;
}
const llama_kv_cache * kv = llama_get_kv_cache(ctx);
// initialize the sampler
llama_sampler * smpl = llama_sampler_chain_init(llama_sampler_chain_default_params());
llama_sampler_chain_add(smpl, llama_sampler_init_min_p(0.05f, 1));
@ -98,7 +100,7 @@ int main(int argc, char ** argv) {
auto generate = [&](const std::string & prompt) {
std::string response;
const bool is_first = llama_get_kv_cache_used_cells(ctx) == 0;
const bool is_first = llama_kv_cache_used_cells(kv) == 0;
// tokenize the prompt
const int n_prompt_tokens = -llama_tokenize(vocab, prompt.c_str(), prompt.size(), NULL, 0, is_first, true);
@ -113,7 +115,7 @@ int main(int argc, char ** argv) {
while (true) {
// check if we have enough space in the context to evaluate this batch
int n_ctx = llama_n_ctx(ctx);
int n_ctx_used = llama_get_kv_cache_used_cells(ctx);
int n_ctx_used = llama_kv_cache_used_cells(kv);
if (n_ctx_used + batch.n_tokens > n_ctx) {
printf("\033[0m\n");
fprintf(stderr, "context size exceeded\n");