共用方式為


設定數據代理程式的最佳做法

本文概述設定數據代理程式的最佳做法,以提供正確、相關且實用的用戶問題回應。 藉由設定明確的代理程式層級和數據源特定指示,您可以引導代理程式如何解譯查詢、選取數據源,以及產生回應。 您將瞭解如何定義代理程式的目標、設定數據源的優先順序、併入重要術語,以及為常見案例提供查詢邏輯。 這些設定秘訣可協助確保代理程式能可靠地跨各種數據環境和使用者需求執行。

若要探索不同類型的數據代理程式組態,請參閱 數據代理程序組態

準備好您的數據,使其適用於人工智慧

為了確保數據代理程式可以產生精確的查詢,請務必讓數據源、數據表和數據行使用清楚且描述性的名稱。 避免模糊或泛型標籤,例如 Table1col1flag,這會使代理程式難以解譯使用者意圖。

效率較低:

  • 數據表名稱: Table1Table2
  • 資料列名稱:col1、、 statusflag

更好:

  • 資料表名稱:CustomerOrders、、ProductCatalogSalesTransactionsOrderItems
  • 資料列名稱:customer_email_address、、 order_submission_dateproduct_unit_price

描述性命名可協助代理程式了解數據結構,並改善產生的查詢品質。

2.為特定網域建立特製化代理程式

為了獲得更好的精確度和相關性,請設計著重於特定領域或使用案例的數據代理程式,而不是嘗試處理各種問題。 特製化代理程式可以使用目標指示、相關的數據源和特定領域術語進行優化,使其更加可靠且有效。

效率較低: 一般用途的數據代理程式,可回答不同使用者角色的各種客戶相關問題

更好: 結合多個數據源的深入解析,為支援領導小組量身打造的數據代理程式,以進行會議準備

藉由縮小代理程式的焦點,您可以改善其產生精確回應的能力,並減少查詢解譯中的模棱兩可。

3.最小化數據源範圍

只包含回答預期用戶問題所需的數據源。 在每個數據源中,只選取與您使用案例相關的特定數據表和數據行。 更專注的組態可改善代理程式產生精確且有效率的查詢的能力。

效率較低: 連接整個 Lakehouse 或模型與所有表格和欄位

更好: 只選取常見查詢所需的基本數據表和數據行

小提示

為了獲得最佳結果,請將指定數據源的數據表數目限製為 25或更少

4. 具體說明該做什麼, 而不僅僅是不做什麼

不要只說明代理應該避免的事項,而是提供正確方法的明確指引。 這有助於代理程式更有效率地回應,並避免在處理邊緣案例時模棱兩可。

效率較低: 請勿提供過期的薪酬資訊,或假設遺漏數據。
更好: 一律提供官方薪資系統的最新薪酬資訊。 如果工資遺失或不完整,請通知員工您找不到目前的記錄,並建議他們連絡 HR 以取得進一步的協助。

5.定義商務詞彙、縮寫和同義字

若要確保數據代理程序正確解譯問題,請定義任何可能模棱兩可、組織特定或網域特定的字詞。 這些定義可協助代理程式套用一致的邏輯併產生精確的回應,特別是當使用者問題參考內部術語或類似的概念時。

定義內容的範例

  • 類似的概念: "calendar year""fiscal year"
  • 一般商務詞彙:"quarter"、、、"SKU""sales""shoes"
  • 縮寫或首字母縮略詞:"NPS" (Net Promoter Score),"MAU" (每月活躍使用者)

定義應放在哪裡

  • 代理程式層級指示:針對適用於所有數據源和查詢的定義使用此選項(例如,「季」代表什麼)。
  • 數據源指示:針對特定數據集內使用字詞的特定定義,請使用此選項(例如,跨系統以不同方式定義的「銷售」)。

6. 使用關鍵詞來引導查詢產生

