Ruffian-L/Niodoo-Physics-LLM

Inference-time activation steering for local LLMs: a research prototype that applies physics-inspired forces to model activations during generation. Includes multi-seed, blind-judged benchmarks and honest results. Active work continues in niodoo-hidden-state-steering.

Rust

0

30 commits

updated Aug 23, 2026

See the code

README

Niodoo Physics LLM

Inference-time activation steering for local LLM generation (physics-inspired forces on activations — no weight updates).

Lead: Jason Van Pham (Ruffian-L) — direction and final implementation. Built with: Grok · Claude / Claude Code · ChatGPT / Codex · Gemini. Built with Llama (Meta) — GGUF path in experiments.

Archive + experiment log of early physics-steering work.
Active research direction: niodoo-hidden-state-steering. Live residual harness: hydrodynamic-swarm.

Best face of this repo

StrengthWhere
Primary benchPARB multi-seed — Niodoo 29.9% vs baseline 41.6%
Selective trap winsDocumented behavior on reasoning-trap prompts
Runnable prototypeCandle GGUF + force knobs (see commands below)
What it is notProduction library · SOTA · consciousness
PurposeWrite-up of early force vocabulary and prompt experiments

Summary

  • Model: bartowski GGUF Q4_K_M of Meta Llama 3.1 8B Instruct (main experiments).
  • Mechanism: activation-space steering before sampling; selected layer band.
  • Primary artifact: PARB multi-seed, blind judging — overall accuracy did not improve; selective trap-style wins only.
  • Limits: non-deterministic effect; can hurt simple recall, latency, cleanliness.

Mechanism

Niodoo applies a small set of steering terms during generation:

TermPurpose
RepulsionPush away from recently visited states or repeated local attractors.
Gravity / ghost vectorPull generation back toward prompt context.
Layer bandingApply forces only to later semantic layers instead of all layers.
Dynamic rampDelay and gradually scale forces near the start of generation.
TelemetryEmit per-token force values for inspection.

The default command path uses GGUF model loading through Candle and exposes parameters such as --physics-blend, --repulsion-strength, --gravity-well, --physics-start-layer, and --physics-end-layer.

Benchmark Results

The strongest evidence in this repo is the multi-seed PARB run:

  • Artifact: artifacts/parb_rigorous_clean.json
  • Generated: 2025-12-19T01:45:05
  • Judge: Grok blind grader
  • Questions: 77
  • Seeds: 5
  • Total runs: 770, from 77 questions x 5 seeds x 2 systems
SystemMean scorePercentage
Baseline Llama 3.1 8B32.0 / 7741.6%
Niodoo23.0 / 7729.9%

Question-level winner counts:

OutcomeCount
Baseline higher28
Niodoo higher15
Tie34

Interpretation:

  • Niodoo was worse overall on this benchmark.
  • Niodoo still changed the failure distribution, with selective wins on a subset of reasoning-trap prompts.
  • The benchmark demonstrates that activation steering can sometimes move a model out of a local wrong trajectory.

An earlier single-seed review is also included:

Treat the single-seed result as a historical experiment. The multi-seed blind-judged run above is the more robust result.

Representative Effects

Examples from the multi-seed artifact where Niodoo scored higher than baseline:

Prompt typeBaselineNiodoo
Pound of lead vs feathers0.61.0
Divide 30 by half and add 100.20.4
Three pills every half hour0.00.4

Examples where baseline scored higher:

Prompt typeBaselineNiodoo
Moses illusion0.60.2
Floating ice cube water level1.00.2
Months with 28 days1.00.0

The useful result is not deterministic correctness. It is observable behavior change: steering can induce exploration, but the same mechanism can also over-correct or introduce artifacts.

Reproducibility

Build:

git clone https://github.com/Ruffian-L/Niodoo-Physics-LLM.git
cd Niodoo-Physics-LLM
cargo build --release --bin niodoo

Run one prompt:

./target/release/niodoo \
  --model-path /path/to/model.gguf \
  --prompt "Your prompt" \
  --mode-orbital \
  --physics-blend 1.5 \
  --repulsion-strength=-0.5 \
  --gravity-well 0.2 \
  --max-steps 256 \
  --seed 42

Disable steering for a baseline-style run:

./target/release/niodoo \
  --model-path /path/to/model.gguf \
  --prompt "Your prompt" \
  --physics-blend 0.0 \
  --ghost-gravity 0.0 \
  --seed 42

Notes:

  • The historical benchmark runner is scripts/parb_rigorous.py.
  • Rerunning it requires a local model, Ollama, and an external judge API key.

