Skip to content

AIサポート

LLMを統合してインテリジェントなアノテーション支援を実現する。

AIサポート

Potato 2.0には、アノテーターにインテリジェントなヒント、キーワードハイライト、ラベル提案を提供するための大規模言語モデル(LLM)のビルトインサポートが含まれています。

サポートされるプロバイダー

Potatoは複数のLLMプロバイダーをサポートしています:

クラウドプロバイダー:

  • OpenAI(GPT-4、GPT-4 Turbo、GPT-3.5)
  • Anthropic(Claude 3、Claude 3.5)
  • Google(Gemini 1.5 Pro、Gemini 2.0 Flash)
  • Hugging Face
  • OpenRouter

ローカル/セルフホスト:

  • Ollama(ローカルでモデルを実行)
  • vLLM(高性能セルフホスト推論)

設定

基本設定

設定ファイルにai_supportセクションを追加します:

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

プロバイダー固有の設定

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

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

Google 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
    base_url: http://localhost:11434

vLLM(セルフホスト)

yaml
ai_support:
  enabled: true
  endpoint_type: vllm
 
  ai_config:
    model: meta-llama/Llama-2-7b-chat-hf
    base_url: http://localhost:8000/v1

ビジュアルAIエンドポイント

v2.1.0で新規追加

画像やビデオのアノテーションタスク向けに、PotatoはYOLO、Ollama Vision、OpenAI Vision、Anthropic Visionなどの専用ビジョンエンドポイントをサポートしています。これらにより、オブジェクト検出、事前アノテーション、視覚的分類が可能になります。

完全な設定の詳細はビジュアルAIサポートを参照してください。

AI機能

PotatoのAIサポートは5つの主要な機能を提供します:

1. インテリジェントヒント

回答を明かさずにアノテーターに文脈に即したガイダンスを提供する:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
 
  # Hints appear as tooltips or sidebars
  features:
    hints:
      enabled: true

2. キーワードハイライト

テキスト内の関連キーワードを自動的にハイライトする:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
 
  features:
    keyword_highlighting:
      enabled: true
      # Highlights are rendered as box overlays on the text

3. ラベル提案

アノテーターの検討のためにラベルを提案する(信頼度インジケーター付き):

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

4. ラベル根拠

v2.1.0で新規追加

各ラベルがテキストに該当する可能性がある理由についてバランスの取れた説明を生成し、アノテーターが異なる分類の背後にある推論を理解するのを助けます:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
 
  features:
    rationales:
      enabled: true

根拠は、各利用可能なラベルとそれが該当する可能性がある理由の説明をリスト化するツールチップとして表示されます。これはアノテーターのトレーニングやアノテーション判断が困難な場合に有用です。

5. オプションハイライト

v2.2.0で新規追加

離散的なアノテーションタスク(radio、multiselect、likert、select)向けのAI支援による最も可能性の高い正解オプションのハイライト。システムがコンテンツを分析し、上位k個の可能性の高いオプションをハイライトしながら、可能性の低いオプションを薄く表示します。すべてのオプションは完全にクリック可能なままです。

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4o-mini
    api_key: ${OPENAI_API_KEY}
 
  option_highlighting:
    enabled: true
    top_k: 3
    dim_opacity: 0.4
    auto_apply: true

完全な設定の詳細はオプションハイライトを参照してください。

補完機能:多様性順序付け

v2.2.0で新規追加

厳密にはAI機能ではありませんが、多様性順序付けはsentence-transformerの埋め込みを使用してアイテムをクラスタリングし、多様な順序で提示することで、アノテーターの疲労を軽減し、カバレッジを向上させます。並べ替えられたアイテムに対してAIヒントを自動的にプリフェッチすることで、AIサポートと統合されます。

キャッシュとパフォーマンス

AIレスポンスはパフォーマンス向上とAPIコスト削減のためにキャッシュできます:

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

キャッシュ戦略

  1. ウォームアップ:サーバー起動時にインスタンスの初期バッチに対してAIヒントを事前生成する(warm_up_page_count
  2. プリフェッチ:アノテーターが前方(on_next)または後方(on_prev)にナビゲートするとき、次のインスタンスのヒントを生成する
  3. ディスク永続化:キャッシュはディスクに保存され、サーバー再起動後も持続する

カスタムプロンプト

Potatoには各アノテーションタイプのデフォルトプロンプトがpotato/ai/prompt/に格納されています。特定のタスクに合わせてカスタマイズできます:

アノテーションタイププロンプトファイル
ラジオボタンradio_prompt.txt
リッカート尺度likert_prompt.txt
チェックボックスcheckbox_prompt.txt
スパンアノテーションspan_prompt.txt
スライダーslider_prompt.txt
ドロップダウンdropdown_prompt.txt
数値入力number_prompt.txt
テキスト入力text_prompt.txt

プロンプトは変数置換をサポートしています:

  • {text} - ドキュメントテキスト
  • {labels} - スキーマで利用可能なラベル
  • {description} - スキーマの説明

マルチスキーマサポート

複数のアノテーションスキーマを持つタスクでは、AIサポートを選択的に有効にできます:

yaml
ai_support:
  enabled: true
  endpoint_type: openai
 
  ai_config:
    model: gpt-4
    api_key: ${OPENAI_API_KEY}
 
  # Only enable for specific schemes
  special_include:
    - page: 1
      schema: sentiment
    - page: 1
      schema: topics

完全な例

AI支援感情分析の完全な設定:

yaml
annotation_task_name: "AI-Assisted Sentiment Analysis"
task_dir: "."
port: 8000
 
data_files:
  - "data/reviews.json"
 
item_properties:
  id_key: id
  text_key: text
 
annotation_schemes:
  - annotation_type: radio
    name: sentiment
    description: "What is the sentiment of this review?"
    labels:
      - Positive
      - Negative
      - Neutral
 
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
      # Highlights are rendered as box overlays on the text
    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: 3
      on_prev: 2
 
output_annotation_dir: "output/"
output_annotation_format: "json"
allow_all_users: true

環境変数

環境変数を使用してAPIキーを安全に保存する:

bash
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GOOGLE_API_KEY="..."

設定で${VARIABLE_NAME}構文で参照します。

コストに関する考慮事項

  • AI呼び出しはデフォルトでインスタンスごとに行われる
  • キャッシュを有効にして繰り返しのAPI呼び出しを削減する
  • ウォームアップとプリフェッチを使用してヒントを事前生成する
  • 単純なタスクにはより小さい/安価なモデルの使用を検討する
  • ローカルプロバイダー(Ollama、vLLM)にはAPIコストがかからない

ベストプラクティス

  1. AIを置換ではなく支援として使用する - 最終判断はアノテーターに任せる
  2. 本番ではキャッシュを有効にする - レイテンシーとコストを削減する
  3. プロンプトを徹底的にテストする - カスタムプロンプトは検証する必要がある
  4. APIコストを監視する - 特にクラウドプロバイダーでの使用状況を追跡する
  5. ローカルプロバイダーを検討する - 大量アノテーション向けにOllamaやvLLMを使用する
  6. API認証情報を保護する - 環境変数を使用し、キーをコミットしない

関連情報

実装の詳細とカスタムプロンプトテンプレートについては、ソースドキュメントを参照してください。