> For the complete documentation index, see [llms.txt](https://docs.skydeck.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skydeck.ai/zh-hk/integrations/llms-and-databases/huggingface-integration.md).

# HuggingFace 整合

在 HuggingFace 上部署您的推理端點後，您應該會看到以下用戶界面：

<figure><img src="/files/52GWKnai8oCTqQr8OAUb" alt="huggingface deploy interface"><figcaption></figcaption></figure>

在此頁面上，您需要以下資訊：

* 端點 URL
* 模型庫
* API 令牌。您可以通過在呼叫範例代碼區塊中勾選「添加 API 令牌」框來查看此項。

除了這些，您還需要模型的上下文窗口。這可以在模型的資訊頁面上找到。

收集完這些資訊後，將其格式化為 JSON，如下例所示：

```json
{
    "api_key":"your_api_key",
    "endpoint": "your_api_endpoint",
    "model_name": "meta-llama/Llama-2-7b-chat-hf",
    "context_window": 4096
}
```

接下來，將此內容粘貼到您的整合的憑證欄位中。

<figure><img src="/files/RSnsdwt8Kr84F2BC1nzC" alt="credential field"><figcaption></figcaption></figure>

一旦憑證成功驗證，您應該會在 GenStudio 的模型列表中看到您的 HuggingFace 模型：

<figure><img src="/files/EpM9RWKpX3bckV7Hkym4" alt="huggingface model as genstudio model"><figcaption></figcaption></figure>

### 將 HuggingFace 端點擴展至零

擴展至零是由推理端點提供的動態功能，旨在優化資源使用和成本。通過智能監控請求模式並在空閒時間將副本數減少至無，確保您僅在需要時使用資源。

然而，當流量恢復時，這確實會引入一個冷啟動期，也有一些需要注意的事項。請參閱 [HuggingFace 的 Autoscaling 指南](https://huggingface.co/docs/inference-endpoints/autoscaling)以深入了解此功能的運作方式、其優點以及可能的挑戰。

### 支援的模型

目前，我們僅支援具有 `text-generation` 標籤的模型的端點，這些模型以 `text-generation-inference` 容器的形式部署。我們正在努力擴展我們支援的模型列表。

<figure><img src="/files/BEECmpEX0AyYQdV6GveG" alt="image (48)"><figcaption><p>LLaMA 2 是一個具有文本生成標籤的模型</p></figcaption></figure>

<figure><img src="/files/o7376eSGYCMSdwNP6gY3" alt="image (49)"><figcaption><p>確保在部署期間選擇文本生成推理作為容器類型</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.skydeck.ai/zh-hk/integrations/llms-and-databases/huggingface-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
