Sentence -> Sequence. Removed output_mask from the special token addition methods.
This commit is contained in:
@@ -754,28 +754,21 @@ class XLMTokenizer(PreTrainedTokenizer):
|
||||
out_string = ''.join(tokens).replace('</w>', ' ').strip()
|
||||
return out_string
|
||||
|
||||
def add_special_tokens_single_sentence(self, token_ids):
|
||||
def add_special_tokens_single_sequence(self, token_ids):
|
||||
"""
|
||||
Adds special tokens to a sequence for sequence classification tasks.
|
||||
An XLM sequence has the following format: [CLS] X [SEP]
|
||||
"""
|
||||
return [self.cls_token_id] + token_ids + [self.sep_token_id]
|
||||
|
||||
def add_special_tokens_sentences_pair(self, token_ids_0, token_ids_1, output_mask=False):
|
||||
def add_special_tokens_sequence_pair(self, token_ids_0, token_ids_1):
|
||||
"""
|
||||
Adds special tokens to a sequence pair for sequence classification tasks.
|
||||
An XLM sequence pair has the following format: [CLS] A [SEP] B [SEP]
|
||||
"""
|
||||
sep = [self.sep_token_id]
|
||||
cls = [self.cls_token_id]
|
||||
|
||||
if output_mask:
|
||||
return (
|
||||
cls + token_ids_0 + sep + token_ids_1 + sep,
|
||||
[0] * len(cls + token_ids_0 + sep) + [1] * len(token_ids_1 + sep)
|
||||
)
|
||||
else:
|
||||
return cls + token_ids_0 + sep + token_ids_1 + sep
|
||||
return cls + token_ids_0 + sep + token_ids_1 + sep
|
||||
|
||||
def save_vocabulary(self, save_directory):
|
||||
"""Save the tokenizer vocabulary and merge files to a directory."""
|
||||
|
||||
Reference in New Issue
Block a user