成對比較
比較成對項目,用於偏好和品質評估。
成對比較允許標註者並排比較兩個項目並表明其偏好。支援兩種模式:
- 二元模式(預設):點選首選的選項卡(A 或 B),可選平局按鈕
- 量表模式:使用滑塊評估一個選項相對於另一個的偏好程度
常見使用場景包括比較模型輸出、RLHF 偏好學習、翻譯或摘要的品質比較以及 A/B 測試。
二元模式
二元模式顯示兩個可點選的選項卡。標註者點選其首選選項。
yaml
annotation_schemes:
- annotation_type: pairwise
name: preference
description: "Which response is better?"
mode: binary
# Data source - key in instance data containing items to compare
items_key: "responses"
# Display options
show_labels: true
labels:
- "Response A"
- "Response B"
# Tie option
allow_tie: true
tie_label: "No preference"
# Keyboard shortcuts
sequential_key_binding: true
# Validation
label_requirement:
required: true量表模式
量表模式在兩個項目之間顯示一個滑塊,允許標註者表示偏好程度。
yaml
annotation_schemes:
- annotation_type: pairwise
name: preference_scale
description: "Rate how much better A is than B"
mode: scale
items_key: "responses"
labels:
- "Response A"
- "Response B"
# Scale configuration
scale:
min: -3 # Negative = prefer left item (A)
max: 3 # Positive = prefer right item (B)
step: 1
default: 0
# Endpoint labels
labels:
min: "A is much better"
max: "B is much better"
center: "Equal"
label_requirement:
required: true資料格式
該方案期望實例資料包含要比較的項目列表:
json
{"id": "1", "responses": ["Response A text", "Response B text"]}
{"id": "2", "responses": ["First option here", "Second option here"]}items_key 配置指定哪個欄位包含要比較的項目。該欄位應包含至少 2 個項目的列表。
鍵盤快捷鍵
在 sequential_key_binding: true 的二元模式中:
| 按鍵 | 操作 |
|---|---|
1 | 選擇選項 A |
2 | 選擇選項 B |
0 | 選擇平局/無偏好(如果 allow_tie: true) |
量表模式使用滑塊互動。
輸出格式
二元模式
json
{
"preference": {
"selection": "A"
}
}平局時:
json
{
"preference": {
"selection": "tie"
}
}量表模式
負值表示偏好 A,正值偏好 B,零表示相等:
json
{
"preference_scale": {
"scale_value": "-2"
}
}示例
基本二元比較
yaml
annotation_schemes:
- annotation_type: pairwise
name: quality
description: "Which text is higher quality?"
labels: ["Text A", "Text B"]
allow_tie: true多方面比較
從多個維度進行比較:
yaml
annotation_schemes:
- annotation_type: pairwise
name: fluency
description: "Which response is more fluent?"
labels: ["Response A", "Response B"]
- annotation_type: pairwise
name: relevance
description: "Which response is more relevant?"
labels: ["Response A", "Response B"]
- annotation_type: pairwise
name: overall
description: "Which response is better overall?"
labels: ["Response A", "Response B"]
allow_tie: true自定義範圍的偏好量表
yaml
annotation_schemes:
- annotation_type: pairwise
name: sentiment_comparison
description: "Compare the sentiment of these two statements"
mode: scale
labels: ["Statement A", "Statement B"]
scale:
min: -5
max: 5
step: 1
labels:
min: "A is much more positive"
max: "B is much more positive"
center: "Equal sentiment"RLHF 偏好收集
yaml
annotation_schemes:
- annotation_type: pairwise
name: overall
description: "Overall, which response is better?"
labels: ["Response A", "Response B"]
allow_tie: true
sequential_key_binding: true
- annotation_type: multiselect
name: criteria
description: "What factors influenced your decision?"
labels:
- Accuracy
- Helpfulness
- Clarity
- Safety
- Completeness
- annotation_type: text
name: notes
description: "Additional notes (optional)"
rows: 4
label_requirement:
required: false樣式
成對比較標註使用主題系統中的 CSS 變數。新增自定義 CSS 以自定義選項卡:
css
/* Make tiles taller */
.pairwise-tile {
min-height: 200px;
}
/* Change selected tile highlight */
.pairwise-tile.selected {
border-color: #10b981;
background-color: rgba(16, 185, 129, 0.1);
}最佳實踐
- 使用清晰、獨特的標籤 - 標註者應立即理解選項
- 仔細考慮平局選項 - 有時強制選擇更合適
- 使用鍵盤快捷鍵 - 顯著加快標註速度
- 新增理由說明欄位 - 有助於理解推理過程並提高資料品質
- 用您的資料測試 - 確保顯示效果與您的內容長度匹配
延伸閱讀
有關實現細節,請參閱源文件。