赞
踩
相关资源对应网址如下:
网址 | |
---|---|
库的 GitHub 地址 | https://github.com/huggingface/transformers |
官方开发文档 | https://huggingface.co/docs/transformers/index |
预训练模型下载地址 | https://huggingface.co/models |
pytorch 和 tensorflow 都可用,但建议用 pytorch,以下代码全都基于 pytorch.
需要安装的库:
现有的模型和checkpoint,可以直接拿来用,处理某个任务,如情感分类、文本生成、命名实体识别、问答等。
支持的任务
Task | Description | Modality | Pipeline identifier |
---|---|---|---|
Text classification | assign a label to a given sequence of text | NLP | pipeline(task=“sentiment-analysis”) |
Text generation | generate text that follows a given prompt | NLP | pipeline(task=“text-generation”) |
Name entity recognition | assign a label to each token in a sequence (people, organization, location, etc.) | NLP | pipeline(task=“ner”) |
Question answering | extract an answer from the text given some context and a question | NLP | pipeline(task=“question-answering”) |
Fill-mask | predict the correct masked token in a sequence | NLP | pipeline(task=“fill-mask”) |
Summarization | generate a summary of a sequence of text or document | NLP | pipeline(task=“summarization”) |
Translation | translate text from one language into another | NLP | pipeline(task=“translation”) |
Image classification | assign a label to an image | Computer vision | pipeline(task=“image-classification”) |
Image segmentation | assign a label to each individual pixel of an image (supports semantic, panoptic, and instance segmentation) | Computer vision | pipeline(task=“image-segmentation”) |
Object detection | predict the bounding boxes and classes of objects in an image | Computer vision | pipeline(task=“object-detection”) |
Audio classification | assign a label to an audio file | Audio | pipeline(task=“audio-classification”) |
Automatic speech recognition | extract speech from an audio file into text | Audio | pipeline(task=“automatic-speech-recognition”) |
Visual question answering | given an image and a question, correctly answer a question about the image | Multimodal | pipeline(task=“vqa”) |
from transformers import pipeline
classifier = pipeline("sentiment-analysis")
测试 “We are very happy to show you the
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。