fix gpt-2 unk token test
This commit is contained in:
@@ -177,7 +177,9 @@ class GPT2Tokenizer(PreTrainedTokenizer):
|
|||||||
|
|
||||||
def _convert_token_to_id(self, token):
|
def _convert_token_to_id(self, token):
|
||||||
""" Converts a token (str/unicode) in an id using the vocab. """
|
""" Converts a token (str/unicode) in an id using the vocab. """
|
||||||
return self.encoder.get(token)
|
if token in self.encoder:
|
||||||
|
return self.encoder.get(token)
|
||||||
|
return self.encoder.get(self.unk_token)
|
||||||
|
|
||||||
def _convert_id_to_token(self, index):
|
def _convert_id_to_token(self, index):
|
||||||
"""Converts an index (integer) in a token (string/unicode) using the vocab."""
|
"""Converts an index (integer) in a token (string/unicode) using the vocab."""
|
||||||
|
|||||||
Reference in New Issue
Block a user