嵌入模型
AgentBuilder 中的嵌入模型Components使用指定的語言模型 (LLM) 生成文字嵌入。
AgentBuilder 包含一個 Embedding Model 核心Components,具有對某些 LLM 的內建支援。 或者,您可以使用任何其他嵌入模型來替代 Embedding Model 核心Components。
在 Flow中使用嵌入模型Components
在需要生成嵌入的任何地方使用嵌入模型Components。
此示例顯示如何在 Flow中使用嵌入模型Components來建立語義搜尋系統。 此 Flow載入文字檔案,將文字分割成區塊,為每個區塊生成嵌入,然後將區塊和嵌入載入到向量儲存中。輸入和輸出Components允許使用者透過聊天介面查詢向量儲存。

-
建立 Flow,新增 File Components,然後選取包含文字資料的檔案,例如 PDF,您可以用來測試 Flow。
-
新增 Embedding Model 核心Components,然後提供有效的 OpenAI API 金鑰。 您可以直接輸入 API 金鑰或使用 全域變數。
我的偏好提供者或模型未列出如果您的偏好嵌入模型提供者或模型不受 Embedding Model 核心Components支援,您可以使用任何其他嵌入模型來替代核心Components。
瀏覽 Bundles 或 搜尋 您的偏好提供者,以找到其他嵌入模型,例如 Hugging Face Embeddings Inference Components。
-
新增 Split Text Components 到您的 Flow。 此Components將文字輸入分割成較小的區塊以處理成嵌入。
-
新增向量儲存Components,例如 Chroma DB Components,到您的 Flow,然後配置Components以連接到您的向量資料庫。 此Components儲存生成的嵌入,以便用於相似性搜尋。
-
連接Components:
- 將 File Components的 Loaded Files 輸出連接到 Split Text Components的 Data or DataFrame 輸入。
- 將 Split Text Components的 Chunks 輸出連接到向量儲存Components的 Ingest Data 輸入。
- 將 Embedding Model Components的 Embeddings 輸出連接到向量儲存Components的 Embedding 輸入。
-
要查詢向量儲存,請新增 Chat Input and Output Components:
- 將 Chat Input Components連接到向量儲存Components的 Search Query 輸入。
- 將向量儲存Components的 Search Results 輸出連接到 Chat Output Components。
-
點擊 Playground,然後輸入搜尋查詢以擷取與您的查詢語義最相似的文字區塊。
Embedding Model 參數
以下參數適用於 Embedding Model 核心Components。 其他嵌入模型Components可能有額外或不同的參數。
某些參數在視覺編輯器中預設為隱藏。 您可以透過 Components的標頭選單 中的 Controls 修改所有參數。
| Name | Display Name | Type | Description |
|---|---|---|---|
| provider | Model Provider | List | 輸入參數。選取嵌入模型提供者。 |
| model | Model Name | List | 輸入參數。選取要使用的嵌入模型。 |
| api_key | OpenAI API Key | Secret[String] | 輸入參數。驗證提供者所需的 API 金鑰。 |
| api_base | API Base URL | String | 輸入參數。API 的基礎 URL。留空為預設值。 |
| dimensions | Dimensions | Integer | 輸入參數。輸出嵌入的維度數。 |
| chunk_size | Chunk Size | Integer | 輸入參數。要處理的文字區塊大小。預設:1000。 |
| request_timeout | Request Timeout | Float | 輸入參數。API 請求的逾時。 |
| max_retries | Max Retries | Integer | 輸入參數。最大重試次數。預設:3。 |
| show_progress_bar | Show Progress Bar | Boolean | 輸入參數。是否在嵌入生成期間顯示進度條。 |
| model_kwargs | Model Kwargs | Dictionary | 輸入參數。要傳遞給模型的額外關鍵字參數。 |
| embeddings | Embeddings | Embeddings | 輸出參數。使用選取提供者生成嵌入的實例。 |
其他嵌入模型
如果您的提供者或模型不受 Embedding Model 核心Components支援,您可以用生成嵌入的任何其他Components來替代此Components。
要找到其他嵌入模型Components,請瀏覽 Bundles 或 搜尋 您的偏好提供者。