Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rbavery committed Dec 13, 2024
1 parent 4c1c63a commit 357ad61
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ In order to provide more context, the following roles are also recommended were
| href | string | URI to the model artifact. |
| type | string | The media type of the artifact (see [Model Artifact Media-Type](#model-artifact-media-type). |
| roles | \[string] | **REQUIRED** Specify `mlm:model`. Can include `["mlm:weights", "mlm:checkpoint"]` as applicable. |
| mlm:artifact_type | [Artifact Type](#artifact-type) | Specifies the kind of model artifact. Typically related to a particular ML framework. This is **REQUIRED** if the `mlm:model` role is specified. |
| mlm:artifact_type | [Artifact Type](./best-practices.md#framework-specific-artifact-types) | Specifies the kind of model artifact. Typically related to a particular ML framework. This is **REQUIRED** if the `mlm:model` role is specified. |
| mlm:compile_method | string | Describes the method used to compile the ML model at either save time or runtime prior to inference. These options are mutually exclusive `["aot", "jit", null]`. |

Recommended Asset `roles` include `mlm:weights` or `mlm:checkpoint` for model weights that need to be loaded by a
Expand Down Expand Up @@ -701,19 +701,11 @@ is used for the artifact described by the media-type. However, users need to rem
official. In order to validate the specific framework and artifact type employed by the model, the MLM properties
`mlm:framework` (see [MLM Fields](#item-properties-and-collection-fields)) and
`mlm:artifact_type` (see [Model Asset](#model-asset)) should be employed instead to perform this validation if needed.
See the [the best practices document](./best-practices.md#framework-specific-artifact-types) on suggested
fields for framework specific artifact types.

[iana-media-type]: https://www.iana.org/assignments/media-types/media-types.xhtml

#### Framework Specific Artifact Types

The `mlm:artifact_type` field can be used to clarify how the model was saved which can help users understand how to load it or in
what runtime contexts it should be used. For example, PyTorch offers [various strategies][pytorch-frameworks] for providing model
definitions, such as Pickle (`.pt`), [TorchScript][pytorch-jit-script], or [PyTorch Ahead-of-Time Compilation][pytorch-aot-inductor]
(`.pt2`) approach. Since they all refer to the same ML framework, the [Model Artifact Media-Type](#model-artifact-media-type) can be
insufficient in this case to detect which strategy should be used to employ the model definition.
See the [the best practices document](./best-practices#framework-specific-artifact-types) on suggested
fields for framework specific artifact types.

[pytorch-aot-inductor]: https://pytorch.org/docs/main/torch.compiler_aot_inductor.html

### Source Code Asset

Expand Down
19 changes: 14 additions & 5 deletions best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,19 @@ educational purposes only.

## Framework Specific Artifact Types

The following are some proposed *Artifact Type* values for the Model Asset's [`mlm:artifact_type` field](./README.md#model-asset). Other names are
permitted, as these values are not validated by the schema. Note that the names are selected using the framework-specific definitions to help the users understand how the model artifact was created, although these exact names are not strictly required either.
The `mlm:artifact_type` field can be used to clarify how the model was saved which
can help users understand how to load it or in what runtime contexts it should be used. For example, PyTorch offers
[various strategies][pytorch-frameworks] for providing model definitions, such as Pickle (`.pt`),
[TorchScript][pytorch-jit-script], or [PyTorch Ahead-of-Time Compilation][pytorch-aot-inductor]
(`.pt2`) approach. Since they all refer to the same ML framework, the
[Model Artifact Media-Type](./README.md#model-artifact-media-type) can be insufficient in this case to detect which
strategy should be used to employ the model definition.

The following are some proposed *Artifact Type* values for the Model Asset's
[`mlm:artifact_type` field](./README.md#model-asset). Other names are
permitted, as these values are not validated by the schema. Note that the names are selected using the
framework-specific definitions to help the users understand how the model artifact was created, although these exact
names are not strictly required either.

| Artifact Type | Description |
|--------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -297,12 +308,10 @@ permitted, as these values are not validated by the schema. Note that the names
| `tf.keras.Model.save_weights` | A [.weights.h5][keras-save-weights] file containing only model weights for use by Tensorflow or Keras. |
| `tf.keras.Model.export(format='tf_saved_model')` | TF Saved Model is the [recommended format][tf-keras-recommended] by the Tensorflow team for whole model saving/loading for inference. See this example to [save and load models][keras-example] and the docs for [different save methods][keras-methods] in TF and Keras. Also available from `keras.Model.export(format='tf_saved_model')` |


[exported-program]: https://pytorch.org/docs/main/export.html#serialization
[pytorch-compile]: https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html
[pytorch-aot-inductor]: https://pytorch.org/docs/main/torch.compiler_aot_inductor.html
[pytorch-export]: https://pytorch.org/docs/main/export.html
[pytorch-frameworks]: https://pytorch.org/docs/main/export.html#existing-frameworks
[pytorch-aot-inductor]: https://pytorch.org/docs/main/torch.compiler_aot_inductor.html
[pytorch-jit-script]: https://pytorch.org/docs/stable/jit.html
[pytorch-save]: https://pytorch.org/tutorials/beginner/saving_loading_models.html
[keras-save-weights]: https://keras.io/api/models/model_saving_apis/weights_saving_and_loading/#save_weights-method
Expand Down

0 comments on commit 357ad61

Please sign in to comment.