ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ubuntu20.4下ARM64安装transformer

2022-05-06 11:01:36  阅读:185  来源: 互联网

标签:pipeline name transformer blog ARM64 install model ubuntu20.4 classifier


一、安装依赖库
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

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有