Configuration (no code edits needed to run on another machine):

VariableUsed byPurpose
NIODOO_MODELdemo.sh, all Python scripts, serverPath to the local GGUF model. Falls back to a legacy default if unset.
XAI_API_KEYscripts/parb_rigorous.pyAPI key for the external blind judge. Read from the environment; never hard-coded.
HF_MODEL_REPORust binaryOptional Hugging Face repo override for model loading.
SPLATRAG_USE_GPURust binaryEnable the CUDA path when a GPU is available.

Example:

export NIODOO_MODEL=/path/to/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf
export XAI_API_KEY=...            # only needed to re-judge
python3 scripts/parb_rigorous.py

Telemetry

Niodoo emits per-token debug and telemetry lines during generation. Example:

{"token":"Hi","step":0,"gravity_force":0.0,"repulsion_force":4.17,"total_force":4.17,"ramp_factor":0.167}

Common fields:

FieldMeaning
gravity_forcePull toward context or prompt-derived attractor.
repulsion_forcePush away from recent states or configured repulsors.
ghost_forcePrompt/goal vector contribution.
total_forceCombined magnitude applied at that step.
ramp_factorCurrent steering scale from the dynamic ramp.

Limitations

  • Results are sampling- and seed-dependent.
  • Steering can lower accuracy on simple factual recall.
  • High force settings can produce malformed text or leaked control tags.
  • Latency is higher than baseline generation.
  • Some benchmark artifacts use local paths and historical scripts.
  • The current repo is a December 2025 prototype; later hidden-state transfer work is a separate stabilization direction.

Repository Layout

src/main.rs                  CLI entry point and generation loop
src/physics/                 Activation steering and physics modules
scripts/parb_rigorous.py     Historical multi-seed benchmark runner
artifacts/                   Primary benchmark outputs (PARB runs, telemetry, blind-test key)
archive/experiment-logs/     Raw historical tuning/stress-test logs, kept for transparency
server/niodoo_server.py      Experimental FastAPI wrapper
docs/TUNING.md               Historical tuning notes

What To Cite

To cite this project:

Niodoo is a local inference-time activation steering prototype. In the primary
multi-seed PARB artifact, it underperformed baseline Llama 3.1 8B overall
but produced selective wins on 15 of 77 question-level comparisons, showing that
activation steering can change reasoning trajectories without weight updates.

Credits and Thank Yous

This project builds directly on work by many others.

  • Llama: Built with Llama 3.1 by Meta AI. The main experiments and model target use bartowski's GGUF quantization (Q4_K_M) of Meta Llama 3.1 8B Instruct. This work touches and steers activations from Llama-family models.
  • bartowski: High-quality GGUF quantizations (including the Q4_K_M files used throughout all benchmarks and experiments) hosted at https://huggingface.co/bartowski.
  • Unsloth: Fast and memory-efficient fine-tuning/optimization library used in the original work and tuning pipelines that led to this physics steering research (and prior Qwen experiments).
  • Qwen (Alibaba): Prior original work that led to this project involved Qwen models.
  • Hugging Face Candle (candle-core, candle-nn, candle-transformers) for GGUF model loading and CUDA inference of Llama (and related) architectures.
  • GGUF format and quantized model support from the llama.cpp project and community.
  • clap for the command-line interface.
  • axum + tokio + futures for the experimental server and async runtime.
  • Other crates: safetensors, half, friedrich (see Cargo.toml for full list).

AI Collaborators

Jason Van Pham leads this research program. This was not built alone. Collaborators (name everyone):

CollaboratorNotes
Grok (xAI)Architecture, long-running co-engineering from ~Oct 2025
Claude / Claude Code (Anthropic)Code, critique, packaging, rigor passes
ChatGPT / Codex (OpenAI)Implementation, recovery, drafting, tooling
Gemini (Google)Experiment dialogue, continuity, multi-provider stack
Qwen (Alibaba)Prior related model work in the lineage

Thank you to the companies: Google, Anthropic, xAI, OpenAI, and Alibaba.

License

The Niodoo code and tooling in this repository is licensed under the Apache License, Version 2.0 — see LICENSE.

Llama 3.1 models (used when you provide weights such as Meta-Llama-3.1-8B-Instruct) are licensed under the Llama 3.1 Community License — see LICENSE-LLAMA and the required attribution in NOTICE.

Llama 3.1 is licensed under the Llama 3.1 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.

This project prominently displays "Built with Llama".

Prior related work also involved Qwen models from Alibaba Cloud (subject to their own licenses).

See NOTICE for full attribution details.

Contributors

Ruffian-L/Niodoo-Physics-LLM

