Tool to export Hugging Face models to Core ML
Top 51.4% on sourcepulse
This package facilitates the export of Hugging Face Transformers models to Apple's Core ML format, targeting developers building on macOS, iOS, tvOS, and watchOS. It simplifies the conversion process, aiming for tighter integration with the Hugging Face ecosystem than manual coremltools
scripting.
How It Works
The exporter leverages coremltools
to convert PyTorch or TensorFlow checkpoints to Core ML's .mlpackage
format. It uses pre-defined configuration objects for various model architectures, which can be extended. These configurations manage model inputs, outputs, and pre/post-processing steps, aiming to embed as much logic as possible within the Core ML model for easier app integration.
Quick Start & Requirements
pip install -e .
after cloning the repository..mlpackage
format, requiring iOS 15+, macOS 12.0+, and Xcode 13+.Highlighted Details
past_key_values
for faster autoregressive decoding..mlmodel
).Maintenance & Community
The project is part of the Hugging Face ecosystem. Further community contributions for new configurations are welcomed.
Licensing & Compatibility
The repository's license is not explicitly stated in the README. Compatibility for commercial use or closed-source linking depends on the underlying libraries and Hugging Face's terms.
Limitations & Caveats
The project is marked as "WORK IN PROGRESS." Some models may require the older .mlmodel
format (use_legacy_format=True
) due to issues with the ML Program format. Certain models (e.g., GPT2, DistilGPT2) are known to have conversion issues with flexible sequence lengths, leading to high memory usage and slow processing. Exporting encoder-decoder models requires creating separate encoder and decoder Core ML models.
1 year ago
1 day