A LoRA adapter for Llama 3.1 8B Instruct that predicts political ideology from demographics + psychographic attitudes.
This model was trained on the Canadian Election Study (CES) 2021 to predict self-reported ideology (0-10 left-right scale) from:
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4base_model = AutoModelForCausalLM.from_pretrained(
5 "meta-llama/Meta-Llama-3.1-8B-Instruct",
6 load_in_4bit=True
7)
8model = PeftModel.from_pretrained(base_model, "baglecake/ces-phase2-lora")
9tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
10
11# Example prompt
12system = """You are a 45-year-old man. from Ontario, Canada. You live in a suburb of a large city. Your highest level of education is a bachelor's degree. You are currently employed full-time. You are married. You have children. You are Catholic and religion is somewhat important to you. You were born in Canada.
13
14This person not at all satisfied with the federal government, thinks the economy has gotten worse over the past year, thinks Canada should admit fewer immigrants.
15
16Answer survey questions as this person would, based on their background, experiences, and views. Give direct, concise answers."""
17
18user = "On a scale from 0 to 10, where 0 means left/liberal and 10 means right/conservative, where would you place yourself politically? Just give the number."
19
20# Format as Llama chat and generate
The model is steerable - changing attitudes while holding demographics constant shifts predicted ideology:
This confirms the psychographic compression captures incumbent-relative affect, not arbitrary noise.
1@software{ces-phase2-lora,
2 title = {CES Phase 2 LoRA: Psychographic Ideology Prediction},
3 author = {Coburn, Del},
4 year = {2025},
5 url = {https://huggingface.co/baglecake/ces-phase2-lora}
6}
This model is part of the
émile-GCE project for Generative Computational Ethnography.