Hugging Face
Bundles 包含支援特定第三 方整合的自訂Components,與 AgentBuilder 搭配使用。
Hugging Face bundle 中的Components需要存取 Hugging Face API。
如需有關 Hugging Face Components所使用 Hugging Face 功能和功能的詳細資訊,請參閱 Hugging Face 文件。
Hugging Face 文字生成
Hugging Face Components透過向 Hugging Face API 發送請求,使用指定的模型生成文字,這是託管在 Hugging Face 上的模型的託管推理 API。 需要驗證。
此Components可以輸出 Model Response (Message) 或 Language Model (LanguageModel)。
具體來說,Language Model 輸出是根據Components參數配置的 ChatHuggingFace 實例。
當您想要將 Hugging Face 模型用作另一個 LLM 驅動Components的 LLM 時,請使用 Language Model 輸出,例如 Agent 或 Smart Function Components。
如需詳細資訊,請參閱語言模型Components。
Hugging Face 文字生成參數
某些參數在視覺編輯器中預設為隱藏。 您可以透過 Components的標頭選單 中的 Controls 修改所有參數。
| Name | Type | Description |
|---|---|---|
| model_id | String | 輸入參數。來自 Hugging Face Hub 的模型 ID。例如 "gpt2"、"facebook/bart-large"。 |
| huggingfacehub_api_token | SecretString | 輸入參數。您的 Hugging Face API 權杖,用於驗證。 |
| temperature | Float | 輸入參數。控制輸出的隨機性。範圍:[0.0, 1.0]。預設值:0.7。 |
| max_new_tokens | Integer | 輸入參數。要生成的最大權杖數。預設值:512。 |
| top_p | Float | 輸入參數。核心取樣參數。範圍:[0.0, 1.0]。預設值:0.95。 |
| top_k | Integer | 輸入參數。Top-k 取樣參數。預設值:50。 |
| model_kwargs | Dictionary | 輸入參數。要傳遞給模型的其他關鍵字引數。 |
Hugging Face Embeddings Inference
使用 Hugging Face Embeddings Inference Components以 Hugging Face 的託管模型或您自己的本地託管模型建立嵌入。
此Components使用 Hugging Face Inference API 模型 生成嵌入。 使用非本地模型時需要驗證。
如需在 Flow 中使用嵌入模型Components的詳細資訊,請參閱嵌入模型Components和使用本地 Hugging Face 嵌入模型。
Hugging Face Embeddings Inference 參數
| Name | Display Name | Info |
|---|---|---|
| api_key | API Key | 輸入參數。您的 Hugging Face API 權杖,用於存取 Hugging Face Inference API(如需要)。本地推理模型不需要 API 金鑰。 |
| api_url | API URL | 輸入參數。Hugging Face Inference API 的 URL。 |
| model_name | Model Name | 輸入參數。用於嵌入的模型名稱。 |
使用本地 Hugging Face 嵌入模型
要將本地 Hugging Face 模型連接到 Hugging Face Embeddings Inference Components並在FLOW中使用,請遵循以下步驟:
-
在此範例中,從 Vector Store RAG 範本建立 Flow。
-
以 Hugging Face Embeddings Inference Components替換兩個 OpenAI Embeddings Components。
確保將每個 Embeddings Inference Components的 Embedding Model 連接埠重新連接到其對應的 Astra DB Components。
-
配置 Astra DB Components以連接到您的 Astra 組織,或以其他向量儲存Components替換兩個 Astra DB Components。
-
將每個 Hugging Face Embeddings Inference Components連接到您的本地推理模型:
- Inference Endpoint:輸入您的本地推理模型的 URL。
- API Key:本地推理可以為空。
- Model Name:如果未自動偵測到,請輸入您的本地推理模型名稱。
-
要測試 Flow,請點擊 Playground,然後輸入一些文字來生成嵌入。