From e08c01aa1ad63efff83548ea69d5ba3ce4a75acc Mon Sep 17 00:00:00 2001 From: LysandreJik Date: Mon, 26 Aug 2019 18:13:06 -0400 Subject: [PATCH] fix #1102 --- pytorch_transformers/modeling_roberta.py | 6 +++--- pytorch_transformers/tokenization_roberta.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pytorch_transformers/modeling_roberta.py b/pytorch_transformers/modeling_roberta.py index e49b2a06b1..cbd88ab86e 100644 --- a/pytorch_transformers/modeling_roberta.py +++ b/pytorch_transformers/modeling_roberta.py @@ -98,15 +98,15 @@ ROBERTA_INPUTS_DOCSTRING = r""" Inputs: **input_ids**: ``torch.LongTensor`` of shape ``(batch_size, sequence_length)``: Indices of input sequence tokens in the vocabulary. - To match pre-training, RoBERTa input sequence should be formatted with [CLS] and [SEP] tokens as follows: + To match pre-training, RoBERTa input sequence should be formatted with and tokens as follows: (a) For sequence pairs: - ``tokens: [CLS] is this jack ##son ##ville ? [SEP][SEP] no it is not . [SEP]`` + ``tokens: Is this Jacksonville ? No it is not . `` (b) For single sequences: - ``tokens: [CLS] the dog is hairy . [SEP]`` + ``tokens: the dog is hairy . `` Fully encoded sequences or sequence pairs can be obtained using the RobertaTokenizer.encode function with the ``add_special_tokens`` parameter set to ``True``. diff --git a/pytorch_transformers/tokenization_roberta.py b/pytorch_transformers/tokenization_roberta.py index edf4717c89..13d963d432 100644 --- a/pytorch_transformers/tokenization_roberta.py +++ b/pytorch_transformers/tokenization_roberta.py @@ -163,14 +163,14 @@ class RobertaTokenizer(PreTrainedTokenizer): def add_special_tokens_single_sentence(self, token_ids): """ Adds special tokens to a sequence for sequence classification tasks. - A RoBERTa sequence has the following format: [CLS] X [SEP] + A RoBERTa sequence has the following format: X """ return [self._convert_token_to_id(self.cls_token)] + token_ids + [self._convert_token_to_id(self.sep_token)] def add_special_tokens_sentences_pair(self, token_ids_0, token_ids_1): """ Adds special tokens to a sequence pair for sequence classification tasks. - A RoBERTa sequence pair has the following format: [CLS] A [SEP][SEP] B [SEP] + A RoBERTa sequence pair has the following format: A B """ sep = [self._convert_token_to_id(self.sep_token)] cls = [self._convert_token_to_id(self.cls_token)]