Unverified Commit 3d39226a authored by Stas Bekman's avatar Stas Bekman Committed by GitHub
Browse files

s|Pretrained|PreTrained| (#11048)

parent b0d49fd5
...@@ -22,10 +22,10 @@ class RagPyTorchDistributedRetriever(RagRetriever): ...@@ -22,10 +22,10 @@ class RagPyTorchDistributedRetriever(RagRetriever):
Args: Args:
config (:class:`~transformers.RagConfig`): config (:class:`~transformers.RagConfig`):
The configuration of the RAG model this Retriever is used with. Contains parameters indicating which ``Index`` to build. The configuration of the RAG model this Retriever is used with. Contains parameters indicating which ``Index`` to build.
question_encoder_tokenizer (:class:`~transformers.PretrainedTokenizer`): question_encoder_tokenizer (:class:`~transformers.PreTrainedTokenizer`):
The tokenizer that was used to tokenize the question. The tokenizer that was used to tokenize the question.
It is used to decode the question and then use the generator_tokenizer. It is used to decode the question and then use the generator_tokenizer.
generator_tokenizer (:class:`~transformers.PretrainedTokenizer`): generator_tokenizer (:class:`~transformers.PreTrainedTokenizer`):
The tokenizer used for the generator part of the RagModel. The tokenizer used for the generator part of the RagModel.
index (:class:`~transformers.models.rag.retrieval_rag.Index`, optional, defaults to the one defined by the configuration): index (:class:`~transformers.models.rag.retrieval_rag.Index`, optional, defaults to the one defined by the configuration):
If specified, use this index instead of the one built using the configuration If specified, use this index instead of the one built using the configuration
......
...@@ -50,10 +50,10 @@ class RagRayDistributedRetriever(RagRetriever): ...@@ -50,10 +50,10 @@ class RagRayDistributedRetriever(RagRetriever):
Args: Args:
config (:class:`~transformers.RagConfig`): config (:class:`~transformers.RagConfig`):
The configuration of the RAG model this Retriever is used with. Contains parameters indicating which ``Index`` to build. The configuration of the RAG model this Retriever is used with. Contains parameters indicating which ``Index`` to build.
question_encoder_tokenizer (:class:`~transformers.PretrainedTokenizer`): question_encoder_tokenizer (:class:`~transformers.PreTrainedTokenizer`):
The tokenizer that was used to tokenize the question. The tokenizer that was used to tokenize the question.
It is used to decode the question and then use the generator_tokenizer. It is used to decode the question and then use the generator_tokenizer.
generator_tokenizer (:class:`~transformers.PretrainedTokenizer`): generator_tokenizer (:class:`~transformers.PreTrainedTokenizer`):
The tokenizer used for the generator part of the RagModel. The tokenizer used for the generator part of the RagModel.
retrieval_workers (:obj:`List[ray.ActorClass(RayRetriever)]`): A list of already initialized `RayRetriever` actors. retrieval_workers (:obj:`List[ray.ActorClass(RayRetriever)]`): A list of already initialized `RayRetriever` actors.
These actor classes run on remote processes and are responsible for performing the index lookup. These actor classes run on remote processes and are responsible for performing the index lookup.
......
...@@ -27,7 +27,7 @@ PROCESS_INPUTS_DOCSTRING = r""" ...@@ -27,7 +27,7 @@ PROCESS_INPUTS_DOCSTRING = r"""
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size * num_beams, sequence_length)`): input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size * num_beams, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Indices of input sequence tokens in the vocabulary.
Indices can be obtained using any class inheriting from :class:`~transformers.PretrainedTokenizer`. See Indices can be obtained using any class inheriting from :class:`~transformers.PreTrainedTokenizer`. See
:meth:`transformers.PreTrainedTokenizer.encode` and :meth:`transformers.PreTrainedTokenizer.__call__` for :meth:`transformers.PreTrainedTokenizer.encode` and :meth:`transformers.PreTrainedTokenizer.__call__` for
details. details.
...@@ -60,7 +60,7 @@ FINALIZE_INPUTS_DOCSTRING = r""" ...@@ -60,7 +60,7 @@ FINALIZE_INPUTS_DOCSTRING = r"""
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size * num_beams, sequence_length)`): input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size * num_beams, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Indices of input sequence tokens in the vocabulary.
Indices can be obtained using any class inheriting from :class:`~transformers.PretrainedTokenizer`. See Indices can be obtained using any class inheriting from :class:`~transformers.PreTrainedTokenizer`. See
:meth:`transformers.PreTrainedTokenizer.encode` and :meth:`transformers.PreTrainedTokenizer.__call__` for :meth:`transformers.PreTrainedTokenizer.encode` and :meth:`transformers.PreTrainedTokenizer.__call__` for
details. details.
...@@ -86,8 +86,8 @@ FINALIZE_INPUTS_DOCSTRING = r""" ...@@ -86,8 +86,8 @@ FINALIZE_INPUTS_DOCSTRING = r"""
class BeamScorer(ABC): class BeamScorer(ABC):
""" """
Abstract base class for all beam scorers that are used for :meth:`~transformers.PretrainedModel.beam_search` and Abstract base class for all beam scorers that are used for :meth:`~transformers.PreTrainedModel.beam_search` and
:meth:`~transformers.PretrainedModel.beam_sample`. :meth:`~transformers.PreTrainedModel.beam_sample`.
""" """
@abstractmethod @abstractmethod
......
...@@ -474,7 +474,7 @@ class PrefixConstrainedLogitsProcessor(LogitsProcessor): ...@@ -474,7 +474,7 @@ class PrefixConstrainedLogitsProcessor(LogitsProcessor):
class HammingDiversityLogitsProcessor(LogitsProcessor): class HammingDiversityLogitsProcessor(LogitsProcessor):
r""" r"""
:class:`transformers.LogitsProcessor` that enforces diverse beam search. Note that this logits processor is only :class:`transformers.LogitsProcessor` that enforces diverse beam search. Note that this logits processor is only
effective for :meth:`transformers.PretrainedModel.group_beam_search`. See `Diverse Beam Search: Decoding Diverse effective for :meth:`transformers.PreTrainedModel.group_beam_search`. See `Diverse Beam Search: Decoding Diverse
Solutions from Neural Sequence Models <https://arxiv.org/pdf/1610.02424.pdf>`__ for more details. Solutions from Neural Sequence Models <https://arxiv.org/pdf/1610.02424.pdf>`__ for more details.
Args: Args:
......
...@@ -586,7 +586,7 @@ class CTRLLMHeadModel(CTRLPreTrainedModel): ...@@ -586,7 +586,7 @@ class CTRLLMHeadModel(CTRLPreTrainedModel):
def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]: def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]:
""" """
This function is used to re-order the :obj:`past_key_values` cache if This function is used to re-order the :obj:`past_key_values` cache if
:meth:`~transformers.PretrainedModel.beam_search` or :meth:`~transformers.PretrainedModel.beam_sample` is :meth:`~transformers.PreTrainedModel.beam_search` or :meth:`~transformers.PreTrainedModel.beam_sample` is
called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step. called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step.
""" """
return tuple( return tuple(
......
...@@ -89,7 +89,7 @@ ENCODER_DECODER_INPUTS_DOCSTRING = r""" ...@@ -89,7 +89,7 @@ ENCODER_DECODER_INPUTS_DOCSTRING = r"""
:obj:`past_key_values`). :obj:`past_key_values`).
Provide for sequence to sequence training to the decoder. Indices can be obtained using Provide for sequence to sequence training to the decoder. Indices can be obtained using
:class:`~transformers.PretrainedTokenizer`. See :meth:`transformers.PreTrainedTokenizer.encode` and :class:`~transformers.PreTrainedTokenizer`. See :meth:`transformers.PreTrainedTokenizer.encode` and
:meth:`transformers.PreTrainedTokenizer.__call__` for details. :meth:`transformers.PreTrainedTokenizer.__call__` for details.
decoder_attention_mask (:obj:`torch.BoolTensor` of shape :obj:`(batch_size, target_sequence_length)`, `optional`): decoder_attention_mask (:obj:`torch.BoolTensor` of shape :obj:`(batch_size, target_sequence_length)`, `optional`):
Default behavior: generate a tensor that ignores pad tokens in :obj:`decoder_input_ids`. Causal mask will Default behavior: generate a tensor that ignores pad tokens in :obj:`decoder_input_ids`. Causal mask will
......
...@@ -951,7 +951,7 @@ class GPT2LMHeadModel(GPT2PreTrainedModel): ...@@ -951,7 +951,7 @@ class GPT2LMHeadModel(GPT2PreTrainedModel):
def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]: def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]:
""" """
This function is used to re-order the :obj:`past_key_values` cache if This function is used to re-order the :obj:`past_key_values` cache if
:meth:`~transformers.PretrainedModel.beam_search` or :meth:`~transformers.PretrainedModel.beam_sample` is :meth:`~transformers.PreTrainedModel.beam_search` or :meth:`~transformers.PreTrainedModel.beam_sample` is
called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step. called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step.
""" """
return tuple( return tuple(
...@@ -1157,7 +1157,7 @@ class GPT2DoubleHeadsModel(GPT2PreTrainedModel): ...@@ -1157,7 +1157,7 @@ class GPT2DoubleHeadsModel(GPT2PreTrainedModel):
def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]: def _reorder_cache(past: Tuple[Tuple[torch.Tensor]], beam_idx: torch.Tensor) -> Tuple[Tuple[torch.Tensor]]:
""" """
This function is used to re-order the :obj:`past_key_values` cache if This function is used to re-order the :obj:`past_key_values` cache if
:meth:`~transformers.PretrainedModel.beam_search` or :meth:`~transformers.PretrainedModel.beam_sample` is :meth:`~transformers.PreTrainedModel.beam_search` or :meth:`~transformers.PreTrainedModel.beam_sample` is
called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step. called. This is required to match :obj:`past_key_values` with the correct beam_idx at every generation step.
""" """
return tuple( return tuple(
......
...@@ -1141,8 +1141,8 @@ class TransfoXLLMHeadModel(TransfoXLPreTrainedModel): ...@@ -1141,8 +1141,8 @@ class TransfoXLLMHeadModel(TransfoXLPreTrainedModel):
@staticmethod @staticmethod
def _reorder_cache(mems: List[torch.Tensor], beam_idx: torch.Tensor) -> List[torch.Tensor]: def _reorder_cache(mems: List[torch.Tensor], beam_idx: torch.Tensor) -> List[torch.Tensor]:
""" """
This function is used to re-order the :obj:`mems` cache if :meth:`~transformers.PretrainedModel.beam_search` or This function is used to re-order the :obj:`mems` cache if :meth:`~transformers.PreTrainedModel.beam_search` or
:meth:`~transformers.PretrainedModel.beam_sample` is called. This is required to match :obj:`mems` with the :meth:`~transformers.PreTrainedModel.beam_sample` is called. This is required to match :obj:`mems` with the
correct beam_idx at every generation step. correct beam_idx at every generation step.
""" """
return [layer_past.index_select(1, beam_idx.to(layer_past.device)) for layer_past in mems] return [layer_past.index_select(1, beam_idx.to(layer_past.device)) for layer_past in mems]
......
...@@ -1470,8 +1470,8 @@ class XLNetLMHeadModel(XLNetPreTrainedModel): ...@@ -1470,8 +1470,8 @@ class XLNetLMHeadModel(XLNetPreTrainedModel):
@staticmethod @staticmethod
def _reorder_cache(mems: List[torch.Tensor], beam_idx: torch.Tensor) -> List[torch.Tensor]: def _reorder_cache(mems: List[torch.Tensor], beam_idx: torch.Tensor) -> List[torch.Tensor]:
""" """
This function is used to re-order the :obj:`mems` cache if :meth:`~transformers.PretrainedModel.beam_search` or This function is used to re-order the :obj:`mems` cache if :meth:`~transformers.PreTrainedModel.beam_search` or
:meth:`~transformers.PretrainedModel.beam_sample` is called. This is required to match :obj:`mems` with the :meth:`~transformers.PreTrainedModel.beam_sample` is called. This is required to match :obj:`mems` with the
correct beam_idx at every generation step. correct beam_idx at every generation step.
""" """
return [layer_past.index_select(1, beam_idx.to(layer_past.device)) for layer_past in mems] return [layer_past.index_select(1, beam_idx.to(layer_past.device)) for layer_past in mems]
......
...@@ -351,7 +351,7 @@ def pipeline( ...@@ -351,7 +351,7 @@ def pipeline(
# Impossible to guest what is the right tokenizer here # Impossible to guest what is the right tokenizer here
raise Exception( raise Exception(
"Impossible to guess which tokenizer to use. " "Impossible to guess which tokenizer to use. "
"Please provided a PretrainedTokenizer class or a path/identifier to a pretrained tokenizer." "Please provided a PreTrainedTokenizer class or a path/identifier to a pretrained tokenizer."
) )
modelcard = None modelcard = None
......
...@@ -1930,7 +1930,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin): ...@@ -1930,7 +1930,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin):
""" """
if not legacy_format: if not legacy_format:
raise ValueError( raise ValueError(
"Only fast tokenizers (instances of PretrainedTokenizerFast) can be saved in non legacy format." "Only fast tokenizers (instances of PreTrainedTokenizerFast) can be saved in non legacy format."
) )
save_directory = str(save_directory) save_directory = str(save_directory)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment