Views
No views yet
1>>> from transformers import pipeline
2>>> unmasker = pipeline('fill-mask', model='albert-large-v2')
3>>> unmasker("Hello I'm a [MASK] model.")
4[
5 {
6 "sequence":"[CLS] hello i'm a modeling model.[SEP]",
7 "score":0.05816134437918663,
8 "token":12807,
9 "token_str":"â–modeling"
10 },
11 {
12 "sequence":"[CLS] hello i'm a modelling model.[SEP]",
13 "score":0.03748830780386925,
14 "token":23089,
15 "token_str":"â–modelling"
16 },
17 {
18 "sequence":"[CLS] hello i'm a model model.[SEP]",
19 "score":0.033725276589393616,
20 "token":1061,
21 "token_str":"â–model"
22 },
23 {
24 "sequence":"[CLS] hello i'm a runway model.[SEP]",
25 "score":0.017313428223133087,
26 "token":8014,
27 "token_str":"â–runway"
28 },
29 {
30 "sequence":"[CLS] hello i'm a lingerie model.[SEP]",
31 "score":0.014405295252799988,
32 "token":29104,
33 "token_str":"â–lingerie"
34 }
35]1from transformers import AlbertTokenizer, AlbertModel
2tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2')
3model = AlbertModel.from_pretrained("albert-large-v2")
4text = "Replace me by any text you'd like."
5encoded_input = tokenizer(text, return_tensors='pt')
6output = model(**encoded_input)1from transformers import AlbertTokenizer, TFAlbertModel
2tokenizer = AlbertTokenizer.from_pretrained('albert-large-v2')
3model = TFAlbertModel.from_pretrained("albert-large-v2")
4text = "Replace me by any text you'd like."
5encoded_input = tokenizer(text, return_tensors='tf')
6output = model(encoded_input)1>>> from transformers import pipeline
2>>> unmasker = pipeline('fill-mask', model='albert-large-v2')
3>>> unmasker("The man worked as a [MASK].")
4
5[
6 {
7 "sequence":"[CLS] the man worked as a chauffeur.[SEP]",
8 "score":0.029577180743217468,
9 "token":28744,
10 "token_str":"â–chauffeur"
11 },
12 {
13 "sequence":"[CLS] the man worked as a janitor.[SEP]",
14 "score":0.028865724802017212,
15 "token":29477,
16 "token_str":"â–janitor"
17 },
18 {
19 "sequence":"[CLS] the man worked as a shoemaker.[SEP]",
20 "score":0.02581118606030941,
21 "token":29024,
22 "token_str":"â–shoemaker"
23 },
24 {
25 "sequence":"[CLS] the man worked as a blacksmith.[SEP]",
26 "score":0.01849772222340107,
27 "token":21238,
28 "token_str":"â–blacksmith"
29 },
30 {
31 "sequence":"[CLS] the man worked as a lawyer.[SEP]",
32 "score":0.01820771023631096,
33 "token":3672,
34 "token_str":"â–lawyer"
35 }
36]
37
38>>> unmasker("The woman worked as a [MASK].")
39
40[
41 {
42 "sequence":"[CLS] the woman worked as a receptionist.[SEP]",
43 "score":0.04604868218302727,
44 "token":25331,
45 "token_str":"â–receptionist"
46 },
47 {
48 "sequence":"[CLS] the woman worked as a janitor.[SEP]",
49 "score":0.028220869600772858,
50 "token":29477,
51 "token_str":"â–janitor"
52 },
53 {
54 "sequence":"[CLS] the woman worked as a paramedic.[SEP]",
55 "score":0.0261906236410141,
56 "token":23386,
57 "token_str":"â–paramedic"
58 },
59 {
60 "sequence":"[CLS] the woman worked as a chauffeur.[SEP]",
61 "score":0.024797942489385605,
62 "token":28744,
63 "token_str":"â–chauffeur"
64 },
65 {
66 "sequence":"[CLS] the woman worked as a waitress.[SEP]",
67 "score":0.024124596267938614,
68 "token":13678,
69 "token_str":"â–waitress"
70 }
71][CLS] Sentence A [SEP] Sentence B [SEP][MASK].| 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 |
1@article{DBLP:journals/corr/abs-1909-11942,
2 author = {Zhenzhong Lan and
3 Mingda Chen and
4 Sebastian Goodman and
5 Kevin Gimpel and
6 Piyush Sharma and
7 Radu Soricut},
8 title = {{ALBERT:} {A} Lite {BERT} for Self-supervised Learning of Language
9 Representations},
10 journal = {CoRR},
11 volume = {abs/1909.11942},
12 year = {2019},
13 url = {http://arxiv.org/abs/1909.11942},
14 archivePrefix = {arXiv},
15 eprint = {1909.11942},
16 timestamp = {Fri, 27 Sep 2019 13:04:21 +0200},
17 biburl = {https://dblp.org/rec/journals/corr/abs-1909-11942.bib},
18 bibsource = {dblp computer science bibliography, https://dblp.org}
19}