-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
feat: add "stop" keywords as alternative to eot token #769
Conversation
for (auto id : last_n_tokens) { | ||
last_output += llama_token_to_str(ctx, id); | ||
} | ||
} | ||
|
||
// Check for stop keywords, a configurable alternative to the end-of-text token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should check the token id instead of the string for stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this should work in the same way as "antiprompts" to provide a better UX to users. Users should be able to add to the CLI parameters --stop "### Assistant"
(for example, in the spirit of the trained vicuna
model) or --stop PAUSE
(for example, to implement Simon Willinson's ReAct Python example), even though these are multi-token markers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know why? It will be a good learning for me to understand why token will not work? Because one stop string can be generated by the different tokens??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see #292 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noticed that the stop words weren't always consistently formatted. Sometimes it would do STOP
instead of stop
. I'd appreciate a normalize function to down case before comparing.
Yes, I got busy and no longer have time to maintain that PR. Thanks for rewriting! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked in details.
Merge it if you have confirmed to be working as expected
While #863 appears to be more polished, I'd merge these changes since it's uncertain when that one will be reviewed and integrated. Plus, it's likely that any significant use of this code would involve utilizing the library rather than relying on this example binary. |
@longregen |
#863 is a superset of this PR. Closed this one as that other got merged. Thank you for your awesome work! |
@longregen The PR you mentioned has been reverted (c85e03d). Is the plan to wait for that to be tested more or should we reopen this PR? |
Rewrite of #365 (addresses #57) by @joshmackwilliams, updated to the new folder/file structure as the PR might have been abandoned.
From the original author: