這很重要
這項功能目前處於 公開預覽版。 您可以在 預覽 頁面確認預覽報名。 請參閱 管理 Azure Databricks 預覽。
本頁說明如何在指標檢視中使用語意中繼資料來增強資料視覺化並提高大型語言模型 (LLM) 的準確性。
備註
需要 Databricks Runtime 17.2 或更新版本。 度量檢視 YAML 定義必須使用規格 1.1 版或更新版本。 如需詳細資訊,請參閱 版本規格變更日誌 。
什麼是語義元資料?
語意中繼資料包括顯示名稱、格式規格和提供額外內容的同義字。 此元資料可協助視覺化工具 (例如 AI/BI 儀表板) 和自然語言工具 ( 例如 Genie 空間) 更有效地解釋和處理您的資料。 語意中繼資料是在度量視圖的 YAML 定義中定義的。
備註
當您使用規格 1.1 版建立或變更度量視圖時,儲存定義時,會移除 YAML 定義中的任何單行註解 (以 表示 #)。 請參閱 將 YAML 升級至 1.1 ,以取得升級現有 YAML 定義時的選項和建議。
顯示名稱
顯示名稱提供人類可讀的標籤,這些標籤出現在視覺化工具中,而不是技術欄名稱。 顯示名稱限制為 255 個字元。
下列範例顯示在order_date維度和total_revenue量值上定義的顯示名稱。
version: 1.1
source: samples.tpch.orders
dimensions:
- name: order_date
expr: o_orderdate
display_name: 'Order Date'
measures:
- name: total_revenue
expr: SUM(o_totalprice)
display_name: 'Total Revenue'
Synonyms
同義詞可協助 LLM 工具 ( 例如 AI/BI Genie) 透過提供替代名稱,透過使用者輸入來發現維度和度量。 您可以使用區塊樣式或流程樣式 YAML 來定義同義字。 每個維度或量值最多可以有 10 個同義字。 每個同義詞限制為 255 個字元。
下列範例顯示在order_date維度上定義的同義字:
version: 1.1
source: samples.tpch.orders
dimensions:
- name: order_date
expr: o_orderdate
# block style
synonyms:
- 'order time'
- 'date of order'
measures:
- name: total_revenue
expr: SUM(o_totalprice)
# flow style
synonyms: ['revenue', 'total sales']
格式規格
格式規格定義了值在視覺化工具中的顯示方式。 下表包含支援的格式類型和範例。
數值格式
| 格式類型 | 必要選項 | 選用選項 |
|---|---|---|
| 數字:對一般數值使用純數字格式,並具有可選的小數位數控制項和縮寫選項。 | type: number |
|
| 貨幣:使用貨幣格式來表示貨幣價值,並配合 ISO-4217 貨幣代碼。 | type: currency |
|
| 百分比:對以百分比表示的比率值使用百分比格式。 | type: percentage |
|
數值格式範例
Number
format:
type: number
decimal_places:
type: max
places: 2
hide_group_separator: false
abbreviation: compact
貨幣
format:
type: currency
currency_code: USD
decimal_places:
type: exact
places: 2
hide_group_separator: false
abbreviation: compact
百分比
format:
type: percentage
decimal_places:
type: all
hide_group_separator: true
日期和時間格式
下表說明如何使用日期和時間格式。
| 格式類型 | 必要選項 | 選用選項 |
|---|---|---|
| 日期:使用具有各種顯示選項的日期值的日期格式。 |
|
|
| 日期時間:使用日期時間格式來取得結合日期和時間的時間戳記值。 |
|
|
備註
使用date_time類型時,至少一個 date_format 或 time_format 必須指定no_date或no_time以外的值。
日期時間格式範例
Date
format:
type: date
date_format: year_month_day
leading_zeros: true
DateTime
format:
type: date_time
date_format: year_month_day
time_format: locale_hour_minute_second
leading_zeros: false
完整範例
下列範例顯示包含所有語意中繼資料類型的度量檢視定義:
version: 1.1
source: samples.tpch.orders
comment: Comprehensive sales metrics with enhanced semantic metadata
dimensions:
- name: order_date
expr: o_orderdate
comment: Date when the order was placed
display_name: Order Date
format:
type: date
date_format: year_month_day
leading_zeros: true
synonyms:
- order time
- date of order
- name: customer_segment
expr: |
CASE
WHEN o_totalprice > 100000 THEN 'Enterprise'
WHEN o_totalprice > 10000 THEN 'Mid-market'
ELSE 'SMB'
END
comment: Customer classification based on order value
display_name: Customer Segment
synonyms:
- segment
- customer tier
measures:
- name: total_revenue
expr: SUM(o_totalprice)
comment: Total revenue from all orders
display_name: Total Revenue
format:
type: currency
currency_code: USD
decimal_places:
type: exact
places: 2
hide_group_separator: false
abbreviation: compact
synonyms:
- revenue
- total sales
- sales amount
- name: order_count
expr: COUNT(1)
comment: Total number of orders
display_name: Order Count
format:
type: number
decimal_places:
type: all
hide_group_separator: true
synonyms:
- count
- number of orders
- name: avg_order_value
expr: SUM(o_totalprice) / COUNT(1)
comment: Average revenue per order
display_name: Average Order Value
format:
type: currency
currency_code: USD
decimal_places:
type: exact
places: 2
synonyms:
- aov
- average revenue