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
b24ead87
"examples/vscode:/vscode.git/clone" did not exist on "32883b310ba30d72e67bb2ebb5847888f03a90a8"
Unverified
Commit
b24ead87
authored
Apr 26, 2021
by
LSinev
Committed by
GitHub
Apr 26, 2021
Browse files
fix some typos in docs, comments, logging/errors (#11432)
parent
e3e70f95
Changes
77
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
26 additions
and
26 deletions
+26
-26
src/transformers/commands/add_new_model.py
src/transformers/commands/add_new_model.py
+2
-2
src/transformers/data/processors/squad.py
src/transformers/data/processors/squad.py
+1
-1
src/transformers/feature_extraction_sequence_utils.py
src/transformers/feature_extraction_sequence_utils.py
+1
-1
src/transformers/file_utils.py
src/transformers/file_utils.py
+1
-1
src/transformers/generation_logits_process.py
src/transformers/generation_logits_process.py
+1
-1
src/transformers/generation_stopping_criteria.py
src/transformers/generation_stopping_criteria.py
+1
-1
src/transformers/generation_tf_utils.py
src/transformers/generation_tf_utils.py
+2
-2
src/transformers/generation_utils.py
src/transformers/generation_utils.py
+1
-1
src/transformers/modeling_flax_utils.py
src/transformers/modeling_flax_utils.py
+1
-1
src/transformers/modeling_outputs.py
src/transformers/modeling_outputs.py
+2
-2
src/transformers/modeling_tf_pytorch_utils.py
src/transformers/modeling_tf_pytorch_utils.py
+1
-1
src/transformers/modeling_tf_utils.py
src/transformers/modeling_tf_utils.py
+2
-2
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+1
-1
src/transformers/models/auto/modeling_auto.py
src/transformers/models/auto/modeling_auto.py
+1
-1
src/transformers/models/auto/modeling_flax_auto.py
src/transformers/models/auto/modeling_flax_auto.py
+1
-1
src/transformers/models/auto/modeling_tf_auto.py
src/transformers/models/auto/modeling_tf_auto.py
+1
-1
src/transformers/models/bart/configuration_bart.py
src/transformers/models/bart/configuration_bart.py
+1
-1
src/transformers/models/bart/modeling_bart.py
src/transformers/models/bart/modeling_bart.py
+3
-3
src/transformers/models/bart/modeling_tf_bart.py
src/transformers/models/bart/modeling_tf_bart.py
+1
-1
src/transformers/models/bert_japanese/tokenization_bert_japanese.py
...ormers/models/bert_japanese/tokenization_bert_japanese.py
+1
-1
No files found.
src/transformers/commands/add_new_model.py
View file @
b24ead87
...
...
@@ -57,14 +57,14 @@ class AddNewModelCommand(BaseTransformersCLICommand):
if
not
_has_cookiecutter
:
raise
ImportError
(
"Model creation dependencies are required to use the `add_new_model` command. Install them by running "
"the folowing at the root of your `transformers` clone:
\n\n\t
$ pip install -e .[modelcreation]
\n
"
"the fol
l
owing at the root of your `transformers` clone:
\n\n\t
$ pip install -e .[modelcreation]
\n
"
)
# Ensure that there is no other `cookiecutter-template-xxx` directory in the current working directory
directories
=
[
directory
for
directory
in
os
.
listdir
()
if
"cookiecutter-template-"
==
directory
[:
22
]]
if
len
(
directories
)
>
0
:
raise
ValueError
(
"Several directories starting with `cookiecutter-template-` in current working directory. "
"Please clean your directory by removing all folders starti
g
n with `cookiecutter-template-` or "
"Please clean your directory by removing all folders startin
g
with `cookiecutter-template-` or "
"change your working directory."
)
...
...
src/transformers/data/processors/squad.py
View file @
b24ead87
...
...
@@ -244,7 +244,7 @@ def squad_convert_example_to_features(
cls_index
=
span
[
"input_ids"
].
index
(
tokenizer
.
cls_token_id
)
# p_mask: mask with 1 for token than cannot be in the answer (0 for token which can be in an answer)
# Original TF implem also keep the classification token (set to 0)
# Original TF implem
entation
also keep the classification token (set to 0)
p_mask
=
np
.
ones_like
(
span
[
"token_type_ids"
])
if
tokenizer
.
padding_side
==
"right"
:
p_mask
[
len
(
truncated_query
)
+
sequence_added_tokens
:]
=
0
...
...
src/transformers/feature_extraction_sequence_utils.py
View file @
b24ead87
...
...
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Sequence feature extraction class for common feature extr
c
actors to preprocess sequences.
Sequence feature extraction class for common feature extractors to preprocess sequences.
"""
from
typing
import
Dict
,
List
,
Optional
,
Union
...
...
src/transformers/file_utils.py
View file @
b24ead87
...
...
@@ -551,7 +551,7 @@ BACKENDS_MAPPING = OrderedDict(
(
"sklearn"
,
(
is_sklearn_available
,
SKLEARN_IMPORT_ERROR
)),
(
"speech"
,
(
is_speech_available
,
SPEECH_IMPORT_ERROR
)),
(
"tf"
,
(
is_tf_available
,
TENSORFLOW_IMPORT_ERROR
)),
(
"token
z
iers"
,
(
is_tokenizers_available
,
TOKENIZERS_IMPORT_ERROR
)),
(
"tokeni
z
ers"
,
(
is_tokenizers_available
,
TOKENIZERS_IMPORT_ERROR
)),
(
"torch"
,
(
is_torch_available
,
PYTORCH_IMPORT_ERROR
)),
(
"vision"
,
(
is_vision_available
,
VISION_IMPORT_ERROR
)),
]
...
...
src/transformers/generation_logits_process.py
View file @
b24ead87
...
...
@@ -446,7 +446,7 @@ class NoBadWordsLogitsProcessor(LogitsProcessor):
class
PrefixConstrainedLogitsProcessor
(
LogitsProcessor
):
r
"""
:class:`transformers.LogitsProcessor` that enforces contrained generation and is useful for prefix-conditioned
:class:`transformers.LogitsProcessor` that enforces con
s
trained generation and is useful for prefix-conditioned
constrained generation. See `Autoregressive Entity Retrieval <https://arxiv.org/abs/2010.00904>`__ for more
information.
...
...
src/transformers/generation_stopping_criteria.py
View file @
b24ead87
...
...
@@ -23,7 +23,7 @@ STOPPING_CRITERIA_INPUTS_DOCSTRING = r"""
Prediction scores of a language modeling head. These can be scores for each vocabulary token before SoftMax
or scores for each vocabulary token after SoftMax.
kwargs:
Additional stopping critera specific kwargs.
Additional stopping criter
i
a specific kwargs.
Return:
:obj:`bool`. :obj:`False` indicates we should continue, :obj:`True` indicates we should stop.
...
...
src/transformers/generation_tf_utils.py
View file @
b24ead87
...
...
@@ -442,8 +442,8 @@ class TFGenerationMixin:
**
kwargs
):
"""
Generate sequences for each example without beam search (num_beams == 1). All returned sequence are generated
independ
a
ntly.
Generate sequences for each example without beam search (num_beams == 1). All returned sequence
s
are generated
independ
e
ntly.
"""
# length of generated sentences / unfinished sentences
...
...
src/transformers/generation_utils.py
View file @
b24ead87
...
...
@@ -821,7 +821,7 @@ class GenerationMixin:
... "at least two people were killed in a suspected bomb attack on a passenger bus "
... "in the strife-torn southern philippines on monday , the military said."
... )
>>> # encode input contex
>>> # encode input contex
t
>>> input_ids = tokenizer(document, return_tensors="pt").input_ids
>>> # generate 3 independent sequences using beam search decoding (5 beams)
>>> # with T5 encoder-decoder model conditioned on short news article.
...
...
src/transformers/modeling_flax_utils.py
View file @
b24ead87
...
...
@@ -94,7 +94,7 @@ class FlaxPreTrainedModel(PushToHubMixin):
self
.
key
=
PRNGKey
(
seed
)
self
.
dtype
=
dtype
# random
e
ly initialized parameters
# randomly initialized parameters
random_params
=
self
.
init_weights
(
self
.
key
,
input_shape
)
# save required_params as set
...
...
src/transformers/modeling_outputs.py
View file @
b24ead87
...
...
@@ -343,7 +343,7 @@ class CausalLMOutputWithPast(ModelOutput):
Language modeling loss (for next-token prediction).
logits (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length, config.vocab_size)`):
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
past_key_values (:obj:`tuple(tup
e
l(torch.FloatTensor))`, `optional`, returned when ``use_cache=True`` is passed or when ``config.use_cache=True``):
past_key_values (:obj:`tuple(tupl
e
(torch.FloatTensor))`, `optional`, returned when ``use_cache=True`` is passed or when ``config.use_cache=True``):
Tuple of :obj:`tuple(torch.FloatTensor)` of length :obj:`config.n_layers`, with each tuple having 2 tensors
of shape :obj:`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
...
...
@@ -423,7 +423,7 @@ class SequenceClassifierOutputWithPast(ModelOutput):
Classification (or regression if config.num_labels==1) loss.
logits (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, config.num_labels)`):
Classification (or regression if config.num_labels==1) scores (before SoftMax).
past_key_values (:obj:`tuple(tup
e
l(torch.FloatTensor))`, `optional`, returned when ``use_cache=True`` is passed or when ``config.use_cache=True``):
past_key_values (:obj:`tuple(tupl
e
(torch.FloatTensor))`, `optional`, returned when ``use_cache=True`` is passed or when ``config.use_cache=True``):
Tuple of :obj:`tuple(torch.FloatTensor)` of length :obj:`config.n_layers`, with each tuple having 2 tensors
of shape :obj:`(batch_size, num_heads, sequence_length, embed_size_per_head)`)
...
...
src/transformers/modeling_tf_pytorch_utils.py
View file @
b24ead87
...
...
@@ -51,7 +51,7 @@ def convert_tf_weight_name_to_pt_weight_name(tf_name, start_prefix_to_remove="")
)
# '_._' is replaced by a level separation (can be used to convert TF2.0 lists in PyTorch nn.ModulesList)
tf_name
=
re
.
sub
(
r
"//+"
,
"/"
,
tf_name
)
# Remove empty levels at the end
tf_name
=
tf_name
.
split
(
"/"
)
# Convert from TF2.0 '/' separators to PyTorch '.' separators
# Some weights have a single name with
t
out "/" such as final_logits_bias in BART
# Some weights have a single name without "/" such as final_logits_bias in BART
if
len
(
tf_name
)
>
1
:
tf_name
=
tf_name
[
1
:]
# Remove level zero
...
...
src/transformers/modeling_tf_utils.py
View file @
b24ead87
...
...
@@ -659,7 +659,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
Args:
inputs (:obj:`Dict[str, tf.Tensor]`):
The input of the saved model as a diction
n
ary of tensors.
The input of the saved model as a dictionary of tensors.
"""
output
=
self
.
call
(
inputs
)
...
...
@@ -944,7 +944,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
vectors from the end. If not provided or :obj:`None`, just returns None
Return:
:obj:`tf.Variable`: Pointer to the resized decoder or None if the output embeddings are different
s of
the
:obj:`tf.Variable`: Pointer to the resized decoder or None if the output embeddings are different
from
the
input ones.
"""
new_lm_head_decoder
=
old_lm_head_decoder
...
...
src/transformers/modeling_utils.py
View file @
b24ead87
...
...
@@ -291,7 +291,7 @@ class ModuleUtilsMixin:
The mask indicating if we should keep the heads or not (1.0 for keep, 0.0 for discard).
num_hidden_layers (:obj:`int`):
The number of hidden layers in the model.
is_attention_chunked: (:obj:`bool`, `optional, defaults to :obj:`False`):
is_attention_chunked: (:obj:`bool`, `optional
`
, defaults to :obj:`False`):
Whether or not the attentions scores are computed by chunks or not.
Returns:
...
...
src/transformers/models/auto/modeling_auto.py
View file @
b24ead87
...
...
@@ -716,7 +716,7 @@ AutoModelForPreTraining = auto_class_factory(
"AutoModelForPreTraining"
,
MODEL_FOR_PRETRAINING_MAPPING
,
head_doc
=
"pretraining"
)
# Private on pu
p
rose, the public class will add the deprecation warnings.
# Private on pur
p
ose, the public class will add the deprecation warnings.
_AutoModelWithLMHead
=
auto_class_factory
(
"AutoModelWithLMHead"
,
MODEL_WITH_LM_HEAD_MAPPING
,
head_doc
=
"language modeling"
)
...
...
src/transformers/models/auto/modeling_flax_auto.py
View file @
b24ead87
...
...
@@ -103,7 +103,7 @@ FlaxAutoModelForMaskedLM = auto_class_factory(
)
FlaxAutoModelForSequenceClassification
=
auto_class_factory
(
"
A
FlaxutoModelForSequenceClassification"
,
"Flax
A
utoModelForSequenceClassification"
,
FLAX_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
,
head_doc
=
"sequence classification"
,
)
...
...
src/transformers/models/auto/modeling_tf_auto.py
View file @
b24ead87
...
...
@@ -469,7 +469,7 @@ TFAutoModelForPreTraining = auto_class_factory(
"TFAutoModelForPreTraining"
,
TF_MODEL_FOR_PRETRAINING_MAPPING
,
head_doc
=
"pretraining"
)
# Private on pu
p
rose, the public class will add the deprecation warnings.
# Private on pur
p
ose, the public class will add the deprecation warnings.
_TFAutoModelWithLMHead
=
auto_class_factory
(
"TFAutoModelWithLMHead"
,
TF_MODEL_WITH_LM_HEAD_MAPPING
,
head_doc
=
"language modeling"
)
...
...
src/transformers/models/bart/configuration_bart.py
View file @
b24ead87
...
...
@@ -171,7 +171,7 @@ class BartConfig(PretrainedConfig):
self
.
gradient_checkpointing
=
gradient_checkpointing
self
.
scale_embedding
=
scale_embedding
# scale factor will be sqrt(d_model) if True
# ensure backward compatibilty for BART CNN models
# ensure backward compatibil
i
ty for BART CNN models
if
self
.
forced_bos_token_id
is
None
and
kwargs
.
get
(
"force_bos_token_to_be_generated"
,
False
):
self
.
forced_bos_token_id
=
self
.
bos_token_id
warnings
.
warn
(
...
...
src/transformers/models/bart/modeling_bart.py
View file @
b24ead87
...
...
@@ -111,7 +111,7 @@ class BartLearnedPositionalEmbedding(nn.Embedding):
def
__init__
(
self
,
num_embeddings
:
int
,
embedding_dim
:
int
):
# Bart is set up so that if padding_idx is specified then offset the embedding ids by 2
# and adjust num_embeddings appropriately. Other models dont have this hack
# and adjust num_embeddings appropriately. Other models don
'
t have this hack
self
.
offset
=
2
super
().
__init__
(
num_embeddings
+
self
.
offset
,
embedding_dim
)
...
...
@@ -236,9 +236,9 @@ class BartAttention(nn.Module):
attn_weights
=
attn_weights
.
view
(
bsz
*
self
.
num_heads
,
tgt_len
,
src_len
)
if
output_attentions
:
# this operation is a bit akward, but it's required to
# this operation is a bit a
w
kward, but it's required to
# make sure that attn_weights keeps its gradient.
# In order to do so, attn_weights have to reshaped
# In order to do so, attn_weights have to
be
reshaped
# twice and have to be reused in the following
attn_weights_reshaped
=
attn_weights
.
view
(
bsz
,
self
.
num_heads
,
tgt_len
,
src_len
)
attn_weights
=
attn_weights_reshaped
.
view
(
bsz
*
self
.
num_heads
,
tgt_len
,
src_len
)
...
...
src/transformers/models/bart/modeling_tf_bart.py
View file @
b24ead87
...
...
@@ -116,7 +116,7 @@ class TFBartLearnedPositionalEmbedding(TFSharedEmbeddings):
def
__init__
(
self
,
num_embeddings
:
int
,
embedding_dim
:
int
,
**
kwargs
):
# Bart is set up so that if padding_idx is specified then offset the embedding ids by 2
# and adjust num_embeddings appropriately. Other models dont have this hack
# and adjust num_embeddings appropriately. Other models don
'
t have this hack
self
.
offset
=
2
super
().
__init__
(
num_embeddings
+
self
.
offset
,
embedding_dim
,
**
kwargs
)
...
...
src/transformers/models/bert_japanese/tokenization_bert_japanese.py
View file @
b24ead87
...
...
@@ -304,7 +304,7 @@ class MecabTokenizer:
class
CharacterTokenizer
:
"""Runs Character token
z
iation."""
"""Runs Character tokeni
z
ation."""
def
__init__
(
self
,
vocab
,
unk_token
,
normalize_text
=
True
):
"""
...
...
Prev
1
2
3
4
Next
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