exporters  by huggingface

Tool to export Hugging Face models to Core ML

Created 3 years ago
676 stars

Top 50.0% on SourcePulse

GitHubView on GitHub
Project Summary

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

  • Install via pip: pip install -e . after cloning the repository.
  • macOS is recommended for validation steps.
  • Core ML models use the .mlpackage format, requiring iOS 15+, macOS 12.0+, and Xcode 13+.

Highlighted Details

  • Supports a wide range of Hugging Face model architectures out-of-the-box.
  • Enables exporting models with past_key_values for faster autoregressive decoding.
  • Allows customization of input/output properties and export formats (ML Program vs. legacy .mlmodel).
  • Includes a validation step to compare exported model outputs against the original.

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.

Health Check
Last Commit

1 year ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
8 stars in the last 30 days

Explore Similar Projects

Starred by Luca Soldaini Luca Soldaini(Research Scientist at Ai2), Edward Sun Edward Sun(Research Scientist at Meta Superintelligence Lab), and
4 more.

parallelformers by tunib-ai

0%
790
Toolkit for easy model parallelization
Created 4 years ago
Updated 2 years ago
Starred by Jeremy Howard Jeremy Howard(Cofounder of fast.ai) and Stas Bekman Stas Bekman(Author of "Machine Learning Engineering Open Book"; Research Engineer at Snowflake).

SwissArmyTransformer by THUDM

0.3%
1k
Transformer library for flexible model development
Created 4 years ago
Updated 8 months ago
Starred by Didier Lopes Didier Lopes(Founder of OpenBB), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
5 more.

mlx-lm by ml-explore

26.1%
2k
Python package for LLM text generation and fine-tuning on Apple silicon
Created 6 months ago
Updated 22 hours ago
Feedback? Help us improve.