本文整理汇总了Python中pytorch_transformers.BertTokenizer方法的典型用法代码示例。如果您正苦于以下问题:Python pytorch_transformers.BertTokenizer方法的具体用法?Python pytorch_transformers.BertTokenizer怎么用?Python pytorch_transformers.BertTokenizer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytorch_transformers
的用法示例。
在下文中一共展示了pytorch_transformers.BertTokenizer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pytorch_transformers [as 别名]
# 或者: from pytorch_transformers import BertTokenizer [as 别名]
def __init__(self, vocab_path, do_lower_case):
self.tokenizer = BertTokenizer(vocab_path, do_lower_case)
示例2: test_tokenizer_from_pretrained
# 需要导入模块: import pytorch_transformers [as 别名]
# 或者: from pytorch_transformers import BertTokenizer [as 别名]
def test_tokenizer_from_pretrained(self):
logging.basicConfig(level=logging.INFO)
for model_name in list(BERT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
tokenizer = AutoTokenizer.from_pretrained(model_name)
self.assertIsNotNone(tokenizer)
self.assertIsInstance(tokenizer, BertTokenizer)
self.assertGreater(len(tokenizer), 0)
for model_name in list(GPT2_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
tokenizer = AutoTokenizer.from_pretrained(model_name)
self.assertIsNotNone(tokenizer)
self.assertIsInstance(tokenizer, GPT2Tokenizer)
self.assertGreater(len(tokenizer), 0)