A script and information to convert a Huggingface models to CoreML

Huggingface to CoreML

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

Info

  • Model to transform: “facebook/blenderbot-400M-distill”Example of usage Try it by executing in command line $ python3 try.py

Links

Initial steps

  1. Clone repo: $ git clone https://github.com/madcato/huggingface-coreml.git
  2. Execute chatbot to download model, $ python3 try.py
  3. Install huggingface exporters submodule, $ git submodule init && git submodule update
  4. $ cd exporters && pip3 install -e . && cd ..
  5. python3 -m exporters.coreml --model=facebook/blenderbot-400M-distill exported/ --feature=text2text-generation

The last step will create an mlpackage file in the exported folder. This file can be opened with Xcode and the model can be tested in the playground or project.

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’

GitHub

View Github