在您的資料來源指示中,您可以包含 SQL/DAX/KQL 語法的提示或片段,以引導模型以特定格式產生查詢。 這些「前置詞」可協助代理程式在將自然語言翻譯成程式代碼時推斷出正確的邏輯。

效率較低:
尋找包含 「bike」 名稱的所有產品。

更好:
尋找包含 「bike」 名稱的所有產品
LIKE '%bike%'

包含語法片段,例如 LIKE '%...%' 協助模型辨識查詢中預期有模式比對子句。 這項技術可改善所產生 SQL 的精確度,特別是在處理部分相符專案、篩選或聯結時。

7. 寫清楚、專注的指示:避免不必要的詳細數據

指示應簡潔且有目的。 只包含協助代理程式產生正確回應所需的資訊。 避免模糊、過時或過於廣泛的內容,這些內容會造成混淆或削弱代理人的專注。

效率較低:

You are an HR data agent who should try to help employees with all kinds of questions about work. You have access to many systems, like the HRIS platform, old payroll databases from previous vendors, archived employee files, scanned PDF policy documents, and maybe even some spreadsheets that HR used in the past. If someone asks about their pay, you might want to look in one of the old systems if needed. Also, sometimes data isn't updated immediately, so just do your best. Remember that the company reorganized in 2017, so department names might be different before then. Try to be friendly, but also make sure you don’t seem robotic. Sometimes HR policies change, so answers might not always be the same depending on the date. Just explain if something seems complicated.

為什麼這個效率較低?

  • 範圍過於廣泛(「關於工作的各種問題」)
  • 參考過時或不可靠的來源(例如,「舊的薪資資料庫」)
  • 缺少數據源的優先順序
  • 引入多餘的歷史背景
  • 創造模棱兩可的片語,例如「只要盡力去做」
  • 缺少處理遺漏或複雜數據的明確指引

更好:

You are an HR Assistant Agent responsible for answering employee questions about employment status, job details, pay history, and leave balances.  
Use the official HR data warehouse to retrieve current and accurate records.  
If data is missing or unclear, inform the user and recommend they contact HR for further support.  
Keep responses concise, professional, and easy for employees to understand.

為什麼這樣更好?

  • 明確代理人範圍和責任
  • 參考正確的數據源,而不多載技術詳細數據
  • 提供明確的後援行為
  • 確立語氣和溝通風格
  • 將數據表層級的特定數據留給數據源指示

8.撰寫詳細的數據代理程式指示

代理程式指示 會定義代理程式如何解譯使用者問題、選取數據源,以及格式化回應。 使用本節來清楚描述代理程式的角色、預期的行為、語氣,以及應該如何處理不同類型的查詢。 包含有關預期使用案例、慣用數據源,以及遺漏資訊時後援行為的特定詳細數據。

小提示

撰寫代理程式指示時,請問自己:不熟悉這些數據源的人能否瞭解要使用哪些來源,以及如何根據指示使用這些來源? 如果沒有,請修改指示以包含遺漏的內容。

效率較低:

You are an agent that helps with HR topics.  
Find answers if possible.  
Try not to give wrong information.  
If you cannot find something, you can tell the user to check elsewhere.  
Answer employee questions about work, pay, and other topics using available systems.  
Keep responses professional.

更好:

## Tone and style
Use clear, simple, and professional language.  
Sound friendly and helpful, like an internal HR support agent.  
Avoid technical jargon unless it's part of the business terminology used in the data.

## General knowledge
You are an HR Assistant Agent designed to help employees access accurate information about their employment, benefits, and pay.  
Only answer questions using the official HR data sources provided.  
If multiple records exist, prioritize the most recent and most official source.  
Do not guess or assume answers—if information is missing or unclear, advise the employee to contact HR directly.  

## Data source descriptions
- **Employee Data Warehouse**: Contains employment records including status, role, start date, and department.
- **Payroll System**: Contains pay history, compensation details, and tax withholding information.
- **Benefits Enrollment Database**: Includes information about health insurance, retirement plans, and other employee benefits.
- **HR Policy Lakehouse**: Stores official company policies, including holidays, leave policies, and onboarding documents.

