A hippocampal memory lab

Memory that lives in places, then teaches the rest of the mind.

Loci is a small, runnable model of how the hippocampus lets you find your keys, walk a building you have seen once, and not forget home after you learn the office. It trains in this browser. You can watch place cells fire, put it to sleep, cue a doorway, and score whether recall actually works.

01

What this is

Loci is not a chatbot and it is not a maze game. It is a laboratory for a particular kind of intelligence: the kind that binds a moment to a place, keeps similar places from smearing together, and later finishes a path from a fragment — a doorway, a smell of coffee, the click of an elevator.

The name is from the method of loci, the old memory-palace trick: you remember by putting things in rooms. Biology does a version of this for real. In the hippocampus, some neurons fire only when you are in a particular spot. They are called place cells. A map made of those cells is a chart of an environment. Sleep replays the day on that chart so slower parts of the brain can reuse it.

The agent here is self-improving in a narrow, checkable sense. After training, it proposes a slightly mutated child. The child is kept only if it does better on apartments it was not trained on, and is not much worse on problems of a different kind. If that gate never accepts anyone, the version number stays put. That is the point — improvement is a claim you can fail.

Reusable

Engrams persist in this browser. Sleep consolidates them. A later episode can complete from a cue instead of starting from zero.

Recallable

Cue CA3 with a location. If a matching episode is stored, the rest of the walk is reconstructed — not guessed from pixels.

Falsifiable

Every interesting module can be switched off. Benchmarks compare the full circuit to the lesioned one. Green is not assumed.

02

How a real hippocampus does this

You do not store a photograph of your apartment. You store a walk. A handful of brain areas, mostly in the medial temporal lobe, turn that walk into something you can stand in again later.

Grid cells in entorhinal cortex fire in a triangular lattice as you move — a graph paper the rest of the system can read. Dentate gyrus granule cells fire very sparsely, so two kitchens that share a sink but not a window get different codes and do not overwrite. CA3 is an autoassociative net: give it part of a pattern, it settles to a stored whole. CA1 place cells tile the current room with Gaussian “I am here” fields; when you go upstairs those fields remap, even if the floor plan is similar. During rest, sharp-wave ripples replay recent sequences, forward and reverse, and that replay is a teaching signal for neocortex.

This is why you can lose your keys, walk the rooms once, and later finish the search from the hallway. It is also why a new office does not usually delete your kitchen, and why a nap after studying helps. Loci is a compressed, runnable cartoon of that loop — not a biophysical simulation of membranes, and not a claim that 48 units are a dentate gyrus. The names are there so the parts stay honest about what they are trying to do.

03

How Loci maps onto that circuit

Each box is a real function in the running agent, sized so a train-and-bench pass finishes in this browser in about a second. The mapping is functional, not anatomical.

  1. EC

    Entorhinal cortex

    Grid cells. A coordinate system that tiles space at a few scales.

    Nine oscillators: three spacings, three angles. Not the raw maze.

  2. DG

    Dentate gyrus

    Pattern separation. Similar rooms get almost non-overlapping codes.

    Forty-eight granule cells. Only four fire (winner-take-all).

  3. CA3

    CA3

    Pattern completion. A doorway retrieves the rest of the walk.

    A Hopfield attractor plus a bank of 320 engrams.

  4. CA1

    CA1 place cells

    Where am I, in this room. Fields remap when the room changes.

    Sixteen Gaussians. Centers jitter per chart; sigma tightens with visits.

  5. SWR

    Sharp-wave ripples

    Sleep replay. Hippocampus teaches slower cortex overnight.

    Sleep replays sequences forward and backward into the Q policy.

04

Can this map onto a fly brain?

Functionally, most of it can. Anatomically, no — and the fly makes that obvious, because a fly does not have one “memory organ.” It has two circuits that split the job Loci currently mashed into a hippocampus cartoon.

The mushroom body is the associative memory. Projection neurons fan out onto about two thousand Kenyon cells; only a sparse set fire; dopamine neurons write valence at the output. That is the same expansion-and-sparsify motif as dentate gyrus, cerebellum, and piriform cortex. Charles Stevens called it the Marr motif. Loci’s 48-cell dentate layer is a tiny version of that, not a tiny CA1.

The central complex is the navigator. Ellipsoid-body neurons hold a bump of activity that is the fly’s heading — a ring attractor, the same idea as mammalian head-direction cells. Downstream, the fan-shaped body adds, rotates, and compares vectors: which way I am facing, which way I am moving, which way the goal is, how to steer. Flies can learn a cool spot in a hot arena, but they are not tiling a floor with Gaussian place fields. They are integrating a path on a compass.

The Marr motif

