Skip to content
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

fix #1224 reverse prompt and multi line #1297

Merged
merged 2 commits into from
May 4, 2023

Conversation

newTomas
Copy link
Contributor

@newTomas newTomas commented May 3, 2023

Fixes #1224
In the original code, when an empty line is encountered, it stops the user from entering, although in reality, an empty line can be a side effect of the previous input and should simply be ignored.

@DeveloperOl
Copy link

works great for me :)

@newTomas newTomas changed the title fix reverse prompt and multi line fix #1224 reverse prompt and multi line May 3, 2023
@newTomas
Copy link
Contributor Author

newTomas commented May 3, 2023

Tested with a wider set of models and found 1 more bug in another part of the code. If the antiprompt is "User: ", and the model generated the tokens "User", ":", " How", then the program takes the last n characters, where n is the length of the antiprompt, and it turns out that it compares "User: " and "r: How" and does the conclusion that the antiprompt was not met.
I'll try to make a fix tomorrow. Or someone else can do it, it's a bit more difficult than the previous bug.
https://github.com/ggerganov/llama.cpp/blob/master/examples/main/main.cpp#L514

@ggerganov
Copy link
Member

@newTomas

The fix for this issue is not very trivial.
One has to check for the described situation and decrease n_past by 1. And also somehow erase the extra generated token (i.e. " How" in your example).

To resolve this, we introduced the --input-prefix argument that can be used to inject the extra space.
Let's merge this PR like it is after the indentation fixes

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
@newTomas
Copy link
Contributor Author

newTomas commented May 4, 2023

@ggerganov
I approved your commit. Let's merge

@DannyDaemonic DannyDaemonic merged commit f647ce0 into ggml-org:master May 4, 2023
DannyDaemonic pushed a commit to DannyDaemonic/llama.cpp that referenced this pull request May 4, 2023
* fix reverse prompt and multi line

* Code Formatting

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
@agronholm
Copy link

Unfortunately, I discovered that not only did this not fix the problem, it made it a whole lot worse. Previously, I was able to at least get it to produce more tokens by pressing enter. Now even that won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Llama Ignoring Reverse Prompt Every Other Time
5 participants