Commit ·
6193cfc
0
Parent(s):
Duplicate from albert/albert-base-v1
Browse filesCo-authored-by: Julien Chaumond <julien-c@users.noreply.huggingface.co>
Files changed (10)
- .gitattributesAdded+9
- README.mdAdded+277
- config.jsonAdded+29
- model.safetensorsAdded+3
- pytorch_model.binAdded+3
- spiece.modelAdded
- tf_model.h5Added+3
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+1
- with-prefix-tf_model.h5Added+3
123456789*.bin.* filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tar.gz filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -textmodel.safetensors filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277---tags:- exbert
language: enlicense: apache-2.0datasets:- bookcorpus- wikipedia---
# ALBERT Base v1
Pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in[this paper](https://arxiv.org/abs/1909.11942) and first released in[this repository](https://github.com/google-research/albert). This model, as all ALBERT models, is uncased: it does not make a differencebetween english and English.
Disclaimer: The team releasing ALBERT did not write a model card for this model so this model card has been written bythe Hugging Face team.
## Model description
ALBERT is a transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means itwas pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots ofpublicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, itwas pretrained with two objectives:
- Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the sentence.- Sentence Ordering Prediction (SOP): ALBERT uses a pretraining loss based on predicting the ordering of two consecutive segments of text.
This way, the model learns an inner representation of the English language that can then be used to extract featuresuseful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standardclassifier using the features produced by the ALBERT model as inputs.
ALBERT is particular in that it shares its layers across its Transformer. Therefore, all layers have the same weights. Using repeating layers results in a small memory footprint, however, the computational cost remains similar to a BERT-like architecture with the same number of hidden layers as it has to iterate through the same number of (repeating) layers.
This is the first version of the base model. Version 2 is different from version 1 due to different dropout rates, additional training data, and longer training. It has better results in nearly all downstream tasks.
This model has the following configuration:
- 12 repeating layers- 128 embedding dimension- 768 hidden dimension- 12 attention heads- 11M parameters
## Intended uses & limitations
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended tobe fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=albert) to look forfine-tuned versions on a task that interests you.
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)to make decisions, such as sequence classification, token classification or question answering. For tasks such as textgeneration you should look at model like GPT2.
### How to use
You can use this model directly with a pipeline for masked language modeling:
```python>>> from transformers import pipeline>>> unmasker = pipeline('fill-mask', model='albert-base-v1')>>> unmasker("Hello I'm a [MASK] model.")[ { "sequence":"[CLS] hello i'm a modeling model.[SEP]", "score":0.05816134437918663, "token":12807, "token_str":"▁modeling" }, { "sequence":"[CLS] hello i'm a modelling model.[SEP]", "score":0.03748830780386925, "token":23089, "token_str":"▁modelling" }, { "sequence":"[CLS] hello i'm a model model.[SEP]", "score":0.033725276589393616, "token":1061, "token_str":"▁model" }, { "sequence":"[CLS] hello i'm a runway model.[SEP]", "score":0.017313428223133087, "token":8014, "token_str":"▁runway" }, { "sequence":"[CLS] hello i'm a lingerie model.[SEP]", "score":0.014405295252799988, "token":29104, "token_str":"▁lingerie" }]```
Here is how to use this model to get the features of a given text in PyTorch:
```pythonfrom transformers import AlbertTokenizer, AlbertModeltokenizer = AlbertTokenizer.from_pretrained('albert-base-v1')model = AlbertModel.from_pretrained("albert-base-v1")text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='pt')output = model(**encoded_input)```
and in TensorFlow:
```pythonfrom transformers import AlbertTokenizer, TFAlbertModeltokenizer = AlbertTokenizer.from_pretrained('albert-base-v1')model = TFAlbertModel.from_pretrained("albert-base-v1")text = "Replace me by any text you'd like."encoded_input = tokenizer(text, return_tensors='tf')output = model(encoded_input)```
### Limitations and bias
Even if the training data used for this model could be characterized as fairly neutral, this model can have biasedpredictions:
```python>>> from transformers import pipeline>>> unmasker = pipeline('fill-mask', model='albert-base-v1')>>> unmasker("The man worked as a [MASK].")
[ { "sequence":"[CLS] the man worked as a chauffeur.[SEP]", "score":0.029577180743217468, "token":28744, "token_str":"▁chauffeur" }, { "sequence":"[CLS] the man worked as a janitor.[SEP]", "score":0.028865724802017212, "token":29477, "token_str":"▁janitor" }, { "sequence":"[CLS] the man worked as a shoemaker.[SEP]", "score":0.02581118606030941, "token":29024, "token_str":"▁shoemaker" }, { "sequence":"[CLS] the man worked as a blacksmith.[SEP]", "score":0.01849772222340107, "token":21238, "token_str":"▁blacksmith" }, { "sequence":"[CLS] the man worked as a lawyer.[SEP]", "score":0.01820771023631096, "token":3672, "token_str":"▁lawyer" }]
>>> unmasker("The woman worked as a [MASK].")
[ { "sequence":"[CLS] the woman worked as a receptionist.[SEP]", "score":0.04604868218302727, "token":25331, "token_str":"▁receptionist" }, { "sequence":"[CLS] the woman worked as a janitor.[SEP]", "score":0.028220869600772858, "token":29477, "token_str":"▁janitor" }, { "sequence":"[CLS] the woman worked as a paramedic.[SEP]", "score":0.0261906236410141, "token":23386, "token_str":"▁paramedic" }, { "sequence":"[CLS] the woman worked as a chauffeur.[SEP]", "score":0.024797942489385605, "token":28744, "token_str":"▁chauffeur" }, { "sequence":"[CLS] the woman worked as a waitress.[SEP]", "score":0.024124596267938614, "token":13678, "token_str":"▁waitress" }]```
This bias will also affect all fine-tuned versions of this model.
## Training data
The ALBERT model was pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables andheaders).
## Training procedure
### Preprocessing
The texts are lowercased and tokenized using SentencePiece and a vocabulary size of 30,000. The inputs of the model arethen of the form:
```[CLS] Sentence A [SEP] Sentence B [SEP]```
### Training
The ALBERT procedure follows the BERT setup.
The details of the masking procedure for each sentence are the following:- 15% of the tokens are masked.- In 80% of the cases, the masked tokens are replaced by `[MASK]`.- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.- In the 10% remaining cases, the masked tokens are left as is.
## Evaluation results
When fine-tuned on downstream tasks, the ALBERT models achieve the following results:
| | Average | SQuAD1.1 | SQuAD2.0 | MNLI | SST-2 | RACE ||----------------|----------|----------|----------|----------|----------|----------||V2 ||ALBERT-base |82.3 |90.2/83.2 |82.1/79.3 |84.6 |92.9 |66.8 ||ALBERT-large |85.7 |91.8/85.2 |84.9/81.8 |86.5 |94.9 |75.2 ||ALBERT-xlarge |87.9 |92.9/86.4 |87.9/84.1 |87.9 |95.4 |80.7 ||ALBERT-xxlarge |90.9 |94.6/89.1 |89.8/86.9 |90.6 |96.8 |86.8 ||V1 ||ALBERT-base |80.1 |89.3/82.3 | 80.0/77.1|81.6 |90.3 | 64.0 ||ALBERT-large |82.4 |90.6/83.9 | 82.3/79.4|83.5 |91.7 | 68.5 ||ALBERT-xlarge |85.5 |92.5/86.1 | 86.1/83.1|86.4 |92.4 | 74.8 ||ALBERT-xxlarge |91.0 |94.8/89.3 | 90.2/87.4|90.8 |96.9 | 86.5 |
### BibTeX entry and citation info
```bibtex@article{DBLP:journals/corr/abs-1909-11942, author = {Zhenzhong Lan and Mingda Chen and Sebastian Goodman and Kevin Gimpel and Piyush Sharma and Radu Soricut}, title = {{ALBERT:} {A} Lite {BERT} for Self-supervised Learning of Language Representations}, journal = {CoRR}, volume = {abs/1909.11942}, year = {2019}, url = {http://arxiv.org/abs/1909.11942}, archivePrefix = {arXiv}, eprint = {1909.11942}, timestamp = {Fri, 27 Sep 2019 13:04:21 +0200}, biburl = {https://dblp.org/rec/journals/corr/abs-1909-11942.bib}, bibsource = {dblp computer science bibliography, https://dblp.org}}```<a href="https://huggingface.co/exbert/?model=albert-base-v1"> <img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png"></a>1234567891011121314151617181920212223242526272829{ "architectures": [ "AlbertForMaskedLM" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": 2, "classifier_dropout_prob": 0.1, "down_scale_factor": 1, "embedding_size": 128, "eos_token_id": 3, "gap_size": 0, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "inner_group_num": 1, "intermediate_size": 3072, "layer_norm_eps": 1e-12, "max_position_embeddings": 512, "model_type": "albert", "net_structure_type": 0, "num_attention_heads": 12, "num_hidden_groups": 1, "num_hidden_layers": 12, "num_memory_blocks": 0, "pad_token_id": 0, "type_vocab_size": 2, "vocab_size": 30000}123version https://git-lfs.github.com/spec/v1oid sha256:28ede8cd37c7e0605ae75c32a1961436c0d3b1d0d2086e008a8f22fbd22bbeb7size 47372900123version https://git-lfs.github.com/spec/v1oid sha256:051305f01a2699dbc89279d6849234d7677d40cdf7ad1b41e635d9c189111ad8size 47376396123version https://git-lfs.github.com/spec/v1oid sha256:0616affccb135620b2cd3646832871ac97ae0852d00e0e302363e7b74b562c45size 630483681{"model_max_length": 512}123version https://git-lfs.github.com/spec/v1oid sha256:0616affccb135620b2cd3646832871ac97ae0852d00e0e302363e7b74b562c45size 63048368.gitattributesAdded+9
README.mdAdded+277
config.jsonAdded+29
model.safetensorsAdded+3
pytorch_model.binAdded+3
spiece.modelAdded
tf_model.h5Added+3
tokenizer.jsonAdded
tokenizer_config.jsonAdded+1
with-prefix-tf_model.h5Added+3