ユーザーシミュレーター
設定可能な動作を持つ複数のアノテーターをシミュレートする自動テストツール。
ユーザーシミュレーター
ユーザーシミュレーターは、設定可能な動作と能力レベルを持つ複数のユーザーをシミュレートして、Potatoアノテーションタスクの自動テストを可能にします。
概要
シミュレーターは以下に有用です:
- 品質管理テスト:注意チェック、ゴールドスタンダード、ブロック動作のテスト
- ダッシュボードテスト:管理者ダッシュボード用のリアルなアノテーションデータの生成
- スケーラビリティテスト:多数の同時ユーザーでサーバーのストレステスト
- AI支援の評価:人間のような動作に対するLLM精度の比較
- 能動学習テスト:反復的なアノテーションワークフローのシミュレーション
クイックスタート
bash
# Basic random simulation with 10 users
python -m potato.simulator --server http://localhost:8000 --users 10
# With configuration file
python -m potato.simulator --config simulator-config.yaml --server http://localhost:8000
# Fast scalability test (no waiting between annotations)
python -m potato.simulator --server http://localhost:8000 --users 50 --parallel 10 --fast-mode設定
YAML設定ファイル
シミュレーター設定のYAMLファイルを作成します:
yaml
simulator:
# User configuration
users:
count: 20
competence_distribution:
good: 0.5 # 50% will be "good" annotators (80-90% accuracy)
average: 0.3 # 30% "average" (60-70% accuracy)
poor: 0.2 # 20% "poor" (40-50% accuracy)
# Annotation strategy
strategy: random # random, biased, llm, pattern
# Timing configuration
timing:
annotation_time:
min: 2.0
max: 45.0
mean: 12.0
std: 6.0
distribution: normal # uniform, normal, exponential
# Execution
execution:
parallel_users: 5
delay_between_users: 0.5
max_annotations_per_user: 50
server:
url: http://localhost:8000能力レベル
| レベル | 精度 | 説明 |
|---|---|---|
perfect | 100% | 常にゴールドスタンダードと一致 |
good | 80-90% | 高品質なアノテーター |
average | 60-70% | 一般的なクラウドワーカー |
poor | 40-50% | 低品質なアノテーター |
random | ~1/N | ラベルからランダム選択 |
adversarial | 0% | 意図的に誤回答(品質管理テスト用) |
アノテーション戦略
ランダム戦略(デフォルト)
ラベルを一様にランダムに選択します:
yaml
strategy: randomバイアス戦略
ラベルの好みに基づく重み付き選択:
yaml
strategy: biased
biased_config:
label_weights:
positive: 0.6
negative: 0.3
neutral: 0.1LLM戦略
テキスト内容に基づいてLLMでアノテーションを生成します:
yaml
strategy: llm
llm_config:
endpoint_type: openai
model: gpt-4o-mini
api_key: ${OPENAI_API_KEY}
temperature: 0.1
add_noise: true
noise_rate: 0.05Ollamaを使用したローカルLLMの場合:
yaml
strategy: llm
llm_config:
endpoint_type: ollama
model: llama3.2
base_url: http://localhost:11434CLIオプション
text
Usage: python -m potato.simulator [OPTIONS]
Required:
--server, -s URL Potato server URL
User Configuration:
--users, -u NUM Number of simulated users (default: 10)
--competence DIST Competence distribution
Strategy:
--strategy TYPE Strategy: random, biased, llm, pattern
--llm-endpoint TYPE LLM endpoint: openai, anthropic, ollama
--llm-model NAME LLM model name
Execution:
--parallel, -p NUM Max concurrent users (default: 5)
--max-annotations, -m Max annotations per user
--fast-mode Disable waiting between annotations
Output:
--output-dir, -o DIR Output directory (default: simulator_output)
品質管理テスト
注意チェックの検出をテストします:
yaml
simulator:
users:
count: 10
competence_distribution:
adversarial: 1.0 # All users will fail
quality_control:
attention_check_fail_rate: 0.5
respond_fast_rate: 0.3出力ファイル
シミュレーション後、結果は出力ディレクトリにエクスポートされます:
summary_{timestamp}.json- 集計統計user_results_{timestamp}.json- ユーザーごとの詳細結果annotations_{timestamp}.csv- フラット形式のすべてのアノテーション
サマリーの例
json
{
"user_count": 20,
"total_annotations": 400,
"total_time_seconds": 125.3,
"attention_checks": {
"passed": 18,
"failed": 2,
"pass_rate": 0.9
}
}プログラムからの使用
python
from potato.simulator import SimulatorManager, SimulatorConfig
# Create configuration
config = SimulatorConfig(
user_count=10,
strategy="random",
competence_distribution={"good": 0.5, "average": 0.5}
)
# Create and run simulator
manager = SimulatorManager(config, "http://localhost:8000")
results = manager.run_parallel(max_annotations_per_user=20)
# Print summary and export
manager.print_summary()
manager.export_results()テストとの統合
シミュレーターはpytestフィクスチャで使用できます:
python
import pytest
from potato.simulator import SimulatorManager, SimulatorConfig
@pytest.fixture
def simulated_annotations(flask_test_server):
config = SimulatorConfig(user_count=5, strategy="random")
manager = SimulatorManager(config, flask_test_server.base_url)
return manager.run_parallel(max_annotations_per_user=10)
def test_dashboard_shows_annotations(simulated_annotations, flask_test_server):
response = requests.get(f"{flask_test_server.base_url}/admin/api/overview")
assert response.json()["total_annotations"] > 0トラブルシューティング
ログイン失敗
- サーバーが匿名登録を許可しているか、
require_password: falseが設定されていることを確認 - サーバーログで認証エラーを確認
インスタンスが利用できない
- データファイルが正しく読み込まれていることを確認
- 割り当て戦略の設定を確認
LLM戦略が動作しない
- APIキーが設定されていることを確認
- Ollamaの場合、サーバーが実行中であることを確認
- モデル名が正しいことを確認
関連情報
- 品質管理 - 注意チェックとゴールドスタンダードのテスト
- 管理者ダッシュボード - シミュレーションデータの確認
- デバッグガイド - 問題のトラブルシューティング
実装の詳細については、ソースドキュメントを参照してください。