Skip to content

Commit

Permalink
generate token until context filled
Browse files Browse the repository at this point in the history
  • Loading branch information
VJHack committed Oct 28, 2024
1 parent e0614ca commit b4bf5df
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,15 @@ struct server_slot {
if (params.n_predict == -1 && global_params.n_predict == -1) {
return true; // limitless
}
else if (global_params.n_predict == -2) {
return true; // generate until context is filled
}

n_remaining = -1;

if (params.n_predict != -1) {
n_remaining = params.n_predict - n_decoded;
} else if (global_params.n_predict == -2) {
n_remaining = n_ctx - n_past;
} else if (global_params.n_predict != -1) {
}else if (global_params.n_predict != -1) {
n_remaining = global_params.n_predict - n_decoded;
}

Expand Down Expand Up @@ -1814,6 +1815,12 @@ struct server_context {
continue;
}

if (params.n_predict == -2) {
slot.release();
send_final_response(slot);
continue;
}

// Shift context
const int n_keep = slot.params.n_keep + add_bos_token;
const int n_left = slot.n_past - n_keep;
Expand Down

0 comments on commit b4bf5df

Please sign in to comment.