https://github.com/beomi/bort
Repository for the paper "Optimal Subarchitecture Extraction for BERT"
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.7%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Repository for the paper "Optimal Subarchitecture Extraction for BERT"
Basic Info
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Fork of alexa/bort
Created over 5 years ago
· Last pushed over 5 years ago
https://github.com/Beomi/bort/blob/master/
# Bort
##### Companion code for the paper "Optimal Subarchitecture Extraction for BERT."
Bort is an optimal subset of architectural parameters for the BERT architecture, extracted by applying a fully polynomial-time approximation scheme (FPTAS) for neural architecture search. Bort has an effective (that is, not counting the embedding layer) size of 5.5\% the original BERT-large architecture, and 16\% of the net size. It is also able to be pretrained in 288 GPU hours, which is 1.2\% of the time required to pretrain the highest-performing BERT parametric architectural variant, RoBERTa-large.
It is also 7.9x faster on a CPU, and performs better than other compressed variants of the architecture, and some of the non-compressed variants; it obtains an average performance improvement of between 0.3\% and 31\%, absolute with respect to BERT-large on multiple public natural language understanding (NLU) benchmarks.
Here are the corresponding GLUE scores on the test set:
|Model|Score|CoLA|SST-2|MRPC|STS-B|QQP|MNLI-m|MNLI-mm|QNLI(v2)|RTE|WNLI|AX|
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|Bort |83.6|63.9|96.2|94.1/92.3|89.2/88.3|66.0/85.9|88.1|87.8|92.3|82.7|71.2|51.9|
|BERT-Large|80.5|60.5|94.9|89.3/85.4|87.6/86.5|72.1/89.3|86.7|85.9|92.7|70.1|65.1|39.6|
And SuperGLUE scores on the test set:
|Model|Score|BoolQ|CB|COPA|MultiRC|ReCoRD|RTE|WiC|WSC|AX-b|AX-g|
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|Bort |74.1|83.7|81.9/86.5|89.6|83.7/54.1|49.8/49.0|81.2|70.1|65.8|48.0|96.1/61.5|
|BERT-Large|69.0|77.4|75.7/83.6|70.6|70.0/24.1|72.0/71.3|71.7|69.6|64.4|23.0|97.8/51.7
And here are the architectural parameters:
|Model|Parameters (M) |Layers |Attention heads|Hidden size| Intermediate size| Embedding size (M) | Encoder proportion (%)|
|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|Bort |56 | 4| 8 | 1024 | 768 | 39 | 30.3 |
|BERT-Large|340| 24| 16 | 1024 | 4096 | 31.8| 90.6 |
## Setup:
1. You need to install the requirements from the `requirements.txt` file:
```
pip install -r requirements.txt
```
This code has been tested with Python 3.6.5+.
To save yourself some headache we recommend you install Horovod from source, _after_ you install MxNet. This is only needed if you are pre-training the architecture. For this, run the following commands (you'll need a C++ compiler which supports c++11 standards, like gcc > 4.8):
```bash
pip uninstall horovod
HOROVOD_CUDA_HOME=/usr/local/cuda-10.1 \
HOROVOD_WITH_MXNET=1 \
HOROVOD_GPU_ALLREDUCE=NCCL \
pip install horovod==0.16.2 --no-cache-dir
```
2. You also need to download the model from [here](https://alexa-saif-bort.s3.amazonaws.com/bort.params). If you have the AWS CLI, all you need to do is run:
```
aws s3 cp s3://alexa-saif-bort/bort.params model/
```
3. To run the tests, you also need to download the sample text from [Gluon](https://github.com/dmlc/gluon-nlp/blob/v0.9.x/scripts/bert/sample_text.txt) and put it in `test_data/`:
```
wget https://github.com/dmlc/gluon-nlp/blob/v0.9.x/scripts/bert/sample_text.txt
mv sample_text.txt test_data/
```
## Pre-training:
Bort is already pre-trained, but if you want to try out other datasets, you can follow the steps here. Note that this does not run the FPTAS described in the paper, and works for a fixed architecture (Bort).
1. First, you will need to tokenize the pre-training text:
```bash
python create_pretraining_data.py \
--input_file \
--output_dir
Owner
- Name: Junbum Lee
- Login: Beomi
- Kind: user
- Location: Seoul, South Korea
- Website: https://junbuml.ee
- Twitter: __Beomi__
- Repositories: 110
- Profile: https://github.com/Beomi
AI/ML GDE @ml-gde. Korean AI/NLP Researcher and creator of multiple Korean PLMs. Focused on advancing Open LLMs.