Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
ebba9e92
"tests/tokenization_gpt2_test.py" did not exist on "f2a337b3ed5ecc7339e0103af74f8f54b56d22ce"
Commit
ebba9e92
authored
Jan 10, 2020
by
VictorSanh
Browse files
minor spring cleaning - missing configs + processing
parent
b1e1a9f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
0 deletions
+46
-0
examples/distillation/lm_seqs_dataset.py
examples/distillation/lm_seqs_dataset.py
+17
-0
examples/distillation/training_configs/distilbert-base-multilingual-cased.json
.../training_configs/distilbert-base-multilingual-cased.json
+15
-0
examples/distillation/training_configs/distilroberta-base.json
...les/distillation/training_configs/distilroberta-base.json
+14
-0
No files found.
examples/distillation/lm_seqs_dataset.py
View file @
ebba9e92
...
...
@@ -42,6 +42,7 @@ class LmSeqsDataset(Dataset):
self
.
check
()
self
.
remove_long_sequences
()
self
.
remove_empty_sequences
()
self
.
remove_unknown_sequences
()
self
.
check
()
self
.
print_statistics
()
...
...
@@ -109,6 +110,22 @@ class LmSeqsDataset(Dataset):
new_size
=
len
(
self
)
logger
.
info
(
f
"Remove
{
init_size
-
new_size
}
too short (<=11 tokens) sequences."
)
def
remove_unknown_sequences
(
self
):
"""
Remove sequences with a (too) high level of unknown tokens.
"""
if
'unk_token'
not
in
self
.
params
.
special_tok_ids
:
return
else
:
unk_token_id
=
self
.
params
.
special_tok_ids
[
'unk_token'
]
init_size
=
len
(
self
)
unk_occs
=
np
.
array
([
np
.
count_nonzero
(
a
==
unk_token_id
)
for
a
in
self
.
token_ids
])
indices
=
(
unk_occs
/
self
.
lengths
)
<
0.5
self
.
token_ids
=
self
.
token_ids
[
indices
]
self
.
lengths
=
self
.
lengths
[
indices
]
new_size
=
len
(
self
)
logger
.
info
(
f
'Remove
{
init_size
-
new_size
}
sequences with a high level of unknown tokens (50%).'
)
def
print_statistics
(
self
):
"""
Print some statistics on the corpus. Only the master process.
...
...
examples/distillation/training_configs/distilbert-base-multilingual-cased.json
0 → 100644
View file @
ebba9e92
{
"activation"
:
"gelu"
,
"attention_dropout"
:
0.1
,
"dim"
:
768
,
"dropout"
:
0.1
,
"hidden_dim"
:
3072
,
"initializer_range"
:
0.02
,
"max_position_embeddings"
:
512
,
"n_heads"
:
12
,
"n_layers"
:
6
,
"sinusoidal_pos_embds"
:
true
,
"tie_weights_"
:
true
,
"vocab_size"
:
119547
}
\ No newline at end of file
examples/distillation/training_configs/distilroberta-base.json
0 → 100644
View file @
ebba9e92
{
"vocab_size"
:
50265
,
"hidden_size"
:
768
,
"num_hidden_layers"
:
6
,
"num_attention_heads"
:
12
,
"intermediate_size"
:
3072
,
"hidden_act"
:
"gelu"
,
"hidden_dropout_prob"
:
0.1
,
"attention_probs_dropout_prob"
:
0.1
,
"max_position_embeddings"
:
514
,
"type_vocab_size"
:
1
,
"initializer_range"
:
0.02
,
"layer_norm_eps"
:
0.00001
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment