我试图借助拥抱面部情绪分析预训练模型来获取评论的情绪。它返回错误,就像Token indices sequence length is longer than the specified maximum sequence length for this model (651 > 512)拥抱面部情感分类器一样。
下面我附上代码请看一下
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
import transformers
import pandas as pd
model = AutoModelForSequenceClassification.from_pretrained('/content/drive/MyDrive/Huggingface-Sentiment-Pipeline')
token = AutoTokenizer.from_pretrained('/content/drive/MyDrive/Huggingface-Sentiment-Pipeline')
classifier = pipeline(task='sentiment-analysis', model=model, tokenizer=token)
data = pd.read_csv('/content/drive/MyDrive/DisneylandReviews.csv', encoding='latin-1')
data.head()
Run Code Online (Sandbox Code Playgroud)
输出是
Review
0 If you've ever been to Disneyland anywhere you...
1 Its been a while since d last time we visit HK...
2 Thanks God it wasn t too hot …Run Code Online (Sandbox Code Playgroud) nlp sentiment-analysis deep-learning huggingface-transformers huggingface-tokenizers
nlp ×1