aabroukh's picture
Add files using upload-large-folder tool
849f535 verified
|
Raw History Blame Contribute Delete
13.7 kB

Analysis

Every number and table in the paper is produced by a script in this folder, reading only the data shipped in data/ and stimuli/. Run everything from the repository root.

analysis/
├── common/                  shared helpers (imported, never run directly)
├── 01_data_prep/            raw exports → analysis tables (only for new collections)
├── 02_main_study/           the human study (Tables 1, 2, 5, 21)
├── 03_synthetic_raters/     AI-rater alignment (Tables 3, 4, 6–8)
├── 04_annotation_budget/    using AI ratings to allocate human raters (Table 20)
├── 05_prompt_analyses/      which prompts swing across modality (Table 19, Appendix J)
├── 06_voice_study/          Ablation A: four TTS voices (Tables 9, 10, 12; Appendix G)
├── 07_audio_context_study/  Ablation B: conversation history heard as audio (Table 13; Appendix H)
├── 08_cross_study/          contrasts across arms of both ablations (Tables 11, 14–18)
├── run_all.sh               runs every script below in order
└── Stimuli_Sampling.pdf     stimulus-screening worksheet (reference only)

Scripts write tables to results/<folder>/ and figures to figures/. Inputs in data/ are never overwritten.

Setup

The analyses need Python and R together, so the simplest setup is pixi, which installs both from pixi.toml and pixi.lock:

pixi install
pixi run python analysis/02_main_study/01_omnibus_bias_model.py

To use pip instead, install R (≥ 4.2) yourself along with the R packages that pymer4 and the analyses load:

python3.11 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
brew install r     # or your platform's R installer
R -e 'install.packages(c("lme4","lmerTest","emmeans","broom","broom.mixed","report","parameters","performance","insight","tidyverse","arrow","boot"), repos="https://cloud.r-project.org")'

Results were verified with Python 3.11.7, R 4.5.2, lme4 1.1-38, lmerTest 3.1-3 and emmeans 2.0.0. 08_cross_study/09_validate_lme4_substitution.py checks that the direct lme4 bridge used by the follow-up analyses reproduces the paper's Table 1 before you rely on it.

Where each result comes from

The synthetic-rater scripts take --model gpt4o | gemini_36_flash | qwen35_omni_flash. The default, gpt4o, gives the main-text Tables 3–4; running all three gives the cross-family Tables 6–8. The voice study is Ablation A (arms A1 am_michael, A2 Chatterbox, A3 Serena) and the audio-context study is Ablation B (B1 one-voice history, B2 two-voice history). In Tables 10–18 the text and audio reference rows are the main study's conditions recomputed on each ablation's 30 prompts.

Human study and main-text AI comparisons

Result Script
Table 1: omnibus bias model; per-modality length effects 02_main_study/01_omnibus_bias_model.py
Table 2: ICC and Krippendorff's α, bootstrap CIs, permutation tests 02_main_study/02_reliability_icc_alpha.py (slow, see below)
ICC(2,k) by number of raters (figure) 02_main_study/03_icc_by_k_curve.py
Decision threshold (audio M = 27.9, text M = 41.7); cross-modality winner agreement (53/100, p = .31); agreement-by-decisiveness figures 02_main_study/04_cross_modality_agreement.py
Prompt-specific modality effects (random-slope model, χ²(2) = 22.1) 02_main_study/05_prompt_modality_effects.py
Practice effects on trial duration 02_main_study/06_practice_effects.py
Table 5: session and trial characteristics by condition 02_main_study/07_session_characteristics.py
Table 21: participant demographics by condition 02_main_study/08_participant_demographics.py
Qualitative TF-IDF analysis of justifications 02_main_study/09_qualitative_tfidf.py
Robustness: education covariate 02_main_study/10_robust_education.py
Robustness: audio-quality covariate 02_main_study/11_robust_audio_quality.py
Robustness: relistening to the first clip 02_main_study/12_robust_relisten.py
Robustness: ceiling compression 02_main_study/13_robust_ceiling.py
Table 3: AI–human alignment; PRISM vs. external raters 03_synthetic_raters/01_ai_human_alignment.py
Table 4: AI differentiation predicts human agreement 03_synthetic_raters/02_ai_predicts_agreement.py

04_cross_modality_agreement.py is the authoritative source for the 53/100 winner-agreement figure. 05_prompt_modality_effects.py deliberately prints no winner-agreement number, because its sign-of-mean rule differs from 04 in edge cases.

