Skip to content

Solo Mode

通過 12 階段智慧工作流,單個標註者與 LLM 協作標註整個資料集。

v2.3.0 新增

傳統標註項目需要多名標註者、標註者間一致性計算、仲裁輪次和大量的協調開銷。對於許多研究團隊來說,主要的瓶頸不是標註介面,而是招聘、培訓和管理團隊的後勤工作。

Solo Mode 用單個人類專家與 LLM 的協作取代了多標註者範式。人類在一個小而精心選擇的子集上提供高品質標籤。LLM 從這些標籤中學習,為其餘部分提出標籤建議,人類只稽核 LLM 不確定或可能出錯的案例。12 階段工作流自動編排這一過程。

在內部基準測試中,Solo Mode 達到了與完整多標註者流程 95% 以上的一致性,同時僅需 10-15% 的人工標註量。

12 階段工作流

Solo Mode 經歷 12 個階段。系統根據可配置的閾值自動推進,你也可以從管理面板手動觸發轉換。

階段 1:種子標註

人類標註者標註初始種子集。Potato 使用基於嵌入的聚類選擇多樣化、有代表性的實例,以最大化資料分佈的覆蓋範圍。

預設種子數量: 50 個實例(可通過 seed_count 配置)

階段 2:初始 LLM 校準

LLM 將種子標註作為少樣本示例接收,並標註校準批次。Potato 將 LLM 預測與留出的種子標籤進行比較,以建立基線準確率。

階段 3:混淆分析

Potato 識別人類與 LLM 之間的系統性分歧模式。它構建混淆矩陣並呈現最常見的錯誤類型(例如,"LLM 將中性標註為正面的比例為 40%")。

階段 4:指南最佳化

基於混淆分析,Potato 為 LLM 生成最佳化的標註指南。人類在應用前審查和編輯這些指南。這是一個互動步驟,標註者可以新增示例、澄清邊緣案例和調整標籤定義。

階段 5:標註函式生成

受 ALCHEmist 框架啟發,Potato 從現有標註中生成程式化標註函式。這些是簡單的基於模式的規則(例如,"如果文本包含'優秀'且沒有否定詞,則標註為正面"),可以高精確率地標註簡單實例,將人類和 LLM 的精力留給更難的案例。

階段 6:主動標註

人類標註由主動學習選擇的額外實例。Potato 優先選擇 LLM 最不確定的實例、標註函式不一致的實例,或在嵌入空間中遠離現有訓練樣本的實例。

階段 7:自動化最佳化迴圈

LLM 使用更新的指南和少樣本示例重新標註完整資料集。Potato 與所有人工標籤進行比較,如果準確率低於閾值,則觸發新一輪混淆分析和指南最佳化。

階段 8:分歧探索

人類審查 LLM 和標註函式不一致的所有實例。這些通常是最有資訊量和最困難的示例。人類在這些案例上的標籤提供最高的邊際價值。

階段 9:邊緣案例合成

Potato 使用 LLM 根據已識別的混淆模式生成合成的邊緣案例。人類標註這些合成示例,然後將其新增到 LLM 的訓練上下文中,以提高在最難案例上的效能。

階段 10:級聯置信度升級

LLM 為每個剩餘的未標註實例分配置信度分數。按難度遞減(置信度遞增)的順序將實例升級給人類。人類持續標註直到品質指標趨於穩定。

階段 11:提示最佳化

受 DSPy 啟發,Potato 使用積累的人工標籤作為驗證集執行自動化提示最佳化。它嘗試多種提示變體(指令措辭、示例排序、思維鏈與直接回答),選擇表現最佳的提示。

階段 12:最終驗證

人類對 LLM 標註實例的隨機樣本進行最終審查。如果準確率達到閾值,資料集即告完成。如果沒有,系統迴圈回階段 6。


配置

快速開始

最小的 Solo Mode 配置:

yaml
task_name: "Sentiment Classification"
task_dir: "."
 
data_files:
  - "data/reviews.jsonl"
 
item_properties:
  id_key: id
  text_key: text
 
solo_mode:
  enabled: true
 
  # LLM provider
  llm:
    endpoint_type: openai
    model: "gpt-4o"
    api_key: ${OPENAI_API_KEY}
 
  # Basic thresholds
  seed_count: 50
  accuracy_threshold: 0.92
  confidence_threshold: 0.85
 
annotation_schemes:
  - annotation_type: radio
    name: sentiment
    labels:
      - Positive
      - Neutral
      - Negative
 
output_annotation_dir: "output/"
output_annotation_format: "jsonl"

完整配置參考

