推理端點(專用)文件
支援的 Transformers 和 Diffusers 任務
並獲得增強的文件體驗
開始使用
支援的 Transformers 和 Diffusers 任務
推理端點為以下庫的機器學習任務提供開箱即用的支援
- Transformers
- Sentence-Transformers
- Diffusers (用於文字到影像任務)
下表列出了 Hugging Face 託管的推理端點支援的任務。這些任務不需要任何形式的程式碼或“自定義容器”來部署端點。如果您想自定義以下任何任務,或想編寫自己的自定義任務,請參閱“建立您自己的推理處理器”部分以獲取更多資訊。
以下大多數任務使用 `pipeline` 物件,有關可以傳送到端點的其他引數的更多資訊,請點選此處。
任務 | 框架 | 開箱即用支援 |
---|---|---|
文字到影像 | Diffusers | ✅ |
文字分類 | Transformers | ✅ |
零樣本分類 | Transformers | ✅ |
詞符分類 | Transformers | ✅ |
問答 | Transformers | ✅ |
掩碼填充 | Transformers | ✅ |
摘要 | Transformers | ✅ |
翻譯 | Transformers | ✅ |
文字到文字生成 | Transformers | ✅ |
文字生成 | Transformers | ✅ |
特徵提取 | Transformers | ✅ |
句子嵌入 | Sentence Transformers | ✅ |
句子相似度 | Sentence Transformers | ✅ |
排序 | Sentence Transformers | ✅ |
影像分類 | Transformers | ✅ |
自動語音識別 | Transformers | ✅ |
音訊分類 | Transformers | ✅ |
物體檢測 | Transformers | ✅ |
影像分割 | Transformers | ✅ |
表格問答 | Transformers | ✅ |
對話式 | Transformers | ✅ |
自定義 | 自定義 | ✅ |
視覺問答 | Transformers | ❌ |
零樣本影像分類 | Transformers | ❌ |
請求載荷示例
請參閱以下一些任務的請求示例
自定義處理器
{
"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` 載荷或直接從 `image` 接收二進位制資料。
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` 載荷或直接從 `audio` 接收二進位制資料。有關其他引數,請參閱此參考文件。
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` 載荷或直接從 `audio` 接收二進位制資料。有關其他引數,請參閱此參考文件。
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` 載荷或直接從 `image` 接收二進位制資料。有關其他引數,請參閱此參考文件。
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` 載荷或直接從 `image` 接收二進位制資料。有關其他引數,請參閱此參考文件。
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",
}
對於文字到影像模型,請注意,目前您的模型倉庫需要是一個包含完整權重的 diffusers 模型(即,不僅僅是 LoRA)。
其他引數
您可以新增 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
}
}