FlyBrain-Pollard-CNSv1

A fruit fly's brain, carrying a language model's memory

A transformer's memory is its KV cache. It grows with every token, and when the context window fills, the oldest tokens are gone β€” not compressed, not summarised, gone.

A fruit fly has about 190,000 neurons and no context window.

FlyBrain attaches a real fruit-fly connectome to a frozen language model as a continuous recurrent memory. The connectome is not a metaphor: it is MaleCNS v1.0, the measured wiring of an adult male Drosophila central nervous system (FlyEM/Janelia, Google Research, University of Cambridge) β€” 188,778 neurons and 26,028,386 synaptic connections, with excitatory/inhibitory signs called for 88% of annotated neurons.

CNSv1 uses the fly's associative-memory core β€” mushroom body and central complex β€” pruned to the connections carrying 69.8% of its synaptic mass: 8,552 neurons, 300,880 synapses, stepping once per token, continuously, with no window of its own.

Results

Qwen2.5-0.5B-Instruct, frozen, 128-token attention window, 1,024-token document. The model attends to 128 tokens; the fly brain sees everything.

loss perplexity
128-token window, no memory 1.7733 5.89
128-token window + FlyBrain 1.6271 5.09
full attention over the document 1.6232 5.07

97.4% of the gap closed β€” a model attending to 128 tokens performs essentially identically to one attending to the whole document.

decode overhead +3.1% (within run-to-run variance)
live state 0.03 MB β€” 8,552 floats, constant at any sequence length
state on disk 35 KB, exact round trip
artifact 41.4 MB β€” no backbone weights

Does the wiring matter, or is it just recurrence?

A degree-preserving shuffle β€” same neurons, same synapse count, same in/out degree per neuron, same weight multiset, only who connects to whom randomised β€” with identical parameters, training and data:

seed fly connectome shuffled
0 61.3% 48.1%
1 47.5% 42.5%
2 54.7% 38.3%
3 105.4% 103.2%

The real wiring won all four seeds, mean advantage +9.2 points.

Note: the "full attention" reference runs the frozen backbone with no trained parameters, while the brain has trained adapters β€” which is why seed 3 exceeds 100%. It is a reference point, not a hard upper bound, so raw losses are published alongside percentages.

Portable memory

The state is a file. Save it when a session ends, load it when the next begins, and the model resumes mid-thought β€” there is no session boundary because there is no context window.

A 131k-token KV cache holding the same history is roughly 25.8 GB. This is 35 KB, and it does not grow. You can version it, branch it, or move it between machines.

Usage

pip install torch transformers pandas scipy
from pollard_flybrain import FlyBrain      # or: from flybrain import FlyBrain
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct").eval()
tok = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
probes = open("probe_corpus.txt").read()   # any text; the bridge is built from the model's
                                           # responses to it, at load, never shipped

brain = FlyBrain.load("FlyBrain-Pollard-CNSv1.pt", device="cuda")
brain.attach(model, tokenizer=tok, probe_text=probes)

# use the model exactly as before -- the brain rides underneath
brain.save_state("session.flystate")       # 35 KB: the conversation, portable
brain.load_state("session.flystate")       # tomorrow: pick up mid-thought
brain.detach()                             # the backbone is untouched

Scope and limits

  • One brain per backbone family. The adapters are fitted to a model's representations. Loading CNSv1 into an unrelated backbone runs but does not help β€” measured βˆ’14.6% on an unseen model. Retraining for a new backbone takes about 20 minutes with the backbone frozen.
  • The brain does not write code or see images. Those come from the backbone. 8,552 neurons remember; they do not reason.
  • The backbone is never modified and no backbone weights are redistributed.

Files

file
FlyBrain-Pollard-CNSv1.pt the connectome, its signs, trained synapses and adapters (41.4 MB)
flybrain.py loader: load / attach / save_state / load_state / detach
flybrain_state.py standalone state read/write helpers

Credits

  • Connectome: MaleCNS v1.0 β€” FlyEM/Janelia, Google Research, University of Cambridge (CC-BY)
  • Backbone: Qwen/Qwen2.5-0.5B-Instruct, frozen
  • Method and tooling: Pollard Weights β€” measure first, no claim before a number.

Prior work: connectome simulations (fly.ai, optic-lobe steering, game controllers) and recurrent memory for transformers (Transformer-XL, Compressive Transformer, RMT, Infini-attention, Titans). What is new here is a measured biological connectome serving as the recurrent memory of a frozen transformer, reported against a floor, a ceiling and a wiring control.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for PollardWeights/FlyBrain-Pollard-CNSv1

Adapter
(789)
this model