系统相关
首页 > 系统相关> > ubuntu20.4下ARM64安装transformer

ubuntu20.4下ARM64安装transformer

作者:互联网

一、安装依赖库
sudo apt install python3.8

sudo apt install python3.9
python3 --version

sudo apt install python3-pip
sudo pip3 install --upgrade pip
pip3 --version


pip install transformers
pip install torch
pip install pycosat
pip install conda


二、

验证方法---->
打开python3.8

>>> from transformers import pipeline

# Allocate a pipeline for sentiment-analysis
>>> classifier = pipeline('sentiment-analysis')
>>> classifier('We are very happy to introduce pipeline to the transformers repository.')
[{'label': 'POSITIVE', 'score': 0.9996980428695679}]

 


https://anaconda.cloud/installers

wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh

model_name = "hfl/chinese-bert-wwm-ext"
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
classifier("我很喜欢哥特风格的建筑")
classifier("我很不喜欢哥特风格的建筑")

classifier("我很喜欢".encode('utf-8'))

classifier("我很喜欢哥特风格的建筑".encode('utf-8'))

三、报错处理
【Linux】报错:socket.gaierror: [Errno -3] Temporary failure in name resolution问题解决---->
在 /etc/hosts 文件里加上::
127.0.0.1 localhost
127.0.0.1 <your hostname>


参考---->
https://zhuanlan.zhihu.com/p/340843194
https://www.jianshu.com/p/c22aea96565f
https://blog.csdn.net/KRISNAT/article/details/124068391
https://blog.csdn.net/KRISNAT/article/details/124041869
https://blog.csdn.net/weixin_44566432/article/details/108990225
https://www.cnblogs.com/lian1995/p/11947522.html
https://anaconda.cloud/installers
https://docs.conda.io/en/latest/miniconda.html
https://blog.csdn.net/xujianjun229/article/details/118500154

 

标签:pipeline,name,transformer,blog,ARM64,install,model,ubuntu20.4,classifier
来源: https://www.cnblogs.com/loongson-artc-lyc/p/16227847.html