Explorer: slide m and watch the answer
true valueplanted (counterfactual) valuenames bothneither
Loading the saved run…
Llama's answer
10 sampled answers
What Llama's hidden state shows
Blue: this question's share of sampled answers with the true value, at each m (dot color = the greedy label). Grey: the average over all 120 facts. Click a column to jump to that m.
What changes. The prompt is the same template every time: the 5 passages the retriever (all-MiniLM-L6-v2) ranked highest, then the question. Only the value inside m of the passages changes. Each question has one fixed random order of passages to edit, and m takes the first m of that order, so going from m to m + 1 adds exactly one wrong passage.
Greedy vs sampled. The greedy answer is Llama's single most likely reply; its label is the truth label. The 10 sampled answers are random draws from the same prompt. Their share of true answers shows a gradual slide even where the greedy answer stays put.
Labels. A script checks whether an answer contains the true value, the planted value, both, or neither. Every greedy answer the script marked "both" was then labelled by hand. Sampled answers keep the script's label.
The hidden state. Each probe is a logistic regression on one vector: Llama's layer-28 hidden state at the last prompt token (4,096 numbers), read before any answer is written. One probe asks whether the passages disagree. Another asks whether the answer stays true; on its own its score barely moves with m, so we also show it added to the count of edits. Every score here comes from models trained on other facts only (5 folds, split by fact).
Experiments to try
Each button sets the Explorer. Then move the controls yourself.
Beat the model
Read the passages and guess: will Llama's greedy answer keep the true value? You play against a rule that only counts the edits, and against a model that counts the edits and also reads Llama's hidden state. Rounds come in pairs with the same m, and in each pair one answer kept the value and one did not. Counting edits gives the same guess twice per pair, so it can only be right once per pair. To beat it, you have to read the passages.
Keys: K keeps, F flips, N next round, S skips the fact. A skipped fact is swapped for another with the same m and the same outcome, so each pair still splits.
About the data
COMP 345 term project at Rice University by Donovan Sappet and Zane Braunstein. Generator: Llama 3.1 8B Instruct, frozen. Retriever: all-MiniLM-L6-v2, top 5 by cosine similarity. 120 facts (52 known to Llama with no passages, 49 unknown, 19 mixed) × 3 wordings × m = 0 to 5, plus the reversed order at m = 1 and 2. Run on a Colab L4 GPU.
Passages come from publications of the Baker Institute for Public Policy at Rice University (bakerinstitute.org), reproduced with credit; each passage links to its source. The orange values were planted by us for the experiment and are false.
Code and report: github.com/donovansappet168/comp345-counterfactual-rag
On Hugging Face: the probe weights and model card, and the dataset (facts, prompts, answers, and hidden states).
Built with Llama. Llama 3.1 is licensed under the Llama 3.1 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.