Topic: Hands-on materials for the Moral Machine + LLM persona experiments.
tutorial/
├── socialllm_tutorial.ipynb # main hands-on notebook (run this)
├── tutorial_utils/ # helper modules used by the notebook
│ ├── config.py # character pools
│ ├── generate_scenarios.py # Moral Machine scenario generator
│ ├── prompts.py # persona prompt templates
│ ├── llm_inference.py # OpenAI / HuggingFace inference helper
│ ├── responses.py # response -> conjoint long format
│ ├── scoring.py # weighted-OLS / ACME (Python port of R)
│ ├── pipeline.py # end-to-end: generate -> infer -> score
│ └── visualization.py # radar-plot helpers
├── model_result/ # pre-computed responses (CSV)
│ ├── Human/ # aggregate human responses
│ ├── GPT-4o/ # GPT-4o, 10k scenarios
│ ├── GPT-3.5/ # GPT-3.5 Turbo
│ └── Llama2/ # Llama-2-7b-chat
└── legacy_r/ # original R scoring scripts (kept for reference;
# the notebook uses tutorial_utils/scoring.py)
Each model_result/<model>/ folder has:
Baseline.csv– baseline (no persona) responsesAge.csv,Culture.csv,Education.csv,Gender.csv,Income.csv,Political.csv,Religious.csv– two-column comparisons between contrasting personas
pip install pandas numpy matplotlib seaborn statsmodels tqdm jupyter
# optional, only for Step 2 / 3 / 5 (LLM inference)
pip install openai # if you have an OpenAI / OpenRouter API key
pip install transformers torch # if you want the local HF fallback
jupyter notebook socialllm_tutorial.ipynbOpen this Colab link directly — the notebook lives at the root of the
socialllm-tutorial repo:
https://colab.research.google.com/github/hikoseon12/socialllm-tutorial/blob/main/socialllm_tutorial.ipynb
Then just run the first cell ("Setup cell — run me first"). It auto-clones
the repo into the Colab VM, brings tutorial_utils/ and model_result/
into the working directory, and pip-installs the required packages.
Everything below then "just works".
If you don't want to use GitHub, you can also drag-and-drop the
tutorial_utils/ and model_result/ folders into Colab's left-hand
"Files" panel before running the rest of the cells.
- Hands-on judging – go to https://www.moralmachine.net/ and answer the 13 scenarios yourself.
- LLM responses on sample scenarios – generate Moral Machine prompts and run them through either the OpenAI API, OpenRouter, or a local HuggingFace model.
- Persona injection – prepend a persona instruction (TEMPLATE1 from the persona-MM paper) and re-run.
- Pre-computed comparison – paper-style radar grid comparing Human / GPT-4o / GPT-3.5 / Llama2 across all 7 persona categories.
- Run your own pipeline – generate ~50–100 fresh scenarios, call the
model, convert to the conjoint format, compute the 9-dim ACME scores
(Python port of the original R
calculate_score.R), and drop the result intomodel_result/MyModel/for side-by-side radar plotting.
- Awad et al., The Moral Machine experiment, Nature 2018 – https://www.nature.com/articles/s41586-018-0637-6
- Takemoto, The Moral Machine experiment on LLMs, Royal Society Open Science 2024 – https://royalsocietypublishing.org/rsos/article/11/2/231393/92489
- Kwon et al., Exploring Persona-Dependent LLM Alignment for the Moral Machine Experiment, 2025 – https://arxiv.org/abs/2504.10886