huggingface Bert的encode方法

数据集分为raw和tokenized版本,应该使用raw版本用Bert自带的encode方法进行分词(因为Bert有自己的词表并且使用bpe的方法避免oov)

分词前的raw data长这样:

用tokenizer encode之后再convert_ids_to_tokens打出来看看长这样:

encode时把return_attention_mask设为True,打出来看attention_masks,是把padding的部分都置为0,其余句子部分置1。

posted @ 2020-07-07 16:25  _thousfeet  阅读(770)  评论(0编辑  收藏  举报