yaml
solo_mode:
  enabled: true
 
  # LLM configuration
  llm:
    endpoint_type: openai        # openai, anthropic, ollama, vllm
    model: "gpt-4o"
    api_key: ${OPENAI_API_KEY}
    temperature: 0.1             # low temperature for consistency
    max_tokens: 256
 
  # Phase control
  phases:
    seed:
      count: 50                  # number of seed instances
      selection: diversity        # diversity, random, or stratified
      embedding_model: "all-MiniLM-L6-v2"
 
    calibration:
      batch_size: 100
      holdout_fraction: 0.2      # fraction of seed used for validation
 
    confusion_analysis:
      min_samples: 30
      significance_threshold: 0.05
 
    guideline_refinement:
      auto_suggest: true         # LLM suggests guideline edits
      require_approval: true     # human must approve changes
 
    labeling_functions:
      enabled: true
      max_functions: 20
      min_precision: 0.90        # only keep high-precision rules
      min_coverage: 0.01         # must cover at least 1% of data
 
    active_labeling:
      batch_size: 25
      strategy: uncertainty       # uncertainty, diversity, or hybrid
      max_batches: 10
 
    refinement_loop:
      max_iterations: 3
      improvement_threshold: 0.02
 
    disagreement_exploration:
      max_instances: 200
      sort_by: confidence_gap
 
    edge_case_synthesis:
      enabled: true
      count: 50
      diversity_weight: 0.3
 
    confidence_escalation:
      escalation_budget: 200     # max instances to escalate
      batch_size: 25
      stop_when_stable: true     # stop if last batch accuracy is 100%
 
    prompt_optimization:
      enabled: true
      candidates: 10             # number of prompt variants to try
      metric: f1_macro
      search_strategy: bayesian  # bayesian, grid, or random
 
    final_validation:
      sample_size: 100
      min_accuracy: 0.92
      fallback_phase: 6          # go back to Phase 6 if validation fails
 
  # Instance prioritization across phases
  prioritization:
    pools:
      - name: uncertain
        weight: 0.30
        description: "LLM confidence below threshold"
      - name: disagreement
        weight: 0.25
        description: "LLM and labeling functions disagree"
      - name: boundary
        weight: 0.20
        description: "Near decision boundary in embedding space"
      - name: novel
        weight: 0.10
        description: "Far from all existing labeled examples"
      - name: error_pattern
        weight: 0.10
        description: "Matches known confusion patterns"
      - name: random
        weight: 0.05
        description: "Random sample for calibration"

關鍵能力

混淆分析

每輪標註後,Potato 構建人類與 LLM 標籤之間的混淆矩陣。管理面板顯示:

  • 從 LLM 角度的每類精確率、召回率和 F1
  • 最常見的混淆對(例如,"中性被誤分類為正面:23 個實例")
  • 每個混淆對的示例實例
  • 跨最佳化輪次的改進趨勢圖表

通過命令列訪問混淆分析:

bash
python -m potato.solo confusion --config config.yaml

輸出:

text
Confusion Analysis (Round 2)
============================
Overall Accuracy: 0.87 (target: 0.92)

Top Confusion Pairs:
  neutral -> positive:  23 instances (15.3%)
  negative -> neutral:  11 instances (7.3%)
  positive -> neutral:   5 instances (3.3%)

Per-Class Performance:
  Positive:  P=0.91  R=0.94  F1=0.92
  Neutral:   P=0.78  R=0.71  F1=0.74
  Negative:  P=0.93  R=0.88  F1=0.90

自動化最佳化迴圈

最佳化迴圈在 LLM 標註、混淆分析和指南更新之間迭代。每次迭代:

  1. LLM 使用當前指南標註完整資料集
  2. Potato 與所有可用的人工標籤進行比較
  3. 如果準確率低於閾值,執行混淆分析
  4. LLM 根據錯誤模式提出指南編輯建議
  5. 人類審查並批准編輯
  6. 迴圈重複(最多 max_iterations 次)
yaml
solo_mode:
  llm:
    endpoint_type: anthropic
    model: "claude-sonnet-4-20250514"
    api_key: ${ANTHROPIC_API_KEY}
 
  phases:
    refinement_loop:
      max_iterations: 3
      improvement_threshold: 0.02    # stop if improvement is less than 2%

標註函式(受 ALCHEmist 啟發)

Potato 從人工標註中觀察到的模式生成輕量級標註函式。這些不是 LLM 呼叫;它們是快速、確定性的規則。

示例生成的標註函式:

python
# Auto-generated labeling function 1
# Precision: 0.96, Coverage: 0.08
def lf_strong_positive_words(text):
    positive = {"excellent", "amazing", "fantastic", "outstanding", "perfect"}
    if any(w in text.lower() for w in positive):
        if not any(neg in text.lower() for neg in {"not", "never", "no"}):
            return "Positive"
    return None  # abstain
 
# Auto-generated labeling function 2
# Precision: 0.93, Coverage: 0.05
def lf_explicit_negative(text):
    negative = {"terrible", "awful", "horrible", "worst", "disgusting"}
    if any(w in text.lower() for w in negative):
        return "Negative"
    return None

配置標註函式行為:

yaml
solo_mode:
  phases:
    labeling_functions:
      enabled: true
      max_functions: 20
      min_precision: 0.90
      min_coverage: 0.01
      types:
        - keyword_match
        - regex_pattern
        - length_threshold
        - embedding_cluster

分歧探索器

