-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 : add functions to get the model's metadata #4013
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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.
What's this doing here then? Why aren't you taking your own suggestion to just
gguf_init_from_file
again?All I'm saying is save this information in a format that's not only useful for Jinja templates or whatever. Where there's a way to reliably access it and something like
1
can be differentiated from"1"
.And yes, yes, I know. "Premature optimization is the root of all evil." To be honest, I never forget it but pretty much always disregard it. My objection here isn't really about optimization, but more for a logical relatively intuitive API where you don't have to do weird stuff reload the same file from disk multiple times.
When you do that, there's also no way to even know for sure you reloaded the same file as the model that's in memory.
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 am not trying to be snarky, but it would take a lot more code to re-load the gguf when using the metadata reading functions, and the only purpose would be to save a few bytes of memory (the reason arrays are excluded is precisely because it would waste too much memory for something of questionable utility). So doing that would be another case of premature optimization.
To be clear, I am not opposed to extending the API to support more types of metadata, that's why the function are called
llama_model_meta_val_str
and not justllama_model_meta_val
, I expected that somebody may want to extend the API in the future. I am just not convinced that it is really worth the effort and complexity to do that because the expected use of these functions is to get very specific metadata like the jinja templates, which is trivial to convert to a number if needed, or just to dump a bunch of useless info to the user, in which case it doesn't matter what the type is. Making everything accesible as a string is simpler than having to check the correct function to call depending on the type. If this was a C++17 library I would be happy to make it return astd::variant
, but that's not what it is.