diff --git a/tools/completion/completion.cpp b/tools/completion/completion.cpp index 58d598fcc0..a24482956e 100644 --- a/tools/completion/completion.cpp +++ b/tools/completion/completion.cpp @@ -146,13 +146,19 @@ int main(int argc, char ** argv) { ctx = llama_init->context(); model = llama_init->model(); - smpl = llama_init->sampler(0); if (ctx == NULL) { LOG_ERR("%s: error: unable to create context\n", __func__); return 1; } + if (model == NULL) { + LOG_ERR("%s: error: unable to load model\n", __func__); + return 1; + } + + smpl = llama_init->sampler(0); + llama_memory_t mem = llama_get_memory(ctx); const llama_vocab * vocab = llama_model_get_vocab(model);