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
7fe98d8c
Commit
7fe98d8c
authored
Oct 09, 2019
by
LysandreJik
Browse files
Update CTRL documentation
parent
89f86f96
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
37 deletions
+38
-37
docs/source/index.rst
docs/source/index.rst
+1
-0
transformers/modeling_ctrl.py
transformers/modeling_ctrl.py
+14
-14
transformers/modeling_tf_ctrl.py
transformers/modeling_tf_ctrl.py
+23
-23
No files found.
docs/source/index.rst
View file @
7fe98d8c
...
@@ -87,3 +87,4 @@ The library currently contains PyTorch and Tensorflow implementations, pre-train
...
@@ -87,3 +87,4 @@ The library currently contains PyTorch and Tensorflow implementations, pre-train
model_doc/xlnet
model_doc/xlnet
model_doc/roberta
model_doc/roberta
model_doc/distilbert
model_doc/distilbert
model_doc/ctrl
transformers/modeling_ctrl.py
View file @
7fe98d8c
transformers/modeling_tf_ctrl.py
View file @
7fe98d8c
...
@@ -352,7 +352,7 @@ CTRL_START_DOCSTRING = r""" CTRL model was proposed in
...
@@ -352,7 +352,7 @@ CTRL_START_DOCSTRING = r""" CTRL model was proposed in
"""
"""
CTRL_INPUTS_DOCSTRING
=
r
""" Inputs:
CTRL_INPUTS_DOCSTRING
=
r
""" Inputs:
**input_ids**: ``
torch.Long
Tensor`` of shape ``(batch_size, sequence_length)``:
**input_ids**: ``
Numpy array`` or ``tf.
Tensor`` of shape ``(batch_size, sequence_length)``:
Indices of input sequence tokens in the vocabulary.
Indices of input sequence tokens in the vocabulary.
CTRL is a model with absolute position embeddings so it's usually advised to pad the inputs on
CTRL is a model with absolute position embeddings so it's usually advised to pad the inputs on
the right rather than the left.
the right rather than the left.
...
@@ -360,21 +360,21 @@ CTRL_INPUTS_DOCSTRING = r""" Inputs:
...
@@ -360,21 +360,21 @@ CTRL_INPUTS_DOCSTRING = r""" Inputs:
See :func:`transformers.PreTrainedTokenizer.encode` and
See :func:`transformers.PreTrainedTokenizer.encode` and
:func:`transformers.PreTrainedTokenizer.convert_tokens_to_ids` for details.
:func:`transformers.PreTrainedTokenizer.convert_tokens_to_ids` for details.
**past**:
**past**:
list of ``
torch.Float
Tensor`` (one for each layer):
list of ``
Numpy array`` or ``tf.
Tensor`` (one for each layer):
that contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model
that contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model
(see `past` output below). Can be used to speed up sequential decoding.
(see `past` output below). Can be used to speed up sequential decoding.
**attention_mask**: (`optional`) ``
torch.Float
Tensor`` of shape ``(batch_size, sequence_length)``:
**attention_mask**: (`optional`) ``
Numpy array`` or ``tf.
Tensor`` of shape ``(batch_size, sequence_length)``:
Mask to avoid performing attention on padding token indices.
Mask to avoid performing attention on padding token indices.
Mask values selected in ``[0, 1]``:
Mask values selected in ``[0, 1]``:
``1`` for tokens that are NOT MASKED, ``0`` for MASKED tokens.
``1`` for tokens that are NOT MASKED, ``0`` for MASKED tokens.
**token_type_ids**: (`optional`) ``
torch.Long
Tensor`` of shape ``(batch_size, sequence_length)``:
**token_type_ids**: (`optional`) ``
Numpy array`` or ``tf.
Tensor`` of shape ``(batch_size, sequence_length)``:
A parallel sequence of tokens (can be used to indicate various portions of the inputs).
A parallel sequence of tokens (can be used to indicate various portions of the inputs).
The embeddings from these tokens will be summed with the respective token embeddings.
The embeddings from these tokens will be summed with the respective token embeddings.
Indices are selected in the vocabulary (unlike BERT which has a specific vocabulary for segment indices).
Indices are selected in the vocabulary (unlike BERT which has a specific vocabulary for segment indices).
**position_ids**: (`optional`) ``
torch.Long
Tensor`` of shape ``(batch_size, sequence_length)``:
**position_ids**: (`optional`) ``
Numpy array`` or ``tf.
Tensor`` of shape ``(batch_size, sequence_length)``:
Indices of positions of each input sequence tokens in the position embeddings.
Indices of positions of each input sequence tokens in the position embeddings.
Selected in the range ``[0, config.max_position_embeddings - 1]``.
Selected in the range ``[0, config.max_position_embeddings - 1]``.
**head_mask**: (`optional`) ``
torch.Float
Tensor`` of shape ``(num_heads,)`` or ``(num_layers, num_heads)``:
**head_mask**: (`optional`) ``
Numpy array`` or ``tf.
Tensor`` of shape ``(num_heads,)`` or ``(num_layers, num_heads)``:
Mask to nullify selected heads of the self-attention modules.
Mask to nullify selected heads of the self-attention modules.
Mask values selected in ``[0, 1]``:
Mask values selected in ``[0, 1]``:
``1`` indicates the head is **not masked**, ``0`` indicates the head is **masked**.
``1`` indicates the head is **not masked**, ``0`` indicates the head is **masked**.
...
@@ -450,15 +450,15 @@ class TFCTRLLMHeadModel(TFCTRLPreTrainedModel):
...
@@ -450,15 +450,15 @@ class TFCTRLLMHeadModel(TFCTRLPreTrainedModel):
**prediction_scores**: ``torch.FloatTensor`` of shape ``(batch_size, sequence_length, config.vocab_size)``
**prediction_scores**: ``torch.FloatTensor`` of shape ``(batch_size, sequence_length, config.vocab_size)``
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
**past**:
**past**:
list of ``t
orch.Float
Tensor`` (one for each layer) of shape ``(batch_size, num_heads, sequence_length, sequence_length)``:
list of ``t
f.
Tensor`` (one for each layer) of shape ``(batch_size, num_heads, sequence_length, sequence_length)``:
that contains pre-computed hidden-states (key and values in the attention blocks).
that contains pre-computed hidden-states (key and values in the attention blocks).
Can be used (see `past` input) to speed up sequential decoding.
Can be used (see `past` input) to speed up sequential decoding.
**hidden_states**: (`optional`, returned when ``config.output_hidden_states=True``)
**hidden_states**: (`optional`, returned when ``config.output_hidden_states=True``)
list of ``t
orch.Float
Tensor`` (one for the output of each layer + the output of the embeddings)
list of ``t
f.
Tensor`` (one for the output of each layer + the output of the embeddings)
of shape ``(batch_size, sequence_length, hidden_size)``:
of shape ``(batch_size, sequence_length, hidden_size)``:
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
Hidden-states of the model at the output of each layer plus the initial embedding outputs.
**attentions**: (`optional`, returned when ``config.output_attentions=True``)
**attentions**: (`optional`, returned when ``config.output_attentions=True``)
list of ``t
orch.Float
Tensor`` (one for each layer) of shape ``(batch_size, num_heads, sequence_length, sequence_length)``:
list of ``t
f.
Tensor`` (one for each layer) of shape ``(batch_size, num_heads, sequence_length, sequence_length)``:
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Attentions weights after the attention softmax, used to compute the weighted average in the self-attention heads.
Examples::
Examples::
...
...
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