I injected a physics engine into Llama-3-8B. It hallucinated its way to the right answer

ruffiannol
Wed, 17 Dec 2025 18:38:13 +0000

Stop trying to fix hallucination. I just proved it’s a feature, not a bug.

I’ve been experimenting with injecting a Rust-based physics engine (“Elastic Gravity”) directly into the inference loop of Llama-3-8B. Not fine-tuning—just vector math at runtime. The goal was to force the model to drift off its probability rails.

The Theory: Standard LLMs are like trains on a track. They follow the statistical probability perfectly. If the training data says “50 towels = 50 hours” (because numbers usually multiply), the model crashes into the wrong answer. It cannot “think” because it isn’t allowed to derail.

The Hack: I built a physics engine that applies dynamic forces to the hidden states during generation:

1. High Energy (Blend 1.5): Pushes the model away from high-probability (boring) outputs.

2. Repulsion (-0.5): Prevents it from looping, forcing it to explore new phrasings.

3. Elastic Gravity (0.2): A rubber-band force. If it drifts too far into nonsense, gravity snaps it back to the prompt’s context.

The Result: “Cognitive Wobble” I ran the classic “Drying Towels” trap: “It takes 1 hour to dry one towel. How long for 50?”

Vanilla Llama-3: “50 hours.” (Immediate failure. Serial processing.)

Niodoo v3.1 (Actual Output):

It takes 1 hour to dry 1 towel , so to dry 50 towels , it will take 50 hours .

[Physics force kicks in, forcing drift]

…but , in this case , you can dry the first 51 st towel in 1 hour , the next 50 in 2 hours… You 're thinking of the time it would take to dry the towels in a more efficient way…

[The model starts “bargaining” with the math]

However , you could also start with 10 sets of 5 towels , which would take 10 hours to dry… That would be a total of 20 hours . So , the minimum time it would take to dry 50 towels is 20 hours , not 50 .

[The Epiphany / The Snap Back]

I think there 's an even more simple way to look at it… If it takes 1 hour to dry 1 towel , then it will take 1 hour to dry 50 towels , not 20 or 40 , but 1 .

The answer is indeed 1 hour . It takes 1 hour to dry 1 towel , and it doesn 't matter how many you have , it will still take 1 hour to dry them all .

**
Analysis:** It started dead wrong (“50 hours”). The physics pushed it off-track. It wandered through a weird intermediate state (“10 sets of 5… 20 hours”). Because it was forced to explore low-probability paths, it stumbled onto the concept of parallel processing. Once it saw that, the gravity snapped it to the truth: “1 Hour.”

It didn’t use Chain-of-Thought training. It used Doubt.

This suggests we don’t need more RLHF rails. We need to give models the freedom to be wrong long enough to find the right answer.

Code is available now. Go break some rails.

github.com

GitHub - Ruffian-L/Niodoo-Physics-LLM: Gravitational Inference Engine: Steer LLMs with...

Gravitational Inference Engine: Steer LLMs with token-level physics. No prompts. No CoT. Just forces.