Skip to content

Commit

Permalink
Init llama_context_params properly from CLI (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Mar 22, 2023
1 parent 56817b1 commit 928480e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,10 @@ struct llama_context * llama_init_from_file(

llama_context * ctx = new llama_context;

if (params.seed <= 0) {
params.seed = time(NULL);
}

ctx->rng = std::mt19937(params.seed);
ctx->logits_all = params.logits_all;

Expand Down
5 changes: 4 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ int main(int argc, char ** argv) {
{
auto lparams = llama_context_default_params();

lparams.f16_kv = params.memory_f16;
lparams.n_ctx = params.n_ctx;
lparams.n_parts = params.n_parts;
lparams.seed = params.seed;
lparams.f16_kv = params.memory_f16;
lparams.logits_all = params.perplexity;

ctx = llama_init_from_file(params.model.c_str(), lparams);
Expand Down

0 comments on commit 928480e

Please sign in to comment.