Guides3 min read
整合 LLM 實現智慧標註提示
學習如何使用 OpenAI、Claude 或 Gemini 為標註者提供智慧提示和建議。
Potato Team
AI 輔助標註可以顯著提升標註速度和品質。本指南涵蓋如何整合 OpenAI、Claude、Gemini 和本地模型,為標註者提供智慧建議。
LLM 整合的功能
- 預標註建議:AI 提供初始標籤供稽核
- 關鍵詞高亮:自動高亮相關術語
- 品質提示:標記潛在的標註錯誤
- 解釋生成:幫助標註者理解困難案例
基本 OpenAI 整合
yaml
annotation_task_name: "AI-Assisted Sentiment Analysis"
# AI configuration
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
temperature: 0.3
max_tokens: 500
features:
hints:
enabled: true
keyword_highlighting:
enabled: true
label_suggestions:
enabled: true
# ... rest of config
annotation_schemes:
- annotation_type: radio
name: sentiment
labels: [Positive, Negative, Neutral]支援的提供商
OpenAI
yaml
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4 # or gpt-4o, gpt-3.5-turbo
api_key: ${OPENAI_API_KEY}
temperature: 0.3
max_tokens: 500Anthropic Claude
yaml
ai_support:
enabled: true
endpoint_type: anthropic
ai_config:
model: claude-3-sonnet-20240229
api_key: ${ANTHROPIC_API_KEY}
temperature: 0.3
max_tokens: 500Google Gemini
yaml
ai_support:
enabled: true
endpoint_type: google
ai_config:
model: gemini-1.5-pro
api_key: ${GOOGLE_API_KEY}本地模型 (Ollama)
yaml
ai_support:
enabled: true
endpoint_type: ollama
ai_config:
model: llama2 # or mistral, mixtral, etc.
base_url: http://localhost:11434功能:標籤建議
AI 模型可以建議標籤供標註者參考:
yaml
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
features:
label_suggestions:
enabled: true
show_confidence: true
annotation_schemes:
- annotation_type: radio
name: category
labels: [News, Opinion, Satire, Other]功能:關鍵詞高亮
自動高亮重要術語:
yaml
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
features:
keyword_highlighting:
enabled: true功能:智慧提示
為標註者提供上下文引導:
yaml
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
features:
hints:
enabled: true提示以上下文引導的形式出現,不會直接揭示答案,幫助標註者思考困難案例。
完整 AI 輔助配置
yaml
annotation_task_name: "AI-Assisted NER Annotation"
# AI Configuration
ai_support:
enabled: true
endpoint_type: openai
ai_config:
model: gpt-4
api_key: ${OPENAI_API_KEY}
temperature: 0.2
max_tokens: 500
features:
hints:
enabled: true
keyword_highlighting:
enabled: true
label_suggestions:
enabled: true
show_confidence: true
cache_config:
disk_cache:
enabled: true
path: "ai_cache/cache.json"
prefetch:
warm_up_page_count: 50
on_next: 5
on_prev: 2
data_files:
- data/texts.json
item_properties:
id_key: id
text_key: content
annotation_schemes:
- annotation_type: span
name: entities
description: "Label named entities (AI suggestions provided)"
labels:
- name: PERSON
color: "#FF6B6B"
- name: ORG
color: "#4ECDC4"
- name: LOC
color: "#45B7D1"
- name: DATE
color: "#96CEB4"
output_annotation_dir: "annotation_output/"
export_annotation_format: "json"使用 AI 建議
當 AI 支援啟用時,標註者會在標註介面旁看到建議。他們可以接受、修改或忽略 AI 的推薦。最終標註始終反映標註者的決定,確保人工監督。
啟用快取後,AI 響應會自動快取,同一實例不會觸發多次 API 呼叫。
自定義提示詞
Potato 為每種標註類型包含預設提示詞,儲存在 potato/ai/prompt/ 中。你可以通過編輯提示詞檔案進行自定義:
| 標註類型 | 提示詞檔案 |
|---|---|
| 單選按鈕 | radio_prompt.txt |
| 李克特量表 | likert_prompt.txt |
| 核取方塊 | checkbox_prompt.txt |
| Span 標註 | span_prompt.txt |
| 文本輸入 | text_prompt.txt |
提示詞支援使用 {text}、{labels} 和 {description} 進行變數替換。
AI 輔助標註技巧
- 從保守開始:初期稽核所有建議
- 監控接受率:低接受率表明提示詞有問題
- 迭代提示詞:根據常見錯誤進行最佳化
- 保持人工監督:AI 輔助,人類決策
- 跟蹤 AI 與人工標籤:隨時間測量 AI 準確率
v2.2 新功能:選項高亮
Potato 2.2 添加了一個新的 AI 功能叫做選項高亮,它分析內容並高亮離散標註任務(單選、多選、李克特)中最可能正確的選項。前 k 個選項以星標指示器高亮顯示,而可能性較低的選項變暗,但所有選項仍可點選。
yaml
ai_support:
option_highlighting:
enabled: true
top_k: 3
dim_opacity: 0.4下一步
完整 AI 文件請參閱 AI 支援。