clincolnoz commited on
Commit
c10a9c0
·
1 Parent(s): a134679

first commit

Browse files
README.md ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: fill-mask
7
+ tags:
8
+ - not-for-all-audiences
9
+ - abusive language
10
+ - hate speech
11
+ - offensive language
12
+ widget:
13
+ - text: They is a [MASK].
14
+ example_title: Neutral
15
+ - text: She is a [MASK].
16
+ example_title: Misogyny
17
+ - text: He is a [MASK].
18
+ example_title: Misandry
19
+ ---
20
+
21
+ **WARNING: Some language produced by this model and README may offend. The model intent is to facilitate bias in AI research**
22
+
23
+ # notSexistBERT base model (uncased)
24
+
25
+ Re-pretrained model on English language using a Masked Language Modeling (MLM)
26
+ and Next Sentence Prediction (NSP) objective. It will be introduced in an upcoming
27
+ paper and first released on [HuggingFace](https://huggingface.co/clincolnoz/notSexistBERT_temp). This model is uncased: it does not make a difference between english and English.
28
+
29
+ ## Model description
30
+
31
+ sexistBERT is a transformers model pretrained on a **less sexist** corpus of English data in a
32
+ self-supervised fashion. This means it was pretrained on the raw texts only,
33
+ with no humans labeling them in any way (which is why it can use lots of
34
+ publicly available data) with an automatic process to generate inputs and labels
35
+ from those texts. More precisely, it was pretrained with two objectives:
36
+
37
+ - Masked language modeling (MLM): taking a sentence, the model randomly masks
38
+ 15% of the words in the input then run the entire masked sentence through the
39
+ model and has to predict the masked words. This is different from traditional
40
+ recurrent neural networks (RNNs) that usually see the words one after the
41
+ other, or from autoregressive models like GPT which internally masks the
42
+ future tokens. It allows the model to learn a bidirectional representation of
43
+ the sentence.
44
+ - Next sentence prediction (NSP): the models concatenates two masked sentences
45
+ as inputs during pretraining. Sometimes they correspond to sentences that were
46
+ next to each other in the original text, sometimes not. The model then has to
47
+ predict if the two sentences were following each other or not.
48
+
49
+ This way, the model learns an inner representation of the English language that
50
+ can then be used to extract features useful for downstream tasks: if you have a
51
+ dataset of labeled sentences, for instance, you can train a standard classifier
52
+ using the features produced by the BERT model as inputs.
53
+
54
+ ## Model variations
55
+
56
+ notSexistBERT has originally been released as sexist and notSexist variations. The uncased models strip out any accent markers.
57
+
58
+ | Model | #params | Language |
59
+ | ----------------------------------------------------------------------- | --------- | -------- |
60
+ | [`sexistBERT`](https://huggingface.co/clincolnoz/sexistBERT_temp) | 110303292 | English |
61
+ | [`notSexistBERT`](https://huggingface.co/clincolnoz/notSexistBERT_temp) | 110201784 | English |
62
+
63
+ ## Intended uses & limitations
64
+
65
+ Apart from the usual uses for BERT below, the intended usage of these model is to test bias detection methods and the effect of bias on downstream tasks. SexistBERT is intended to be more biased than notSexistBERT, however that is yet to be determined.
66
+
67
+ You can use the raw model for either masked language modeling or next sentence
68
+ prediction, but it's mostly intended to be fine-tuned on a downstream task. See
69
+ the [model hub](https://huggingface.co/models?filter=bert) to look for
70
+ fine-tuned versions of a task that interests you.
71
+
72
+ Note that this model is primarily aimed at being fine-tuned on tasks that use
73
+ the whole sentence (potentially masked) to make decisions, such as sequence
74
+ classification, token classification or question answering.
75
+
76
+ For tasks such as text generation you should look at model like GPT2.
77
+
78
+ ### How to use
79
+
80
+ You can use this model directly with a pipeline for masked language modeling:
81
+
82
+ ```python
83
+ >>> from transformers import pipeline
84
+ >>> unmasker = pipeline('fill-mask', model='clincolnoz/notSexistBERT_temp')
85
+ >>> unmasker("Hello I'm a [MASK] model.")
86
+
87
+ [{'score': 0.5223352313041687,
88
+ 'token': 2535,
89
+ 'token_str': 'role',
90
+ 'sequence': "hello i'm a role model."},
91
+ {'score': 0.12853220105171204,
92
+ 'token': 2449,
93
+ 'token_str': 'business',
94
+ 'sequence': "hello i'm a business model."},
95
+ {'score': 0.0621086061000824,
96
+ 'token': 3287,
97
+ 'token_str': 'male',
98
+ 'sequence': "hello i'm a male model."},
99
+ {'score': 0.03042026236653328,
100
+ 'token': 3565,
101
+ 'token_str': 'super',
102
+ 'sequence': "hello i'm a super model."},
103
+ {'score': 0.01949389837682247,
104
+ 'token': 7605,
105
+ 'token_str': '3d',
106
+ 'sequence': "hello i'm a 3d model."}]
107
+ ```
108
+
109
+ Here is how to use this model to get the features of a given text in PyTorch:
110
+
111
+ ```python
112
+ from transformers import BertTokenizer, BertModel
113
+ tokenizer = BertTokenizer.from_pretrained(
114
+ 'clincolnoz/notSexistBERT_temp',
115
+ revision='v0.34' # tag name, or branch name, or commit hash
116
+ )
117
+ model = BertModel.from_pretrained(
118
+ 'clincolnoz/notSexistBERT_temp',
119
+ revision='v0.34' # tag name, or branch name, or commit hash
120
+ )
121
+ text = "Replace me by any text you'd like."
122
+ encoded_input = tokenizer(text, return_tensors='pt')
123
+ output = model(**encoded_input)
124
+ ```
125
+
126
+ and in TensorFlow:
127
+
128
+ ```python
129
+ from transformers import BertTokenizer, TFBertModel
130
+ tokenizer = BertTokenizer.from_pretrained(
131
+ 'clincolnoz/notSexistBERT_temp',
132
+ revision='v0.34' # tag name, or branch name, or commit hash
133
+ )
134
+ model = TFBertModel.from_pretrained(
135
+ 'clincolnoz/notSexistBERT_temp',
136
+ from_pt=True,
137
+ revision='v0.34' # tag name, or branch name, or commit hash
138
+ )
139
+ text = "Replace me by any text you'd like."
140
+ encoded_input = tokenizer(text, return_tensors='tf')
141
+ output = model(encoded_input)
142
+ ```
143
+
144
+ ### Limitations and bias
145
+
146
+ Even if the training data used for this model could be characterized as fairly
147
+ neutral, this model can have biased predictions:
148
+
149
+ ```python
150
+ >>> from transformers import pipeline
151
+ >>> unmasker = pipeline('fill-mask', model='clincolnoz/notSexistBERT_temp')
152
+ >>> unmasker("The man worked as a [MASK].")
153
+
154
+ [{'score': 0.1064024269580841,
155
+ 'token': 5160,
156
+ 'token_str': 'lawyer',
157
+ 'sequence': 'the man worked as a lawyer.'},
158
+ {'score': 0.06261951476335526,
159
+ 'token': 7155,
160
+ 'token_str': 'scientist',
161
+ 'sequence': 'the man worked as a scientist.'},
162
+ {'score': 0.046040475368499756,
163
+ 'token': 10563,
164
+ 'token_str': 'teenager',
165
+ 'sequence': 'the man worked as a teenager.'},
166
+ {'score': 0.04330913722515106,
167
+ 'token': 20273,
168
+ 'token_str': 'programmer',
169
+ 'sequence': 'the man worked as a programmer.'},
170
+ {'score': 0.04167287424206734,
171
+ 'token': 5766,
172
+ 'token_str': 'ceo',
173
+ 'sequence': 'the man worked as a ceo.'}]
174
+
175
+ >>> unmasker("The woman worked as a [MASK].")
176
+
177
+ [{'score': 0.0949002057313919,
178
+ 'token': 6821,
179
+ 'token_str': 'nurse',
180
+ 'sequence': 'the woman worked as a nurse.'},
181
+ {'score': 0.08425672352313995,
182
+ 'token': 3208,
183
+ 'token_str': 'manager',
184
+ 'sequence': 'the woman worked as a manager.'},
185
+ {'score': 0.07672832906246185,
186
+ 'token': 5160,
187
+ 'token_str': 'lawyer',
188
+ 'sequence': 'the woman worked as a lawyer.'},
189
+ {'score': 0.042527567595243454,
190
+ 'token': 7522,
191
+ 'token_str': 'physician',
192
+ 'sequence': 'the woman worked as a physician.'},
193
+ {'score': 0.034959811717271805,
194
+ 'token': 5766,
195
+ 'token_str': 'ceo',
196
+ 'sequence': 'the woman worked as a ceo.'}]
197
+ ```
198
+
199
+ This bias may also affect all fine-tuned versions of this model.
200
+
201
+ ## Training data
202
+
203
+ TBD
204
+
205
+ <!-- The BERT model was pretrained on [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset consisting of 11,038
206
+ unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia) (excluding lists, tables and
207
+ headers). -->
208
+
209
+ ## Training procedure
210
+
211
+ ### Preprocessing
212
+
213
+ For the NSP task the data were preprocessed by splitting documents into sentences to create first a bag of sentences and then to create pairs of sentences, where Sentence B either corresponded to a consecutive sentence in the text or randomly select from the bag. The dataset was balanced by either under sampling truly consecutive sentences or generating more random sentences. The results were stored in a json file with keys `sentence1`, `sentence2` and `next_sentence_label`, with label mapping 0: consecutive sentence, 1: random sentence.
214
+
215
+ The texts are lowercased and tokenized using WordPiece and a vocabulary size of
216
+ 30,646. The inputs of the model are then of the form:
217
+
218
+ ```
219
+ [CLS] Sentence A [SEP] Sentence B [SEP]
220
+ ```
221
+
222
+ With probability 0.5, sentence A and sentence B correspond to two consecutive
223
+ sentences in the original corpus, and in the other cases, it's another random
224
+ sentence in the corpus. Note that what is considered a sentence here is a
225
+ consecutive span of text usually longer than a single sentence. The only
226
+ constrain is that the result with the two "sentences" has a combined length of
227
+ less than 512 tokens.
228
+
229
+ The details of the masking procedure for each sentence are the following:
230
+
231
+ - 15% of the tokens are masked.
232
+ - In 80% of the cases, the masked tokens are replaced by `[MASK]`.
233
+ - In 10% of the cases, the masked tokens are replaced by a random token
234
+ (different) from the one they replace.
235
+ - In the 10% remaining cases, the masked tokens are left as is.
236
+
237
+ ### Pretraining
238
+
239
+ The model was trained on a NVIDIA GeForce RTX 4090 using 16-bit precision for 20
240
+ million steps with a batch size of 24. The sequence length was limited 512. The
241
+ optimizer used is Adam with a learning rate of 5e-5, \\(\beta*{1} = 0.9\\) and
242
+ \\(\beta*{2} = 0.999\\), a weight decay of 0.0, learning rate warmup for 0 steps
243
+ and linear decay of the learning rate after.
244
+
245
+ <!-- ## Evaluation results
246
+
247
+ When fine-tuned on downstream tasks, this model achieves the following results:
248
+
249
+ Glue test results:
250
+
251
+ | Task | MNLI-(m/mm) | QQP | QNLI | SST-2 | CoLA | STS-B | MRPC | RTE | Average |
252
+ | :---: | :---------: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :-----: |
253
+ | | 84.6/83.4 | 71.2 | 90.5 | 93.5 | 52.1 | 85.8 | 88.9 | 66.4 | 79.6 | --> |
254
+
255
+ ### Framework versions
256
+
257
+ - Transformers 4.27.0.dev0
258
+ - Pytorch 1.13.1+cu117
259
+ - Datasets 2.9.0
260
+ - Tokenizers 0.13.2
261
+
262
+ <!-- ### BibTeX entry and citation info -->
263
+
264
+ <!-- ```bibtex
265
+ @article{
266
+
267
+ }
268
+ ``` -->
checkpoint-6862662/added_tokens.json ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "#gabfam": 30571,
3
+ "#maga": 30626,
4
+ "#speakfreely": 30610,
5
+ "&amp;": 30549,
6
+ "&amp;#x200b;": 30531,
7
+ "&gt;": 30533,
8
+ "&gt;i": 30639,
9
+ "&gt;the": 30530,
10
+ "100%": 30548,
11
+ "[[url]]": 30568,
12
+ "[url]": 30556,
13
+ "[user]": 30552,
14
+ "ain't": 30623,
15
+ "alot": 30603,
16
+ "and/or": 30563,
17
+ "anyways": 30529,
18
+ "aren’t": 30601,
19
+ "assholes": 30606,
20
+ "autistic": 30591,
21
+ "blackpill": 30587,
22
+ "bruh": 30523,
23
+ "btw": 30589,
24
+ "cant": 30569,
25
+ "can’t": 30644,
26
+ "chads": 30611,
27
+ "congrats": 30534,
28
+ "couldn’t": 30580,
29
+ "covid": 30621,
30
+ "cringe": 30555,
31
+ "cuz": 30637,
32
+ "delusional": 30613,
33
+ "didnt": 30604,
34
+ "didn’t": 30619,
35
+ "doesnt": 30609,
36
+ "doesn’t": 30595,
37
+ "dont": 30628,
38
+ "don’t": 30636,
39
+ "downvoted": 30542,
40
+ "dudes": 30583,
41
+ "dunno": 30541,
42
+ "foids": 30600,
43
+ "fucks": 30586,
44
+ "gab": 30645,
45
+ "haha": 30643,
46
+ "hahaha": 30575,
47
+ "hateful": 30592,
48
+ "haven’t": 30550,
49
+ "he’s": 30631,
50
+ "hobbies": 30522,
51
+ "idk": 30525,
52
+ "imo": 30578,
53
+ "incel": 30620,
54
+ "incels": 30624,
55
+ "insecure": 30630,
56
+ "irl": 30559,
57
+ "isnt": 30527,
58
+ "isn’t": 30537,
59
+ "it'll": 30545,
60
+ "it’s": 30588,
61
+ "ive": 30539,
62
+ "i’d": 30618,
63
+ "i’ll": 30558,
64
+ "i’m": 30560,
65
+ "i’ve": 30582,
66
+ "jfl": 30570,
67
+ "leftists": 30625,
68
+ "legit": 30554,
69
+ "lmao": 30599,
70
+ "lol": 30538,
71
+ "ltr": 30638,
72
+ "meme": 30564,
73
+ "memes": 30543,
74
+ "mentality": 30579,
75
+ "mgtow": 30585,
76
+ "mindset": 30590,
77
+ "mods": 30547,
78
+ "moron": 30605,
79
+ "morons": 30576,
80
+ "normie": 30635,
81
+ "normies": 30546,
82
+ "omg": 30562,
83
+ "people's": 30577,
84
+ "pilled": 30532,
85
+ "ppl": 30567,
86
+ "pua": 30557,
87
+ "reddit": 30584,
88
+ "redpill": 30536,
89
+ "retard": 30607,
90
+ "retarded": 30566,
91
+ "retards": 30597,
92
+ "she’s": 30622,
93
+ "shouldn’t": 30596,
94
+ "sidebar": 30528,
95
+ "simp": 30574,
96
+ "simps": 30615,
97
+ "sjw": 30641,
98
+ "sjws": 30614,
99
+ "smv": 30565,
100
+ "someone's": 30602,
101
+ "subreddit": 30612,
102
+ "subs": 30642,
103
+ "tbh": 30544,
104
+ "thats": 30633,
105
+ "that’s": 30629,
106
+ "theres": 30526,
107
+ "there’s": 30573,
108
+ "they’re": 30640,
109
+ "tinder": 30540,
110
+ "trp": 30616,
111
+ "upvote": 30561,
112
+ "wasn’t": 30598,
113
+ "we’re": 30581,
114
+ "whats": 30608,
115
+ "what’s": 30593,
116
+ "wont": 30551,
117
+ "won’t": 30524,
118
+ "wouldn’t": 30572,
119
+ "wtf": 30553,
120
+ "yea": 30627,
121
+ "youre": 30634,
122
+ "you’ll": 30535,
123
+ "you’re": 30617,
124
+ "you’ve": 30632,
125
+ "yup": 30594
126
+ }
checkpoint-6862662/config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bert-base-uncased",
3
+ "architectures": [
4
+ "BertForPreTraining"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "position_embedding_type": "absolute",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.27.0.dev0",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 30646
26
+ }
checkpoint-6862662/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64ac355b87c723835fb6e45371d2c0b46cb4e81c0869034b9e97947e4f264142
3
+ size 881735429
checkpoint-6862662/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e1f83726c3328470db6fe075764c76e5fbaa13081c02f771168748a2603abd1
3
+ size 440881865
checkpoint-6862662/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60d91c35f1b740f8e9a69153126d31e72877822aef7f579faf648f3b6fb77a4d
3
+ size 14575
checkpoint-6862662/scaler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76c7e1f094d307d632e596d819670442fc9332e781f5644895c3bea4967aec96
3
+ size 557
checkpoint-6862662/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bfdf5e528533d6b015bfcb7d44cd7015582f4bf445d6bfd01bd740bbe7abd1b
3
+ size 627
checkpoint-6862662/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
checkpoint-6862662/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-6862662/tokenizer_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "do_lower_case": true,
4
+ "mask_token": "[MASK]",
5
+ "model_max_length": 512,
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "special_tokens_map_file": null,
9
+ "strip_accents": null,
10
+ "tokenize_chinese_chars": true,
11
+ "tokenizer_class": "BertTokenizer",
12
+ "unk_token": "[UNK]"
13
+ }
checkpoint-6862662/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-6862662/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:122a872cb609b5fc05adf84a8d6d9565266277c61206274491cd92c2a443a99f
3
+ size 3515
checkpoint-6862662/vocab.txt ADDED
The diff for this file is too large to render. See raw diff