Skip to content

사용자 시뮬레이터

통합 테스트를 위해 Potato에서 여러 동시 주석자를 시뮬레이션합니다 — 현실적인 부하 테스트를 위해 주석 전략, 속도, 일치 수준을 구성합니다.

사용자 시뮬레이터를 사용하면 구성 가능한 동작과 역량 수준을 가진 여러 사용자를 시뮬레이션하여 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

역량 수준

수준정확도설명
perfect100%항상 골드 스탠다드와 일치
good80-90%고품질 주석자
average60-70%일반적인 크라우드워커
poor40-50%저품질 주석자
random~1/N레이블에서 무작위 선택
adversarial0%의도적으로 틀림 (QC 테스트용)

주석 전략

무작위 전략 (기본값)

레이블을 균일하게 무작위로 선택합니다.

yaml
strategy: random

편향 전략

레이블 선호도에 기반한 가중 선택입니다.

yaml
strategy: biased
biased_config:
  label_weights:
    positive: 0.6
    negative: 0.3
    neutral: 0.1

LLM 전략

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.05

Ollama를 사용하는 로컬 LLM의 경우:

yaml
strategy: llm
llm_config:
  endpoint_type: ollama
  model: llama3.2
  base_url: http://localhost:11434

CLI 옵션

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의 경우 서버가 실행 중인지 확인하십시오
  • 모델 이름이 올바른지 확인하십시오

더 읽어보기

구현 세부 사항은 원본 문서를 참조하십시오.