分歧探索器呈現不同訊號衝突的實例。對於每個實例,標註者看到:

  • LLM 的預測標籤和置信度
  • 標註函式投票(如果有的話)
  • 嵌入空間中最近的已標註鄰居
  • 原始文本/內容

這是最高價值的標註活動:每個標籤都解決了一個真正的歧義。

yaml
solo_mode:
  phases:
    disagreement_exploration:
      max_instances: 200
      sort_by: confidence_gap     # or "lf_disagreement" or "random"
      show_llm_reasoning: true    # display LLM's chain-of-thought
      show_nearest_neighbors: 3   # show 3 nearest labeled examples

級聯置信度升級

在資料集大部分被 LLM 標註後,Potato 按置信度對所有 LLM 標註的實例進行排序,並將最低置信度的實例升級給人類。這以批次方式持續進行直到品質穩定。

yaml
solo_mode:
  phases:
    confidence_escalation:
      escalation_budget: 200
      batch_size: 25
      stop_when_stable: true
      stability_window: 3        # stop if last 3 batches are all correct

多訊號實例優先順序

在所有涉及人工標註的階段中,Potato 使用加權池系統選擇最有資訊量的實例。六個池匯入一個統一的優先順序佇列:

yaml
solo_mode:
  prioritization:
    pools:
      - name: uncertain
        weight: 0.30
      - name: disagreement
        weight: 0.25
      - name: boundary
        weight: 0.20
      - name: novel
        weight: 0.10
      - name: error_pattern
        weight: 0.10
      - name: random
        weight: 0.05
  • uncertain:LLM 置信度低於 confidence_threshold 的實例
  • disagreement:LLM 和標註函式產生不同標籤的實例
  • boundary:嵌入空間中靠近決策邊界的實例
  • novel:遠離任何現有已標註示例的實例
  • error_pattern:匹配之前輪次中已知混淆模式的實例
  • random:小的隨機樣本,用於保持校準和發現盲區

邊緣案例合成

Potato 使用 LLM 生成針對已知弱點的合成示例:

yaml
solo_mode:
  phases:
    edge_case_synthesis:
      enabled: true
      count: 50
      diversity_weight: 0.3
      confusion_pairs:            # focus on these error types
        - ["neutral", "positive"]
        - ["negative", "neutral"]

LLM 生成在指定標籤對之間模糊的示例。人類標註它們,這些標籤被新增到後續 LLM 標註輪次的少樣本上下文中。

提示最佳化(受 DSPy 啟發)

在階段 11,Potato 執行自動化提示最佳化以找到 LLM 的最佳指令格式:

yaml
solo_mode:
  phases:
    prompt_optimization:
      enabled: true
      candidates: 10
      metric: f1_macro
      search_strategy: bayesian
      variations:
        - instruction_style      # formal vs. conversational
        - example_ordering       # random, by-class, by-difficulty
        - reasoning_mode         # direct, chain-of-thought, self-consistency
        - example_count          # 3, 5, 10, 15 few-shot examples

監控進度

管理面板即時顯示 Solo Mode 進度:

  • 當前階段和每個階段內的進度
  • 已完成的人工標籤與總預算
  • LLM 準確率隨時間的變化(每輪)
  • 標註函式的覆蓋率和精確率
  • 置信度分佈直方圖
  • 預計完成時間

通過命令列訪問:

bash
python -m potato.solo status --config config.yaml
text
Solo Mode Status
================
Current Phase: 6 (Active Labeling) - Batch 3/10
Human Labels: 142 / ~300 estimated total
LLM Accuracy: 0.89 (target: 0.92)
LF Coverage: 0.23 (labeling functions cover 23% of data)
Dataset Size: 10,000 instances
  - Human labeled: 142
  - LF labeled: 2,300
  - LLM labeled: 7,558
  - Unlabeled: 0

何時使用 Solo Mode vs. 傳統多標註者

使用 Solo Mode 的場景:

  • 你有一位能提供高品質標籤的領域專家
  • 預算或後勤條件不允許僱用多名標註者
  • 任務有明確、定義清晰的類別
  • 你需要標註大型資料集(1,000+ 實例)
  • 速度比衡量標註者間一致性更重要

使用傳統多標註者的場景:

  • 你需要標註者間一致性統計用於發表
  • 任務高度主觀(例如,冒犯性、幽默感)
  • 你需要研究標註者分歧模式
  • 法規要求多名獨立標註者
  • 標籤空間複雜或不斷演變(標註指南仍在開發中)

混合方法: 使用 Solo Mode 進行初始批次標註,然後分配第二個標註者對隨機的 10-20% 樣本進行標註以計算一致性統計。這樣你既獲得了 Solo Mode 的效率,又有多標註者驗證的品質保證。

yaml
solo_mode:
  enabled: true
  # ... solo mode config ...
 
  # Hybrid: assign verification sample to second annotator
  verification:
    enabled: true
    sample_fraction: 0.15
    annotator: "reviewer_1"

延伸閱讀

有關實現詳情,請參閱源文件