Skip to content

[Feature request] Support saving meta data to mlxfn files and reading them back #2410

@csukuangfj

Description

@csukuangfj

Motivation

mlx supports exporting a model with its parameters into an mlxfn file and later loads it into other programming languages, e.g., Python, C++, without the need for the source code of the model, which is very similar to torchscript.

That is a very nice feature.

However, mlx does not support saving meta data into the mlxfn file and later reading it from the code.

Model meta data is a very useful feature. For instance, there are many parakeet models in the mlx-community for ASR. Some of the model uses feature dim 128, while others use 80. Some of the model has 2 LSTM layers in the decoder, while others have only 1 layer.

The feature dim info is required to initialize the feature extractor, while the LSTM info is required to initialize the state array that are later sent to the decoder model.

If we can save such information in the mlxfn file and later read them from the code, it can greatly simplify how users use the model. They are not forced to provide the information about the model files.

onnx supports saving meta data to *.onnx files. See
https://onnxruntime.ai/docs/api/python/auto_examples/plot_metadata.html

There are APIs in onnxruntime to read the meta data.


To give you a concrete example, we have converted some parakeet models to mxlfn format
https://github.com/k2-fsa/sherpa-mlx/releases
which can be used in sherpa-mlx.

The problem is that different parakeet models need to be handled differently in the code, e.g., feature dim, decoder LSTM state, etc. But such information is not available from the mlxfn files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions