Hugging Face快速上手
参考视频: Getting Started With Hugging Face in 15 Minutes
https://www.google.com/search?q=Huggingface+tutorial&oq=Huggingface+tutorial&aqs=chrome…69i57j0l5.9301j0j8&sourceid=chrome&ie=UTF-8#fpstate=ive&vld=cid:61ceeebe,vid:QEaBAZQCtwE
Hugging Face transformer 库是目前最受欢迎的机器学习库,可以帮助初学者快速上手
Tansformers安装
需要先安装好 Pytorch或TensorFlow2.0或Flax
pip install transformers
1. PipeLine-一些可以直接拿来调用的功能模块流程
具体调用方法见下面的例子
from transformers import pipeline
第一个例子使用了情感分析流程的默认模型
from transformers import pipeline
classifier = pipeline("sentiment-analysis") # default model
res = classier("I'd love to learn the HuggingFace course")
print(res)
第二个例子使用了指定的模型
from transformers import pipeline
generator = pipeline("text-generation",model="distilgpt2")
res = generator(
"In this workshop, we will help you finish",
max_length=