main : minor

This commit is contained in:
Georgi Gerganov 2024-03-04 09:55:39 +02:00
parent 60325ec78e
commit 98dae326b1
No known key found for this signature in database
GPG key ID: BF970631944C16B7

View file

@ -511,6 +511,14 @@ int main(int argc, char ** argv) {
std::vector<llama_token> embd;
std::vector<llama_token> embd_guidance;
// tokenized antiprompts
std::vector<std::vector<llama_token>> antiprompt_ids;
antiprompt_ids.reserve(params.antiprompt.size());
for (const std::string & antiprompt : params.antiprompt) {
antiprompt_ids.emplace_back(::llama_tokenize(ctx, antiprompt, false, true));
}
struct llama_sampling_context * ctx_sampling = llama_sampling_init(sparams);
while ((n_remain != 0 && !is_antiprompt) || params.interactive) {
@ -769,14 +777,6 @@ int main(int argc, char ** argv) {
}
}
// tokenize reverse/antiprompt special tokens only once using static
static std::vector<std::vector<llama_token>> antiprompt_ids;
if (antiprompt_ids.empty()) {
for (std::string& antiprompt : params.antiprompt) {
antiprompt_ids.push_back(::llama_tokenize(ctx, antiprompt, false, true));
}
}
// check for reverse prompt using special tokens
llama_token last_token = llama_sampling_last(ctx_sampling);
for (std::vector<llama_token> ids : antiprompt_ids) {