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