Additional synthetic raters, triage and prompt analyses (Appendices F, J, K)

Result Script
Table 6: AI–human agreement and rating error, three rater families 03_synthetic_raters/01_ai_human_alignment.py --model <m>
Table 6 follow-up: calibration offset vs. rank agreement (centered MAE) 03_synthetic_raters/05_mae_bias_decomposition.py
Table 7: AI differentiation predicts human agreement, three families 03_synthetic_raters/02_ai_predicts_agreement.py --model <m>
Table 8: PRISM vs. AI annotators across raters 03_synthetic_raters/01_ai_human_alignment.py --model <m> (writes h2_prism_comparisons*.csv)
Cross-family judge agreement, text vs. audio 03_synthetic_raters/03_cross_model_agreement.py --models gpt4o gemini_36_flash qwen35_omni_flash
Do AI judges reproduce the human order and length biases? 03_synthetic_raters/04_synth_bias_effects.py
Triage experiment: gap-threshold sweep, budget-matched allocation 04_annotation_budget/01_triage_experiment.py --model <m>
Human raters needed per AI-gap band 04_annotation_budget/02_human_sample_size_by_ai_gap.py --model <m>
Table 20: first-hit vs. stable ratings by gap band 04_annotation_budget/03_raters_to_gold_by_gap.py --model <m>
Tiered vs. uniform allocation at matched budget 04_annotation_budget/04_triage_allocation_table.py
Cost per trial behind the triage savings ($0.26 text, $0.46 audio) 04_annotation_budget/05_annotation_cost_per_trial.py
Length and conversation-structure predictors of the modality effect (Appendix J) 05_prompt_analyses/01_modality_effect_features.py
Table 19: modality effect by induced prompt type; inter-coder κ = .699 05_prompt_analyses/05_topic_code_stimuli.py --reuse
Context-dependent prompts flip winners more often (68% vs. 35%; Section 5.2) 05_prompt_analyses/06_context_dependence_flips.py
Qualitative fail cases: prompts ranked by human cross-modal gap, with justifications 05_prompt_analyses/02_qual_rating_disagreement.py, 03_qual_raw_rating_diff.py, 04_qual_pair_diff_table.py

05_topic_code_stimuli.py --reuse rebuilds Table 19 from the shipped topic codes (data/main_study/stimulus_topic_codes*.csv) and makes no network calls. Without --reuse it re-runs the topic induction and coding through the Gemini and OpenAI APIs, which needs API keys, costs money, and will not return exactly the same codes.

Voice and audio-context ablations (Appendices G–I)

Result Script
Table 9: acoustic characterization (WPM, f0, loudness) 06_voice_study/03_acoustics.py (needs the WAVs)
Voice f0 level and self-consistency (drift 0.27–0.98 st) 06_voice_study/04_f0_drift.py (needs the WAVs)
Table 10: modality signatures by voice. Threshold and ICC columns come from the threshold summary; recency and length come from the replication script 08_cross_study/01_threshold_summary.py, 06_voice_study/05_replication.py
Tables 11 and 14: equivalence tests (TOST) between arms 08_cross_study/03_equivalence_tost.py (run 02 first)
Table 12: synthetic-rating alignment by voice 06_voice_study/06_synth_alignment.py
Table 12 follow-up: prompt-clustered bootstrap CIs 06_voice_study/07_synth_alignment_bootstrap.py (5,000 reps)
Table 13: audio-context modality signatures 08_cross_study/01_threshold_summary.py, 07_audio_context_study/02_replication.py
Table 15: winner agreement with a split-half noise floor 08_cross_study/04_winner_floor.py
Table 16: rating-scale usage by condition 08_cross_study/05_scale_usage.py
Tie probability by condition (companion to Table 16) 08_cross_study/06_tie_probability.py
Table 17: estimated marginal means for the decision threshold 08_cross_study/02_condition_contrasts.py
Table 18: pairwise contrasts between conditions 08_cross_study/02_condition_contrasts.py
Arm × position and arm × length interactions (p = .15, p = .003) 08_cross_study/07_bias_interactions.py
History depth, trial position, session duration, completion rates 08_cross_study/08_feasibility_covariates.py
B1 split at median trial duration (slower half threshold 19.6) 07_audio_context_study/03_duration_split.py
Audio-quality ratings and transcript divergence by voice (Serena −18.5) 06_voice_study/09_quality_by_voice.py
AI-judge winner agreement across voices 06_voice_study/08_judge_winner_agreement.py --model <m>
Transcript consistency of each voice against the baseline 06_voice_study/02_transcript_consistency.py
Prompt selection for each study 06_voice_study/01_select_prompts.py, 07_audio_context_study/01_select_prompts.py

