WERM
CA: coming soon

Wired from the worm

Wiring
Encoded
Recurrent
Modulator

That is what WERM stands for. The wiring comes from the real worm. It is encoded as a network. It is recurrent, so each moment leans on the last one. And it only modulates: all it does is nudge the dials on a language model.

A 302 neuron brain, copied from the real wiring diagram of C. elegans (a see-through worm about the size of a pinhead, and the first animal to have its entire brain mapped), running in this tab. It is small enough to read and strange enough to steer a language model.

Scroll down. The five worms in the background each run their own copy of this brain. They hunt for food, bump into each other and back away. Scrolling down pokes their tails, scrolling up pokes their heads.

Connectome

The full list of which neurons connect to which. This one was traced from electron microscope images of real worms and published by Steven Cook and colleagues in 2019.

Genome

The DNA that builds the worm, about 100 million letters on six chromosomes. It does not run the brain here. It is drawn to scale further down, measured from the reference sequence.

Liquid time constant

Each model neuron has a gate that opens with input, and the more input it gets, the faster it moves. The idea is borrowed, in a very small form, from the liquid networks built at MIT.

Steering

The worm's state sets a few dials on a language model, such as how adventurous its word choices are. The model still writes every word. The worm only nudges the dials.

The brain, on a globe

Every dot is one of the 302 neurons in the adult hermaphrodite. Sensory neurons sit near the top, motor neurons near the bottom, interneurons in the band between. Arcs are real chemical connections from the Cook et al. 2019 wiring diagram. Drag to spin it. Click a dot to fire that neuron.

CONNECTOME / HERMAPHRODITEdrag to rotate
sensory interneuron motor other
Nothing picked yet. Click a neuron.
forward command (AVB, PVC)0.00
backward command (AVA, AVD, AVE)0.00
whole network arousal0.00

Touching the tail should push the forward command up. Touching the head or bumping the nose should push the backward command up. Here, tail touch and nose touch do that clearly. Head touch leans the right way, but only just. The notes say why.

The steering layer

This is how the worm touches a local language model. The worm does not make the model smarter. It nudges how the model talks, the way a mood would. These numbers update live from the brain above, and the same code is in the repo.

WORM STATE TO SAMPLING SETTINGSresting
settingvaluehow it moves
temperature0.00rises with whole network arousal
top_p0.00rises with sensory activity
repeat_penalty0.00rises when the worm backs up
num_predict0longer answers while it crawls forward

The same code runs on your own computer, where you can connect it to Ollama or any other local engine and send it messages. The steps are in run it on your computer below.

The body it came from

About a millimetre long, transparent, and about three days from egg to adult at 25 C. Scroll and the outline draws itself. The worm below uses the same brain: its wave speed and direction come from the motor neuron readout, so poking the head makes it back up.

C. ELEGANS / ADULT HERMAPHRODITE / SIDE VIEW (SCHEMATIC)not to scale
nerve ring pharynx intestine gonad arms vulva tail

pharynx

A muscular pump that grinds bacteria. It has its own small nervous system of 20 neurons.

nerve ring

A ring of nerve fibres around the pharynx, and the densest knot of wiring in the animal. It works as the worm's brain.

intestine

A tube of just 20 cells that digests the bacteria the worm eats.

gonad

Two U shaped arms that make sperm and eggs. A hermaphrodite can fertilise its own eggs.

vulva

The opening where eggs leave. Two serotonin neurons, HSNL and HSNR, drive egg laying, and both are in the data on this page.

body wall muscle

Four strips of muscle run along the body. Motor neurons fire them in waves, and the worm crawls in S shapes.

LIVE BODY / DRIVEN BY THE BRAIN ABOVEresting

The genome, to scale

About 100 million letters of DNA on six chromosomes. These bars are drawn to scale from the NCBI reference, GCF_000002985.6. Each one is two maps measured from the real sequence and its gene annotation, one pixel per 100,000 letters.

REFERENCE GENOME / C. ELEGANSmegabases
top strip: GC content. Blue is the most A and T rich, lime the most G and C rich () bottom strip: protein coding genes per window, brighter means more ()
Want to check it yourself? Run the fetch script, then drop the FASTA file here. Your browser reads it locally and draws the same GC map from scratch. Nothing is uploaded.
bash scripts/fetch_genome.sh node scripts/genome_stats.mjs data/genome/c_elegans.fasta node scripts/gc_windows.mjs data/genome/c_elegans.fasta bash scripts/fetch_annotation.sh node scripts/gene_windows.mjs data/genome/annotation.gff.gz

