Git Product home page Git Product logo

yoco-bert's Introduction

You Only Compress Once: Towards Effective and Elastic BERT Compression via Exploit-Explore Stochastic Nature Gradient (paper)

@misc{zhang2021compress,
      title={You Only Compress Once: Towards Effective and Elastic BERT Compression via Exploit-Explore Stochastic Nature Gradient}, 
      author={Shaokun Zhang and Xiawu Zheng and Chenyi Yang and Yuchao Li and Yan Wang and Fei Chao and Mengdi Wang and Shen Li and Jun Yang and Rongrong Ji},
      year={2021},
      eprint={2106.02435},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
      } 

Overview

This repository is the official implementation of You Only Compress Once: Towards Effective and Elastic BERT Compression via Exploit-Explore Stochastic Nature Gradient

📋 We propose a novel approach, YOCO-BERT, to achieve compress once and deploy everywhere. Compared with state of-the-art algorithms, YOCO-BERT provides more compact models, yet achieving superior average accuracy improvement on the GLUE.

Requirements

  • Python > 3.6
  • Pytorch = 1.7.0
  • transformers = 3.5.0

Training

To train the super-BERTs in the paper, run this command:

python train_superbert.py --cfg /path_to_superbert_training_config/config.yaml

Searching

To search the optimal sub-BERTs given any constraints in the paper, run this command:

python search_subbert.py --cfg /path_to_subbert_searching_config/config.yaml

Evaluation

The evaluation results will be reported after the searching process.

Config

We release all the traning and searching configs in config

Results

Our model achieves the following performance on :

Results given various FlOPs and parameters.

Results under common constraints (compress to no more than 66M)

Datasets SST-2 MRPC CoLA RTE MNLI QQP QNLI
Results 92.8 90.3 59.8 72.9 82.6 90.5 87.2

📋 The detailed metrics used in this code are reported in the paper.

Licence

This repository is released under the MIT license. See LICENSE for more information.

Contact

Any problem regarding this code re-implementation, feel free to contact the first author: [email protected]

yoco-bert's People

Contributors

skzhang1 avatar

Stargazers

賴祺清 avatar xihajun avatar  avatar tuofeilun avatar abdel_kareem avatar  avatar  avatar  avatar 林豪佳 avatar kerepran avatar Jon Chun avatar  avatar App Service avatar Tin C. avatar Betterme avatar ljx avatar  avatar Elisa Terumi Rubel Schneider avatar edwincheong avatar Arash Farahani avatar Mamunur Rahaman Mamun avatar  avatar Ashish Patel avatar  avatar Dasen Yan avatar Vinod avatar Gowtham.R avatar xingliang lin avatar Haoxuan You avatar Bencheng avatar Felix avatar Ashin avatar  avatar Peizhuo Lv avatar yanren avatar 爱可可-爱生活 avatar Jose Cohenca avatar  avatar  avatar lang tang avatar Ming Li avatar Bohong Chen avatar  avatar Roger GOU avatar Ninnart Fuengfusin avatar Yuxin Zhang avatar Ah-Weii avatar SherwoodZheng avatar

Watchers

James Cloos avatar SherwoodZheng avatar

yoco-bert's Issues

Bugs repair please~

Hi, buddy, there are a lot of bugs that I cannot run the "train-supernet.py" successfully !

model settings issue in train_supernet.py

In addition, there is one imported model >from model.supermodel import BertForSequenceClassification
And you try to create teacher_model and super_model with the same SuperModel (SuperEmbedding, SuperLinear, SuperLayerNorm) setting?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.