Guides3 min read
集成 LLM 实现智能标注提示
学习如何使用 OpenAI、Claude 或 Gemini 为标注者提供智能提示和建议。
Potato Team·
集成 LLM 实现智能标注提示
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/"
output_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 文档请参阅 /docs/features/ai-support。