Skip to content

This repository contains a script and information to convert a Huggingface models to CoreML.

Notifications You must be signed in to change notification settings

madcato/huggingface-coreml

Repository files navigation

Huggingface to CoreML

This repository contains a script and information to convert a Huggingface models to CoreML.

Info

Links

Initial steps

  1. Clone repo: $ git clone https://github.com/madcato/huggingface-coreml.git
  2. Execute chatbot to try chatbot (optional), $ python3 try.py
  3. Install huggingface exporters submodule, $ git submodule init && git submodule update
  4. $ cd exporters && pip3 install -e . && cd ..
  5. python3 export

The last step will create two mlpackage files in the exported folder: one for decoder and another for decoder part of the model. These files can be opened with Xcode and the model can be tested in the playground or project.

Try

  • $ python3 -m exporters.coreml --model=t5-small --feature=text2text-generation exported
  • $ python3 -m exporters.coreml --model=distilgpt2 --feature=text2text-generation exported

Exporters features

  • 'feature-extraction',
  • 'feature-extraction-with-past',
  • 'fill-mask',
  • 'image-classification',
  • 'masked-im',
  • 'multiple-choice',
  • 'next-sentence-prediction',
  • 'object-detection',
  • 'question-answering',
  • 'semantic-segmentation',
  • 'text-classification',
  • 'text-generation',
  • 'text-generation-with-past',
  • 'text2text-generation',
  • 'token-classification',
  • 'sequence-classification',
  • 'causal-lm',
  • 'causal-lm-with-past',
  • 'seq2seq-lm',
  • 'seq2seq-lm-with-past',
  • 'speech2seq-lm',
  • 'speech2seq-lm-with-past',
  • 'masked-lm',
  • 'vision2seq-lm',
  • 'default',
  • 'default-with-past',
  • 'automatic-speech-recognition',
  • 'ctc'

About

This repository contains a script and information to convert a Huggingface models to CoreML.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published