Views
No views yet
1>>> from transformers import pipeline
2>>> nlp = pipeline('fill-mask', model='zanelim/singbert-large-sg')
3>>> nlp("kopi c siew [MASK]")
4
5[{'sequence': '[CLS] kopi c siew dai [SEP]',
6 'score': 0.9003700017929077,
7 'token': 18765,
8 'token_str': 'dai'},
9 {'sequence': '[CLS] kopi c siew mai [SEP]',
10 'score': 0.0779474675655365,
11 'token': 14736,
12 'token_str': 'mai'},
13 {'sequence': '[CLS] kopi c siew. [SEP]',
14 'score': 0.0032227332703769207,
15 'token': 1012,
16 'token_str': '.'},
17 {'sequence': '[CLS] kopi c siew bao [SEP]',
18 'score': 0.0017727474914863706,
19 'token': 25945,
20 'token_str': 'bao'},
21 {'sequence': '[CLS] kopi c siew peng [SEP]',
22 'score': 0.0012526646023616195,
23 'token': 26473,
24 'token_str': 'peng'}]
25
26>>> nlp("one teh c siew dai, and one kopi [MASK]")
27
28[{'sequence': '[CLS] one teh c siew dai, and one kopi. [SEP]',
29 'score': 0.5249741077423096,
30 'token': 1012,
31 'token_str': '.'},
32 {'sequence': '[CLS] one teh c siew dai, and one kopi o [SEP]',
33 'score': 0.27349168062210083,
34 'token': 1051,
35 'token_str': 'o'},
36 {'sequence': '[CLS] one teh c siew dai, and one kopi peng [SEP]',
37 'score': 0.057190295308828354,
38 'token': 26473,
39 'token_str': 'peng'},
40 {'sequence': '[CLS] one teh c siew dai, and one kopi c [SEP]',
41 'score': 0.04022320732474327,
42 'token': 1039,
43 'token_str': 'c'},
44 {'sequence': '[CLS] one teh c siew dai, and one kopi? [SEP]',
45 'score': 0.01191170234233141,
46 'token': 1029,
47 'token_str': '?'}]
48
49>>> nlp("die [MASK] must try")
50
51[{'sequence': '[CLS] die die must try [SEP]',
52 'score': 0.9921030402183533,
53 'token': 3280,
54 'token_str': 'die'},
55 {'sequence': '[CLS] die also must try [SEP]',
56 'score': 0.004993876442313194,
57 'token': 2036,
58 'token_str': 'also'},
59 {'sequence': '[CLS] die liao must try [SEP]',
60 'score': 0.000317625846946612,
61 'token': 727,
62 'token_str': 'liao'},
63 {'sequence': '[CLS] die still must try [SEP]',
64 'score': 0.0002260878391098231,
65 'token': 2145,
66 'token_str': 'still'},
67 {'sequence': '[CLS] die i must try [SEP]',
68 'score': 0.00016935862367972732,
69 'token': 1045,
70 'token_str': 'i'}]
71
72>>> nlp("dont play [MASK] leh")
73
74[{'sequence': '[CLS] dont play play leh [SEP]',
75 'score': 0.9079819321632385,
76 'token': 2377,
77 'token_str': 'play'},
78 {'sequence': '[CLS] dont play punk leh [SEP]',
79 'score': 0.006846973206847906,
80 'token': 7196,
81 'token_str': 'punk'},
82 {'sequence': '[CLS] dont play games leh [SEP]',
83 'score': 0.004041737411171198,
84 'token': 2399,
85 'token_str': 'games'},
86 {'sequence': '[CLS] dont play politics leh [SEP]',
87 'score': 0.003728888463228941,
88 'token': 4331,
89 'token_str': 'politics'},
90 {'sequence': '[CLS] dont play cheat leh [SEP]',
91 'score': 0.0032805048394948244,
92 'token': 21910,
93 'token_str': 'cheat'}]
94
95>>> nlp("confirm plus [MASK]")
96
97{'sequence': '[CLS] confirm plus chop [SEP]',
98 'score': 0.9749826192855835,
99 'token': 24494,
100 'token_str': 'chop'},
101 {'sequence': '[CLS] confirm plus chopped [SEP]',
102 'score': 0.017554156482219696,
103 'token': 24881,
104 'token_str': 'chopped'},
105 {'sequence': '[CLS] confirm plus minus [SEP]',
106 'score': 0.002725469646975398,
107 'token': 15718,
108 'token_str': 'minus'},
109 {'sequence': '[CLS] confirm plus guarantee [SEP]',
110 'score': 0.000900257145985961,
111 'token': 11302,
112 'token_str': 'guarantee'},
113 {'sequence': '[CLS] confirm plus one [SEP]',
114 'score': 0.0004384620988275856,
115 'token': 2028,
116 'token_str': 'one'}]
117
118>>> nlp("catch no [MASK]")
119
120[{'sequence': '[CLS] catch no ball [SEP]',
121 'score': 0.9381157159805298,
122 'token': 3608,
123 'token_str': 'ball'},
124 {'sequence': '[CLS] catch no balls [SEP]',
125 'score': 0.060842301696538925,
126 'token': 7395,
127 'token_str': 'balls'},
128 {'sequence': '[CLS] catch no fish [SEP]',
129 'score': 0.00030917322146706283,
130 'token': 3869,
131 'token_str': 'fish'},
132 {'sequence': '[CLS] catch no breath [SEP]',
133 'score': 7.552534952992573e-05,
134 'token': 3052,
135 'token_str': 'breath'},
136 {'sequence': '[CLS] catch no tail [SEP]',
137 'score': 4.208395694149658e-05,
138 'token': 5725,
139 'token_str': 'tail'}]
1401from transformers import BertTokenizer, BertModel
2tokenizer = BertTokenizer.from_pretrained('zanelim/singbert-large-sg')
3model = BertModel.from_pretrained("zanelim/singbert-large-sg")
4text = "Replace me by any text you'd like."
5encoded_input = tokenizer(text, return_tensors='pt')
6output = model(**encoded_input)1from transformers import BertTokenizer, TFBertModel
2tokenizer = BertTokenizer.from_pretrained("zanelim/singbert-large-sg")
3model = TFBertModel.from_pretrained("zanelim/singbert-large-sg")
4text = "Replace me by any text you'd like."
5encoded_input = tokenizer(text, return_tensors='tf')
6output = model(encoded_input)r/singapore and r/malaysia, and forums such as hardwarezone.