Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -18,40 +18,40 @@ pipeline_tag: text-generation
|
|
| 18 |
|
| 19 |
# CES Phase 3A LoRA: Leader Affect + Policy Positions
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|-------|-----------|---|
|
| 27 |
-
| **Phase 3A (this model)** | Demographics + Leader Ratings + Wedge Issues | **0.560** |
|
| 28 |
-
| Phase 3B | Same + Party ID | 0.574 |
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
## Key Finding: "The Null Result of the Label"
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
**What this means:**
|
| 37 |
- Party identity is **redundant** — it's already encoded in how people feel about leaders and their policy positions
|
| 38 |
- Canadian ideology is **substantive, not tribal** — people's "team" reflects their actual views
|
| 39 |
-
- **Phase 3A is
|
| 40 |
-
|
| 41 |
-
## Variables
|
| 42 |
-
|
| 43 |
-
### Demographics
|
| 44 |
-
Age, gender, province, education, employment, religion, marital status, urban/rural, born in Canada
|
| 45 |
-
|
| 46 |
-
### Leader Thermometers (0-100 ratings)
|
| 47 |
-
- Justin Trudeau
|
| 48 |
-
- Erin O'Toole
|
| 49 |
-
- Jagmeet Singh
|
| 50 |
-
|
| 51 |
-
### Wedge Issues
|
| 52 |
-
- Carbon tax support
|
| 53 |
-
- Energy sector/pipelines
|
| 54 |
-
- Medical assistance in dying
|
| 55 |
|
| 56 |
## Usage
|
| 57 |
|
|
@@ -65,22 +65,61 @@ base_model = AutoModelForCausalLM.from_pretrained(
|
|
| 65 |
)
|
| 66 |
model = PeftModel.from_pretrained(base_model, "baglecake/ces-phase3a-lora")
|
| 67 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
```
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
## Training Details
|
| 71 |
|
| 72 |
- **Base model**: meta-llama/Meta-Llama-3.1-8B-Instruct (4-bit quantized via Unsloth)
|
| 73 |
-
- **Training data**:
|
| 74 |
- **LoRA rank**: 32
|
| 75 |
- **LoRA alpha**: 64
|
|
|
|
| 76 |
- **Epochs**: 3
|
| 77 |
- **Hardware**: NVIDIA A100 40GB (Colab Pro)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
## Limitations
|
| 80 |
|
| 81 |
-
1. **Narrow task**: Model only outputs ideology numbers (0-10).
|
| 82 |
2. **Canadian-specific**: Trained on CES 2021 under Trudeau government.
|
| 83 |
-
3. **Leader-specific**: Uses 2021 leader names.
|
| 84 |
|
| 85 |
## Citation
|
| 86 |
|
|
|
|
| 18 |
|
| 19 |
# CES Phase 3A LoRA: Leader Affect + Policy Positions
|
| 20 |
|
| 21 |
+
A LoRA adapter for Llama 3.1 8B Instruct that predicts political ideology from demographics, leader thermometer ratings, and wedge issue positions. This is the **recommended** model in the Phase 3 series.
|
| 22 |
|
| 23 |
+
## Model Description
|
| 24 |
+
|
| 25 |
+
This model was trained on the Canadian Election Study (CES) 2021 to predict self-reported ideology (0-10 left-right scale) from:
|
| 26 |
+
|
| 27 |
+
- **Demographics**: Age, gender, province, education, employment, religion, marital status, urban/rural, born in Canada
|
| 28 |
+
- **Leader Thermometers**: Ratings (0-100) of Justin Trudeau, Erin O'Toole, and Jagmeet Singh
|
| 29 |
+
- **Wedge Issues**: Positions on carbon tax, energy/pipelines, and medical assistance in dying (MAID)
|
| 30 |
+
- **Government Satisfaction**: Overall satisfaction with federal government
|
| 31 |
|
| 32 |
+
## Performance
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
| Model | Inputs | Correlation (r) |
|
| 35 |
+
|-------|--------|-----------------|
|
| 36 |
+
| Base Llama 8B | Demographics only | 0.03 |
|
| 37 |
+
| GPT-4o-mini | Demographics only | 0.285 |
|
| 38 |
+
| Phase 1 | Demographics only | 0.213 |
|
| 39 |
+
| Phase 2 | + Gov satisfaction, economy, immigration | 0.428 |
|
| 40 |
+
| **Phase 3A (this model)** | **+ Leader thermometers + wedge issues** | **0.560** |
|
| 41 |
+
| Phase 3B | + Party ID | 0.574 |
|
| 42 |
|
| 43 |
## Key Finding: "The Null Result of the Label"
|
| 44 |
|
| 45 |
+
We trained two versions of Phase 3:
|
| 46 |
+
- **Phase 3A** (this model): Uses leader ratings and policy positions, but NOT party identification
|
| 47 |
+
- **Phase 3B**: Adds party identification ("I usually think of myself as a Liberal/Conservative...")
|
| 48 |
+
|
| 49 |
+
**Result**: Adding party ID only improves correlation by 0.014 (from 0.560 to 0.574).
|
| 50 |
|
| 51 |
**What this means:**
|
| 52 |
- Party identity is **redundant** — it's already encoded in how people feel about leaders and their policy positions
|
| 53 |
- Canadian ideology is **substantive, not tribal** — people's "team" reflects their actual views
|
| 54 |
+
- **Phase 3A is preferred** — predicts ideology without "cheating" by asking party affiliation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
## Usage
|
| 57 |
|
|
|
|
| 65 |
)
|
| 66 |
model = PeftModel.from_pretrained(base_model, "baglecake/ces-phase3a-lora")
|
| 67 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
|
| 68 |
+
|
| 69 |
+
# Example prompt
|
| 70 |
+
system = """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. You were born in Canada.
|
| 71 |
+
|
| 72 |
+
Political Profile:
|
| 73 |
+
Leader Ratings: Justin Trudeau: 25/100, Erin O'Toole: 70/100, Jagmeet Singh: 30/100.
|
| 74 |
+
Views: Strongly disagrees that the federal government should continue the carbon tax; strongly agrees that the government should do more to help the energy sector/pipelines.
|
| 75 |
+
Overall Satisfaction: Is not at all satisfied with the federal government.
|
| 76 |
+
|
| 77 |
+
Answer survey questions as this person would, based on their background and detailed political profile."""
|
| 78 |
+
|
| 79 |
+
user = "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."
|
| 80 |
+
|
| 81 |
+
# Format as Llama chat and generate
|
| 82 |
```
|
| 83 |
|
| 84 |
+
## Steerability
|
| 85 |
+
|
| 86 |
+
The model is steerable — changing leader ratings and policy positions shifts predicted ideology:
|
| 87 |
+
|
| 88 |
+
| Profile | Trudeau | O'Toole | Carbon Tax | Predicted |
|
| 89 |
+
|---------|---------|---------|------------|-----------|
|
| 90 |
+
| Liberal | 85/100 | 15/100 | Strongly agree | 3 (left) |
|
| 91 |
+
| Conservative | 10/100 | 90/100 | Strongly disagree | 8 (right) |
|
| 92 |
+
| Moderate | 50/100 | 55/100 | Neutral | 6 (center) |
|
| 93 |
+
|
| 94 |
+
**5-point ideology swing** from profile changes alone, holding demographics constant.
|
| 95 |
+
|
| 96 |
## Training Details
|
| 97 |
|
| 98 |
- **Base model**: meta-llama/Meta-Llama-3.1-8B-Instruct (4-bit quantized via Unsloth)
|
| 99 |
+
- **Training data**: 14,452 examples from CES 2021
|
| 100 |
- **LoRA rank**: 32
|
| 101 |
- **LoRA alpha**: 64
|
| 102 |
+
- **Target modules**: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
|
| 103 |
- **Epochs**: 3
|
| 104 |
- **Hardware**: NVIDIA A100 40GB (Colab Pro)
|
| 105 |
|
| 106 |
+
## Implications
|
| 107 |
+
|
| 108 |
+
This model is ideal for:
|
| 109 |
+
- Simulating political discourse with leader-specific affect
|
| 110 |
+
- Agent-based models where leader ratings drive polarization
|
| 111 |
+
- Studying how policy positions (not just party labels) shape ideology
|
| 112 |
+
|
| 113 |
+
Not suitable for:
|
| 114 |
+
- General political conversation (model only outputs 0-10 numbers)
|
| 115 |
+
- Elections with different leaders (trained on 2021 Trudeau/O'Toole/Singh)
|
| 116 |
+
- Predicting specific budget or policy preferences
|
| 117 |
+
|
| 118 |
## Limitations
|
| 119 |
|
| 120 |
+
1. **Narrow task**: Model only outputs ideology numbers (0-10). Not suitable for general political conversation.
|
| 121 |
2. **Canadian-specific**: Trained on CES 2021 under Trudeau government.
|
| 122 |
+
3. **Leader-specific**: Uses 2021 leader names (Trudeau, O'Toole, Singh). Would need adaptation for different elections.
|
| 123 |
|
| 124 |
## Citation
|
| 125 |
|