The prompt-selection scripts write their reselection to results/ and never overwrite the fielded prompt lists in stimuli/*/prompts.csv.

Two values print slightly differently from the paper, which was rounded from an earlier pass: the f0 drift script prints .694/.973 st for Serena and Chatterbox (paper: 0.70/0.98), and the Table 15 split-half floors print .544/.565/.547/.557 (paper: .543/.564/.548/.555). Conclusions are unchanged.

Running everything

pixi run bash analysis/run_all.sh runs the commands below in order:

M="gpt4o gemini_36_flash qwen35_omni_flash"

for s in 01 03 04 05 06 07 08 09 10 11 12 13; do python analysis/02_main_study/${s}_*.py; done
python analysis/02_main_study/02_reliability_icc_alpha.py          # ~3 hours

for m in $M; do
  python analysis/03_synthetic_raters/01_ai_human_alignment.py --model $m
  python analysis/03_synthetic_raters/02_ai_predicts_agreement.py --model $m
  for s in 01 02 03; do python analysis/04_annotation_budget/${s}_*.py --model $m; done
done
python analysis/03_synthetic_raters/03_cross_model_agreement.py --models $M
for s in 04 05; do python analysis/03_synthetic_raters/${s}_*.py; done
for s in 04 05; do python analysis/04_annotation_budget/${s}_*.py; done

for s in 01 02 03 04 06; do python analysis/05_prompt_analyses/${s}_*.py; done
python analysis/05_prompt_analyses/05_topic_code_stimuli.py --reuse

for s in 01 02 05 06 07 09; do python analysis/06_voice_study/${s}_*.py; done
for m in gemini_36_flash qwen35_omni_flash; do
  python analysis/06_voice_study/08_judge_winner_agreement.py --model $m
done
for s in 01 02 03; do python analysis/07_audio_context_study/${s}_*.py; done
for s in 01 02 03 04 05 06 07 08 09; do python analysis/08_cross_study/${s}_*.py; done

Runtime and dependencies:

  • Reliability (02_main_study/02) takes about three hours, from the bootstrap and permutation tests. It checkpoints to _internal/run_outputs/ and resumes after an interruption. Delete that folder to recompute from scratch.
  • Replication scripts (06/05, 07/02) accept --skip-models for a fast descriptive pass.
  • Acoustics (06_voice_study/03, about 30 minutes) and f0 drift (04) read the rendered WAVs in stimuli/voice_study/audio/ (see stimuli/voice_study/README.md). Their outputs ship in stimuli/voice_study/, so you can skip them. 03_acoustics.py --out <path> writes elsewhere instead of overwriting the shipped table.

Running on your own data

The main-study scripts (02_main_study/*, 03_synthetic_raters/01, 02) read from data/main_study/ by default. Point them at another folder with an environment variable or a flag:

ANALYSIS_DATA_DIR=data/your_study python analysis/02_main_study/01_omnibus_bias_model.py

To build that folder from a new collection:

node tools/export-firestore.js                      # → data/your_study/raw/firebase_export.json
ANALYSIS_DATA_DIR=data/your_study python analysis/01_data_prep/01_build_stim_tables.py
ANALYSIS_DATA_DIR=data/your_study python analysis/01_data_prep/02_convert_main_json_to_csv.py

The convert script refuses to run against data/main_study/. The remaining folders (03–08) read the shipped follow-up and synthetic-rating tables directly, so they don't take a data folder.

The data-prep scripts are only needed for new collections; the shipped tables are their outputs:

Script Produces
01_data_prep/01_build_stim_tables.py prompt_stim_table.csv, survey_long_format.csv from a survey_data.json
01_data_prep/02_convert_main_json_to_csv.py main-study long, wide and participant tables from a Firestore export
01_data_prep/03_synth_to_long_csv_multi.py synth_long_* tables from a wide synthetic-ratings file (--model, --input)
01_data_prep/04_convert_followup_json_to_csv.py follow-up long tables from data/<study>/raw/ exports (see tools/export-firestore-followup.js)

Stimulus-screening worksheet

Stimuli_Sampling.pdf is a 39-page export of the sheet used to screen candidate PRISM turns before the 200 study clips were chosen: yellow = poor audio, orange = other language, green = empty output, red = harmful. It is reference material only. The machine-readable provenance is stimuli/main_study/study_stimuli_mapping.csv.