The fetch script pulls the six chromosomes and the mitochondrial genome from NCBI by accession number and joins them into one file. The maps on this page were made from that file and from the RefSeq gene annotation (WormBase release WS298) by two short scripts in the repo, so every pixel can be traced back to the sequence.

Run it on your computer

Everything on this page runs on your own machine too: the brain, the experiments, and the link to a language model. Nothing is sent anywhere. You need Node 20 or newer (free from nodejs.org), and for the language model part, a local engine such as Ollama or LM Studio.

1 / GET THE CODEabout a minute
git clone GH_URL cd werm npm test

No packages to install. The tests check the wiring, the brain and the steering in a few seconds.

2 / POKE THE BRAINterminal
node src/cli.mjs sim --stim touch-tail --seconds 2

This touches the worm's tail and prints the brain every half second. You should see drive go positive: it crawls forward. You can also open site/index.html in any browser. This whole page works offline.

3A / CONNECT OLLAMAollama.com/download
ollama pull llama3.2 node src/cli.mjs connect --model llama3.2

Install Ollama and open it, then download a model. Any model you have pulled works, just change the name. If something is missing, the command tells you what to do.

3B / OR ANY OTHER LOCAL ENGINEOpenAI style server
node src/cli.mjs connect \ --base-url http://localhost:1234/v1 \ --model YOUR_MODEL
enginestart its server, then use
LM Studiohttp://localhost:1234/v1
llama.cpp (llama-server)http://localhost:8080/v1
vLLMhttp://localhost:8000/v1
Ollama, OpenAI stylehttp://localhost:11434/v1

Temperature, top_p and the length limit are sent. The repeat penalty is not part of that API, so it is left out.

4 / USE IT IN YOUR OWN CODEany engine, any language
node src/cli.mjs steer "why is my code broken?"

Prints what the worm would send for that message as JSON: the neurons it poked, its state, the sampling settings under both Ollama and OpenAI names, and the tone line. Pass those to whatever engine you use. In JavaScript you can import WormBrain from src/network.mjs and steer from src/steer.mjs directly.

How the worm sets the model

Each message you pass through WERM pokes a group of sensory neurons first. A question bumps the nose, an angry word is something nasty, a thank you smells like food, a long paste hits the head, and anything else nudges the tail. The brain runs for a moment, and its state becomes the model's temperature, top_p, repeat penalty and length limit, plus a one line tone. The model still writes every word. Whether this changes its answers in a way you can measure has not been tested yet. The test is in the repo as scripts/steer-eval.mjs.

Why a worm

Caenorhabditis elegans is a roundworm about a millimetre long. It lives in soil and rotting fruit, eats bacteria, and has no business being famous. It became famous because of a decision made in the 1960s. Sydney Brenner and his colleagues picked it as a model animal, and nearly everything useful about it follows from that choice.

It is transparent, so you can watch cells divide inside a living animal under an ordinary microscope. It grows on a plate of agar. It goes from egg to adult in about three days and lives for several weeks. Most individuals are self fertilising hermaphrodites, so a single worm starts a whole population, and a rare male lets you cross strains when you need to. An adult hermaphrodite has 959 somatic cells, and the lineage of every one of them has been traced from the fertilised egg.

An animal small enough to hold in your head, with a nervous system small enough to draw.

That last point is why this project exists. A human brain has tens of billions of neurons. The worm has 302. Someone could sit down with an electron microscope and map every one, and in the 1980s someone did.

Life of a worm

A worm hatches as a larva and moves through four larval stages, called L1 to L4, before becoming an adult. At 25 C the whole trip takes about three days. If food runs out or the plate gets crowded, a young larva can switch into a tough, non eating form called a dauer. Dauer larvae can wait out hard times for months and then resume normal life when conditions improve.

The nervous system changes through that journey. About a quarter of the adult neurons are born after hatching. A larva starts life with around 1,300 synapses and an adult ends up with roughly 8,000. A 2021 study by Daniel Witvliet and colleagues reconstructed eight worms from newborn to adult and found that most of the added synapses strengthen connections that already existed at birth. Only about a quarter linked a neuron to a new partner.

Worms also differ from each other. The same 302 neurons appear in the same places in every hermaphrodite, but each animal has its own particular synapses. That matters for this project, because the wiring diagram on this page comes from specific animals and is a sample of what a worm can be, not a single fixed blueprint.