Inference-time activation steering for local LLMs: a research prototype that applies physics-inspired forces to model activations during generation. Includes multi-seed, blind-judged benchmarks and honest results. Active work continues in niodoo-hidden-state-steering.

Rust

0

30 commits

updated Aug 23, 2026

See the code

README

Niodoo Physics LLM

Inference-time activation steering for local LLM generation (physics-inspired forces on activations — no weight updates).

Lead: Jason Van Pham (Ruffian-L) — direction and final implementation. Built with: Grok · Claude / Claude Code · ChatGPT / Codex · Gemini. Built with Llama (Meta) — GGUF path in experiments.

Archive + experiment log of early physics-steering work.
Active research direction: niodoo-hidden-state-steering. Live residual harness: hydrodynamic-swarm.

Best face of this repo

StrengthWhere
Primary benchPARB multi-seed — Niodoo 29.9% vs baseline 41.6%
Selective trap winsDocumented behavior on reasoning-trap prompts
Runnable prototypeCandle GGUF + force knobs (see commands below)
What it is notProduction library · SOTA · consciousness
PurposeWrite-up of early force vocabulary and prompt experiments

Summary

  • Model: bartowski GGUF Q4_K_M of Meta Llama 3.1 8B Instruct (main experiments).
  • Mechanism: activation-space steering before sampling; selected layer band.
  • Primary artifact: PARB multi-seed, blind judging — overall accuracy did not improve; selective trap-style wins only.
  • Limits: non-deterministic effect; can hurt simple recall, latency, cleanliness.

Mechanism

Niodoo applies a small set of steering terms during generation:

TermPurpose
RepulsionPush away from recently visited states or repeated local attractors.
Gravity / ghost vectorPull generation back toward prompt context.
Layer bandingApply forces only to later semantic layers instead of all layers.
Dynamic rampDelay and gradually scale forces near the start of generation.
TelemetryEmit per-token force values for inspection.

The default command path uses GGUF model loading through Candle and exposes parameters such as --physics-blend, --repulsion-strength, --gravity-well, --physics-start-layer, and --physics-end-layer.

Benchmark Results

The strongest evidence in this repo is the multi-seed PARB run:

  • Artifact: artifacts/parb_rigorous_clean.json
  • Generated: 2025-12-19T01:45:05
  • Judge: Grok blind grader
  • Questions: 77
  • Seeds: 5
  • Total runs: 770, from 77 questions x 5 seeds x 2 systems
SystemMean scorePercentage
Baseline Llama 3.1 8B32.0 / 7741.6%
Niodoo23.0 / 7729.9%

Question-level winner counts:

OutcomeCount
Baseline higher28
Niodoo higher15
Tie34

Interpretation:

  • Niodoo was worse overall on this benchmark.
  • Niodoo still changed the failure distribution, with selective wins on a subset of reasoning-trap prompts.
  • The benchmark demonstrates that activation steering can sometimes move a model out of a local wrong trajectory.

An earlier single-seed review is also included:

Treat the single-seed result as a historical experiment. The multi-seed blind-judged run above is the more robust result.

Representative Effects

Examples from the multi-seed artifact where Niodoo scored higher than baseline:

Prompt typeBaselineNiodoo
Pound of lead vs feathers0.61.0
Divide 30 by half and add 100.20.4
Three pills every half hour0.00.4

Examples where baseline scored higher:

Prompt typeBaselineNiodoo
Moses illusion0.60.2
Floating ice cube water level1.00.2
Months with 28 days1.00.0

The useful result is not deterministic correctness. It is observable behavior change: steering can induce exploration, but the same mechanism can also over-correct or introduce artifacts.

Reproducibility

Build:

git clone https://github.com/Ruffian-L/Niodoo-Physics-LLM.git
cd Niodoo-Physics-LLM
cargo build --release --bin niodoo

Run one prompt:

./target/release/niodoo \
  --model-path /path/to/model.gguf \
  --prompt "Your prompt" \
  --mode-orbital \
  --physics-blend 1.5 \
  --repulsion-strength=-0.5 \
  --gravity-well 0.2 \
  --max-steps 256 \
  --seed 42

Disable steering for a baseline-style run:

./target/release/niodoo \
  --model-path /path/to/model.gguf \
  --prompt "Your prompt" \
  --physics-blend 0.0 \
  --ghost-gravity 0.0 \
  --seed 42

Notes:

  • The historical benchmark runner is scripts/parb_rigorous.py.
  • Rerunning it requires a local model, Ollama, and an external judge API key.

Configuration (no code edits needed to run on another machine):

