Apple Silicon Experiment 6— MLX Framework BERT Port [WIP]

Youngrok Song
Dec 7, 2023

--

Apple announced MLX Framework for ML Models

Porting transformers package BERT model for MLX inference

Environment

  • transformers 4.33.2
  • mlx 0.0.3
  • M1 Max — macOS 14.1.2 with Python 3.8
  • model: bert-base-uncased from huggingface

Loading Model Example:

Weight Conversion:

Inference Example:

  • sequence_output, pooled_output: results from the MLX model
  • og_model_outputs: results from transformers package model

Code:

References:

--

--

No responses yet