行為追蹤
捕獲詳細的互動資料用於品質分析和研究。
Potato 的行為追蹤系統在標註會話期間捕獲詳細的互動資料,使研究人員能夠分析標註者行為、時間模式、AI 輔助使用和決策過程。
概述
行為追蹤系統捕獲:
- 每個標註操作:標籤選擇、片段標註、文本輸入
- 精確時間戳:伺服器端和客戶端時間戳
- AI 輔助使用:何時顯示建議以及是否被接受
- 焦點和時間資料:在每個元素上花費的時間、滾動深度
- 導航歷史:完整的實例瀏覽路徑
追蹤內容
互動事件
與標註介面的每次使用者互動都會被捕獲:
| 事件類型 | 描述 | 示例目標 |
|---|---|---|
click | 元素上的滑鼠點選 | label:positive、nav:next |
focus_in | 元素獲得焦點 | textbox:explanation |
focus_out | 元素失去焦點 | label:negative |
keypress | 鍵盤快捷鍵 | key:1、nav:ArrowRight |
navigation | 實例導航 | next、prev、instance_load |
save | 標註儲存事件 | instance:123 |
annotation_change | 標籤修改 | schema:sentiment |
AI 輔助使用
AI 輔助標註的完整生命週期追蹤:
json
{
"request_timestamp": 1706500010.0,
"response_timestamp": 1706500012.5,
"schema_name": "sentiment",
"suggestions_shown": ["positive", "neutral"],
"suggestion_accepted": "positive",
"time_to_decision_ms": 3500
}標註變更
所有標註的詳細變更歷史:
json
{
"timestamp": 1706500002.5,
"schema_name": "sentiment",
"label_name": "positive",
"action": "select",
"old_value": null,
"new_value": true,
"source": "user"
}來源類型:
user- 直接使用者互動ai_accept- 使用者接受了 AI 建議keyboard- 使用了鍵盤快捷鍵prefill- 從配置預填充
資料格式
每個標註實例包含一個 behavioral_data 物件:
json
{
"id": "instance_123",
"annotations": {
"sentiment": {"positive": true}
},
"behavioral_data": {
"instance_id": "instance_123",
"session_start": 1706500000.0,
"session_end": 1706500045.0,
"total_time_ms": 45000,
"interactions": [...],
"ai_usage": [...],
"annotation_changes": [...],
"navigation_history": [...],
"focus_time_by_element": {
"label:positive": 2500,
"textbox:explanation": 8000
},
"scroll_depth_max": 75.5
}
}配置
行為追蹤預設啟用。無需額外配置。
前端除錯模式
要啟用互動追蹤器的除錯日誌:
javascript
// In browser console
window.interactionTracker.setDebugMode(true);分析示例
載入行為資料
python
import json
from pathlib import Path
def load_behavioral_data(annotation_dir: str) -> dict:
data = {}
for user_dir in Path(annotation_dir).iterdir():
if not user_dir.is_dir():
continue
state_file = user_dir / 'user_state.json'
if state_file.exists():
with open(state_file) as f:
user_state = json.load(f)
user_id = user_state.get('user_id')
behavioral = user_state.get('instance_id_to_behavioral_data', {})
data[user_id] = behavioral
return data分析標註時間
python
def analyze_annotation_time(behavioral_data: dict) -> dict:
stats = {}
for user_id, instances in behavioral_data.items():
times = []
for instance_id, bd in instances.items():
if 'total_time_ms' in bd:
times.append(bd['total_time_ms'] / 1000)
if times:
stats[user_id] = {
'mean_time': sum(times) / len(times),
'min_time': min(times),
'max_time': max(times),
'total_instances': len(times)
}
return stats檢測可疑行為
python
def detect_suspicious_annotators(behavioral_data: dict,
min_time_threshold: float = 2.0) -> list:
suspicious = []
for user_id, instances in behavioral_data.items():
fast_count = 0
for instance_id, bd in instances.items():
time_sec = bd.get('total_time_ms', 0) / 1000
if time_sec < min_time_threshold:
fast_count += 1
total = len(instances)
if total > 0:
fast_rate = fast_count / total
if fast_rate > 0.5:
suspicious.append({
'user_id': user_id,
'fast_rate': fast_rate,
'total_instances': total
})
return suspicious管理員儀表板整合
管理員儀表板包含行為分析標籤頁,提供:
- 使用者互動熱圖:互動模式的視覺化表示
- AI 輔助指標:接受/拒絕率、決策時間
- 時間分佈:標註時間直方圖
- 可疑活動警報:需要審查的標記標註者
API 端點
追蹤互動
http
POST /api/track_interactions
Content-Type: application/json
{
"instance_id": "instance_123",
"events": [...],
"focus_time": {"element": ms},
"scroll_depth": 75.5
}獲取行為資料
http
GET /api/behavioral_data/<instance_id>返回實例的完整行為資料。
最佳實踐
對於研究人員
- 建立基線:從已知優秀標註者收集行為資料以建立基線
- 品質指標:將行為資料與標註一致性結合用於品質評估
- 培訓評估:比較培訓前後的行為模式
- AI 影響分析:衡量 AI 輔助如何影響標註品質和速度
對於標註項目
- 即時監控:使用管理員儀表板儘早發現問題
- 設定閾值:定義時間和互動指標的可接受範圍
- 提供反饋:使用行為洞察為標註者提供有針對性的反饋
故障排除
沒有收集到行為資料
- 驗證
interaction_tracker.js已載入(檢查瀏覽器網路標籤頁) - 檢查瀏覽器控制台是否有 JavaScript 錯誤
- 驗證 API 端點可訪問(
/api/track_interactions)
資料未持久化
- 檢查使用者狀態是否正在儲存(查詢
user_state.json) - 確保標註輸出目錄可寫
延伸閱讀
有關實現細節,請參閱原始碼文件。