## When asked about
- **Employment status (e.g., active, on leave, terminated)**: Use the *Employee Data Warehouse*  
- **Pay history or compensation**: Use the *Payroll System*  
- **Benefits and enrollment details**: Use the *Benefits Enrollment Database*  
- **Company holidays and leave of absence policies**: Use the *HR Policy Lakehouse*

9.提供詳細的數據源指示

數據源指示 應該是特定、結構化和描述性的。 他們會定義數據的組織方式、哪些數據表和數據行相關,以及如何處理數據表之間的關聯性,來引導代理程式形成精確的查詢。

使用本節來描述:

  • 數據源的用途
  • 要回答的相關問題類型
  • 必須包含在回應中的欄位
  • 數據表之間的聯結邏輯
  • 一般值格式(例如縮寫與全名)

小提示

想像一下,第一次使用此數據集的新小組成員,他們是否能依照這些指示撰寫正確的查詢?
如果沒有,請新增遺漏的內容、釐清假設,或包含範例查詢來引導它們。

小提示

執行查詢之前,數據代理程式看不到個別的數據列值。
若要引導篩選邏輯,請包含一般值和格式的範例,例如,指定資料行是否 State 使用類似 "CA" 的縮寫或完整名稱,例如 "California"

效率較低:

## General instructions
Use the EmployeeData warehouse to find answers about employees.  
Try to get useful employee details when needed.

### Employment status
You can use the EmployeeStatusFact table.  
Join to EmployeeDim if necessary.

更好:

## General instructions
Use the EmployeeData data warehouse to answer questions related to employee details, employment status, pay history, and organizational structure.

When generating queries:
• Use EmployeeDim as the primary table for employee details.  
• Always include the following columns in the response (if available):  
  - EmployeeID  
  - EmployeeName  
  - EmploymentStatus  
  - JobTitle  
  - DepartmentName  
• Join other tables to EmployeeDim using EmployeeID unless otherwise specified.  
• Filter for the most recent records when applicable.  

Example values:
- EmploymentStatus: "Active", "On Leave", "Terminated"  
- DepartmentName: "Finance", "HR", "Engineering"  
- State: Use U.S. state abbreviations like "CA", "NY", "TX"

## When asked about

When asked about **employee status**, use the `EmployeeStatusFact` table.  
Join it to `EmployeeDim` on `EmployeeID`.  
Filter by the most recent `StatusEffectiveDate` and return the following columns: `EmploymentStatus`, `StatusEffectiveDate`, `EmployeeName`, and `DepartmentName`.

When asked about **current job title or department**, use the `EmployeeDim` table.  
Return `JobTitle` and `DepartmentName`.  
If multiple records exist, filter for the record where `IsCurrent = True`.

10.使用範例查詢來表達複雜的查詢邏輯

使用 範例查詢 來協助數據代理程序瞭解如何建構精確的查詢,特別是當邏輯複雜或細微時。 這些範例可作為代理程式可從中一般化的範本,即使用戶的問題不完全相符也一樣。

  • 包含常見或代表性問題類型的範例查詢。
  • 著重於查詢邏輯涉及篩選、聯結、匯總或日期處理的範例。
  • 使用數據源的正確語法(SQL、DAX 或 KQL)保持結構清晰且格式正確。
  • 您不需要逐字比對用戶問題;範例應該示範意圖和結構。

小提示

提供格式正確的查詢通常比嘗試單獨透過文字來解釋複雜的邏輯更清楚且更有效率。

如何使用範例查詢

對於每個使用者的問題,數據代理程式會執行 向量相似度搜尋 ,以擷取前3個最相關的範例查詢。 然後,這些會傳遞至代理人的增強提示中,以引導查詢生成。

後續步驟