diff --git a/main.cpp b/main.cpp index f02b5dd..10fa501 100644 --- a/main.cpp +++ b/main.cpp @@ -782,8 +782,10 @@ int main(int argc, char ** argv) { // tokenize the prompt std::vector embd_inp = ::llama_tokenize(vocab, params.prompt, true); - - params.n_predict = std::min(params.n_predict, model.hparams.n_ctx - (int) embd_inp.size()); + if (embd_inp.size() + params.n_predict > model.hparams.n_ctx) { + int offset = embd_inp.size() - model.hparams.n_ctx + params.n_predict; + embd_inp = std::vector(embd_inp.begin() + offset, embd_inp.end()); + } printf("\n"); printf("%s: prompt: '%s'\n", __func__, params.prompt.c_str());