支持可逆变换 & Diffusers 任务
推理端点为以下库中的机器学习任务提供开箱即用的支持
- Transformer
- 句子变换器
- Diffusers(用于文本到图像任务)
下面是 Hugging Face 管理的推理端点支持的任务表。这些任务不需要任何形式的代码或 “自定义容器” 即可部署端点。如果您想自定义以下任何任务,或想编写自己的自定义任务,请参阅 “创建您自己的推理处理器” 部分以获取更多信息。
以下大部分任务使用 pipeline
对象,更多有关可以发送到端点附加参数的信息请访问 此处。
任务 | 框架 | 开箱即用支持 |
---|---|---|
文本到图像 | Diffusers | ✅ |
文本分类 | Transformer | ✅ |
零样本分类 | Transformer | ✅ |
标记分类 | Transformer | ✅ |
问答 | Transformer | ✅ |
填空 | Transformer | ✅ |
摘要 | Transformer | ✅ |
翻译 | Transformer | ✅ |
文本到文本生成 | Transformer | ✅ |
文本生成 | Transformer | ✅ |
特征提取 | Transformer | ✅ |
句子嵌入 | 句子转换器 | ✅ |
句子相似度 | 句子转换器 | ✅ |
排序 | 句子转换器 | ✅ |
图像分类 | Transformer | ✅ |
自动语音识别 | Transformer | ✅ |
音频分类 | Transformer | ✅ |
目标检测 | Transformer | ✅ |
图像分割 | Transformer | ✅ |
表格问答 | Transformer | ✅ |
对话式 | Transformer | ✅ |
自定义 | 自定义 | ✅ |
视觉问答 | Transformer | ❌ |
零样本图像分类 | Transformer | ❌ |
示例请求负载
查看以下请求示例了解一些任务
自定义处理程序
{
"inputs": "This is a sample input",
"moreData": 1,
"customTask": true
}
文本分类
有关更多参数,请参阅此参考。
对单个文本进行分类
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
对文本对进行分类
{
"inputs": {
"text": "This sound track was beautiful!",
"text_pair": "It paints the scenery in your mind so well I would recomend it even to people who hate vid. game music!"
}
}
零样本分类
有关其他参数,请参阅此参考文献。
{
"inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
"parameters": {
"candidate_labels": ["refund", "legal", "faq"]
}
}
标记分类
有关其他参数,请参阅此参考文献。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
问答
有关其他参数,请参阅此参考文献。
{
"inputs": {
"question": "What is used for inference?",
"context": "My Name is Philipp and I live in Nuremberg. This model is used with sagemaker for inference."
}
}
填充掩码
有关其他参数,请参阅此参考文献。
{
"inputs": "This sound track was <mask>! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
摘要
关于其他参数,请参阅此参考。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
翻译
关于其他参数,请参阅此参考。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
文本到文本生成
关于其他参数,请参阅此参考。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
文本生成
关于其他参数,请参阅此参考。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
特征提取
有关其他参数,请参见此参考。
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
句子嵌入
{
"inputs": "This sound track was beautiful! It paints the scenery in your mind so well I would recomend it
even to people who hate vid. game music!"
}
句子相似度
{
"inputs": {
"sentences": ["This sound track was beautiful!", "It paints the scenery in your mind so well"],
"source_sentence": "What a wonderful day to listen to music"
}
}
排序
{
"inputs": ["This sound track was beautiful!", "It paints the scenery in your mind so well"]
}
图片分类
图片分类可以直接接收来自图片的 JSON 负载或二进制数据。
JSON
{
"inputs": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgI"
}
二进制
curl --request POST \
--url https://{ENDPOINT}/ \
--header 'Content-Type: image/jpg' \
--header 'Authorization: Bearer {HF_TOKEN}' \
--data-binary '@test.jpg'
自动语音识别
自动语音识别可以直接接收来自音频的 JSON 负载或二进制数据。有关其他参数,请参阅此参考。
JSON
{
"inputs": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgI"
}
二进制
curl --request POST \
--url https://{ENDPOINT}/ \
--header 'Content-Type: audio/x-flac' \
--header 'Authorization: Bearer {HF_TOKEN}' \
--data-binary '@sample.flac'
音频分类
音频分类可以直接接收来自音频的 JSON 负载或二进制数据。有关其他参数,请参阅此 参考。
JSON
{
"inputs": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgI"
}
二进制
curl --request POST \
--url https://{ENDPOINT}/ \
--header 'Content-Type: audio/x-flac' \
--header 'Authorization: Bearer {HF_TOKEN}' \
--data-binary '@sample.flac'
目标检测
目标检测可以直接接收来自图片的 JSON 负载或二进制数据。有关其他参数,请参阅此 参考。
JSON
{
"inputs": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgI"
}
二进制
curl --request POST \
--url https://{ENDPOINT}/ \
--header 'Content-Type: image/jpg' \
--header 'Authorization: Bearer {HF_TOKEN}' \
--data-binary '@test.jpg'
图像分割
图像分割可以从直接从image
接收json
有效载荷或二进制数据。对于其他参数,请参阅此参考资料。
JSON
{
"inputs": "/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgI"
}
二进制
curl --request POST \
--url https://{ENDPOINT}/ \
--header 'Content-Type: image/jpg' \
--header 'Authorization: Bearer {HF_TOKEN}' \
--data-binary '@test.jpg'
表格问答
对于其他参数,请参阅此参考资料。
{
"inputs": {
"query": "How many stars does the transformers repository have?",
"table": {
"Repository": ["Transformers", "Datasets", "Tokenizers"],
"Stars": ["36542", "4512", "3934"],
"Contributors": ["651", "77", "34"],
"Programming language": ["Python", "Python", "Rust, Python and NodeJS"]
}
}
}
对话
对于其他参数,请参阅此参考资料。
{"inputs": [
{
"role": "user",
"content": "Which movie is the best ?"
},
{
"role": "assistant",
"content": "It's Die Hard for sure."
},
{
"role": "user",
"content": "Can you explain why?"
}
]}
文本转图像
{
"inputs": "realistic render portrait realistic render portrait of group of flying blue whales towards the moon, intricate, toy, sci - fi, extremely detailed, digital painting, sculpted in zbrush, artstation, concept art, smooth, sharp focus, illustration, chiaroscuro lighting, golden ratio, incredible art by artgerm and greg rutkowski and alphonse mucha and simon stalenhag",
}
对于文本到图像模型,请注意,当前您的模型仓库需要一个包含完全权重(即,不仅仅是LoRA)的diffusers模型。
附加参数
您可以添加由 transformers 的 pipelines
api 支持的附加参数。
例如,如果您有一个 text-generation
管道,您可以为 repetition_penalty
或 max_length
提供额外的 generation_kwargs
参数。
{
"inputs": "Hugging Face, the winner of VentureBeat’s Innovation in Natural Language Process/Understanding Award for 2021, is looking to level the playing field. The team, launched by Clément Delangue and Julien Chaumond in 2016, was recognized for its work in democratizing NLP, the global market value for which is expected to hit $35.1 billion by 2026. This week, Google’s former head of Ethical AI Margaret Mitchell joined the team.",
"parameters": {
"repetition_penalty": 4.0,
"max_length": 128
}
}