-
Notifications
You must be signed in to change notification settings - Fork 87
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
Read model weights #91
Conversation
* Separate Safetensor from the weights * Rename test tensors to include type * Rename ModelWeights to Weights * Throw error for unsupported data types * Remove model weights from LanguageModel.Configurations
Weights are now accessible independently of configurations for flexibility and without MLModel or conversion. |
That's very cool @shavit! May I ask what use case you have in mind for this? Edit: Oh, I see it's for your embeddings work. Any highlights on the general architecture you're considering? |
Yes
The plan is to use models directly from local files or the hub, and maybe support more types like mlx/numpy. |
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.
Very cool work, thanks a lot for contributing! I only have one suggestion regarding one of the tests.
|
||
func testLoadWeightsFromFileURL() async throws { | ||
let repo = "google/bert_uncased_L-2_H-128_A-2" | ||
let modelDir = try await hubApi.snapshot(from: repo) |
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'd suggest you use matching globs to only download the two files we need and avoid additional downloads. There's a version that supports multiple patterns.
Enable safe access to keys.
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.
Ready to merge, in my opinion! Are you planning any more tweaks?
No, that's it. |
Thanks a lot @shavit! |
Read model weights from safetensors.
Related #86