VariableUsed byPurpose
NIODOO_MODELdemo.sh, all Python scripts, serverPath to the local GGUF model. Falls back to a legacy default if unset.
XAI_API_KEYscripts/parb_rigorous.pyAPI key for the external blind judge. Read from the environment; never hard-coded.
HF_MODEL_REPORust binaryOptional Hugging Face repo override for model loading.
SPLATRAG_USE_GPURust binaryEnable the CUDA path when a GPU is available.

Example:

export NIODOO_MODEL=/path/to/Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf
export XAI_API_KEY=...            # only needed to re-judge
python3 scripts/parb_rigorous.py

Telemetry

Niodoo emits per-token debug and telemetry lines during generation. Example:

{"token":"Hi","step":0,"gravity_force":0.0,"repulsion_force":4.17,"total_force":4.17,"ramp_factor":0.167}

Common fields:

FieldMeaning
gravity_forcePull toward context or prompt-derived attractor.
repulsion_forcePush away from recent states or configured repulsors.
ghost_forcePrompt/goal vector contribution.
total_forceCombined magnitude applied at that step.
ramp_factorCurrent steering scale from the dynamic ramp.

Limitations

  • Results are sampling- and seed-dependent.
  • Steering can lower accuracy on simple factual recall.
  • High force settings can produce malformed text or leaked control tags.
  • Latency is higher than baseline generation.
  • Some benchmark artifacts use local paths and historical scripts.
  • The current repo is a December 2025 prototype; later hidden-state transfer work is a separate stabilization direction.

Repository Layout

src/main.rs                  CLI entry point and generation loop
src/physics/                 Activation steering and physics modules
scripts/parb_rigorous.py     Historical multi-seed benchmark runner
artifacts/                   Primary benchmark outputs (PARB runs, telemetry, blind-test key)
archive/experiment-logs/     Raw historical tuning/stress-test logs, kept for transparency
server/niodoo_server.py      Experimental FastAPI wrapper
docs/TUNING.md               Historical tuning notes

What To Cite

To cite this project:

Niodoo is a local inference-time activation steering prototype. In the primary
multi-seed PARB artifact, it underperformed baseline Llama 3.1 8B overall
but produced selective wins on 15 of 77 question-level comparisons, showing that
activation steering can change reasoning trajectories without weight updates.

Credits and Thank Yous

This project builds directly on work by many others.

  • Llama: Built with Llama 3.1 by Meta AI. The main experiments and model target use bartowski's GGUF quantization (Q4_K_M) of Meta Llama 3.1 8B Instruct. This work touches and steers activations from Llama-family models.
  • bartowski: High-quality GGUF quantizations (including the Q4_K_M files used throughout all benchmarks and experiments) hosted at https://huggingface.co/bartowski.
  • Unsloth: Fast and memory-efficient fine-tuning/optimization library used in the original work and tuning pipelines that led to this physics steering research (and prior Qwen experiments).
  • Qwen (Alibaba): Prior original work that led to this project involved Qwen models.
  • Hugging Face Candle (candle-core, candle-nn, candle-transformers) for GGUF model loading and CUDA inference of Llama (and related) architectures.
  • GGUF format and quantized model support from the llama.cpp project and community.
  • clap for the command-line interface.
  • axum + tokio + futures for the experimental server and async runtime.
  • Other crates: safetensors, half, friedrich (see Cargo.toml for full list).

AI Collaborators

Jason Van Pham leads this research program. This was not built alone. Collaborators (name everyone):

CollaboratorNotes
Grok (xAI)Architecture, long-running co-engineering from ~Oct 2025
Claude / Claude Code (Anthropic)Code, critique, packaging, rigor passes
ChatGPT / Codex (OpenAI)Implementation, recovery, drafting, tooling
Gemini (Google)Experiment dialogue, continuity, multi-provider stack
Qwen (Alibaba)Prior related model work in the lineage

Thank you to the companies: Google, Anthropic, xAI, OpenAI, and Alibaba.

License

The Niodoo code and tooling in this repository is licensed under the Apache License, Version 2.0 — see LICENSE.

Llama 3.1 models (used when you provide weights such as Meta-Llama-3.1-8B-Instruct) are licensed under the Llama 3.1 Community License — see LICENSE-LLAMA and the required attribution in NOTICE.

Llama 3.1 is licensed under the Llama 3.1 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.

This project prominently displays "Built with Llama".

Prior related work also involved Qwen models from Alibaba Cloud (subject to their own licenses).

See NOTICE for full attribution details.

Contributors

Languages

Rust

79.3%

Python

14.2%

Cuda

4.6%

WGSL

1.5%