mlx icon indicating copy to clipboard operation
mlx copied to clipboard

Is there an example code for convert hugging face model to pytorch then mlx ?

Open znsoftm opened this issue 2 years ago • 1 comments

as title

znsoftm avatar Dec 09 '23 07:12 znsoftm

Most HuggingFace models are (default) already in PyTorch. Check out the https://github.com/ml-explore/mlx-examples repo, there's a script to convert the weights from HuggingFace BERT to an MLX model: https://github.com/ml-explore/mlx-examples/blob/main/bert/convert.py

The rest of the BERT example shows how the model is implemented. You need to ensure that the tensors are mapped correctly and that the computations are set up exactly the same.

jbarrow avatar Dec 10 '23 19:12 jbarrow