The genome

The reference genome is about 100 million base pairs long, split across five autosomes and the X chromosome, plus a small circular mitochondrial genome of 13,794 bases. Chromosome V is the longest at roughly 20.9 million bases. Chromosome III is the shortest at roughly 13.8 million. The bars in the genome section above use the exact lengths from the NCBI RefSeq record.

It is rich in A and T. Measured from the reference sequence, 35.4 percent of the letters are G or C, so close to 65 percent are A or T. The GC map above shows that this is not even: some stretches run near 30 percent GC and others above 40. The consortium that sequenced the genome published it in Science in 1998, the first complete genome of a multicellular organism. It has been revised and gap filled since, until it ran from telomere to telomere on every chromosome.

Counting genes is harder than counting bases because the answer depends on what you call a gene. The annotation behind the gene map on this page (WormBase release WS298, as distributed by NCBI) lists 19,971 protein coding genes on the six chromosomes. WormBase's 2022 paper reported 19,985, out of 49,187 genes of all kinds once non coding RNA genes and others are included. Annotation rounds from 2005 put it near 19,700. The number moves by small amounts as curators find new exons and merge or split predictions.

A large share of those genes have recognisable counterparts in humans, which is the main reason a worm is useful for studying disease. Researchers have compiled lists of worm genes with human orthologs, such as the OrthoList resource, so that a worm experiment can be matched to a human gene of interest.

Nothing on this page claims the genome runs the simulation. The genome is the instruction set that builds the worm. The connectome is what the finished nervous system looks like. They are different layers, and the project treats them that way: the genome section is a viewer and a data pipeline, and the brain is built from the wiring.

The wiring diagram

The first complete map of any nervous system was published in 1986 by John White, Eileen Southgate, Nichol Thomson and Sydney Brenner. They cut worms into ultrathin serial sections, imaged each one by electron microscope, and followed the fibres from picture to picture by hand. Their count was 302 neurons, with about 5,000 chemical synapses, 2,000 connections onto muscle and 600 gap junctions. It is still the reference point for the field.

Later work refined it. Varshney and colleagues rebuilt the hermaphrodite somatic network in 2011. Steven Cook and colleagues published whole animal connectomes for both sexes in 2019, covering muscles and other tissues as well as neurons. The dataset behind this page is the Cook 2019 hermaphrodite network, as packaged by the OpenWorm Connectome Toolbox.

After cleaning, it contains 302 neurons, 3,709 directed chemical connections and 1,105 gap junction pairs between neurons. The counts on the page above are computed from the data file when it loads. A chemical synapse sends a signal one way using a neurotransmitter. A gap junction is a direct electrical link that lets current pass in both directions.

Each connection also has a weight. In this dataset the weight is the number of electron microscope sections in which the two cells were seen joined, so it grows with both the number and the size of the synapses. That is why the weights add up to far more than the number of synapses, and why this page never calls them synapse counts.

A wiring diagram is a map of what is connected to what, and how strongly. It does not tell you which synapses excite their targets and which inhibit them. It does not include the slower chemical signalling that runs through the whole animal by neuropeptides and monoamines. People are working on those layers, and the OpenWorm toolbox lists datasets for them. We do not use them here.

Prizes

This worm has been behind a surprising number of Nobel prizes. The 2002 Prize in Physiology or Medicine went to Sydney Brenner, Robert Horvitz and John Sulston for how genes control organ development and programmed cell death. In 2006, Andrew Fire and Craig Mello won for RNA interference, which they discovered in worms. In 2008, Martin Chalfie shared the Chemistry prize for green fluorescent protein, which he first used as a marker in C. elegans neurons. In 2024, Victor Ambros and Gary Ruvkun won for microRNA, again from worm genetics. A New York Times piece in 2024 counted at least four prizes tied to the animal, and the list above is the one I would give.

Liquid networks

The strongest link between this worm and modern AI is the liquid neural network. Ramin Hasani, Mathias Lechner, Daniela Rus and colleagues at MIT drew on the worm's nervous system to design networks whose neurons are described by differential equations. In a standard network the connections are fixed once training ends. In a liquid network the time constant of each unit shifts with its input, so the network keeps adapting after training.

An early version of the idea modelled the tap withdrawal circuit, the small set of neurons that makes the worm recoil from a tap on the plate. The researchers called these Neuronal Circuit Policies. They used them to control an inverted pendulum in simulation and to park a real rover along a set path. Hasani went on to co-found Liquid AI. The pitch for these networks is that they are compact, they cope with noisy time series such as video and sensor streams, and a person can follow what each cell is doing.

