vietnam-society-sim
A LoRA fine-tune of Qwen/Qwen3.5-2B that answers survey-style decision questions in the role of a described Vietnamese person. Ask it like a System One (Jev) decision model: a persona and a scenario (a product, price or policy) as the state, survey questions with a 1–5 scale as the questions, and it returns a probability for every answer, plus how likely the person is to say there is "not enough information". It can add a one-sentence reason in Vietnamese.
Aggregated over many personas, this gives a synthetic-population hypothesis, not a poll: the output reflects a language model's responses to synthetic personas and has not been validated against real Vietnamese respondents unless stated under Evaluation.
How to use
Ask in the System One (Jev) format: a state (one persona and a situation) and typed questions, and get a probability for every answer. Nothing is generated, so there is no text to parse. Each question is a survey question with five answer levels from lowest to highest, and every answer also says how likely the person is to find the information not enough to decide. Needs torch and a transformers version with Qwen3.5 (tested with 5.22).
import json
from transformers import AutoModel
model = AutoModel.from_pretrained("hong-hai-le/vietnam-society-sim", trust_remote_code=True).to("cuda") # or "cpu"
state = {
"persona": {
"age": 34,
"sex": "Nữ",
"marital_status": "Đã kết hôn",
"education_level": "Đại học",
"occupation": "Kế toán",
"zone": "Đô Thị",
"region": "Đông Nam Bộ",
"persona": "Một kế toán ở TP.HCM, cẩn thận với chi tiêu gia đình.",
},
"situation": {
"title": "Ứng dụng AI quản lý tài chính cá nhân",
"description": "Một ứng dụng trên điện thoại dùng trí tuệ nhân tạo (AI) để giúp người dùng theo dõi thu chi, lập ngân sách "
"hằng tháng và nhận gợi ý tiết kiệm. Ứng dụng kết nối với tài khoản ngân hàng và ví điện tử của người dùng để tự động "
"phân loại các khoản chi tiêu. Giá sử dụng là 99.000 đồng mỗi tháng.",
},
}
questions = {
"subscribe": {
"type": "score",
"instructions": "Bạn có khả năng đăng ký sử dụng ứng dụng này với giá 99.000 đồng mỗi tháng không?",
"criteria": ["Chắc chắn không", "Có lẽ không", "Phân vân", "Có lẽ có", "Chắc chắn có"],
},
}
result = model.system_one(state=state, questions=questions)
print(json.dumps(result["answers"], ensure_ascii=False, indent=2))
Output (recorded during evaluation):
{
"subscribe": {
"type": "score",
"score": 4.187,
"probabilities": {
"Chắc chắn không": 0.001,
"Có lẽ không": 0.018,
"Phân vân": 0.077,
"Có lẽ có": 0.602,
"Chắc chắn có": 0.303
},
"choice": "Có lẽ có",
"not_enough_info": 0.0,
"confidence": 0.414
}
}
Ask a group
Pick people from Nemotron-Personas-Vietnam, whose rows are personas as they are, and vote() averages their probabilities into the group's answer. Needs datasets; the first call downloads the dataset.
from datasets import load_dataset
people = load_dataset("nvidia/Nemotron-Personas-Vietnam", split="train") # 1 million personas, about 2.2 GB
people = people.filter(lambda zone, age: zone == "Đô Thị" and 25 <= age <= 49, input_columns=["zone", "age"])
people = people.shuffle(seed=0).select(range(200))
vote = model.vote(personas=people, situation=state["situation"], questions=questions, by="age_group")
print(json.dumps(vote["answers"], ensure_ascii=False, indent=2))
A persona is a dict with the dataset's English column names and Vietnamese values: age, sex, marital_status, education_level, occupation, zone, region, persona, professional_persona, cultural_background, hobbies_and_interests_list, career_goals_and_ambitions. A record from your own database with the same keys works too; leave out the fields you don't have.
| Field | Meaning |
|---|---|
score | probability-weighted average of the levels, 1 = first criterion … 5 = last: the number to compare between scenarios |
probabilities | each level's probability, without "not enough information" |
choice | the most likely level, for display |
not_enough_info | probability that the profile and situation are not enough to decide; kept out of the score |
confidence | 1 − entropy / log 5: 1 = all probability on one level, 0 = spread evenly |
reason | only with system_one(..., reason=True): one first-person sentence in Vietnamese, generated after the choice |
n | vote() only: how many personas were averaged |
top_2_box | vote() only: the two highest levels together, the share leaning yes |
top_2_box_margin | vote() only: 95% margin of top_2_box from the sample size (at most about ±7 points at 200 people, ±3 at 1,000) |
by_<field> | vote(..., by="<field>") only: the same figures for each value of a persona field, or of age_group (18-24, 25-34, 35-49, 50-64, 65+) |
Columns to filter on (exact values in the dataset):
| Column | Values |
|---|---|
sex | Nam, Nữ |
zone | Đô Thị, Nông Thôn |
region | Đồng bằng sông Hồng, Trung du và miền núi phía Bắc, Bắc Trung Bộ và Duyên hải miền Trung, Tây Nguyên, Đông Nam Bộ, Đồng bằng sông Cửu Long |
age | 18 to 90 |
education_level | Không có học vấn, Tiểu học, Trung học cơ sở, Trung học phổ thông, Trung cấp / Cao đẳng, Đại học, Sau đại học |
marital_status | Độc thân, Đã kết hôn, Ly hôn, Góa |
occupation | exact occupation names from the dataset |
Good practice:
- Describe one person, not a group. Ranges or catch-alls such as
"age": "20 to 30", "sex": "Toàn bộ"are not what the model was trained on: it answers as a generic person, about the same as an empty profile, and does not say "not enough information" either. For a group, filter the dataset and usevote(). - Read
scoreandprobabilities, not onlychoice: on an ordered scale, 4 is close to 5, andchoicethrows that away. - For a group, use
vote(), which averages the probabilities. Counting each person'schoiceexaggerates the majority (1,000 people each 45% likely to pick 4 would count as 100%).top_2_boxis the usual purchase-intent figure. - Scoring is cheap (one forward pass per option order); reasons are not (up to 120 generated tokens each), so ask for
reason=Trueon a few people only. - Only
scorequestions with five levels, lowest first: the model was trained on these, with "not enough information" as an extra option.choiceandnoulquestions are refused, and unordered options (e.g. which payment method) are outside its training.
Training
- Method: BF16 LoRA (r=16, alpha=32, dropout=0.0) on the language layers only, completion-only loss on the JSON answer.
- Framework: Unsloth with Hugging Face TRL (
SFTTrainer) and PEFT - Target modules: down_proj, gate_proj, in_proj_qkv, in_proj_z, k_proj, o_proj, out_proj, q_proj, up_proj, v_proj
- Epochs: 2.0, learning rate 0.0001, effective batch 16, max length 2048
- Label sources: synthetic_teacher
- Teachers: Qwen/Qwen3.5-9B
- Final eval loss: 0.6801272630691528
Train, validation and test splits are disjoint by persona and by scenario family.
Evaluation
Held-out test splits of the training data (disjoint from training by persona and by scenario family), scored with both option orders averaged as recommended above. The labels are answers from the teacher model (Qwen/Qwen3.5-9B; label source: synthetic_teacher), so these numbers show how closely the model reproduces its teacher on unseen personas and scenarios. They do not measure agreement with real people.
Each cell is base Qwen/Qwen3.5-2B → this model.
| Split | Held out | Labels | Accuracy | NLL ↓ | Brier ↓ | ECE ↓ | Distribution TVD ↓ |
|---|---|---|---|---|---|---|---|
test_persona | personas not seen in training | 238 | 21.0% → 54.6% | 1.71 → 1.10 | 0.81 → 0.57 | 0.07 → 0.09 | 0.39 → 0.16 |
test_scenario | a scenario family not seen in training | 356 | 4.2% → 27.2% | 1.58 → 1.77 | 0.81 → 0.81 | 0.29 → 0.18 | 0.41 → 0.41 |
test_both | unseen personas and scenario family | 44 | 2.3% → 22.7% | 1.55 → 1.83 | 0.80 → 0.83 | 0.31 → 0.28 | 0.47 → 0.49 |
- Accuracy: the model's most likely option is the teacher's answer. The teacher's answers were sampled, so it does not always agree with itself: two teacher answers for the same persona and scenario are the same in 51.3% of pairs on
test_persona, 46.6% of pairs ontest_scenario, 59.1% of pairs ontest_both: a rough ceiling for accuracy. - NLL, Brier, ECE: how well the probabilities fit the teacher's answers (lower is better; ECE is the calibration error of the top option).
- Distribution TVD: per scenario, the total variation distance between the model's average answer distribution and the teacher's answer distribution, averaged over scenarios (0 = identical, 1 = no overlap). This is the error of the aggregate result a simulation reports.
- Held-out scenario family: mobility_purchase.
Robustness
| Check | Base → This model |
|---|---|
| Same top option with options listed ascending vs descending | 15.7% → 40.4% |
| Mean TVD between the two option orders ↓ | 0.25 → 0.34 |
| Probability on the valid option digits (format compliance) | 100.0% → 100.0% |
| Valid JSON answer when generating freely (n=40, sampled at temperature 0.7) | 100.0% → 100.0% |
| … that also has a reason | 100.0% → 100.0% |
Hardware requirements
Measured on an NVIDIA GeForce RTX 4060 (8 GB, compute capability 8.9) in bfloat16 with plain transformers, loading the text model with AutoModelForCausalLM:
| Download | 4.4 GB of safetensors (bf16; includes the vision tower, which the text model does not load) |
| Parameters loaded (text model) | 1.88 B |
| Weights in memory | 3.8 GB |
| Peak GPU memory, scoring (batch 8) | 6.1 GB |
| Peak GPU memory, generating reasons (batch 4, up to 160 new tokens) | 6.1 GB |
| Scoring speed | 5.4 prompts/s (one prompt = one persona in one option order) |
| Generation speed | 0.53 s per answer at batch 4 |
| Load time (weights already downloaded) | 8 s |
Rough guide (derived from the measurements above):
- GPU: an NVIDIA GPU with at least 8 GB of memory (the measured peak plus about 1 GB for the CUDA context). BF16 needs compute capability 8.0 or newer (RTX 30 series and later, A10, L4, A100); older cards can load it with
dtype=torch.float16(not tested). - No GPU: the code above also runs on CPU (
.to("cpu"), in bfloat16), but slowly: about 1 minute per dataset persona on an Apple M2 (16 GB), so keepvote()to a few dozen people there. - Cost of a simulation: one forward pass per persona and option order, so 1,000 personas with both orders is 2,000 prompts, about 6 min on the GPU above.
- Speed: on CUDA, install
flash-linear-attentionandcausal-conv1d; without themtransformersruns Qwen3.5's linear-attention layers with slower reference kernels. - Fine-tuning: this LoRA recipe (bf16, batch 2 × 8 gradient accumulation, max length 2048, adamw_8bit) was trained on a machine with 16 GB of VRAM (2 × RTX 4060, 8 GB each).
Limitations
- Personas are synthetic (NVIDIA Nemotron-Personas-Vietnam); attribute combinations follow the generator's assumptions.
- Probabilities are model-derived. Without calibration on real human answers they are not estimates of public opinion.
- Sensitive to prompt wording and option order; keep the format above.
- Reasons are post-hoc explanations generated after the choice, not evidence of how a choice was made.
- Not for decisions about individuals, targeting, or presenting results as survey findings.
License and attribution
- This release: MIT. It contains Qwen/Qwen3.5-2B's weights, which stay under Apache-2.0: keep that license and its notices with them.
- Base model: Qwen/Qwen3.5-2B, Apache-2.0.
- Personas: nvidia/Nemotron-Personas-Vietnam, CC BY 4.0.