You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/guides/integrations.md
+28-44Lines changed: 28 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ are ready to go. You don't need to worry about stuff like repo creation, commits
148
148
of this is handled by the mixin and is available to your users. The Mixin also ensures that public methods are well
149
149
documented and type annotated.
150
150
151
-
As a bonus, [`ModelHubMixin`] handles the model configuration for you. In some cases, you have a `config` input parameter when initializing your class (dictionary or dataclass containing high-level settings). In such cases, the `config`value is automatically serialized into a `config.json` dictionary for you. When re-loading the model from the Hub, the configuration is correctly deserialized. Make sure to use type annotation if you want to deserialize it as a dataclass. The big advantage of having a `config.json` file in your model repository is that it automatically enables the analytics on the Hub (e.g. the "downloads" count).
151
+
As a bonus, [`ModelHubMixin`] handles the model configuration for you. If your `__init__` method expects a `config` input, it will be automatically saved in the repo when calling `save_pretrained` and reloaded correctly by `load_pretrained`. Moreover, if the `config`input parameter is annotated with dataclass type (e.g. `config: Optional[MyConfigClass] = None`), then the `config` value will be correctly deserialized for you. Finally, all jsonable values passed at initialization will be also stored in the config file. This means you don't necessarily have to expect a `config` input to benefit from it. The big advantage of having a `config.json` file in your model repository is that it automatically enables the analytics on the Hub (e.g. the "downloads" count).
152
152
153
153
### A concrete example: PyTorch
154
154
@@ -159,40 +159,38 @@ A good example of what we saw above is [`PyTorchModelHubMixin`], our integration
159
159
Here is how any user can load/save a PyTorch model from/to the Hub:
0 commit comments