transformers/examples/research_projects/deebert
Arthur 651408a077
[Styling] stylify using ruff (#27144)
* try to stylify using ruff

* might need to remove these changes?

* use ruf format andruff check

* use isinstance instead of type comparision

* use # fmt: skip

* use # fmt: skip

* nits

* soem styling changes

* update ci job

* nits isinstance

* more files update

* nits

* more nits

* small nits

* check and format

* revert wrong changes

* actually use formatter instead of checker

* nits

* well docbuilder is overwriting this commit

* revert notebook changes

* try to nuke docbuilder

* style

* fix feature exrtaction test

* remve `indent-width = 4`

* fixup

* more nits

* update the ruff version that we use

* style

* nuke docbuilder styling

* leve the print for detected changes

* nits

* Remove file I/O

Co-authored-by: charliermarsh
 <charlie.r.marsh@gmail.com>

* style

* nits

* revert notebook changes

* Add # fmt skip when possible

* Add # fmt skip when possible

* Fix

* More `  # fmt: skip` usage

* More `  # fmt: skip` usage

* More `  # fmt: skip` usage

* NIts

* more fixes

* fix tapas

* Another way to skip

* Recommended way

* Fix two more fiels

* Remove asynch
Remove asynch

---------

Co-authored-by: charliermarsh <charlie.r.marsh@gmail.com>
2023-11-16 17:43:19 +01:00
..
src [Styling] stylify using ruff (#27144) 2023-11-16 17:43:19 +01:00
entropy_eval.sh Reorganize examples (#9010) 2020-12-11 10:07:02 -05:00
eval_deebert.sh Reorganize examples (#9010) 2020-12-11 10:07:02 -05:00
README.md Reorganize examples (#9010) 2020-12-11 10:07:02 -05:00
requirements.txt Reorganize examples (#9010) 2020-12-11 10:07:02 -05:00
run_glue_deebert.py Add many missing spaces in adjacent strings (#26751) 2023-10-12 10:28:40 +02:00
test_glue_deebert.py Update quality tooling for formatting (#21480) 2023-02-06 18:10:56 -05:00
train_deebert.sh Reorganize examples (#9010) 2020-12-11 10:07:02 -05:00

DeeBERT: Early Exiting for *BERT

This is the code base for the paper DeeBERT: Dynamic Early Exiting for Accelerating BERT Inference, modified from its original code base.

The original code base also has information for downloading sample models that we have trained in advance.

Usage

There are three scripts in the folder which can be run directly.

In each script, there are several things to modify before running:

  • PATH_TO_DATA: path to the GLUE dataset.
  • --output_dir: path for saving fine-tuned models. Default: ./saved_models.
  • --plot_data_dir: path for saving evaluation results. Default: ./results. Results are printed to stdout and also saved to npy files in this directory to facilitate plotting figures and further analyses.
  • MODEL_TYPE: bert or roberta
  • MODEL_SIZE: base or large
  • DATASET: SST-2, MRPC, RTE, QNLI, QQP, or MNLI

train_deebert.sh

This is for fine-tuning DeeBERT models.

eval_deebert.sh

This is for evaluating each exit layer for fine-tuned DeeBERT models.

entropy_eval.sh

This is for evaluating fine-tuned DeeBERT models, given a number of different early exit entropy thresholds.

Citation

Please cite our paper if you find the resource useful:

@inproceedings{xin-etal-2020-deebert,
    title = "{D}ee{BERT}: Dynamic Early Exiting for Accelerating {BERT} Inference",
    author = "Xin, Ji  and
      Tang, Raphael  and
      Lee, Jaejun  and
      Yu, Yaoliang  and
      Lin, Jimmy",
    booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
    month = jul,
    year = "2020",
    address = "Online",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/2020.acl-main.204",
    pages = "2246--2251",
}