8000 Check for reverse prompt by characters instead of tokens (#292) by tjohnman · Pull Request #330 · ggml-org/llama.cpp · GitHub
[go: up one dir, main page]

Skip to content

Check for reverse prompt by characters instead of tokens (#292) #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup.
  • Loading branch information
Johnman committed Mar 20, 2023
commit 6242d1ccd5fd2b9c403ad526647176bd9edfedf0
9 changes: 2 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ int main(int argc, char ** argv) {

if(params.antiprompt.size()) {
for (auto antiprompt : params.antiprompt) {
fprintf(stderr, "Reverse prompt: %s\n", antiprompt);
fprintf(stderr, "Reverse prompt: '%s'\n", antiprompt.c_str());
}
}
}
Expand Down Expand Up @@ -1023,23 +1023,18 @@ int main(int argc, char ** argv) {
// check if we should prompt the user for more
if (params.interactive && embd_inp.size() <= input_consumed) {
// check for reverse prompt

std::stringstream last_output_ss;
for (auto id : last_n_tokens) {
last_output_ss << vocab.id_to_token[id];
}
std::string last_output = last_output_ss.str();

// Check if each of the reverse prompts appears at the end of the output.
for (std::string antiprompt : params.antiprompt) {
if (last_output.find(antiprompt.c_str(), last_output.length() - antiprompt.length(), antiprompt.length()) != std::string::npos) {
is_interacting = true;
break;
}
/*if (antiprompt_inp.size() && std::equal(antiprompt_inp.rbegin(), antiprompt_inp.rend(), last_n_tokens.rbegin())) {
// reverse prompt found
is_interacting = true;
break;
}*/
}
if (is_interacting) {
if (params.instruct) {
Expand Down
0