User Simulator
Simulate multiple concurrent annotators in Potato for integration testing — configure annotation strategies, speed, and agreement levels for realistic load tests.
The User Simulator enables automated testing of Potato annotation tasks by simulating multiple users with configurable behaviors and competence levels.
Overview
The simulator is useful for:
- Quality control testing: Test attention checks, gold standards, and blocking behavior
- Dashboard testing: Generate realistic annotation data for admin dashboard
- Scalability testing: Stress test the server with many concurrent users
- AI assistance evaluation: Compare LLM accuracy against human-like behaviors
- Active learning testing: Simulate iterative annotation workflows
Quick Start
# 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-modeConfiguration
YAML Configuration File
Create a YAML file with simulator settings:
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, gold_standard, agent
# 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:8000Competence Levels
| Level | Accuracy | Description |
|---|---|---|
perfect | 100% | Always matches gold standard |
good | 80-90% | High-quality annotator |
average | 60-70% | Typical crowdworker |
poor | 40-50% | Low-quality annotator |
random | ~1/N | Random selection from labels |
adversarial | 0% | Intentionally wrong (for testing QC) |
Annotation Strategies
Random Strategy (default)
Selects labels uniformly at random:
strategy: randomBiased Strategy
Weighted selection based on label preferences:
strategy: biased
biased_config:
label_weights:
positive: 0.6
negative: 0.3
neutral: 0.1LLM Strategy
Uses an LLM to generate annotations based on text content:
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.05For local LLMs with Ollama:
strategy: llm
llm_config:
endpoint_type: ollama
model: llama3.2
base_url: http://localhost:11434Agent Strategy
The agent strategy sends a vision-capable model the item's whole data record and asks for answers to every scheme in one call per item. The record includes dialogue traces, tables, and images. Because --strategy on the command line does not accept agent, set the strategy in the YAML file:
strategy: agent
agent_config:
endpoint_type: ollama_vision
model: gemma4:e4b
base_url: http://localhost:11434
max_image_count: 4
max_dialogue_chars: 12000endpoint_type defaults to ollama_vision. max_image_count and max_dialogue_chars cap the images and the dialogue text in each prompt. When the model cannot be reached, or the model's reply leaves a scheme out, the simulated user picks a random label for the scheme. examples/simulator-configs/simulator-agent-trace-ollama.yaml in the Potato repository runs the strategy over an agent-trace study.
Gold Standard Strategy
Answers from a file of known labels. Use the strategy to test quality control with simulated users whose accuracy you set:
simulator:
strategy: gold_standard
gold_standard_file: gold.jsonThe gold file is a JSON list with one object per item. Each object holds the item's id and, for each annotation scheme, the scheme name with the correct label:
[
{"id": "item_001", "sentiment": "positive"},
{"id": "item_002", "sentiment": "negative"}
]A simulated user gives the gold label when the user's competence level calls for a correct answer, and a different label from the scheme otherwise. A good user therefore matches the file on about 80-90% of the items the file covers. Items the file does not list get a random label. The random strategy reads a loaded gold file in the same way, so --gold-file changes a random run as well. --gold-file on the command line sets the same path as gold_standard_file.
CLI Options
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, gold_standard
--llm-endpoint TYPE LLM endpoint: openai, anthropic, ollama, gemini,
huggingface, vllm
--llm-model NAME LLM model name
Gold standards:
--gold-file FILE JSON file of gold answers, keyed by item id
Execution:
--parallel, -p NUM Max concurrent users (default: 5)
--sequential Run users one at a time instead of in parallel
--max-annotations, -m Max annotations per user
--fast-mode Disable waiting between annotations
Output:
--output-dir, -o DIR Output directory (default: simulator_output)
--sequential finishes each simulated user before starting the next, and ignores --parallel. Use --sequential when the order in which users arrive matters, such as checking how an assignment strategy splits items between the first and second annotator.
Quality Control Testing
Test attention check detection:
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.3Output Files
After simulation, results are exported to the output directory:
summary_{timestamp}.json- Aggregate statisticsuser_results_{timestamp}.json- Per-user detailed resultsannotations_{timestamp}.csv- All annotations in flat format
Summary Example
{
"user_count": 20,
"total_annotations": 400,
"total_time_seconds": 125.3,
"attention_checks": {
"passed": 18,
"failed": 2,
"pass_rate": 0.9
}
}Programmatic Usage
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()Integration with Tests
The simulator can be used in pytest fixtures:
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"] > 0Troubleshooting
Login failures
A simulated user signs up through /register and then signs in through /auth. The server therefore has to accept registration from an unknown username, or run with require_password: false. Check the server log for authentication errors.
New in v2.15.0
- Crowd studies. A crowd study answers 403 to
/register, whether the study setslogin.type: url_direct,login.type: prolific, or anycrowdsourcing.provider. Setlogin.allow_registration: truein the study's config to run the simulator against such a study. The value must betrueorfalse, and any other value stops the server at startup. - Studies with MCP on. In a study with
mcp.enabled: true, an id declared undermachine_annotatorscannot sign in on the web. Thellmandagentstrategies sign in under the idssim_user_0000,sim_user_0001, and so on, and the simulator's log asks you to declare the simulated ids as machine annotators. Addweb_login: trueto each declared entry, or the simulated users are refused at sign-in. A study without MCP lets declared ids sign in unless an entry setsweb_login: false.
Add the block below to the study's config, with one entry per simulated user:
machine_annotators:
enabled: true
annotators:
- {id: sim_user_0000, kind: llm, model: my-model, web_login: true}No instances available
- Verify data files are loaded correctly
- Check assignment strategy settings
LLM strategy not working
- Verify API key is set
- For Ollama, ensure the server is running
- Check model name is correct
Further Reading
- Quality Control - Test attention checks and gold standards
- Admin Dashboard - View simulated data
- Debugging Guide - Troubleshoot issues
- Train Your First Model from Your Annotations - Labeling a sample project with the simulator before training a first model
For implementation details, see the source documentation.