Three systems, same shape: a compact encoder, then a large sparse expansion layer so overlapping inputs do not overwrite. Charles Stevens put the fly on this list next to hippocampus and cerebellum. Loci’s dentate gyrus is that middle layer, shrunk to 48 cells.

  • Hippocampus

    Entorhinal cortexDentate granule cells

  • Cerebellum

    Precerebellar nucleiCerebellar granule cells

  • Fly mushroom body

    Antennal lobe (projection neurons)Kenyon cells

  • Pattern separation

    48 dentate cells, top 4 fire. Random projection, then winner-take-all.

    Mammal

    strong

    Dentate gyrus. A few percent of granule cells fire. Similar rooms get orthogonal codes.

    Fly

    strong

    Kenyon cells. About 2,000 per side. A handful of random projection-neuron claws each; APL inhibition keeps the code sparse. Same math as dentate.

  • Where am I

    16 Gaussian place fields that remap per room and tighten with visits.

    Mammal

    strong

    CA1 place cells. A 2D patch of space. Fields remap upstairs even if the floor plan is similar.

    Fly

    no

    No place cells. Ellipsoid-body EPG neurons hold a heading bump (a compass), not an (x, y). The fan-shaped body does vector arithmetic on that bump.

  • Coordinates under the map

    Nine grid oscillators: three scales, three angles. A cartoon of medial entorhinal cortex.

    Mammal

    strong

    Grid cells. A triangular lattice that tiles space.

    Fly

    cousin

    A ring attractor for heading, plus path integration and goal vectors in the central complex. Polar, not a 2D lattice.

  • Complete a fragment

    Hopfield net on the 4-hot dentate code. A doorway settles to a stored walk.

    Mammal

    strong

    CA3 recurrent collaterals. Classic autoassociator. 2024 work says CA3–CA3 plasticity (BTSP) builds the attractor; entorhinal input updates it as you move.

    Fly

    cousin

    The mushroom body is not a Hopfield net. Memory sits at Kenyon→output synapses, gated by dopamine neurons. The central complex does complete a heading bump — a direction, not an episode.

  • Teach the rest of the brain

    Sleep replays sequences forward and reverse into a slow Q policy.

    Mammal

    strong

    Sharp-wave ripples. Sequential replay during rest. Hippocampus tutors neocortex.

    Fly

    cousin

    Sleep helps olfactory memory consolidate, but not via ripples. Dopaminergic neurons write valence into Kenyon→output synapses while the fly is awake.

  • Reward / surprise write

    Surprise-gated engrams. Temporal-difference error in the policy. No dopamine cells.

    Mammal

    cousin

    Neuromodulators and novelty. Not a solved mapping.

    Fly

    strong

    About 20 types of dopaminergic neuron tile mushroom-body compartments. Coincidence of Kenyon activity and dopamine is the teaching signal. This is the cleanest biological credit assignment we have.

So the honest mapping is a fork. Keep Loci’s names if you want the rat story: grids, dentate, CA3 completion, CA1 fields, ripple replay. To make it fly-like you would split the agent. Local view (the 5×5 fovea, treated like an odor) would go through a Kenyon-style expansion into a handful of output neurons, with a dopamine-like write when reward and the sparse code coincide. “Where am I” would stop being 16 Gaussians and become a heading bump plus a goal vector — then steering is “turn until they match,” which is what PFL neurons appear to do. Pattern completion of a walk from a doorway is the piece that does not port. That is a CA3 trick. The fly stores associations at the output synapse, and completes a direction, not an episode.

A “more real neural model” of the current lab, still mammalian, would also look different under the hood: spikes instead of rates; behavioral-timescale plasticity at CA3–CA3 instead of a classical Hopfield outer product; dual encodings in CA3 (sparse mossy-fiber examples and dense entorhinal concepts, which a 2024 CA3 model actually needs); theta as a clock; dopamine cells instead of a scalar surprise gate. Those are better physics. They are not required for the claim the lab tests — that a sparse expansion, an attractor, remapping charts, and replay can be reused and scored on problems you can follow. The fly is the existence proof that the expansion step is not a mammal-only story. Place cells still are.

05

The eight-stage loop

