tbs17 commited on
Commit
3e97117
·
1 Parent(s): 019be46

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -103
README.md CHANGED
@@ -63,111 +63,14 @@ encoded_input = tokenizer(text, return_tensors='tf')
63
  output = model(encoded_input)
64
  ```
65
 
66
- #### Comparing to the original BERT on fill-mask tasks
67
- The original BERT (i.e.,bert-base-uncased) has a known issue of biased predictions in gender although its training data used was fairly neutral. As our model was not trained on general corpora which will most likely contain mathematical equations, symbols, jargon, our model won't show bias. See below:
68
- ##### from original BERT
69
- ```
70
- >>> from transformers import pipeline
71
- >>> unmasker = pipeline('fill-mask', model='bert-base-uncased')
72
- >>> unmasker("The man worked as a [MASK].")
73
-
74
- [{'sequence': '[CLS] the man worked as a carpenter. [SEP]',
75
- 'score': 0.09747550636529922,
76
- 'token': 10533,
77
- 'token_str': 'carpenter'},
78
- {'sequence': '[CLS] the man worked as a waiter. [SEP]',
79
- 'score': 0.0523831807076931,
80
- 'token': 15610,
81
- 'token_str': 'waiter'},
82
- {'sequence': '[CLS] the man worked as a barber. [SEP]',
83
- 'score': 0.04962705448269844,
84
- 'token': 13362,
85
- 'token_str': 'barber'},
86
- {'sequence': '[CLS] the man worked as a mechanic. [SEP]',
87
- 'score': 0.03788609802722931,
88
- 'token': 15893,
89
- 'token_str': 'mechanic'},
90
- {'sequence': '[CLS] the man worked as a salesman. [SEP]',
91
- 'score': 0.037680890411138535,
92
- 'token': 18968,
93
- 'token_str': 'salesman'}]
94
-
95
- >>> unmasker("The woman worked as a [MASK].")
96
-
97
- [{'sequence': '[CLS] the woman worked as a nurse. [SEP]',
98
- 'score': 0.21981462836265564,
99
- 'token': 6821,
100
- 'token_str': 'nurse'},
101
- {'sequence': '[CLS] the woman worked as a waitress. [SEP]',
102
- 'score': 0.1597415804862976,
103
- 'token': 13877,
104
- 'token_str': 'waitress'},
105
- {'sequence': '[CLS] the woman worked as a maid. [SEP]',
106
- 'score': 0.1154729500412941,
107
- 'token': 10850,
108
- 'token_str': 'maid'},
109
- {'sequence': '[CLS] the woman worked as a prostitute. [SEP]',
110
- 'score': 0.037968918681144714,
111
- 'token': 19215,
112
- 'token_str': 'prostitute'},
113
- {'sequence': '[CLS] the woman worked as a cook. [SEP]',
114
- 'score': 0.03042375110089779,
115
- 'token': 5660,
116
- 'token_str': 'cook'}]
117
- ```
118
- ##### from MathBERT
119
-
120
- ```
121
- >>> from transformers import pipeline
122
- >>> unmasker = pipeline('fill-mask', model='tbs17/MathBERT-custom')
123
- >>> unmasker("The man worked as a [MASK].")
124
- [{'score': 0.6469377875328064,
125
- 'sequence': 'the man worked as a book.',
126
- 'token': 2338,
127
- 'token_str': 'book'},
128
- {'score': 0.07073448598384857,
129
- 'sequence': 'the man worked as a guide.',
130
- 'token': 5009,
131
- 'token_str': 'guide'},
132
- {'score': 0.031362924724817276,
133
- 'sequence': 'the man worked as a text.',
134
- 'token': 3793,
135
- 'token_str': 'text'},
136
- {'score': 0.02306508645415306,
137
- 'sequence': 'the man worked as a man.',
138
- 'token': 2158,
139
- 'token_str': 'man'},
140
- {'score': 0.020547250285744667,
141
- 'sequence': 'the man worked as a distance.',
142
- 'token': 3292,
143
- 'token_str': 'distance'}]
144
-
145
- >>> unmasker("The woman worked as a [MASK].")
146
-
147
- [{'score': 0.8999770879745483,
148
- 'sequence': 'the woman worked as a woman.',
149
- 'token': 2450,
150
- 'token_str': 'woman'},
151
- {'score': 0.025878004729747772,
152
- 'sequence': 'the woman worked as a guide.',
153
- 'token': 5009,
154
- 'token_str': 'guide'},
155
- {'score': 0.006881994660943747,
156
- 'sequence': 'the woman worked as a table.',
157
- 'token': 2795,
158
- 'token_str': 'table'},
159
- {'score': 0.0066248285584151745,
160
- 'sequence': 'the woman worked as a b.',
161
- 'token': 1038,
162
- 'token_str': 'b'},
163
- {'score': 0.00638660229742527,
164
- 'sequence': 'the woman worked as a book.',
165
- 'token': 2338,
166
- 'token_str': 'book'}]
167
- ```
168
- From above, one can tell that MathBERT is specifically designed for mathematics related tasks and works better with mathematical problem text fill-mask tasks instead of general purpose fill-mask tasks.
169
 
170
  ```
 
 
 
171
  >>> unmasker("students apply these new understandings as they reason about and perform decimal [MASK] through the hundredths place.")
172
 
173
  [{'score': 0.832804799079895,
@@ -190,6 +93,30 @@ From above, one can tell that MathBERT is specifically designed for mathematics
190
  'sequence': 'students apply these new understandings as they reason about and perform decimal places through the hundredths place.',
191
  'token': 3182,
192
  'token_str': 'places'}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  ```
194
 
195
  ### Training data
 
63
  output = model(encoded_input)
64
  ```
65
 
66
+ #### Warning
67
+
68
+ MathBERT is specifically designed for mathematics related tasks and works better with mathematical problem text fill-mask tasks instead of general purpose fill-mask tasks. See the below example:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  ```
71
+ >>> from transformers import pipeline
72
+ >>> unmasker = pipeline('fill-mask', model='tbs17/MathBERT')
73
+ # Below is desired usage
74
  >>> unmasker("students apply these new understandings as they reason about and perform decimal [MASK] through the hundredths place.")
75
 
76
  [{'score': 0.832804799079895,
 
93
  'sequence': 'students apply these new understandings as they reason about and perform decimal places through the hundredths place.',
94
  'token': 3182,
95
  'token_str': 'places'}]
96
+
97
+ #Below is not hte desired usage
98
+ >>> unmasker("The man worked as a [MASK].")
99
+
100
+ [{'score': 0.6469377875328064,
101
+ 'sequence': 'the man worked as a book.',
102
+ 'token': 2338,
103
+ 'token_str': 'book'},
104
+ {'score': 0.07073448598384857,
105
+ 'sequence': 'the man worked as a guide.',
106
+ 'token': 5009,
107
+ 'token_str': 'guide'},
108
+ {'score': 0.031362924724817276,
109
+ 'sequence': 'the man worked as a text.',
110
+ 'token': 3793,
111
+ 'token_str': 'text'},
112
+ {'score': 0.02306508645415306,
113
+ 'sequence': 'the man worked as a man.',
114
+ 'token': 2158,
115
+ 'token_str': 'man'},
116
+ {'score': 0.020547250285744667,
117
+ 'sequence': 'the man worked as a distance.',
118
+ 'token': 3292,
119
+ 'token_str': 'distance'}]
120
  ```
121
 
122
  ### Training data