Skip to content
Guides2 min read

自動關鍵詞高亮

配置 AI 驅動的關鍵詞高亮功能,引導標註者關注重要術語和短語。

Potato Team

AI 驅動的關鍵詞高亮功能引導標註者關注文本中的重要術語、實體或模式。本指南介紹如何配置 Potato 的內建 AI 支援來自動高亮相關關鍵詞。

為什麼使用關鍵詞高亮?

  • 聚焦注意力:引導標註者關注相關內容
  • 提升速度:更快識別關鍵資訊
  • 減少錯誤:降低遺漏重要術語的可能性
  • 利用 AI:讓 LLM 識別上下文相關的關鍵詞

基本 AI 驅動高亮

Potato 使用其 AI 支援系統來識別和高亮重要關鍵詞。以下是基本配置:

yaml
annotation_task_name: "Keyword Highlighted Annotation"
 
data_files:
  - path: "data/reviews.json"
    format: json
 
item_properties:
  id_key: id
  text_key: text
 
annotation_schemes:
  - annotation_type: radio
    name: sentiment
    description: "What is the overall sentiment?"
    labels:
      - Positive
      - Negative
      - Neutral
 
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
 
  features:

使用不同的 AI 提供商

OpenAI

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4o
    api_key: ${OPENAI_API_KEY}
    temperature: 0.3
    max_tokens: 500
 
  features:
    keyword_highlighting:
      enabled: true
 

Anthropic 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: 500
 
  features:
    keyword_highlighting:
      enabled: true
      # Highlights are rendered as box overlays on the text

本地 Ollama(無 API 費用)

yaml
ai_support:
  enabled: true
  endpoint_type: ollama
 
  ai_config:
    model: llama2
    base_url: http://localhost:11434
 
  features:
    keyword_highlighting:
      enabled: true
      # Highlights are rendered as box overlays on the text

組合功能

AI 支援提供多種可以協同工作的功能:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
    temperature: 0.3
    max_tokens: 500
 
  features:
    # Highlight important keywords
    keyword_highlighting:
      enabled: true
      # Highlights are rendered as box overlays on the text
 
    # Show contextual hints
    hints:
      enabled: true
 
    # Suggest labels for consideration
    label_suggestions:
      enabled: true
      show_confidence: true

完整配置示例

以下是一個帶有 AI 高亮的實體感知標註完整配置:

yaml
annotation_task_name: "Entity-Aware Annotation"
 
data_files:
  - path: "data/documents.json"
    format: json
 
item_properties:
  id_key: id
  text_key: text
 
annotation_schemes:
  - annotation_type: span
    name: entities
    labels:
      - name: PERSON
        color: "#FECACA"
      - name: ORG
        color: "#BBF7D0"
      - name: LOCATION
        color: "#BFDBFE"
 
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
 
  features:
 
  cache_config:
 
output_annotation_dir: "output/"
export_annotation_format: json
allow_all_users: true

快取最佳化效能

啟用快取以減少 API 呼叫並提高響應速度:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
 
  features:
    keyword_highlighting:
      enabled: true
 
  cache_config:
    disk_cache:
      enabled: true
      path: "ai_cache/cache.json"
 
    # Pre-generate highlights on startup and prefetch upcoming
    prefetch:
      warm_up_page_count: 100
      on_next: 5
      on_prev: 2

技巧

  1. 匹配任務顏色:使用與標註方案互補的高亮顏色
  2. 啟用快取:避免對相同內容重複 API 呼叫
  3. 考慮本地模型:使用 Ollama 進行大量標註而無需 API 費用
  4. 組合功能:關鍵詞高亮與提示和標籤建議配合使用效果最佳

完整文件請參閱 AI 支援