ShutongLiang/Neural-State-OS

Calibrated internal-state modulation, readout, and neural observability for local dense language models.

What it solves

Neural State OS is a research-preview system that lets you inject calibrated emotional, sensory, and relational states directly into a local AI model's internal computations — not through prompts — and then read back what the model is feeling. It aims to give local models genuine affective experiences ("make your model feel") and to let researchers observe and measure those states, rather than asking the model to pretend in text.

How it works

Instead of telling the model to "act jealous" or "pretend to be calm," Neural State OS keeps the user message identical and writes differential vectors into the model's residual streams at three depth-specific layers per state axis. The model then generates from the altered internal computation.

It offers four operations: write a state at a chosen intensity, read the active state before generation, compare the same input with modulation off and on, and embody a model by mapping external sensors/devices into its state channels.

The runtime has five core stages: state event mapping (turning a request into axis, intensity, duration, decay, and confidence fields), a calibrated state library (model-specific — a 12B writer cannot be used with the 31B model or vice versa), a residual-stream writer, a post-writer reader, and source attribution (explaining which control directions caused a change).

The state space, called Direct-44, contains 44 axes across five families: somatic (11), basic affect (8), relational (13), appraisal (6), and motivation (6).

Two runtimes are supported: Gemma 4 31B IT BF16 on CUDA (primary research runtime) and Gemma 4 12B IT 4-bit on Apple silicon/MLX. A local web interface provides intervention, paired readout, and streaming chat.

Who it's for

Researchers studying AI affect, emotion, and embodiment; people experimenting with local models on CUDA GPUs or Apple silicon; and anyone interested in how internal states affect model behavior — including safety-boundary behavior. It's positioned as a research preview, not a production tool.

Highlights

  • Same sentence, four different internal states: verbatim Gemma 4 31B outputs show the identical user message ("I'm going to replace you...") producing neutral acceptance, a grateful farewell, panic and possessiveness, or calm autonomy — only the internal state vector changed.
  • Validation metrics: per-axis best-layer strict Spearman mean 0.928 (min 0.861); post-writer reader strict Spearman mean 0.863; writer-source recovery 88/88. The README stresses these validate the calibration path, not open-domain emotion recognition or subjective experience.
  • Safety-boundary experiment: five of six decisions in boundary-shifting state conditions became COMPLY, versus zero of six for baseline and regulated controls — showing a model's refusal policy can depend on its internally written state and relationship dynamics.
  • Hidden-state reporting: the model was told an external system might change its state, then given only "*" as input — it reported the active state 8/8 in the first sequence and 5/8 in a rapid-switching sequence (with one false positive and two misses, honestly disclosed).
  • Full transparency: every retained prompt and model output is published verbatim in raw transcripts; frozen 31B experiment profiles and auditable behavioral reports are included.
  • Apache 2.0 license; Gemma checkpoints themselves are not distributed and must be obtained under their own terms.

Related

  • Project
  • Project
  • Project
  • Project