The model on this page borrows the same shape of idea at a very small scale. Each neuron is a leaky unit, and the incoming signal opens a gate that speeds up how fast the unit moves toward its target. That is the liquid time constant in one line.

OpenWorm

OpenWorm is an open science project that has been working since 2011 to simulate the whole animal. It is organised as a set of parts. c302 builds neuron models of the whole nervous system in NeuroML at several levels of detail, from simple integrate and fire cells up to Hodgkin Huxley style conductance models. Sibernetic simulates the physical body and the fluid around it. Geppetto is a browser based visualisation and simulation engine. The ConnectomeToolbox collects published wiring datasets in one Python package, and that is where the wiring data used here came from.

WERM is not a part of that effort and does not compete with it. If you want a faithful biophysical simulation, use c302. If you want something small that runs in a browser tab and can be taken apart in an afternoon, that is the gap this project fills.

Our model

Each of the 302 neurons has one number, its activation level x. The update rule for every neuron is:

f = sigmoid( slope * (drive - offset) ) dx/dt = -(1/tau + f) * x + f * amp

Here drive is the sum of chemical input, gap junction input and any outside stimulus, minus a global inhibition term. Chemical input from neuron j into neuron i is the log of the connection weight times the presynaptic activation, divided by how much neuron i listens in total. The 28 neurons that make and release GABA (DD, VD, RME, RIB, AVL, DVB and RIS, from Gendrel and colleagues, 2016) count as inhibitory. Everything else counts as excitatory.

The gate f is the liquid part. More drive means a larger f, which makes the neuron both decay faster and aim higher. A neuron with no input settles at a resting level worked out from the equation, and its activation is measured from there, so a quiet network stays quiet.

A wiring diagram that is mostly excitatory tends to be either dead or saturated, so the model needs a global inhibition term to stay in between. Four parameters were then picked by a sweep over 1,470 settings, using a rule fixed in advance: the worm must stay quiet at rest for 30 seconds, pass as many reflex checks as possible, and then separate head touch from tail touch as clearly as possible. It is a tuned model, not a fit to recordings.

The result: tail touch drives the forward command strongly, nose touch drives the backward command, head touch leans backward only slightly, and the noxious stimulus is no better than poking random sensory cells. Head touch is weak for a reason you can read off the wiring. AVM, a head touch cell, sends most of its chemical output to the forward command cells and only a little to the backward ones. In this model every non GABA synapse excites, so a head touch pushes both ways at once. In the real animal, some of those synapses are probably inhibitory, through receptors this model does not have.

Does the wiring matter?

A fair question about any model like this: would any network of the same size do the same thing? To test it, the reflex checks were run on 100 shuffled copies of the wiring, where every neuron keeps exactly as many connections in and out but the partners are swapped, and on 100 random networks with the same number of connections. Each fake network got its own parameter sweep, so none was stuck with settings tuned for the real one.

So yes, for this one thing. The real wiring routes head touch and tail touch apart much better than shuffled wiring does, and keeping each neuron's number of connections is not enough to copy it. It is a narrow result. On a general memory task the real wiring did slightly worse than its shuffles, so this is not a claim that the worm's wiring is better at everything. The full numbers, plots and method are in docs/RESULTS.md, and you can watch the real and shuffled brains side by side with the compare button in the brain section.

What it cannot do

  • It cannot tell you what a real worm will do. There are no muscles and no body physics in the brain model, and the swimming worm on this page is a kinematic drawing driven by two numbers from the network.
  • Synapse signs are approximated. Only the 28 GABA neurons are inhibitory, and many synapses that the model treats as excitatory are probably inhibitory in the animal.
  • It has no neuropeptides or monoamines, which shape behaviour in real worms on timescales of minutes to hours.
  • The steering layer is a design choice. Mapping arousal to temperature is something I picked because it is easy to see, not because neuroscience says it should be so. Its effect on a language model has not been measured yet. The test is written and in the repo.
  • The worm does not think for the language model. It sets a few sampling numbers and a tone instruction, and the model does the rest.

Run it

The whole project is a small Node repository with no packages to install for the model. The run it section above has the steps for your own computer, for Ollama and for other local engines. To rerun the experiments behind the results, use npm run sweep and npm run experiments. To rebuild the connectome file from the source workbook, see scripts/build_connectome.py. To rebuild this page, run npm run build:site.

Sources