Bugfix and back to printing as normal

Fix antiprompt
pull/66/head
beiller 2 years ago
parent 703571861f
commit 9425a21db5
No known key found for this signature in database
GPG Key ID: 5AC5D1B01D0E5D75

@ -824,7 +824,8 @@ int main(int argc, char ** argv) {
params.n_predict = std::min(params.n_predict, model.hparams.n_ctx - (int) embd_inp.size()); params.n_predict = std::min(params.n_predict, model.hparams.n_ctx - (int) embd_inp.size());
// tokenize the reverse prompt // tokenize the reverse prompt
std::vector<gpt_vocab::id> antiprompt_inp = ::llama_tokenize(vocab, params.antiprompt, false); std::vector<gpt_vocab::id> antiprompt_inp;
processor.Encode(params.antiprompt, &antiprompt_inp);
printf("\n"); printf("\n");
printf("%s: prompt: '%s'\n", __func__, params.prompt.c_str()); printf("%s: prompt: '%s'\n", __func__, params.prompt.c_str());
@ -951,29 +952,28 @@ int main(int argc, char ** argv) {
// display text // display text
if (!input_noecho) { if (!input_noecho) {
// check if last token is unprintable token
// std::string check = processor.IdToPiece(all_tokens.at(all_tokens.size()-1)); std::string check;
// printf("[%s]", check.c_str()); std::vector<gpt_vocab::id> check_token;
// if(check != "<22>") { // ensure a multi-byte token is finished generating before outputting the text check_token.push_back(all_tokens.at(all_tokens.size()-1));
// std::string text; processor.Decode(check_token, &check);
// processor.Decode(all_tokens, &text); if(check != "<EFBFBD>") {
// std::string chunk = text.substr(full_text.length()); // If the token is printable we wont attempt to print unprintable tokens
// printf("%s", chunk.c_str()); std::string text;
// full_text.reserve (text.size()); processor.Decode(all_tokens, &text);
// full_text += chunk; if(full_text.length() < text.length()) {
std::string chunk = text.substr(full_text.length());
// // reset color to default if we there is no pending user input printf("%s", chunk.c_str());
// if (params.use_color && embd_inp.size() <= input_consumed) { full_text.empty();
// printf(ANSI_COLOR_RESET); processor.Decode(all_tokens, &full_text);
// } // reset color to default if we there is no pending user input
// fflush(stdout); if (params.use_color && embd_inp.size() <= input_consumed) {
// } printf(ANSI_COLOR_RESET);
}
// The code above crashes and is WIP any help appreciated fflush(stdout);
std::string text; }
processor.Decode(all_tokens, &text);
printf("%s\n", text.c_str()); }
fflush(stdout);
} }
// in interactive mode, and not currently processing queued inputs; // in interactive mode, and not currently processing queued inputs;

Loading…
Cancel
Save