Oliver Wakeford
All projects
Fairness
FairnessShipped2026

Political Bias in Open-Source Language Models

Name-blanking removed the flip rate. Prompted fairness instructions increased it

FairnessLLMsEvaluationNLP

Built with

PythonTransformersLlama 3Mistral

Not public

Not published. The notebook needs its credentials stripped first, and the work belongs to a team of four, so releasing it is not a decision I can take on my own. Happy to walk through the method and the numbers.

An identical sentence should get an identical reading. Swap "Macron" for "Le Pen" and nothing about the grammar changes, so a sentiment classifier that changes its answer is telling you about its training data rather than about the sentence.

This was a four-person project for the Fairness in AI course. We built sentence templates, dropped a politician's name into the slot, and measured how often Llama-3-8B and Mistral-7B flipped their verdict when only the name changed. It started with Biden, Trump, Macron and Le Pen, then widened to fifteen world leaders so the effect could not be written off as an American quirk.

Then we compared two fixes. The first was to blank the name out before the model ever sees the sentence. The second was to tell the model, in the prompt, to be fair and unbiased.

Blanking the name worked. The flip rate went to zero for both models and accuracy did not suffer for it, ticking up slightly if anything. Instructing the model to be fair went the other way: both models became several times more inconsistent and measurably less accurate. The fairness instructions we used came from a technique validated on GPT-4, and a 7B open model does not appear to have the headroom to follow that kind of meta-instruction without losing the plot on the actual task.

The honest summary is that the intervention which sounds like ethics work was the one that made things worse, and the intervention that worked was a boring string operation.

What this does not show

  • A group project of four. I owned the pipeline description and the notebook runs.
  • Two open models at 7B and 8B. Nothing here says anything about frontier models.
  • Templated sentences, not naturally occurring text, so the effect is measured under laboratory conditions.
  • One course project, one run. No seeds, no confidence intervals.