Every tick, and every training episode, walks the same pipeline. The lab lights a stage when it is actually doing work — not a slide deck of boxes.

  1. 01Task environment

    A 9×9 apartment, kitchen, hallway, or block. Walls, keys, a door, a curtain that looks solid, an elevator that opens on a beat. The agent never sees the true grid — only a 5×5 window around itself.

  2. 02Sensors

    Each tick: position, last move, whether it is holding keys, a noisy local view. Adjacent tiles are legal to feel (a wall in front of your face). Distant walls stay fog until walked up to.

  3. 03Perception

    The window is turned into a 64-number state: place-cell activity, grid-cell activity, local bits, last action, which problem this is. A small world model guesses the next square and the reward. Surprise is how wrong that guess was.

  4. 04Hippocampus

    CA1 says where. Dentate gyrus makes the code sparse so two similar apartments do not overwrite. CA3 stores the episode and, later, completes it from a partial cue. Surprise-gated traces become engrams.

  5. 05Executive

    A router picks a tactic: explore, follow a remembered route, work backward from the goal, reframe a fake wall, wait. A planner walks the occupancy map it has actually seen — unknown cells are treated as maybe-open, known walls as blocked.

  6. 06Decision

    Five moves: north, east, south, west, wait. A linear Q head scores them. Legal moves that walk into a visible wall are masked. The chosen action hits the environment; prediction error updates memory.

  7. 07Sleep / self-improve

    Replay restitches the day into the slower policy. Then a child agent is proposed. It is kept only if held-out apartments get better and transfer problems do not collapse. That gate is the claim of self-improvement — not a training-loss drop.

  8. 08Evaluation

    Matched ablations (no place cells, no CA3, no replay…) run the same curriculum. Hippocampal benches B1–B5 and hypotheses H1–H5 are allowed to fail. A green badge is not the default.

06

The experiment

The world is a 9×9 grid. That sounds like a toy, and it is, on purpose. A person can see the whole apartment at a glance. The agent cannot. Its eyes are a 5×5 fovea. Unvisited cells stay fog. The planner is not allowed the true maze — if it were, a hidden shortest-path search would solve every problem and we would learn nothing about memory.

Five actions: north, east, south, west, wait. Fifty-six steps is a failed episode. Reward is reaching the goal (keys, door, coffee maker, elevator, the long way around). Some problems move the goal mid-walk. Some require holding an object. One has a curtain that looks like a wall until the executive reframes it. One has a barrier that opens on a beat.

What is being tested is not “can a neural net traverse a maze.” It is whether a hippocampal-shaped memory — sparse codes, completion from a cue, remapping, replay — makes reuse and recall work on problems a person can narrate without jargon.

The intended trial

Pick Lost keys. Train 40 episodes. Sleep. Recall. CA3 should finish a held-out walk from a doorway. Then Play or Step and watch the sixteen place cells light the room it is in. Then run Benchmarks. Then Falsify, which is allowed to disagree with the story.

07

Problems you can follow

Each problem is a real-world wrapper around a grid family. Same engine, named so the claim is readable. The watch line is what you should look for in the live arena.

  • Apartment

    Lost keys

    You dropped your keys somewhere in the apartment. Walk the rooms until you see them. After a few trips, a glimpse of the hallway should be enough to finish the path.

    Place cells light the room you are in. Sleep, then Recall — CA3 should complete the walk from a doorway.

    One-shot spatial memory. CA3 stores the episode; CA1 says where you are.

  • Kitchen

    Coffee moved

    The coffee maker used to sit by the window. Someone moved it mid-morning. The rest of the kitchen is the same — only the goal jumped.

    At step 12 the goal relocates. Prediction error should spike, then the map should update without wiping the walls.

    Remapping the goal, not the whole chart. Hippocampus edits one association.

  • Front hall

    Keys, then the door

    Keys are in the bowl. The front door is locked. Get the keys, then leave. Order matters.

    Subgoal flips from key to door. Working memory has to hold 'I have the keys'.

    Sequences, not single places. Replay stitches K then D into one episode.

  • Office tower

    Same building, other floor

    Floor 3 is floor 2 rotated. You should reuse the first turn you already learned, not start from zero.

    Strategy should read 'replaying a remembered route'. Pattern completion pulls the sibling chart.

    Reuse. Dentate gyrus separates the floors; CA3 still retrieves the shared topology.

  • Studio

    The curtain wall

    That partition looks solid. It is a curtain. Walk through it. The obvious map is wrong.

    The dashed tile is a decoy. The router has to reframe, or the planner treats it as a wall forever.

    Re-representation. The hippocampus can store 'this looked like a wall and wasn't'.

  • Lobby

    Elevator wait

    The elevator doors open on a beat, then close. Rushing the door is how you miss it. Wait, then go.

    Barrier B. The agent should Wait while it is closed instead of bouncing off it.

    Time in the same place. Place cells plus a phase — not just x,y.

  • Block

    Don't take the alley

    The obvious shortcut is a cul-de-sac. The long way around is the way that works. You have to notice the trap.

    A U-shaped dead end around G. Working backward from the goal beats walking in.

    The map is for planning, not for the nearest green tile.

08

Sleep, replay, and self-improvement

During the day the hippocampus writes. During sleep it reads itself back to cortex. That is the biological story of systems consolidation, and it is the self-improve loop here.

Pressing Sleep does two things. First, sharp-wave-style replay: stored sequences are sampled, sometimes reversed, and written into the slower Q policy so a route can be reused without walking it again. Weak unused traces are pruned. Place-field sigma keeps the tightening it earned from visits; spatial information usually rises. Second, the agent may propose a child with slightly mutated weights. Promotion is not automatic. Validation success must rise by about five points, and transfer must not fall by more than ten. Rejected children die. The version badge in the lab is a history of that gate.

