From 5ab6c2132aad2354092a26c096cc5c8f55801141 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 6 Oct 2023 14:32:19 +0300 Subject: [PATCH] server-parallel : add "--reverse-prompt" + compiler warning fixes --- examples/server-parallel/server.cpp | 40 +++++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/examples/server-parallel/server.cpp b/examples/server-parallel/server.cpp index 2b12fc100..607d173e6 100644 --- a/examples/server-parallel/server.cpp +++ b/examples/server-parallel/server.cpp @@ -1,13 +1,15 @@ -#include +#include "frontend.h" +#include "common.h" +#include "llama.h" + #include "../server/httplib.h" #include "../server/json.hpp" + #include #include #include #include -#include "frontend.h" -#include "common.h" -#include "llama.h" +#include using namespace httplib; using namespace std; @@ -241,9 +243,7 @@ struct server_parallel_context { string prompt = data.value("prompt", ""); for (llama_client_slot & slot : slots) { - if ( - slot_id == -1 && slot.available() || - slot.id == slot_id) + if ((slot_id == -1 && slot.available()) || slot.id == slot_id) { slot.start(prompt, temperature); LOG_TEE("slot %i is processing\n", slot.id); @@ -429,8 +429,6 @@ struct server_parallel_context { slot.generated_text += token_str; slot.sampled = id; - size_t pos = 0; - size_t stop_pos = findStoppingStrings(slot.generated_text, token_str.size(), STOP_FULL); @@ -740,20 +738,34 @@ static void server_params_parse(int argc, char **argv, server_params &sparams, else if (arg == "--numa") { params.numa = true; - } else if (arg == "-cb" || arg == "--cont-batching") { + } else if (arg == "-cb" || arg == "--cont-batching") + { params.cont_batching = true; - } else if (arg == "-np" || arg == "--parallel") { - if (++i >= argc) { + } + else if (arg == "-np" || arg == "--parallel") + { + if (++i >= argc) + { invalid_param = true; break; } params.n_parallel = std::stoi(argv[i]); - } else if (arg == "-n" || arg == "--n-predict") { - if (++i >= argc) { + } else if (arg == "-n" || arg == "--n-predict") + { + if (++i >= argc) + { invalid_param = true; break; } params.n_predict = std::stoi(argv[i]); + } else if (arg == "-r" || arg == "--reverse-prompt") + { + if (++i >= argc) + { + invalid_param = true; + break; + } + params.antiprompt.push_back(argv[i]); } else {