-
先安装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
相关推荐
砚底藏山河3 小时前
python量化自定义周期 K 线合成视觉小萌新3 小时前
AI Class 3 · Chapter 1:变量、字符串、list/dict、if/for(python学习-小白版-有经验可跳过)IT召唤狮3 小时前
开源企业级零信任项目Pangolin,零信任能挡住PHP核弹漏洞吗?知已难寻3 小时前
03 · OpenStack的计算管理 NovaRover Ramble3 小时前
C++ 用互斥锁实现读写锁薛定谔的猫-菜鸟程序员4 小时前
软件架构设计师开发资料大全(从入门到精通)码流子4 小时前
移动收费怎么做?手持终端+App+收费中心的架构实践雪落漂泊4 小时前
C++算法 滑动窗口篇(下)云创智城-yuncitys5 小时前
YunParking 4.0:JDK 17 与 Spring Boot 3.2 的停车云升级郭小李5 小时前
openFeign入门