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:
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
- White JG, Southgate E, Thomson JN, Brenner S. 1986. The structure of the nervous system of the nematode Caenorhabditis elegans. Phil Trans R Soc Lond B 314:1 to 340. doi:10.1098/rstb.1986.0056
- Cook SJ et al. 2019. Whole-animal connectomes of both Caenorhabditis elegans sexes. Nature 571:63 to 71. doi:10.1038/s41586-019-1352-7 (the wiring used here)
- Witvliet D et al. 2021. Connectomes across development reveal principles of brain maturation. Nature 596:257 to 261. doi:10.1038/s41586-021-03778-8
- Varshney LR et al. 2011. Structural properties of the Caenorhabditis elegans neuronal network. PLoS Comput Biol 7:e1001066. doi:10.1371/journal.pcbi.1001066
- Gendrel M, Atlas EG, Hobert O. 2016. A cellular and regulatory map of the GABAergic nervous system of C. elegans. eLife 5:e17686. doi:10.7554/eLife.17686 (the inhibitory neurons)
- Chalfie M et al. 1985. The neural circuit for touch sensitivity in Caenorhabditis elegans. J Neurosci 5:956 to 964. doi:10.1523/JNEUROSCI.05-04-00956.1985 (head and tail touch)
- Kaplan JM, Horvitz HR. 1993. A dual mechanosensory and chemosensory neuron in Caenorhabditis elegans. PNAS 90:2227 to 2231. doi:10.1073/pnas.90.6.2227 (nose touch)
- Maslov S, Sneppen K. 2002. Specificity and stability in topology of protein networks. Science 296:910 to 913. doi:10.1126/science.1065103 (the shuffling method)
- Albertson DG, Thomson JN. 1976. The pharynx of Caenorhabditis elegans. Phil Trans R Soc Lond B 275:299 to 325. doi:10.1098/rstb.1976.0085 (the 20 pharyngeal neurons)
- The C. elegans Sequencing Consortium. 1998. Genome sequence of the nematode C. elegans: a platform for investigating biology. Science 282:2012 to 2018. doi:10.1126/science.282.5396.2012
- Hillier LW et al. 2005. Genomics in C. elegans: so many genes, such a little worm. Genome Res 15:1651 to 1660. doi:10.1101/gr.3729105
- Davis P et al. 2022. WormBase in 2022: data, processes, and tools for analyzing Caenorhabditis elegans. Genetics 220:iyac003. doi:10.1093/genetics/iyac003
- NCBI RefSeq assembly GCF_000002985.6 (WBcel235) and its gene annotation (WormBase WS298), the source of the genome maps
- Corsi AK, Wightman B, Chalfie M. 2015. A transparent window into biology: a primer on Caenorhabditis elegans. Genetics 200:387 to 407. doi:10.1534/genetics.115.176099 (life cycle, body plan, first multicellular genome)
- Hasani R, Lechner M, Amini A, Rus D, Grosu R. 2021. Liquid time-constant networks. Proc AAAI 35:7657 to 7666. doi:10.1609/aaai.v35i9.16936
- Lechner M, Hasani RM, Grosu R. 2018. Neuronal circuit policies. arXiv:1803.08554
- Szigeti B et al. 2014. OpenWorm: an open-science approach to modeling Caenorhabditis elegans. Front Comput Neurosci 8:137. doi:10.3389/fncom.2014.00137
- OpenWorm Connectome Toolbox and openworm/c302
- The Nobel Prize in Physiology or Medicine 2024, and the 2002, 2006 and 2008 prizes
- MIT CSAIL via ScienceDaily, 2021, on liquid networks and Quanta Magazine, 2023
- Every citation in the project, with its checked status: docs/research/07-reading-list.md