โ† Open Source

Swift Core ML 3 implementations of GPT-2, DistilGPT-2, BERT, and DistilBERT for Question answering. Other Transformers coming soon.

InfrastructureDeploy & ServeSwift
Momentum
+0stars in 24 hours0.0%
1.68k
Stars
171
Forks
+0
This week
6
Contributors
Created 2019-06-27 ยท Updated 2026-11-19 ยท #11780 today
Top developers
README

This repo is not actively maintained and has been archived. For an in-development replacement, please head over to swift-transformers!

Swift Core ML implementations of Transformers: GPT-2, DistilGPT-2, BERT, DistilBERT, more coming soon!

This repository contains:

  • For BERT and DistilBERT:
    • pretrained Google BERT and Hugging Face DistilBERT models fine-tuned for Question answering on the SQuAD dataset.
    • Swift implementations of the BERT tokenizer (BasicTokenizer and WordpieceTokenizer) and SQuAD dataset parsing utilities.
    • A neat demo question answering app.
  • For GPT-2 and DistilGPT-2:
    • a conversion script from PyTorch trained GPT-2 models (see our transformers repo) to CoreML models.
    • The GPT-2 generation model itself, including decoding strategies (greedy and TopK are currently implemented) and GPT-2 Byte-pair encoder and decoder.
    • A neat demo app showcasing on-device text generation.

๐Ÿฆ„ GPT-2 and DistilGPT-2

Unleash the full power of text generation with GPT-2 on device!!

๐Ÿธ BERT and DistilBERT

The BERTSQUADFP16 Core ML model was packaged by Apple and is linked from the main ML models page. It was demoed at WWDC 2019 as part of the Core ML 3 launch.

The DistilBERT Core ML models were converted from ๐Ÿค—/transformers exports using the scripts in this repo.

๐Ÿฆ„ Demo Time ๐Ÿ”ฅ

Apple demo at WWDC 2019

full video here

BERT Architecture (wwdc slide)

Notes

We use git-lfs to store large model files and it is required to obtain some of the files the app needs to run. See how to install git-lfson the installation page

Nearby in the ranking
Similar items

AI Rank for iPhone

Follow AI model rankings

Download on the App Store