2022/3/29 (BMCook 0.1.0) Now we publicly release the first version of BMCook.
Overview
BMCook is a model compression toolkit for large-scale pre-trained language models (PLMs), which integrates multiple model compression methods. You can combine them in any way to achieve the desired speedup. Specifically, we implement the following four model compression methods, knowledge distillation, model pruning, model quantization, and model MoEfication. It has following features:
Various Supported Methods. Compared to existing compression toolkits, BMCook supports all mainstream acceleration methods for pre-trained language models.
User Friendly. Based on BMCook, we can implement different compression methods with just a few lines of codes.
Combination in Any Way. Due to the decoupled implications, the compression methods can be combined in any way towards extreme acceleration.
Documentation
Our documentation provides more information about the package.
🍳 BMCook
Model Compression for Big Models
Overview • Documentation • Installation • Quick Start • 简体中文
What’s New
Overview
BMCook is a model compression toolkit for large-scale pre-trained language models (PLMs), which integrates multiple model compression methods. You can combine them in any way to achieve the desired speedup. Specifically, we implement the following four model compression methods, knowledge distillation, model pruning, model quantization, and model MoEfication. It has following features:
Documentation
Our documentation provides more information about the package.
Installation
To use BMCook, first install BMTrain.
From PyPI (Recommend)
From Source
Please refer to the installation guide of BMTrain for more details.
Then, clone the repository.
Quick Start
The
example
folder provides example codes based on GPT-J (6B).Quantization-aware training:
Quantization-aware training with knowledge distillation:
Model pruning:
MoEfication (save the hidden states and then use the MoEfication toolkit):
Combine quantization, pruning and knowledge distillation:
Performances
Based on GPT-J, we evaluate different combinations of compression techniques. The corpus is OpenWebText.
D denotes knowledge distillation. P denotes pruning. Q denotes quantization. M denotes MoEfication.
Comparisons
TODO
In the next version, we will provide a one-line interface for the compression of arbitrary PLMs, which could further simplify the code. Stay tuned!
Community
We welcome everyone to contribute codes following our contributing guidelines.
You can also find us on other platforms:
License
The package is released under the Apache 2.0 License.
Contributors
We thank Zhengyan Zhang, Yingfa Chen, Guoyang Zeng, Jie Zhou, and Zhi Zheng for the contribution. More contributors are welcome!