mlx
mlx copied to clipboard
Is there an example code for convert hugging face model to pytorch then mlx ?
as title
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.