llama.cpp icon indicating copy to clipboard operation
llama.cpp copied to clipboard

Stop keywords

Open joshmackwilliams opened this issue 2 years ago • 2 comments

Implements https://github.com/ggerganov/llama.cpp/issues/57.

Stop keywords can be specified using the "--stop" parameter. Upon seeing one of these keywords in the generated output, the model will terminate generation immediately. Like reverse prompts, multiple stop keywords can be specified by specifying the --stop argument multiple times.

The implementation is heavily based on the reverse prompt implementation to keep things simple. Tested using 7B (quantized) in both interactive and non-interactive modes.

joshmackwilliams avatar Mar 21 '23 17:03 joshmackwilliams

Great feature!

Somewhat related to this, but for input : https://github.com/ggerganov/llama.cpp/issues/71#issuecomment-1478510617

anzz1 avatar Mar 21 '23 21:03 anzz1

Perfect!

SpeedyCraftah avatar Mar 22 '23 18:03 SpeedyCraftah

Why are multiple keywords needed? Isn't just one enough (for example [end of text])?

prusnak avatar Mar 30 '23 23:03 prusnak

Sometimes we want to end before Llama decides to generate [end of text], which is the reason this feature was requested. But, sometimes we also might want multiple stop conditions. An example, off the top of my head, might be to stop at the text "YOU WIN" or "GAME OVER" (obviously fairly contrived, but it makes the point that there could be multiple ways in which a generation could terminate).

Also, it's not too hard to implement since the reverse prompt logic already does the heavy lifting. It doesn't really hurt anything to allow multiple keywords, so it seemed like a worthwhile investment.

Unrelated; I've just realized that a lot of conflicts have popped up in this PR. I'll try to correct those over the next few days.

joshmackwilliams avatar Mar 31 '23 00:03 joshmackwilliams

Closing in favor of https://github.com/ggerganov/llama.cpp/pull/769

joshmackwilliams avatar Apr 10 '23 15:04 joshmackwilliams