Chat UI 文档

文本生成推理 (TGI)

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

文本生成推理 (TGI)

特性 可用
工具 是*
多模态 是*

* 工具仅在使用 Xenova 分词器的 Cohere Command R+ 模型中受支持。请参阅工具部分。

* 多模态仅在使用 IDEFICS 模型时受支持。请参阅多模态部分。

默认情况下,如果 endpoints 未指定,Chat UI 将使用模型名称在托管的 Hugging Face 推理 API 上查找模型,并使用您的 HF_TOKEN。有关模型配置的更多信息,请参阅概览

MODELS=`[
  {
    "name": "mistralai/Mistral-7B-Instruct-v0.2",
    "displayName": "mistralai/Mistral-7B-Instruct-v0.2",
    "description": "Mistral 7B is a new Apache 2.0 model, released by Mistral AI that outperforms Llama2 13B in benchmarks.",
    "websiteUrl": "https://mistral.ai/news/announcing-mistral-7b/",
    "preprompt": "",
    "chatPromptTemplate" : "<s>{{#each messages}}{{#ifUser}}[INST] {{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{

{/if}

}{

{/if}

}{{content}} [/INST]{{/ifUser}}{{#ifAssistant}}{{content}}</s>{{/ifAssistant}}{{/each}}",
    "parameters": {
      "temperature": 0.3,
      "top_p": 0.95,
      "repetition_penalty": 1.2,
      "top_k": 50,
      "truncate": 3072,
      "max_new_tokens": 1024,
      "stop": ["</s>"]
    },
    "promptExamples": [
      {
        "title": "Write an email from bullet list",
        "prompt": "As a restaurant owner, write a professional email to the supplier to get these products every week: \n\n- Wine (x10)\n- Eggs (x24)\n- Bread (x12)"
      }, {
        "title": "Code a snake game",
        "prompt": "Code a basic snake game in python, give explanations for each step."
      }, {
        "title": "Assist in a task",
        "prompt": "How do I make a delicious lemon cheesecake?"
      }
    ]
  }
]`

使用自定义端点运行您自己的模型

如果您想避免访问 Hugging Face 推理 API 上的模型,您可以在本地运行自己的模型。

一个好的选择是访问 text-generation-inference 端点。例如,官方 Chat UI Spaces Docker 模板就是这样做的:此应用程序和 text-generation-inference 服务器都在同一个容器内运行。

为此,您可以通过在 MODELS 中为每个模型添加一个 "endpoints" 键,将您自己的端点添加到 .env.local 中的 MODELS 变量。

MODELS=`[{
  "name": "your-model-name",
  "displayName": "Your Model Name",
  ... other model config
  "endpoints": [{
    "type" : "tgi",
    "url": "https://HOST:PORT",
  }]
}]`
< > 在 GitHub 上更新