一键安装tansformer

视频链接:https://www.bilibili.com/video/BV1Sd4y1v7hb/?spm_id_from=333.999.0.0&vd_source=7a32fe7f80f09236fc113c9c6bde1c81

1、conda创建虚拟环境

conda create -n transformer python=3.8.10

2、启动虚拟环境

conda activate transformer

3、!!!不要下载最新版本,使用如下命令

先使用第一种,若成功则跳到第三步

pip3 install farm-haystack -i https://pypi.tuna.tsinghua.edu.cn/simple 
pip install vit-pytorch -i https://pypi.tuna.tsinghua.edu.cn/simple 

若失败,则使用以下命令

conda install -c huggingface transformers

4、测试transformer是否安装成功

from transformers import pipeline

nlp = pipeline("question-answering")

context = "Extractive Question Answering is the task of extracting an answer from a text given a question. An example of a question answering dataset is the SQuAD dataset, which is entirely based on that task. If you would like to fine-tune a model on a SQuAD task, you may leverage the `run_squad.py`."

print(nlp(question="What is extractive question answering?", context=context))
print(nlp(question="What is a good example of a question answering dataset?", context=context))

若输出如下结果,则安装正确
在这里插入图片描述

5、若出现如下图所示错误

错误一

RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
libssl.so.10: cannot open shared object file: No such file or directory

解决方案:

pip3 install farm-haystack

6、开源项目

https://github.com/lucidrains/vit-pytorch

7、conda移除环境

conda remove -n transformer --all
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TechMasterPlus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值