Skip to content

Commit

Permalink
If n_predict == -1, generate forever
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Mar 25, 2023
1 parent e2d490d commit 79b2b26
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/chat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ cd ..
#
# "--keep 48" is based on the contents of prompts/chat-with-bob.txt
#
./main -m ./models/7B/ggml-model-q4_0.bin -c 2048 -b 1024 -n 256 --keep 48 \
./main -m ./models/7B/ggml-model-q4_0.bin -c 512 -b 1024 -n 256 --keep 48 \
--repeat_penalty 1.0 --color -i \
-r "User:" -f prompts/chat-with-bob.txt
2 changes: 1 addition & 1 deletion examples/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void gpt_print_usage(int /*argc*/, char ** argv, const gpt_params & params) {
fprintf(stderr, " --in-prefix STRING string to prefix user inputs with (default: empty)\n");
fprintf(stderr, " -f FNAME, --file FNAME\n");
fprintf(stderr, " prompt file to start generation.\n");
fprintf(stderr, " -n N, --n_predict N number of tokens to predict (default: %d)\n", params.n_predict);
fprintf(stderr, " -n N, --n_predict N number of tokens to predict (default: %d, -1 - infinity)\n", params.n_predict);
fprintf(stderr, " --top_k N top-k sampling (default: %d)\n", params.top_k);
fprintf(stderr, " --top_p N top-p sampling (default: %.1f)\n", params.top_p);
fprintf(stderr, " --repeat_last_n N last n tokens to consider for penalize (default: %d)\n", params.repeat_last_n);
Expand Down
3 changes: 1 addition & 2 deletions examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ int main(int argc, char ** argv) {
}

params.n_keep = std::min(params.n_keep, (int) embd_inp.size());
//params.n_predict = std::min(params.n_predict, n_ctx - (int) embd_inp.size());

// prefix & suffix for instruct mode
const auto inp_pfx = ::llama_tokenize(ctx, "\n\n### Instruction:\n\n", true);
Expand Down Expand Up @@ -293,7 +292,7 @@ int main(int argc, char ** argv) {

std::vector<llama_token> embd;

while (n_remain > 0 || params.interactive) {
while (n_remain != 0 || params.interactive) {
// predict
if (embd.size() > 0) {
// infinite text generation via context swapping
Expand Down

0 comments on commit 79b2b26

Please sign in to comment.