-
Notifications
You must be signed in to change notification settings - Fork 13.9k
llama-cli: add support for reasoning #16603
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
Open
bandoti
wants to merge
21
commits into
ggml-org:master
Choose a base branch
from
bandoti:llamacli-reasoning2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+297
−62
Open
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d230722
Add partial formatter
bandoti 3d94112
Remove extra call to common_chat_templates_apply
bandoti a7771c1
Suppress template markup in system & prompt display
bandoti 8694fa3
Track system/user prompt position
bandoti e403844
Remove complexity
bandoti c3768f4
Add guards against stripped reasoning
bandoti c381ea5
Remove trailing _ for member variables
bandoti 3087ff7
WIP: colorizing the reasoning content
bandoti 98b0d26
Add new console::write routine
bandoti becf4c5
Rename syntax variable
bandoti c879317
Use non-template version of write routine
bandoti edb8c0f
Write to log when enabled otherwise direct
bandoti e8952fb
Merge branch 'master' into llamacli-reasoning2
bandoti 7216448
Fix pointer formatting
bandoti c0ca21d
Only call common_chat_parse with assistant messages
bandoti 1b1629d
Add reasoning delimiters
bandoti fc248d1
Remove stale data from delta
bandoti dc882ee
Merge branch 'master' into llamacli-reasoning2
bandoti e42715e
Use double-arrow as reasoning delimiter
bandoti 7208aee
Merge branch 'master' into llamacli-reasoning2
bandoti e1f24f1
Merge branch 'master' into llamacli-reasoning2
bandoti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since the thinking tags are eaten it makes it really hard to separate thinking from the rest.
Would it be an idea to highlight thinking in another color? Would require some additional logging API to check status of color and/or logging with
g_col.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.
Okay sounds good! What do you think about adding something like "Thinking..." when the reasoning starts as well?
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.
Please see my comment below re. the logging API. It doesn't make sense to tightly couple the notion of reasoning into the logging API, as there is a separation of concerns: application-specific output versus generic logging behavior.
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.
Sorry, didn't notice your comments until now, the coloring works very well, but we do need some kind of separation when colors are not enabled as well, though hard to define so that they can't be confused with actual output.
LOG/write output will get a little jumbled now, take f.ex. the following output from a
--verbose-prompt -p "..."run:Not a major issue, but a little weird.
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.
Hmm. We could call "common_log_pause()/resume()" while writing to the console. This would just require storing the log pointer in the console, which could be passed into the init procedure and be an optional argument.
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.
Or, could use common_log_main() singleton directly and keep it in the
console.cppand always pause the log before output if that's desired.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.
Let's hold off on this until @ggerganov has weighed in on
console::writein the first place as this is disruptive behavior.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 think the
consolecould indeed hold a reference to thecommon_log, but instead of pause/resume, it can simply callLOG_CNTto print stuff through the existing log instance.Uh oh!
There was an error while loading. Please reload this page.
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.
@ggerganov Please see latest check-in. I updated to use the logging system when it is enabled, otherwise it writes directly to console. From my tests with -v and -co everything seems to be in sync now (fixing the jumbled output), and when --log-disable is specified the output stays intact.
When transitioning to user input there was a bit of a race condition so I added a flush routine so the console waits for the remaining log messages to come in before switching to the user prompt. Otherwise colors were spilling into the log messages.