--- name: nemotron-personas-builder description: 'Reproducible workflow and zero-dependency CLI (scripts/personas_cli.py) for building demographically grounded, NeMo Data Designer-compatible synthetic persona datasets (e.g., Swedish SCB or Norwegian SSB Nemotron-Personas), auditing statistical coherence and name realism, running blind native-speaker model vibe-checks, and exporting RL rollout seeds.' --- # Nemotron-Personas Builder (`personas_cli.py`) Build statistically grounded, privacy-safe synthetic persona datasets aligned with NVIDIA's **NeMo Data Designer** 4-stage architecture (`Nemotron-Personas`), while keeping official core schemas clean and optional experimental dimensions cleanly separated. ## Core Principles (Lessons Learned) 1. **Follow the 4-stage NeMo Data Designer pipeline:** - **Stage 1 — OCEAN Big-Five:** Sample psychological traits (`openness`, `conscientiousness`, `extraversion`, `agreeableness`, `neuroticism`) to anchor behavioral diversity. - **Stage 2 — Demographically Grounded Sampling:** Sample age, sex, geography (municipality/county), education, employment, occupation, and cohort-appropriate names from official national statistics (e.g. SCB for Sweden, SSB for Norway) via conditional/PGM tables — never let an LLM invent demographics. For full-scale cascaded Bayesian networks with PyTorch/GPU sampling and native Data Designer plugin integration, use [**NVIDIA-NeMo/SDG-PGMs**](https://github.com/NVIDIA-NeMo/SDG-PGMs) (`PGMGenerator` + `PGMGeneratorPluginConfig`); use `personas_cli.py sample` for fast zero-dependency local prototyping. - **Stage 3 — Structured Persona Attributes (`LLMStructuredColumnConfig`):** Use Pydantic-validated structured outputs to expand seeds into `skills_and_expertise_list`, `hobbies_and_interests_list`, cultural background, and career context. - **Stage 4 — Native-Language Narrative Descriptions (`LLMTextColumnConfig`):** Generate natural, idiomatic prose (`persona`, `professional_persona`, etc.) in the target locale. 2. **Keep the official core lean (no dimension bloat):** Do not overload an official Nemotron-Personas release with extra "vibed" dimensions. Put experimental/domain dimensions (e.g., political leaning, media diet, local quirks, custom Renaissance Labs recipes) behind `--extensions` as a separate downstream layer. 3. **Choose the generator model by native-speaker vibes, not benchmarks:** Automated evals miss stiff phrasing, anglicisms ("translationese"), and uncanny name/location pairings. Always run a blind native-speaker vibe-check (`vibe-pack`) on 30–50 identical seeds across candidate models before scaling to 100k+ rows. 4. **Enforce statistical coherence & name realism:** Reviewers scrutinize impossible combinations (e.g., 19-year-old chief physician, retiree listed as full-time apprentice), collapsed name diversity, and wrong name-to-birth-cohort pairings. Always run `audit` before generating full scale and again before release. 5. **Plan legal & release review early:** Datasets intended for official/partner release (e.g. NVIDIA Legal review) need clean provenance (CC0/open government statistics), zero PII, and pinned data/code revisions well ahead of target events. 6. **Reuse personas for RL rollouts:** Personas + OCEAN traits are high-leverage user-simulator seeds for multi-turn RL rollouts (tool-use, everyday tasks, customer/citizen interactions). ## CLI Quick Reference (`scripts/personas_cli.py`) Zero external dependencies (Python 3.9+ stdlib only). Every command supports `--json` for agent workflows. ### 1. Scaffold a New Locale Project (`init`) Creates a reproducible workspace (`configs/locale.json`, `data/raw/`, `data/tables/`, `pipeline.py`, `eval/`). Built-in starter presets: `sv-SE` (Sweden / SCB) and `nb-NO` (Norway / SSB), plus `custom`. ```bash python3 scripts/personas_cli.py init ./no-personas --locale nb-NO python3 scripts/personas_cli.py init ./se-personas --locale sv-SE --json ``` ### 2. Sample Statistically Coherent Demographic Seeds (`sample`) Deterministically samples grounded seed records (Stages 1 & 2) from the locale's conditional tables. Supports slicing by municipality/region (e.g. "1,000 realistic citizens in Västerås"): ```bash python3 scripts/personas_cli.py sample \ --locale sv-SE \ --count 1000 \ --municipality Västerås \ --seed 42 \ --out seeds_vasteras.jsonl ``` Or use a customized locale config with full SCB/SSB tables: ```bash python3 scripts/personas_cli.py sample \ --config ./se-personas/configs/locale.json \ --count 5000 \ --min-age 18 --max-age 65 \ --out seeds_working_age.jsonl ``` ### 3. Emit a NeMo Data Designer Pipeline (`emit-pipeline`) Generates a runnable Python script using `data_designer.config` (`DataDesignerConfigBuilder`, `SamplerColumnConfig`, `LLMStructuredColumnConfig`, `LLMTextColumnConfig`) wired to your seed dataset and model alias: ```bash # Official lean Nemotron-Personas core schema (seed JSONL) python3 scripts/personas_cli.py emit-pipeline \ --locale sv-SE \ --seeds seeds_vasteras.jsonl \ --model-alias gemma4-31b \ --out pipeline.py # Official NeMo Data Designer + NVIDIA-NeMo/SDG-PGMs plugin (cascaded Bayesian network) python3 scripts/personas_cli.py emit-pipeline \ --locale sv-SE \ --pgm-class my_generators.SwedishPersonGenerator \ --evidence '{"municipality": "Västerås"}' \ --model-alias gemma4-31b \ --out pipeline_pgm.py # Include optional custom/experimental extension columns (separate from official core) python3 scripts/personas_cli.py emit-pipeline \ --locale sv-SE \ --seeds seeds_vasteras.jsonl \ --extensions civic_life,media_habits \ --out pipeline_extended.py ``` ### 4. Audit Statistical Coherence & Name Realism (`audit`) Checks a seed or generated personas JSONL file for: - **Impossible combinations:** Underage/overage occupation mismatches, degree-for-age impossibilities, `not_in_workforce` vs. active job title contradictions. - **Name realism & diversity:** Name entropy, top-name concentration, cohort/age-era mismatch, and duplicate full-name collisions. - **Demographic drift:** Total Variation Distance (TVD) vs. locale reference distributions (sex, age bands, education, geography). - **Text hygiene (when narrative columns exist):** Empty fields, English/translationese leakage markers, and PII-like patterns (personnummer/SSN, emails, phone numbers). ```bash python3 scripts/personas_cli.py audit personas.jsonl --locale sv-SE python3 scripts/personas_cli.py audit personas.jsonl --locale sv-SE --json ``` **Agent rule:** If `status` is `"fail"`, fix the sampling tables, constraints, or prompt before scaling up generation. If `status` is `"warn"`, inspect the flagged items with a native speaker. ### 5. Create a Blind Native-Speaker Model Vibe-Check Pack (`vibe-pack`) Takes outputs from 2+ candidate models generated on the **same seeds** (matched by `uuid` or row index), anonymizes model names into `Model A`, `Model B`, ..., and writes: - A self-contained interactive HTML reviewer (`vibe_review.html`) that native speakers can open in a browser and export ratings from. - A blind Markdown sheet (`vibe_review.md`) and a secret `answer_key.json` to unblind results afterward. ```bash python3 scripts/personas_cli.py vibe-pack \ --models gemma4=out_gemma4.jsonl nemotron=out_nemotron.jsonl \ --sample 30 \ --out-dir ./vibe_eval ``` ### 6. Export RL Rollout User-Simulator Seeds (`rl-export`) Converts personas into structured user-simulator prompts (JSONL) combining demographic context, OCEAN communication style, and locale-grounded task scenarios for multi-turn RL rollouts: ```bash python3 scripts/personas_cli.py rl-export personas.jsonl \ --locale sv-SE \ --domain everyday_civic \ --count 500 \ --out rl_seeds.jsonl ``` ## Reference Guides - [NeMo Data Designer 4-Stage Pipeline & Review Rubric](references/data-designer-pipeline.md) - [Probabilistic Graphical Models with NVIDIA-NeMo/SDG-PGMs](references/sdg-pgms.md) - [Official Locale Data Sources (SCB, SSB & New Countries)](references/locale-data-sources.md) - [Structuring Personas for RL Rollouts](references/rl-rollouts.md)