Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -16,32 +16,86 @@ language:
|
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
-
# CES Phase 3B LoRA: With Party
|
| 20 |
|
| 21 |
-
LoRA adapter that
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
## Performance
|
| 24 |
|
| 25 |
-
| Model |
|
| 26 |
-
|-------|-----------
|
| 27 |
-
| Phase
|
| 28 |
-
|
|
|
|
|
| 29 |
|
| 30 |
-
**Partisan Delta = 0.014**
|
| 31 |
|
| 32 |
## Why Phase 3A is Preferred
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
## Training Details
|
| 39 |
|
| 40 |
- **Base model**: meta-llama/Meta-Llama-3.1-8B-Instruct (4-bit quantized via Unsloth)
|
| 41 |
-
- **Training data**:
|
| 42 |
- **LoRA rank**: 32
|
| 43 |
- **LoRA alpha**: 64
|
|
|
|
| 44 |
- **Epochs**: 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## Citation
|
| 47 |
|
|
|
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# CES Phase 3B LoRA: With Party Identification
|
| 20 |
|
| 21 |
+
A LoRA adapter for Llama 3.1 8B Instruct that predicts political ideology using party identification in addition to leader ratings and policy positions.
|
| 22 |
+
|
| 23 |
+
**For most use cases, prefer [Phase 3A](https://huggingface.co/baglecake/ces-phase3a-lora) instead** — this model exists to demonstrate that party ID is redundant.
|
| 24 |
+
|
| 25 |
+
## Model Description
|
| 26 |
+
|
| 27 |
+
This model was trained on the Canadian Election Study (CES) 2021 to predict self-reported ideology (0-10 left-right scale) from:
|
| 28 |
+
|
| 29 |
+
- **Demographics**: Age, gender, province, education, employment, religion, marital status, urban/rural, born in Canada
|
| 30 |
+
- **Leader Thermometers**: Ratings (0-100) of Justin Trudeau, Erin O'Toole, and Jagmeet Singh
|
| 31 |
+
- **Wedge Issues**: Positions on carbon tax, energy/pipelines, and medical assistance in dying (MAID)
|
| 32 |
+
- **Government Satisfaction**: Overall satisfaction with federal government
|
| 33 |
+
- **Party Identification**: "I usually think of myself as a Liberal/Conservative/NDP..." (ONLY IN THIS MODEL)
|
| 34 |
|
| 35 |
## Performance
|
| 36 |
|
| 37 |
+
| Model | Inputs | Correlation (r) |
|
| 38 |
+
|-------|--------|-----------------|
|
| 39 |
+
| Phase 2 | Demographics + 3 psychographics | 0.428 |
|
| 40 |
+
| Phase 3A | + Leader thermometers + wedge issues | 0.560 |
|
| 41 |
+
| **Phase 3B (this model)** | **+ Party ID** | **0.574** |
|
| 42 |
|
| 43 |
+
**Partisan Delta = 0.014** — Party ID adds only 1.4% improvement.
|
| 44 |
|
| 45 |
## Why Phase 3A is Preferred
|
| 46 |
|
| 47 |
+
We trained this model (Phase 3B) specifically to test whether party identification adds predictive value beyond substantive attitudes. It doesn't.
|
| 48 |
+
|
| 49 |
+
**The null result is the finding:**
|
| 50 |
+
- Party identity is **redundant** — it's already encoded in how people feel about leaders and their policy positions
|
| 51 |
+
- Canadian ideology is **substantive, not tribal** — people's "team" reflects their actual views
|
| 52 |
+
- Adding party ID is "cheating" — you're just asking people their ideology with extra steps
|
| 53 |
+
|
| 54 |
+
Phase 3B exists for reproducibility and to demonstrate this null result empirically.
|
| 55 |
+
|
| 56 |
+
## Usage
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
from peft import PeftModel
|
| 60 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 61 |
|
| 62 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 63 |
+
"meta-llama/Meta-Llama-3.1-8B-Instruct",
|
| 64 |
+
load_in_4bit=True
|
| 65 |
+
)
|
| 66 |
+
model = PeftModel.from_pretrained(base_model, "baglecake/ces-phase3b-lora")
|
| 67 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct")
|
| 68 |
+
|
| 69 |
+
# Example prompt (note: includes party ID)
|
| 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 |
+
Party ID: Generally thinks of themselves as a Conservative.
|
| 77 |
+
|
| 78 |
+
Answer survey questions as this person would, based on their background and detailed political profile."""
|
| 79 |
+
|
| 80 |
+
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."
|
| 81 |
+
```
|
| 82 |
|
| 83 |
## Training Details
|
| 84 |
|
| 85 |
- **Base model**: meta-llama/Meta-Llama-3.1-8B-Instruct (4-bit quantized via Unsloth)
|
| 86 |
+
- **Training data**: 14,455 examples from CES 2021
|
| 87 |
- **LoRA rank**: 32
|
| 88 |
- **LoRA alpha**: 64
|
| 89 |
+
- **Target modules**: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
|
| 90 |
- **Epochs**: 3
|
| 91 |
+
- **Hardware**: NVIDIA A100 40GB (Colab Pro)
|
| 92 |
+
|
| 93 |
+
## Limitations
|
| 94 |
+
|
| 95 |
+
1. **Narrow task**: Model only outputs ideology numbers (0-10).
|
| 96 |
+
2. **Canadian-specific**: Trained on CES 2021 under Trudeau government.
|
| 97 |
+
3. **Leader-specific**: Uses 2021 leader names.
|
| 98 |
+
4. **Redundant information**: Party ID doesn't add meaningful predictive value over Phase 3A.
|
| 99 |
|
| 100 |
## Citation
|
| 101 |
|