FastPLM
An Empirical Study on Adaptive Inference for Pre-trained Language Model.
Model Zoo
FastPLM is supported by the UER project, and all of UER high-quality models can be accelerated in the Adaptive inference way.
FastPLM object supports the following models:
| Models (kernel_name) | URL | Description |
|---|---|---|
| google_bert_base_en | https://share.weiyun.com/fpdOtcmz | Google pretrained English BERT-base model on Wiki corpus. |
| google_bert_base_zh | https://share.weiyun.com/AykBph9V | Google pretrained Chinese BERT-base model on Wiki corpus. |
| uer_bert_large_zh | https://share.weiyun.com/chx2VhGk | UER pretrained Chinese BERT-large model on mixed corpus. |
| uer_bert_small_zh | https://share.weiyun.com/wZuVBM5g | UER pretrained Chinese BERT-small model on mixed corpus. |
| uer_bert_tiny_zh | https://share.weiyun.com/VJ3JEN9Z | UER pretrained Chinese BERT-tiny model on mixed corpus. |
| uer_roberta_base_zh | https://share.weiyun.com/2gdpc4P0 | Facebook pretrained Chinese RoBerta-base model. |
| uer_roberta_base_en | https://share.weiyun.com/xHrPjgEK | Facebook pretrained English RoBerta-base model. |
| uer_gpt_zh | https://share.weiyun.com/Pzn5Iob2 | UER pretrained Chinese GPT model on mixed corpus. |
| uer_gpt_en | https://share.weiyun.com/Kc7KlgBs | UER pretrained English GPT model on Wikien corpus. |
| uer_gcnn_9_zh | https://share.weiyun.com/AIL6xiPa | UER pretrained Chinese GCNN model on Wiki corpus. |
| uer_gcnn_9_en | https://share.weiyun.com/TzjugXLH | UER pretrained English GCNN model on Wikien corpus. |
| google_albert_base_en | https://share.weiyun.com/artkxjB1 | Google pretrained English ALBERT-base model. |
| google_albert_base_zh | https://share.weiyun.com/ewaiqKdR | Google pretrained Chinese ALBERT-base model. |
| huawei_tinybert_4_en | https://share.weiyun.com/HaulZbd2 | Huawei pretrained English TinyBERT_4 model. |
| huawei_tinybert_6_en | https://share.weiyun.com/jPg6FkwA | Huawei pretrained English TinyBERT_6 model. |
In fact, you don't have to download the model yourself. FastPLM will download the corresponding model file automatically at the first time you use it. If the automatically downloading failed, you can download these model files from the above URLs, and saving them to the directory of "~/.fastplm/".
Quick Start
Single-sentence classification
An example of single-sentence classification is shown in single_sentence_classification.
from fastplm import FastPLM
# Loading your dataset
labels = ['T', 'F']
sents_train = [
'Do you like FastPLM?',
'Yes, it runs faster than original PLM!',
...
]
labels_train = [
'T',
'F',
...
]
# Creating a model
model = FastPLM(
kernel_name="google_bert_base_en", # "google_bert_base_zh" for Chinese
labels=labels,
device='cuda:0'
)
# Training the model
model.fit(
sents_train,
labels_train,
model_saving_path='./fastplm.bin',
)
# Loading the model and making inference
model.load_model('./fastplm.bin')
label, exec_layers = model('I like FastPLM', speed=0.7)
Double-sentence classification
An example of double-sentence classification is shown in double_sentence_classification.
Acknowledgement
This work is supported by Tencent Rhino-Bird Program. A portion of this work was presented at the 58th Annual Meeting of the Association for Computational Linguistics (ACL) in July 2020, FastBERT.
@article{weijieliu2021fastplm,
title={An Empirical Study on Adaptive Inference for Pre-trained Language Model},
author={Weijie Liu, Xin Zhao, Zhe Zhao, Qi Ju*, Xuefeng Yang, and Wei Lu},
journal={IEEE TRANSACTIONS ON NEURAL NETWORKS AND LEARNING SYSTEMS},
year={2021}
}
Metadata
Release files for fastplm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastplm-1.0.0.tar.gz | 210.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastplm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 444.3 kB
Release files / fastplm-1.0.0.tar.gz
| Download URL | fastplm-1.0.0.tar.gz |
|---|---|
| Size | 210.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
089cb0befadd50e8d7a1f8bc7390720ff789a29025d41de9205b000b5353bd08
|
|
BLAKE2b-256 checksum How to use checksums |
5d492926f2ebb8eb3d7826e2c114e9ab673a897a20f9d7c59ac46acbe4bbbee7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / fastplm-1.0.0-py3-none-any.whl
| Download URL | fastplm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 233.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
438879572753db6db0b795b92686822fc01cbe5b293b7cb21553cadab3ef08d5
|
|
BLAKE2b-256 checksum How to use checksums |
f6498a1f264fb4bfcec07bc9f93fcf4f2bab29c4f7375dabfc97f8e008a9dc5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for fastplm 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.