-
Notifications
You must be signed in to change notification settings - Fork 7.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
fix: emoji and unicode decoding bug #2404
base: main
Are you sure you want to change the base?
Conversation
@jacoobes @iimez Curious if you think it would be better to implement this kind of thing in the C++ layer like this instead of in the bindings? This is how the llama.cpp server does it: https://github.com/ggerganov/llama.cpp/blob/adc9ff384121f4d550d28638a646b336d051bf42/examples/server/server.cpp#L1147-L1167 |
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.
As-is this PR is in conflict with #2403.
This would be great; all the bindings would benefit. We can remove the extra code from JavaScript and Python bindings! |
100% better in cpp. From maintenance pov it's better for everybody, and I can't think of anything useful to do with the partial utf-8 within the bindings or further downstream. (Or the ability to stop generation with a partial character.) |
Signed-off-by: fritz.f.yan <fritz.f.yan@newegg.com>
This reverts commit 64906b2. Signed-off-by: fritz.f.yan <fritz.f.yan@newegg.com>
Signed-off-by: fritz.f.yan <fritz.f.yan@newegg.com>
I'll try to test this when i'm free! |
Quite some time ago, I was involved with when this was fixed in the Python bindings. Although I don't really remember all the details. Note: this is not against this PR or even the idea, just to give more context on the problem itself. If you really, truly wanted to fix this on the side of the backend, you'd expose the response directly in Unicode. However, there are several issues to consider:
For reference, here's where the decoding happens in the Python bindings: gpt4all/gpt4all-bindings/python/gpt4all/_pyllmodel.py Lines 560 to 594 in 41c9013
|
Keep in mind C++ can use C files in compilation, while there technically is C, its for downstream interop. I think this implementation even though it is implemented in C++, bindings should be able to use it. ( I may be missing something ), I still need to try to get cuda working on windows before I can test this |
Just to clarify: I mean yes, the C++ code is exposed through a C interface for interop with the bindings. C is basically the lowest common denominator in all of this. So everything you do in C++ you somehow have to squeeze into a C-compatible shape to be able to expose it to the bindings. And C by itself is notoriously weak in terms of expressiveness or "batteries included" (as they say in Python), even compared to C++. Also, C++ by itself (without libraries) doesn't solve the Unicode problem. And on a side note, different OSs have their own APIs. |
Alright, in any case and as I said initially: I didn't write here to interfere with this. In a nutshell, I wanted to give more context to the overall Unicode problem. So, assuming there are no further discussions and you're happy with going this route, it's not my intention to stand in the way of this PR getting merged. |
Describe your changes
[Fix]: emoji and unicode decoding bug
[Fix]: fix the typescript build fail on the dlhandle
Issue ticket number and link
Checklist before requesting a review
Demo
Before:

After:

Steps to Reproduce
Notes