huggingface
参考文档
-
引导文档
-
bert相关
名词解释、基本概念
token: 分词,就是一句话分成的每个词
token_type_ids:分词的类型id,比如是个句子对,则属于第一句的token就把他的id设置为0,第二句的就设置为1。
demo:
Bert 的输入需要用 [CLS] 和 [SEP] 进行标记,开头用 [CLS],句子结尾用 [SEP]
两个句子:
tokens:[CLS] is this jack ##son ##ville ? [SEP] no it is not . [SEP]
token_type_ids:0 0 0 0 0 0 0 0 1 1 1 1 1 1
第一个 [SEP] 属于第一句
一个句子:
tokens:[CLS] the dog is hairy . [SEP]
token_type_ids:0 0 0 0 0 0 0
tokenizer相关
见ref. bert相关-2
install
conda install -c huggingface transformers==4.11.3 tokenizers==0.10.3
本文介绍了HuggingFace库的基础概念,包括tokenizer的安装与使用,着重讲解了BERT模型的加载及在下游任务中的实践,涉及token类型标识符(token_type_ids)的概念。通过实例演示如何处理多句子输入并生成对应的token和类型ID。
273

被折叠的 条评论
为什么被折叠?



