-
先安装transformers
-
在huggingface下载模型
模型bert-multi-cased-finetuned-xquadv1可以从huggingface中下载,具体操作方法可以参照文章https://blog.csdn.net/zhaomengsen/article/details/130616837下载
-
git clone就可以了
-
然后使用pipline加载模型
from transformers import pipeline
nlp = pipeline("question-answering",model="mrm8488/bert-multi-cased-finetuned-xquadv1",tokenizer="mrm8488/bert-multi-cased-finetuned-xquadv1") -
测试
context = """非root用户使用HBase客户端,请确保该HBase客户端目录的属主为该用户,否则请参考如下命令修改属主"""
question = "命令是什么?"
result = nlp(question=question, context=context)
print("Answer:", result['answer'])
print("Score:", result['score'])Answer: 修改属主
Score: 0.9437811374664307
python-在transformers的问答模型中使用中文
liwulin05062023-07-21 14:31
相关推荐
李白同学1 小时前
【C语言】结构体内存对齐问题黑子哥呢?2 小时前
安装Bash completion解决tab不能补全问题失败尽常态5232 小时前
用Python实现Excel数据同步到飞书文档2501_904447742 小时前
OPPO发布新型折叠屏手机 起售价8999青龙小码农2 小时前
yum报错:bash: /usr/bin/yum: /usr/bin/python: 坏的解释器:没有那个文件或目录大数据追光猿2 小时前
Python应用算法之贪心算法理解和实践Leuanghing3 小时前
【Leetcode】11. 盛最多水的容器彳卸风3 小时前
Unable to parse timestamp value: “20250220135445“, expected format isdorabighead4 小时前
JavaScript 高级程序设计 读书笔记(第三章)xinxiyinhe4 小时前
如何设置Cursor中.cursorrules文件