赞
踩
默认情况下,pipeline选择一个特定的预训练模型,该模型已为英语情绪分析进行了微调。创建分类器对象时,将下载并缓存模型。如果重新运行该命令,则将使用缓存的模型,无需再次下载该模型。
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
classifier("I've been waiting for a HuggingFace course my whole life.")
输出:[{'label': 'POSITIVE', 'score': 0.9598047137260437}]
from transformers import pipeline
classifier = pipeline("zero-shot-classification")
classifier(
"This is a course about the Transformers library",
candidate_labels=["education", "politics", "business", "course"],
)
输出:
{'sequence': 'This is a course about the Transformers library',
'labels': ['course', 'education', 'business', 'politics'],
'scores': [0.9461037516593933,
0.04552055522799492,
0.0060350666753947735,
0.002340571256354451]}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。