| # RQ4 Lexical Enrichment | |
| This artifact extends Finding 8 with an open lexical profile. It keeps the | |
| pronoun and mental-state counters, then adds Empath social/affective categories | |
| and transparent dialogue counters. The lexical features are bin-level properties | |
| of the WebOrganizer taxonomy and are reused across benchmark rosters. | |
| ## Tools | |
| - **`empath==0.89`** (MIT). Stanford open-source LIWC-adjacent analyzer | |
| (Fast, Chen, & Bernstein, CHI 2016). 20 pre-built categories selected | |
| in `configs/rq4_empath_categories.yaml`. | |
| - **Transparent in-repo counters** (`lexicons/*.json|yaml`): | |
| - pronouns (first/second/third person) | |
| - mental-state verbs | |
| - dialogue markers (question marks, quote marks, speaker turns) | |
| Not used in the main path: paid dictionaries, redistributed third-party | |
| emotion lexicons, or closed analyzers. See `tool_verification.md` for rationale. | |
| ## Inputs | |
| | Input | Path | Hash / size | Notes | | |
| |---------------------|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------| | |
| | Working manifest | `/storage/ice-shared/cs7634/staff/TDA/soc149/working_sample_manifest.parquet` | `e1866c18f77dee06a93000bd1b4043ce0a193d53b275db908c94b0bf88821211` (SHA256) | 5,678,621 docs across 576 WebOrganizer (topic × format) bins. | | |
| | Source shards | `/storage/ice-shared/cs7634/staff/TDA/tracstar/shards_10k/sample_10000_docs/shard_*.jsonl` | 316 files, 43,070,889,103 bytes; inventory SHA256 `07ca3fff7756e6ccee7256541945efc3d51060ffccc89ed81fcc6131366990f9` (over `du -sb shard_*.jsonl | sort`) | Plain JSONL. Doc fields `id`, `text`. | | |
| | Bin influence scores| `artifacts/zscored_bin_scores/aggregated/zscored_<benchmark>.csv` | (versioned in repo) | 576 rows / benchmark. | | |
| | Baseline parity | `/storage/ice-shared/cs7634/staff/TDA/outputs/rq4_bin_features.csv` | Produced by `scripts/analysis/rq4_bin_characterization.py` | Used as the parity anchor in `smoke/verification_report.md`. | | |
| ## Pipeline | |
| ``` | |
| +-----------+ +---------------+ +-----------+ +-------------------+ | |
| | SLURM | | worker mode | | merge | | densities, | | |
| | array +----->| count + write+----->| combine +----->| z-scores, | | |
| | (32x) | | per-shard | | partials | | composites | | |
| +-----------+ +---------------+ +-----------+ +-------------------+ | |
| ``` | |
| ### Worker (`scripts/analysis/rq4_lexical_toolkit_profiles.py --mode worker`) | |
| For each `(chunk_index, chunk_count)` slice of shards: stream JSONL, look up bin | |
| via manifest, tokenize once with `\b\w+\b` (lowercased), accumulate per-bin | |
| sufficient statistics for all transparent + Empath counters, optionally append | |
| a per-document row to `per_doc_features.parquet`. Empath counts use a flat | |
| `token → tuple[category, ...]` map built once at startup from the installed | |
| `empath.cats` dictionary over the selected categories. | |
| ### Merge (`--mode merge`) | |
| Sum per-shard partials, compute per-1,000-word densities, full-grid | |
| unweighted z-scores, and the three composites | |
| (`dialogue_composite_z`, `empath_social_z`, `empath_affect_z`). Emits: | |
| - `per_bin_profiles.parquet` and `.csv` (576 bins × ~90 columns: counts, | |
| per-1k densities, z-scores, composites) | |
| - `corpus_baselines.json` (`{feature_per_1k: {mean, std}}` used for z-scoring) | |
| - `run_summary.json` | |
| ### Bootstrap (`scripts/analysis/rq4_lexical_bootstrap.py`) | |
| Two pre-registered tests at top-20 per benchmark (B=1000, seed=42): | |
| - **Within-benchmark cluster separation.** For each benchmark, intersect the | |
| top-20 bins with `configs/rq4_format_clusters.yaml` and bootstrap the | |
| cluster-mean delta (interpersonal − documentation) on each of | |
| `{mean_words_per_doc, mental_state_per_1k, dialogue_composite_z, | |
| empath_social_z, empath_affect_z}`. Output: | |
| `cluster_separation_bootstrap_all_benchmarks.csv`. | |
| - **Cross-benchmark contrast.** Target benchmark = SocialIQA; "others" = | |
| union of MMLU-SS / ARC-C / MMLU-STEM top-20. Bootstrap the mean delta of | |
| the same five composites. Output: | |
| `cluster_separation_socialiqa_vs_others.csv`. | |
| - **GMM(k=1..3) bimodality diagnostic** over SocialIQA top-10 and top-25. | |
| Appendix-only diagnostic. Output: | |
| `gmm_bimodality_diagnostic.json`. | |
| SocialIQA is the only benchmark with both interpersonal and documentation | |
| formats in its top-20 (10 / 10); the other three are 100 % documentation/ | |
| structural (20 / 20, 20 / 20, 19 / 20). The within-benchmark test is therefore | |
| ill-defined for the three knowledge-recall benchmarks, which is itself the | |
| finding — the cross-benchmark contrast then provides the quantitative | |
| SocialIQA-vs-others statement. | |
| All four benchmarks share the same underlying per-bin lexical computation in | |
| `per_bin_profiles.parquet` (lexical features are bin-level, not | |
| benchmark-level). | |
| ### Tables, heatmap, and review figures | |
| `scripts/analysis/rq4_lexical_profile_figures.py` joins per-bin profiles with | |
| top-N rows from each benchmark's z-scored bin scores; writes: | |
| - `tab-rq4-profiles-expanded-<benchmark>.tex` under this directory | |
| - `fig-rq4-lexical-heatmap.pdf` | |
| - `top_bins_lexical_profiles.parquet` (auditable join) | |
| `scripts/analysis/rq4_lexical_visualize.py` writes the additional curated | |
| figures under `figures/`. | |
| ## Commands | |
| ```bash | |
| # 1. Per-shard worker (smoke or full) | |
| PYTHONPATH=src ~/dev/data-attribution/.venv/bin/python \ | |
| scripts/analysis/rq4_lexical_toolkit_profiles.py \ | |
| --mode worker \ | |
| --manifest /storage/ice-shared/cs7634/staff/TDA/soc149/working_sample_manifest.parquet \ | |
| --shards-dir /storage/ice-shared/cs7634/staff/TDA/tracstar/shards_10k/sample_10000_docs \ | |
| --shard-glob 'shard_*.jsonl' \ | |
| --chunk-index 0 --chunk-count 316 \ | |
| --worker-output-dir artifacts/rq4_lexical_profiles/smoke | |
| # 2. Full run on PACE (32-way SLURM array + dependent merge) | |
| bash scripts/slurm/analysis/launch_rq4_lexical.sh | |
| # 3. Per-benchmark expanded tables + 4-panel heatmap | |
| ~/dev/social-data-attribution/.venv/bin/python \ | |
| scripts/analysis/rq4_lexical_profile_figures.py \ | |
| --per-bin artifacts/rq4_lexical_profiles/per_bin_profiles.parquet \ | |
| --bin-scores-dir artifacts/zscored_bin_scores/aggregated \ | |
| --benchmarks socialiqa,mmlu_social_science,arc_challenge,mmlu_stem \ | |
| --format-clusters configs/rq4_format_clusters.yaml \ | |
| --top-n 20 --heatmap-top-n 10 \ | |
| --out-dir artifacts/rq4_lexical_profiles \ | |
| --top-bins-out artifacts/rq4_lexical_profiles/top_bins_lexical_profiles.parquet | |
| # 4. Per-benchmark cluster-separation bootstrap + SocialIQA-vs-others contrast + GMM | |
| ~/dev/social-data-attribution/.venv/bin/python \ | |
| scripts/analysis/rq4_lexical_bootstrap.py \ | |
| --per-doc 'artifacts/rq4_lexical_profiles/per_doc_features/*.parquet' \ | |
| --per-bin artifacts/rq4_lexical_profiles/per_bin_profiles.parquet \ | |
| --top-bins artifacts/rq4_lexical_profiles/top_bins_lexical_profiles.parquet \ | |
| --format-clusters configs/rq4_format_clusters.yaml \ | |
| --bin-scores-dir artifacts/zscored_bin_scores/aggregated \ | |
| --benchmarks socialiqa,mmlu_social_science,arc_challenge,mmlu_stem \ | |
| --top-n 20 --n-bootstrap 1000 --seed 42 --gmm \ | |
| --out artifacts/rq4_lexical_profiles | |
| ``` | |
| ## Adding a new benchmark or held-out probe | |
| The benchmark set lives in `configs/rq4_paper_benchmarks.yaml` (the roster). | |
| The figures and bootstrap scripts read it via `--roster`, so the canonical way | |
| to add a benchmark is: drop its `zscored_<id>.csv` into | |
| `artifacts/zscored_bin_scores/aggregated/`, then add one entry to the roster | |
| YAML (`id`, `label`, `short`, `group`). No code change. SimpleToM and | |
| ToMBench-False-Belief already have commented-out roster entries ready to | |
| uncomment once their attribution bin-scores exist (none do yet). | |
| The pipeline is parametrized by benchmark id; nothing in the lexical | |
| computation is benchmark-specific. Equivalently, for a one-off run without | |
| editing the roster: | |
| 1. **Produce its per-bin influence-score CSV** in the same schema as the | |
| existing primary benchmarks | |
| (`topic_label, format_label, mean_score, zscore, doc_count`), and drop it | |
| into `artifacts/zscored_bin_scores/aggregated/zscored_<benchmark>.csv`. | |
| 2. **Run steps 3 + 4 above** with the new benchmark id appended to the | |
| `--benchmarks` flag. The figures script auto-discovers the CSV via | |
| `zscored_<benchmark>.csv`; the bootstrap script intersects the new | |
| benchmark's top-N with `configs/rq4_format_clusters.yaml` and emits a | |
| row per (benchmark × feature) into | |
| `cluster_separation_bootstrap_all_benchmarks.csv`. | |
| 3. **(Optional) extend the pretty-name maps** in | |
| `scripts/analysis/rq4_lexical_profile_figures.py` (`BENCHMARK_LABELS`, | |
| `BENCHMARK_SHORT`, `_TOPIC_PRETTY`, `_FORMAT_PRETTY`) for nice LaTeX | |
| captions. Default behaviour is to title-case the id. | |
| 4. **(Optional) revise the format-cluster YAML** if the new benchmark | |
| surfaces formats not yet categorised. The YAML keys `interpersonal_dialogue`, | |
| `documentation_structural`, and `other` cover the full WebOrganizer | |
| format taxonomy; new format labels only appear if the WebOrganizer | |
| taxonomy is extended. | |
| `per_bin_profiles.parquet` is benchmark-agnostic and does **not** need to be | |
| recomputed when a new benchmark is added — the lexical features are | |
| properties of the WebOrganizer bin, not of the benchmark. | |
| ## Reproducibility | |
| - Random seed: 42 (bootstrap, GMM). | |
| - Bootstrap iterations: B = 1000; percentile CI at 2.5 / 97.5. | |
| - All densities expressed per 1,000 words. | |
| - Z-scores against the full 576-bin grid (unweighted), recorded in | |
| `corpus_baselines.json`. | |
| - Tokenizer: legacy `\b\w+\b` lowercased; documented divergence from | |
| Empath's whitespace-split default is in `tool_verification.md`. | |
| - See `smoke/verification_report.md` for the per-shard parity gate | |
| (Pearson r = 1.000000 against the submitted baseline; n_docs / total_words | |
| byte-identical). | |
| ## Output schema | |
| `per_bin_profiles.parquet`: | |
| | column | type | meaning | | |
| |--------------------------------------------|-----------|-----------------------------------------------------------------| | |
| | `bin_topic, bin_format` | str, str | WebOrganizer (topic, format) pair | | |
| | `n_docs, total_words, mean_words_per_doc` | int, int, float | bin-level totals | | |
| | `<feature>_count` | int | raw count (pronoun, mental-state, dialogue, Empath category) | | |
| | `<feature>_per_1k` | float | density per 1,000 words | | |
| | `<feature>_z` | float | full-grid z-score of the per-1k density | | |
| | `dialogue_composite_z` | float | mean z over dialogue components (see config YAML) | | |
| | `empath_social_z` | float | mean z over Empath social-process categories | | |
| | `empath_affect_z` | float | mean z over Empath affective-process categories | | |
| All component-level counts and densities are released even when the paper | |
| reports composites, so reviewers can audit. | |
| ## Known limitations | |
| - English-only; surface-form heuristics. | |
| - Empath categories are LIWC-*adjacent*, not LIWC-identical. | |
| - Pronoun/mental-state counters are transparent proxies, not coreference or | |
| theory-of-mind detectors. | |
| - Dialogue counters are line-anchored heuristics. | |
| - NRC EmoLex is not in the main path (no-redistribute clause). | |
Xet Storage Details
- Size:
- 12 kB
- Xet hash:
- 41b9a575d87c01a942ae61593777b5b46d7b7558f6255206407583ad6a3e706f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.