-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
llama.swiftui: Fix a small bug #8268
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b25654d
fix continuing generating blank lines after getting EOT token or EOS …
ho2103 e8c7a25
change variable name to is_done (variable name suggested by ggerganov)
ho2103 30f122e
minor : fix trailing whitespace
ggerganov 271cc20
minor : add space
ggerganov 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 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
This file contains 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
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.
I'm trying to understand why this issue would only happen in Swift, and not in the other parallel projects, and looking at those, it looks like the paradigm is usually checking
n_cur <= n_len
-- but the Swift library (prior to your change) checksn_cur < n_len
.I'm not able to run this Swift library very easily -- could you please try changing this line:
If you do that, do you still see the problem?
The main reason I ask is that -- as much as possible -- I'd like to keep the logic for all of the various libraries more or less parallel to each other, and I'm leery of one-off solutions that are only implemented in one platform at a time.
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.
"If you do that, do you still see the problem?" --- You changed back to the bug.
The problem is that, the original code for swiftUI frontend haven't checked the circumstances when there is EOT/EOS, so frontend keeps printing blank lines.
In the desired outcome, When there is EOT/EOS, frontend needs to stop generating any blank lines.
So, my solution is, besides checking if reaching n_len, you also need to check if the latest token is EOT/EOS, that is the whole meaning of why I added variable "latest_llama_token_is_eog_or_reach_len".
FYI, I haven't looked each line of original LLAMA code, but I did my best to use fewest line to fix this stupid bug.
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.
Because current n_len is just 64, you are not going to see the problem. If you change the n_len bigger, like 1024, you might find it keeps generating blank lines even after EOT/EOS
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.
The original was
<
, I changed it to<=
-- is there any difference in behavior if you do that?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.
And yeah, don't feel bad -- it's too large of a project for anyone to have done that. I hope I'm not frustrating you -- I haven't looked at each line either. That's largely why I'm asking this. I'm not familiar with the Swift code, and am mainly trying to keep the various libraries from diverging too much. If a different portion of the library already solved this same problem in a different way, then in so far as we can keep the solutions more parallel, we should do that.
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 see what you mean about needing EOT/EOS detection in addition to correct
n_len
handling.What I haven't yet tracked down is -- how do the other portions of the code deal with EOT/EOS detection, and how can we keep the Swift library more parallel with those?
We don't need to read every line, but understanding how at least one other section of the code does it would be good. And if no other place does it, then maybe your fix should be replicated elsewhere.
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.
Here is the check in
simple
example:llama.cpp/examples/simple/simple.cpp
Lines 128 to 134 in d7fd29f
The proposed change is good, but just change the name of the variable to
is_done