在 AWS 上部署的文件

推理工具包API

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

推理工具包API

支援的任務

SageMaker Hugging Face 推理工具包inputs 鍵中接受輸入,並在 parameters 鍵中支援額外的 pipelines 引數。您可以將 pipelines 支援的任何 kwargs 作為 parameters 提供。

推理工具包 API 支援的任務包括

  • 文字分類
  • 情感分析
  • 詞元分類
  • 特徵提取
  • 掩碼填充
  • 摘要
  • 翻譯_xx_到_yy
  • 文字到文字生成
  • 文字生成
  • 音訊分類
  • 自動語音識別
  • 對話
  • 影像分類
  • 影像分割
  • 目標檢測
  • 表格問答
  • 零樣本分類
  • 零樣本影像分類

參閱以下任務的一些請求示例

文字分類

{
  "inputs": "This sound track was beautiful! It paints the senery in your mind so well I would recommend it
  even to people who hate vid. game music!"
}

情感分析

{
  "inputs": "Don't waste your time.  We had two different people come to our house to give us estimates for
a deck (one of them the OWNER).  Both times, we never heard from them.  Not a call, not the estimate, nothing."
}

詞元分類

{
  "inputs": "My name is Sylvain and I work at Hugging Face in Brooklyn."
}

問題回答

{
  "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": "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": {
    "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": "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,
    "length_penalty": 1.5
  }
}

環境變數

推理工具包實現了各種額外的環境變數以簡化部署。Hugging Face 特定的環境變數完整列表如下所示

HF_TASK

HF_TASK 定義了所使用的 🤗 Transformers 流水線的任務。有關任務的完整列表,請參閱此處

HF_TASK="question-answering"

HF_MODEL_ID

HF_MODEL_ID 定義了模型 ID,在建立 SageMaker 端點時,該 ID 會自動從 hf.co/models 載入。🤗 Hub 的 10,000 多個模型均可透過此環境變數訪問。

HF_MODEL_ID="distilbert-base-uncased-finetuned-sst-2-english"

HF_MODEL_REVISION

HF_MODEL_REVISIONHF_MODEL_ID 的擴充套件,允許您定義或固定模型修訂版,以確保您的 SageMaker 端點始終載入相同的模型。

HF_MODEL_REVISION="03b4d196c19d0a73c7e0322684e97db1ec397613"

HF_API_TOKEN

HF_API_TOKEN 定義了您的 Hugging Face 授權令牌。HF_API_TOKEN 用作遠端檔案(如私有模型)的 HTTP 持有者授權。您可以在 Hugging Face 賬戶的設定中找到您的令牌。

HF_API_TOKEN="api_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.