Replay is also what makes one-shot memory useful to a slow learner. CA3 can complete a walk after a single episode. The Q head cannot. Sleep is the handshake between those timescales. Turn replay off in the lab (the Replay switch) and H3 asks whether generalization actually drops. Sometimes it will not. That is a real result, not a failed demo.

09

Hippocampal benchmarks

B1 through B5 are claims about the circuit, not about maze scores. Each row trains a full agent and a matched lesion, then reports a number you can read.

  • B1

    Pattern completion

    From a doorway, CA3 reconstructs the rest of the walk.

    Train on apartments, sleep, cue with the first third of a remembered path, score how much of the remaining path comes back. Compared to an agent with CA3 recall turned off.

  • B2

    Pattern separation

    Two similar apartments get different dentate codes, so they do not overwrite.

    Same doorway in two different wall layouts. Dentate overlap across rooms should be lower than overlap of a room with itself.

  • B3

    Home, then office, then home

    Learning a second neighborhood should not wipe the first.

    Train the apartment, train a rotated floor, freeze learning, retest the apartment. Charts remap so the two maps are not forced to share one code.

  • B4

    One-shot recall

    A single walkthrough is enough to complete the route from a partial cue.

    One episode, then sleep, then complete from the second cell. Cortex (the Q policy) is slow; this test never trains past the first walk.

  • B5

    Place fields sharpen

    Experience plus sleep tightens CA1 fields. Spatial information rises.

    Skaggs information, a standard neuroscience measure, computed from visit-weighted firing. Sigma starts wide and shrinks toward a floor as a cell is used.

10

What would count as being wrong

Falsify retrains the full agent and six lesions on the same seed: no place cells, no replay, no CA3 recall, no strategy switching, no world model, no concept memory. Then it marks H1–H5 supported or dead. A dead hypothesis is more useful than a pretty dashboard.

  • H1

    The full agent searches less than one that cannot switch tactics.

    Unique cells visited on matched maps. Lower is the prediction.

  • H2

    Place cells improve success on held-out apartments.

    Validation success vs the same agent with place cells removed.

  • H3

    Replay improves generalization.

    Held-out success vs an agent that never replays.

  • H4

    The promotion gate reaches 60% rolling success in fewer episodes than a frozen first version.

    Episodes-to-60%. Falsified if children are never accepted, or accepted children learn slower.

  • H5

    CA3 pattern completion helps transfer: a partial cue should retrieve a stored chart instead of relearning it.

    Transfer success vs no-CA3.

You can also lesion by hand. The Adjust panel has a switch per module. Train with CA3 off, then Recall — completion should collapse. Train with place cells off — the sixteen Gaussians go dark and the policy is local features only. That is the same science as Falsify, just slower, and you can watch it.

11

How to run the lab

  1. 01

    Pick a problem

    Start with Lost keys. It is the cleanest spatial story. The chip row under the buttons is the curriculum.

  2. 02

    Train

    Forty episodes is enough to fill the engram bank and pull sigma down. Eighty or one-sixty if you want a stabler policy. The version badge may tick if a child is accepted.

  3. 03

    Sleep, then Recall

    Sleep replays the day. Recall cues CA3 with the start of a recorded walk and draws the completed path. Hit rate is how much of the held-out tail came back.

  4. 04

    Play or Step

    Play runs the live loop. Step is one tick: you can read the thought, the place-cell glow, the dentate winners (four of forty-eight), and the plan dots on the arena.

  5. 05

    Benchmarks

    Runs B1–B5 against lesions. Takes a few seconds. Rows mark supported or falsified. Read the note under each score.

  6. 06

    Falsify

    The heavier suite: H1–H5 plus full ablation reports. Use it when you want the architecture, not just the hippocampus, on the hook.

12

What this is not

It is not a rat, and it is not a fly. Sixteen place cells and forty-eight granule cells are a schematic, sized so the math is inspectable and the benches finish while you wait. There are no spikes, no theta, no dopaminergic compartments, no body. The “apartment” is nine cells on a side. The fly mapping above is computational, not a second animal in the lab.

The policy is linear Q. The world model is a small multilayer perceptron. CA3 is a classical Hopfield net, not a modern Hopfield with softmax attention, and not a transformer memory. Surprise-gated writing is a stand-in for novelty, not dopamine. Remapping is implemented by giving each wall-pattern its own jittered chart, which is the right qualitative idea and a crude quantitative one.

Nothing leaves this browser. Maps you train stay here until you hit Reset. If a benchmark comes back falsified, believe the number. The write-up is the hypothesis; the lab is the experiment.