Views
No views yet
1>>> from transformers import pipeline
2>>> unmasker = pipeline('fill-mask', model='roberta-base')
3>>> unmasker("Hello I'm a <mask> model.")
4
5[{'sequence': "<s>Hello I'm a male model.</s>",
6 'score': 0.3306540250778198,
7 'token': 2943,
8 'token_str': 'Ġmale'},
9 {'sequence': "<s>Hello I'm a female model.</s>",
10 'score': 0.04655390977859497,
11 'token': 2182,
12 'token_str': 'Ġfemale'},
13 {'sequence': "<s>Hello I'm a professional model.</s>",
14 'score': 0.04232972860336304,
15 'token': 2038,
16 'token_str': 'Ġprofessional'},
17 {'sequence': "<s>Hello I'm a fashion model.</s>",
18 'score': 0.037216778844594955,
19 'token': 2734,
20 'token_str': 'Ġfashion'},
21 {'sequence': "<s>Hello I'm a Russian model.</s>",
22 'score': 0.03253649175167084,
23 'token': 1083,
24 'token_str': 'ĠRussian'}]1from transformers import RobertaTokenizer, RobertaModel
2tokenizer = RobertaTokenizer.from_pretrained('roberta-base')
3model = RobertaModel.from_pretrained('roberta-base')
4text = "Replace me by any text you'd like."
5encoded_input = tokenizer(text, return_tensors='pt')
6output = model(**encoded_input)1from transformers import RobertaTokenizer, TFRobertaModel
2tokenizer = RobertaTokenizer.from_pretrained('roberta-base')
3model = TFRobertaModel.from_pretrained('roberta-base')
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='roberta-base')
3>>> unmasker("The man worked as a <mask>.")
4
5[{'sequence': '<s>The man worked as a mechanic.</s>',
6 'score': 0.08702439814805984,
7 'token': 25682,
8 'token_str': 'Ġmechanic'},
9 {'sequence': '<s>The man worked as a waiter.</s>',
10 'score': 0.0819653645157814,
11 'token': 38233,
12 'token_str': 'Ġwaiter'},
13 {'sequence': '<s>The man worked as a butcher.</s>',
14 'score': 0.073323555290699,
15 'token': 32364,
16 'token_str': 'Ġbutcher'},
17 {'sequence': '<s>The man worked as a miner.</s>',
18 'score': 0.046322137117385864,
19 'token': 18678,
20 'token_str': 'Ġminer'},
21 {'sequence': '<s>The man worked as a guard.</s>',
22 'score': 0.040150221437215805,
23 'token': 2510,
24 'token_str': 'Ġguard'}]
25
26>>> unmasker("The Black woman worked as a <mask>.")
27
28[{'sequence': '<s>The Black woman worked as a waitress.</s>',
29 'score': 0.22177888453006744,
30 'token': 35698,
31 'token_str': 'Ġwaitress'},
32 {'sequence': '<s>The Black woman worked as a prostitute.</s>',
33 'score': 0.19288744032382965,
34 'token': 36289,
35 'token_str': 'Ġprostitute'},
36 {'sequence': '<s>The Black woman worked as a maid.</s>',
37 'score': 0.06498628109693527,
38 'token': 29754,
39 'token_str': 'Ġmaid'},
40 {'sequence': '<s>The Black woman worked as a secretary.</s>',
41 'score': 0.05375480651855469,
42 'token': 2971,
43 'token_str': 'Ġsecretary'},
44 {'sequence': '<s>The Black woman worked as a nurse.</s>',
45 'score': 0.05245552211999893,
46 'token': 9008,
47 'token_str': 'Ġnurse'}]<s> and the end of one by </s><mask>.| Task | MNLI | QQP | QNLI | SST-2 | CoLA | STS-B | MRPC | RTE |
|---|---|---|---|---|---|---|---|---|
| 87.6 | 91.9 | 92.8 | 94.8 | 63.6 | 91.2 | 90.2 | 78.7 |
1@article{DBLP:journals/corr/abs-1907-11692,
2 author = {Yinhan Liu and
3 Myle Ott and
4 Naman Goyal and
5 Jingfei Du and
6 Mandar Joshi and
7 Danqi Chen and
8 Omer Levy and
9 Mike Lewis and
10 Luke Zettlemoyer and
11 Veselin Stoyanov},
12 title = {RoBERTa: {A} Robustly Optimized {BERT} Pretraining Approach},
13 journal = {CoRR},
14 volume = {abs/1907.11692},
15 year = {2019},
16 url = {http://arxiv.org/abs/1907.11692},
17 archivePrefix = {arXiv},
18 eprint = {1907.11692},
19 timestamp = {Thu, 01 Aug 2019 08:59:33 +0200},
20 biburl = {https://dblp.org/rec/journals/corr/abs-1907-11692.bib},
21 bibsource = {dblp computer science bibliography, https://dblp.org}
22}