From 789a194da14314fd12cd5fe9b9c4e9f4f28850a8 Mon Sep 17 00:00:00 2001 From: Minsoo Cheong Date: Sat, 23 Mar 2024 14:33:03 +0900 Subject: [PATCH] print error on insufficient batch size --- examples/retrieval/retrieval.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/retrieval/retrieval.cpp b/examples/retrieval/retrieval.cpp index 7cad37401..08902df91 100644 --- a/examples/retrieval/retrieval.cpp +++ b/examples/retrieval/retrieval.cpp @@ -171,7 +171,9 @@ int main(int argc, char ** argv) { for (auto & chunk : chunks) { auto inp = ::llama_tokenize(ctx, chunk.textdata, true, false); if (inp.size() > n_batch) { - inp.resize(n_batch); + // error: chunk size exceeds batch size + fprintf(stderr, "%s: error: chunk size (%zu) exceeds batch size (%zu), increase batch size and re-run\n",__func__, inp.size(), n_batch); + return 1; } // add eos if not present if (inp.empty() || inp.back() != llama_token_eos(model)) {