Skip to content

Repository files navigation

HAG

Installation

pip install -r requirements.txt

Configuration

Model API Configuration

Edit config/model_api_config.py to configure API keys and base URLs:

MODEL_API_CONFIG = {
    "your-model-name": (
        "your_api_key",
        "your_base_url"
    ),
}

Value Constraints

Edit config/value_constraints.json to specify allowed values for each demographic dimension.

Usage

Generate Agents for a Single Topic

python generate_agents.py --topic "Your topic here" --total_target 100 --model "your-model-name"

Run Batch Experiments (for Multiple Topics)

Edit run_batch_experiments.sh to configure topics and models, then run:

bash run_batch_experiments.sh

Evaluation

Evaluate a Single Topic

Population Alignment (Statistical Evaluation)

Edit eval/run_stats_evaluation.sh to configure topic prefix, models, and ground truth stats, then run:

bash eval/run_stats_evaluation.sh

This script compares generated user statistics with ground truth benchmark statistics using statistical metrics (JSD, KL divergence, etc.).

Sociological Consistency (LLM-based Evaluation)

Edit eval/run_llm_evaluation.sh to configure topic prefix, models, theme context, and evaluation model, then run:

bash eval/run_llm_evaluation.sh

This script evaluates the sociological consistency of generated users using LLM-based micro and meso level assessments.

Run Batch Evaluations and Summary (for Multiple Topics)

Edit eval/run_evaluation_summary.sh to configure topics and models, then run:

bash eval/run_evaluation_summary.sh

This script aggregates evaluation results from multiple topics and models into Excel files for easy comparison.

Data

WVS Database

The method requires a database at database/wvs_users.json in World Values Survey format. This database serves as the source for matching and generating users.

Benchmark Datasets

Benchmark datasets are stored in benchmark/ directory and organized by source:

  • Amazon (benchmark/amazon/): Product review datasets
  • Bluesky (benchmark/bluesky/): Social media topic datasets
  • IMDb (benchmark/IMDb/): Movie review datasets

Output Files

topic_prefix Naming Rule

To keep output paths stable and safe, this repo normalizes topic_prefix as:

  • Replace any non-alphanumeric characters with _ (A-Z, a-z, 0-9 are kept)
  • Trim leading/trailing _
  • Truncate to the first 10 characters
  • If the result is empty, use default

Example: "Joker(2019)" → "Joker_2019"

Generated files are saved to:

  • topic-agent/{topic_prefix}/: Distribution trees, matched/generated users, per-blueprint statistics
  • results/{topic_prefix}/: Final users and field distribution statistics
  • eval/eval_results/{topic_prefix}/: Evaluation results (statistical and LLM-based)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages