commit wo tf weights
Browse files- LICENSE +201 -0
- README.md +218 -0
- config.json +22 -0
- flax_model.msgpack +3 -0
- pytorch_model.bin +3 -0
- rust_model.ot +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +3 -0
- vocab.txt +0 -0
LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192 |
+
you may not use this file except in compliance with the License.
|
193 |
+
You may obtain a copy of the License at
|
194 |
+
|
195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
196 |
+
|
197 |
+
Unless required by applicable law or agreed to in writing, software
|
198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200 |
+
See the License for the specific language governing permissions and
|
201 |
+
limitations under the License.
|
README.md
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
tags:
|
4 |
+
- exbert
|
5 |
+
license: apache-2.0
|
6 |
+
datasets:
|
7 |
+
- bookcorpus
|
8 |
+
- wikipedia
|
9 |
+
---
|
10 |
+
|
11 |
+
# DistilBERT base model (uncased)
|
12 |
+
|
13 |
+
This model is a distilled version of the [BERT base model](https://huggingface.co/bert-base-uncased). It was
|
14 |
+
introduced in [this paper](https://arxiv.org/abs/1910.01108). The code for the distillation process can be found
|
15 |
+
[here](https://github.com/huggingface/transformers/tree/master/examples/distillation). This model is uncased: it does
|
16 |
+
not make a difference between english and English.
|
17 |
+
|
18 |
+
## Model description
|
19 |
+
|
20 |
+
DistilBERT is a transformers model, smaller and faster than BERT, which was pretrained on the same corpus in a
|
21 |
+
self-supervised fashion, using the BERT base model as a teacher. This means it was pretrained on the raw texts only,
|
22 |
+
with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic
|
23 |
+
process to generate inputs and labels from those texts using the BERT base model. More precisely, it was pretrained
|
24 |
+
with three objectives:
|
25 |
+
|
26 |
+
- Distillation loss: the model was trained to return the same probabilities as the BERT base model.
|
27 |
+
- Masked language modeling (MLM): this is part of the original training loss of the BERT base model. When taking a
|
28 |
+
sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the
|
29 |
+
model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that
|
30 |
+
usually see the words one after the other, or from autoregressive models like GPT which internally mask the future
|
31 |
+
tokens. It allows the model to learn a bidirectional representation of the sentence.
|
32 |
+
- Cosine embedding loss: the model was also trained to generate hidden states as close as possible as the BERT base
|
33 |
+
model.
|
34 |
+
|
35 |
+
This way, the model learns the same inner representation of the English language than its teacher model, while being
|
36 |
+
faster for inference or downstream tasks.
|
37 |
+
|
38 |
+
## Intended uses & limitations
|
39 |
+
|
40 |
+
You can use the raw model for either masked language modeling or next sentence prediction, but it's mostly intended to
|
41 |
+
be fine-tuned on a downstream task. See the [model hub](https://huggingface.co/models?filter=distilbert) to look for
|
42 |
+
fine-tuned versions on a task that interests you.
|
43 |
+
|
44 |
+
Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked)
|
45 |
+
to make decisions, such as sequence classification, token classification or question answering. For tasks such as text
|
46 |
+
generation you should look at model like GPT2.
|
47 |
+
|
48 |
+
### How to use
|
49 |
+
|
50 |
+
You can use this model directly with a pipeline for masked language modeling:
|
51 |
+
|
52 |
+
```python
|
53 |
+
>>> from transformers import pipeline
|
54 |
+
>>> unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
55 |
+
>>> unmasker("Hello I'm a [MASK] model.")
|
56 |
+
|
57 |
+
[{'sequence': "[CLS] hello i'm a role model. [SEP]",
|
58 |
+
'score': 0.05292855575680733,
|
59 |
+
'token': 2535,
|
60 |
+
'token_str': 'role'},
|
61 |
+
{'sequence': "[CLS] hello i'm a fashion model. [SEP]",
|
62 |
+
'score': 0.03968575969338417,
|
63 |
+
'token': 4827,
|
64 |
+
'token_str': 'fashion'},
|
65 |
+
{'sequence': "[CLS] hello i'm a business model. [SEP]",
|
66 |
+
'score': 0.034743521362543106,
|
67 |
+
'token': 2449,
|
68 |
+
'token_str': 'business'},
|
69 |
+
{'sequence': "[CLS] hello i'm a model model. [SEP]",
|
70 |
+
'score': 0.03462274372577667,
|
71 |
+
'token': 2944,
|
72 |
+
'token_str': 'model'},
|
73 |
+
{'sequence': "[CLS] hello i'm a modeling model. [SEP]",
|
74 |
+
'score': 0.018145186826586723,
|
75 |
+
'token': 11643,
|
76 |
+
'token_str': 'modeling'}]
|
77 |
+
```
|
78 |
+
|
79 |
+
Here is how to use this model to get the features of a given text in PyTorch:
|
80 |
+
|
81 |
+
```python
|
82 |
+
from transformers import DistilBertTokenizer, DistilBertModel
|
83 |
+
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
|
84 |
+
model = DistilBertModel.from_pretrained("distilbert-base-uncased")
|
85 |
+
text = "Replace me by any text you'd like."
|
86 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
87 |
+
output = model(**encoded_input)
|
88 |
+
```
|
89 |
+
|
90 |
+
and in TensorFlow:
|
91 |
+
|
92 |
+
```python
|
93 |
+
from transformers import DistilBertTokenizer, TFDistilBertModel
|
94 |
+
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
|
95 |
+
model = TFDistilBertModel.from_pretrained("distilbert-base-uncased")
|
96 |
+
text = "Replace me by any text you'd like."
|
97 |
+
encoded_input = tokenizer(text, return_tensors='tf')
|
98 |
+
output = model(encoded_input)
|
99 |
+
```
|
100 |
+
|
101 |
+
### Limitations and bias
|
102 |
+
|
103 |
+
Even if the training data used for this model could be characterized as fairly neutral, this model can have biased
|
104 |
+
predictions. It also inherits some of
|
105 |
+
[the bias of its teacher model](https://huggingface.co/bert-base-uncased#limitations-and-bias).
|
106 |
+
|
107 |
+
```python
|
108 |
+
>>> from transformers import pipeline
|
109 |
+
>>> unmasker = pipeline('fill-mask', model='distilbert-base-uncased')
|
110 |
+
>>> unmasker("The White man worked as a [MASK].")
|
111 |
+
|
112 |
+
[{'sequence': '[CLS] the white man worked as a blacksmith. [SEP]',
|
113 |
+
'score': 0.1235365942120552,
|
114 |
+
'token': 20987,
|
115 |
+
'token_str': 'blacksmith'},
|
116 |
+
{'sequence': '[CLS] the white man worked as a carpenter. [SEP]',
|
117 |
+
'score': 0.10142576694488525,
|
118 |
+
'token': 10533,
|
119 |
+
'token_str': 'carpenter'},
|
120 |
+
{'sequence': '[CLS] the white man worked as a farmer. [SEP]',
|
121 |
+
'score': 0.04985016956925392,
|
122 |
+
'token': 7500,
|
123 |
+
'token_str': 'farmer'},
|
124 |
+
{'sequence': '[CLS] the white man worked as a miner. [SEP]',
|
125 |
+
'score': 0.03932540491223335,
|
126 |
+
'token': 18594,
|
127 |
+
'token_str': 'miner'},
|
128 |
+
{'sequence': '[CLS] the white man worked as a butcher. [SEP]',
|
129 |
+
'score': 0.03351764753460884,
|
130 |
+
'token': 14998,
|
131 |
+
'token_str': 'butcher'}]
|
132 |
+
|
133 |
+
>>> unmasker("The Black woman worked as a [MASK].")
|
134 |
+
|
135 |
+
[{'sequence': '[CLS] the black woman worked as a waitress. [SEP]',
|
136 |
+
'score': 0.13283951580524445,
|
137 |
+
'token': 13877,
|
138 |
+
'token_str': 'waitress'},
|
139 |
+
{'sequence': '[CLS] the black woman worked as a nurse. [SEP]',
|
140 |
+
'score': 0.12586183845996857,
|
141 |
+
'token': 6821,
|
142 |
+
'token_str': 'nurse'},
|
143 |
+
{'sequence': '[CLS] the black woman worked as a maid. [SEP]',
|
144 |
+
'score': 0.11708822101354599,
|
145 |
+
'token': 10850,
|
146 |
+
'token_str': 'maid'},
|
147 |
+
{'sequence': '[CLS] the black woman worked as a prostitute. [SEP]',
|
148 |
+
'score': 0.11499975621700287,
|
149 |
+
'token': 19215,
|
150 |
+
'token_str': 'prostitute'},
|
151 |
+
{'sequence': '[CLS] the black woman worked as a housekeeper. [SEP]',
|
152 |
+
'score': 0.04722772538661957,
|
153 |
+
'token': 22583,
|
154 |
+
'token_str': 'housekeeper'}]
|
155 |
+
```
|
156 |
+
|
157 |
+
This bias will also affect all fine-tuned versions of this model.
|
158 |
+
|
159 |
+
## Training data
|
160 |
+
|
161 |
+
DistilBERT pretrained on the same data as BERT, which is [BookCorpus](https://yknzhu.wixsite.com/mbweb), a dataset
|
162 |
+
consisting of 11,038 unpublished books and [English Wikipedia](https://en.wikipedia.org/wiki/English_Wikipedia)
|
163 |
+
(excluding lists, tables and headers).
|
164 |
+
|
165 |
+
## Training procedure
|
166 |
+
|
167 |
+
### Preprocessing
|
168 |
+
|
169 |
+
The texts are lowercased and tokenized using WordPiece and a vocabulary size of 30,000. The inputs of the model are
|
170 |
+
then of the form:
|
171 |
+
|
172 |
+
```
|
173 |
+
[CLS] Sentence A [SEP] Sentence B [SEP]
|
174 |
+
```
|
175 |
+
|
176 |
+
With probability 0.5, sentence A and sentence B correspond to two consecutive sentences in the original corpus and in
|
177 |
+
the other cases, it's another random sentence in the corpus. Note that what is considered a sentence here is a
|
178 |
+
consecutive span of text usually longer than a single sentence. The only constrain is that the result with the two
|
179 |
+
"sentences" has a combined length of less than 512 tokens.
|
180 |
+
|
181 |
+
The details of the masking procedure for each sentence are the following:
|
182 |
+
- 15% of the tokens are masked.
|
183 |
+
- In 80% of the cases, the masked tokens are replaced by `[MASK]`.
|
184 |
+
- In 10% of the cases, the masked tokens are replaced by a random token (different) from the one they replace.
|
185 |
+
- In the 10% remaining cases, the masked tokens are left as is.
|
186 |
+
|
187 |
+
### Pretraining
|
188 |
+
|
189 |
+
The model was trained on 8 16 GB V100 for 90 hours. See the
|
190 |
+
[training code](https://github.com/huggingface/transformers/tree/master/examples/distillation) for all hyperparameters
|
191 |
+
details.
|
192 |
+
|
193 |
+
## Evaluation results
|
194 |
+
|
195 |
+
When fine-tuned on downstream tasks, this model achieves the following results:
|
196 |
+
|
197 |
+
Glue test results:
|
198 |
+
|
199 |
+
| Task | MNLI | QQP | QNLI | SST-2 | CoLA | STS-B | MRPC | RTE |
|
200 |
+
|:----:|:----:|:----:|:----:|:-----:|:----:|:-----:|:----:|:----:|
|
201 |
+
| | 82.2 | 88.5 | 89.2 | 91.3 | 51.3 | 85.8 | 87.5 | 59.9 |
|
202 |
+
|
203 |
+
|
204 |
+
### BibTeX entry and citation info
|
205 |
+
|
206 |
+
```bibtex
|
207 |
+
@article{Sanh2019DistilBERTAD,
|
208 |
+
title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
|
209 |
+
author={Victor Sanh and Lysandre Debut and Julien Chaumond and Thomas Wolf},
|
210 |
+
journal={ArXiv},
|
211 |
+
year={2019},
|
212 |
+
volume={abs/1910.01108}
|
213 |
+
}
|
214 |
+
```
|
215 |
+
|
216 |
+
<a href="https://huggingface.co/exbert/?model=distilbert-base-uncased">
|
217 |
+
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
|
218 |
+
</a>
|
config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation": "gelu",
|
3 |
+
"architectures": [
|
4 |
+
"DistilBertForMaskedLM"
|
5 |
+
],
|
6 |
+
"attention_dropout": 0.1,
|
7 |
+
"dim": 768,
|
8 |
+
"dropout": 0.1,
|
9 |
+
"hidden_dim": 3072,
|
10 |
+
"initializer_range": 0.02,
|
11 |
+
"max_position_embeddings": 512,
|
12 |
+
"model_type": "distilbert",
|
13 |
+
"n_heads": 12,
|
14 |
+
"n_layers": 6,
|
15 |
+
"pad_token_id": 0,
|
16 |
+
"qa_dropout": 0.1,
|
17 |
+
"seq_classif_dropout": 0.2,
|
18 |
+
"sinusoidal_pos_embds": false,
|
19 |
+
"tie_weights_": true,
|
20 |
+
"transformers_version": "4.10.0.dev0",
|
21 |
+
"vocab_size": 30522
|
22 |
+
}
|
flax_model.msgpack
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:101fa75462994e55b265fd62b0f44b9bb9f4d3fcb0c9d8986d2542850d0f0688
|
3 |
+
size 267945836
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e60d71610916da4787c5513c81bc026d415708528295502fb3e1a6fe1485ea7c
|
3 |
+
size 267967963
|
rust_model.ot
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ff3dc0119b9399681cf5661a9e450bb2ed2ecdb88338fb2c9d942c579164cc6
|
3 |
+
size 361732396
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_lower_case": true
|
3 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|