当前位置:网站首页>各种huggingface分词器对比
各种huggingface分词器对比
2023-01-19 15:29:41【Melody2050】
bert-base-chinese
对于dinner这种英语词汇,表现不佳,
tokenizer = AutoTokenizer.from_pretrained("bert-base-chinese")
输出如下,除去收尾的占位符,dinner被分成了3个词,差不多是每两个字符当一个词。这样分词是不合理的。
{‘input_ids’: [101, 9796, 12866, 8180, 102], ‘token_type_ids’: [0, 0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1, 1]}
该分词器将dinner分为了[di, nne, r]三组,如何证明?只需要让其处理dinne,可见两者的分词结果前缀相等。
res = tokenizer("dinner")
print(res)
print(tokenizer.decode(res.input_ids))
print(tokenizer("dinne"))
输出如下:
{‘input_ids’: [101, 9796, 12866, 8180, 102], ‘token_type_ids’: [0, 0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1, 1]}
[CLS] dinner [SEP]
{‘input_ids’: [101, 9796, 12866, 102], ‘token_type_ids’: [0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1]}
hfl/chinese-bert-wwm-ext
tokenizer = AutoTokenizer.from_pretrained("hfl/chinese-bert-wwm-ext")
res = tokenizer("dinner")
print(res)
print(tokenizer.decode(res.input_ids))
print(tokenizer("dinne"))
print(tokenizer("dinn"))
得到基本一致的结果
{‘input_ids’: [101, 9796, 12866, 8180, 102], ‘token_type_ids’: [0, 0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1, 1]}
[CLS] dinner [SEP]
{‘input_ids’: [101, 9796, 12866, 102], ‘token_type_ids’: [0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1]}
{‘input_ids’: [101, 9796, 9502, 102], ‘token_type_ids’: [0, 0, 0, 0], ‘attention_mask’: [1, 1, 1, 1]}
bert-base-chinese
输出居然和上面的也一样。
边栏推荐
猜你喜欢
随机推荐
- uni-app 178添加背景提示音(二)
- uni-app 181查看好友朋友圈完善(二)
- uni-app 180查看好友朋友圈完善(一)
- uni-app 176添加背景提示音(一)
- uni-app 175app端兼容处理(二)
- 关于双碳中的一些单位换算
- OpenMP 环境变量使用总结
- TiCDC 源码阅读(三)TiCDC 集群工作过程解析
- OpenMP 环境变量使用总结
- Inside OpenStack Technology
- MapReduce 实验:二次排序
- scrapy框架利用crawlspider全站爬取招聘信息
- scrapy爬虫框架全栈爬取招聘所有数据3000多条记录
- scrapy爬虫框架介绍与实战
- MeterSphere使用beanshell全局断言解决引用JSONObject问题
- 多种汉语方言语音落地应用,微软智能语音解锁更多交互场景
- 超越TensorFlow?Yann LeCun:“Why? PyTorch. That's why.”
- CTA-敏感行为-AppOps方案
- 年金保险排名前十的保险是哪个,安全吗
- 支付宝的年金保险值得入手吗?安全吗?
- 负电压是怎么产生的原理分析
- 迟滞比较器Hysteresiswindow和comparator(窗口比较器)原理
- 残留物与电子PCBA 的可靠性和三防漆涂敷前后可能导致电路板出现故障的变量
- 京东探索研究院 | 2023年十大科技趋势
- A variety of Chinese dialect voice landing applications, Microsoft's intelligent voice unlocks more interactive scenarios
- Is Alipay's annuity insurance worth buying?is it safe?
- Which is the top ten insurance for annuity insurance? Is it safe?
- Use MeterSphere beanshell global assertion reference JSONObject solution
- CNN+LSTM+Attention实现时间序列预测(PyTorch版)
- WebView加载heml代码简单应用
- CTA-Sensitive Behavior-AppOps Solution
- Beyond TensorFlow?Yann LeCun: "Why? PyTorch. That's why."
- 蜻蜓安全工作台程序编排简要说明
- WSL2安装systemd方法
- 安信证券开户安全吗?佣金是万几?
- 大智慧在上面开户安全吗?谁能告诉我一下
- 从合并石子学区间DP
- Golang的基本数据类型-基本使用
- 线扫相机DALSA--卡间同步
- 海康visionmaster-图像Bitmap和CmvdImage互转的方法



