240 neurons · 5 senses · 4 knobs

SHARQ

Steered by a shark.

SHARQ is a small simulated shark brain, wired from shark anatomy by a handful of rules. It feels the water, decides how hard to swim and which way to turn, and turns that into four settings for a language model on your own machine. The model still picks every word.

Scroll down and the sharks behind this page dart forward. Scroll up and they turn back.

Input

Five ways in

Smell, electric fields, water movement, light and touch each have their own patch of neurons, split into left and right halves.

Drive

It never stops swimming

Many sharks must keep moving to push water over their gills. Here the forward command neurons get a steady push, so the tail never goes still.

Output

Four knobs, no words

The brain sets temperature, top_p, repeat_penalty and num_predict. Your language model still writes the text.

Local

One file on your machine

sharq.mjs runs on Node 20 or newer with no packages and talks to Ollama, LM Studio, llama.cpp or vLLM on localhost.

Brain

240 neurons, wired by rule

Each dot is one simulated neuron, placed where its region sits in a real shark brain: olfactory bulbs out front, the tectum in the middle, the cerebellum on top, and the spinal motor pool trailing off the back. Drag to turn it. Click a dot to make it fire.

Sensory Integrating Command Motor
Drag to rotate · click a dot to fire it
State
cruising
Last input
nothing yet
Neurons
240
Firing this step
0
Synapses
0

Put something in the water

The first half of the prompt reaches the left side, the second half the right.

Drive0.00
Turn0.00
leftright

What the brain sends

These four numbers are the brain's only output. They update live as the shark reacts.

SettingNowRangeMoved by
temperature0.500.45–1.20Drive. A hunting shark writes hotter.
top_p0.700.70–0.98Sense. More in the water opens more choices.
repeat_penalty1.001.00–1.30Turn, either way. Turning pushes away from repeats.
num_predict46064–512Drive, inverted. A strike is short.

Structured wiring vs shuffled

Both brains get a smell on the left, then an electric field on the right. The shuffled brain keeps every synapse and weight but sends each one to a random neuron.

Structured
Shuffled
driveturn (up is left)
Average turnStructuredShuffled
During the smell on the left––
During the field on the right––
Positive is a left turn.
Neuron
One simulated cell. It adds up its input, leaks a little each step, and fires when it crosses a threshold.
Synapse
A one-way link between two neurons. Positive weights excite the target. Negative weights hold it back.
Sensory
Neurons that take input from outside: smell, electric field, ripple, light and touch.
Integrating
Telencephalon, optic tectum and cerebellum. They mix the senses together.
Command
Hindbrain neurons that choose between swimming forward, turning left and turning right.
Motor
Spinal neurons on each side of the body. Their firing is the only thing read out.
Drive
How hard the tail is beating, from 0 to 1. Both sides of the motor pool count.
Turn
Left motor activity minus right, from −1 to 1. Positive means a turn to the left.

Body

The body it would drive

A generic requiem shark in side view, about two metres long. The outline draws itself as you scroll. The labels mark the parts the brain listens through or moves.

Side view of a shark with its fins, gill slits, eye, nostril, ampullae and lateral line labelled Ampullae of Lorenzini Eye Gill slits First dorsal fin Lateral line Second dorsal fin Caudal fin Nostril Pectoral fin Pelvic fin Anal fin
Ampullae of Lorenzini
Jelly-filled pores on the snout that pick up weak electric fields from living muscle.
Nostril
Water flows in and out for smell only. Sharks breathe through their gills.
Eye
Many sharks have a reflective layer behind the retina that helps in dim water.
Gill slits
Five on each side in most sharks. A few species have six or seven.
Pectoral fins
Give lift and help steer. A shark can't paddle them backwards.
First dorsal fin
Keeps the body from rolling.
Lateral line
A canal along each flank that feels water movement and pressure.
Second dorsal fin
A smaller stabiliser near the tail.
Pelvic and anal fins
Stabilisers underneath. Some sharks have no anal fin.
Caudal fin
The tail. In many sharks the upper lobe is longer, which pushes the head up as it beats.

Live body

Seen from above. The tail beats as fast as the brain's drive says, and the turn readout bends its path.

Tail beats 0.0/s Heading steady State cruising

Senses

Five senses, five ranges

Drag the fish around the shark. Each sense only reaches so far, and the brain hears from whichever ones can detect it. While this section is on screen, what the shark senses feeds straight into the brain above. Ranges are rough figures for a two-metre shark in clear coastal water. Real values vary a lot with species, current and visibility. The scale is logarithmic.

    Brain: cruising

    Chum the water

    Drop any file here or . It's read in your browser and nothing is uploaded. SHARQ measures how mixed up the bytes are and turns that into a smell. Plain text usually lands around 4 to 5 bits per byte. Compressed files and photos land near 8 and smell strongest.

    start of filelow mix high mixend
    File
    –
    Size
    –
    Bits per byte
    –
    Smell
    –

    Run it

    Run it on your machine

    Everything here works offline once a model is downloaded. You need Node 20 or newer. There's nothing to install from npm.

    1. Get the file

      SHARQ is one file: the brain on this page plus a small command line. Download it, or fetch it from a terminal with curl -O https://sharq.ink/sharq.mjs.

      Download sharq.mjs
      Show the source
    2. Poke the brain

      Put a smell on its left and read what comes out. No model is needed for this.

      node sharq.mjs poke scent left
      poked scent on the left
      state    turning left
      drive    0.39   turn +0.44   sense 0.27
      settings temperature=0.74 top_p=0.78 repeat_penalty=1.13 num_predict=338
    3. Start a local model

      Any model works. With Ollama, pull one and it serves on port 11434.

      ollama pull llama3.2
    4. Let the shark steer

      Words in your prompt become stimuli, then the brain settles for a couple of seconds and sends its four settings with the request. Add --stim electric:right to drop in your own. For LM Studio, llama.cpp or vLLM, pass the server's address with --openai.

      node sharq.mjs steer "A fish is bleeding near the reef. What happens next?" --model llama3.2

    Local servers

    EngineDefault addressFlag
    Ollamahttp://localhost:11434--base (the default)
    LM Studiohttp://localhost:1234/v1--openai
    llama.cpp serverhttp://localhost:8080/v1--openai
    vLLMhttp://localhost:8000/v1--openai

    Why a shark

    A hunting shark hands the job from one sense to the next. Far from its prey, smell and low-frequency sound do the work. Closer in, vision and the lateral line take over. In the last half metre, many sharks rely on electroreception, picking up the faint fields that living muscle gives off. Separate inputs, a shared middle, and one body that has to pick a direction is a good shape for a small model.

    The brain plan is also familiar. Sharks share it with most other vertebrates: olfactory bulbs at the front, an optic tectum that maps the space around the animal, a cerebellum, and a hindbrain that runs the body. SHARQ borrows that layout and very little else.

    Senses by distance

    From far to near, the order is roughly smell and hearing, then vision, then the lateral line, then the electric sense, then touch and taste at contact. The ranges in the Senses section are illustrations. They depend on species, water clarity, current and the prey itself, so treat them as orders of magnitude.

    The electric sense

    A shark's snout is dotted with pores that lead to jelly-filled canals, the ampullae of Lorenzini, named after Stefano Lorenzini, who described them in 1678. What they did stayed unclear for almost three centuries. In 1971 Adrianus Kalmijn showed that sharks and rays find a flatfish buried in sand by its electric field. They still struck when the fish's smell was blocked, missed it when the field was blocked, and attacked buried electrodes that imitated the field.

    In SHARQ the electric channel feeds the tectum and the command neurons directly. It produces the sharpest turns, which fits its job as the close-range sense used in the final approach.

    The lateral line

    Along each flank runs a canal lined with sensory cells called neuromasts. They respond to water movement and pressure changes, which lets a fish feel a struggling animal or a nearby obstacle without seeing it. In SHARQ, a ripple on one side crosses to the opposite tectum, then crosses back to the command neurons on the original side. The result is a turn toward the source.

    Swimming to breathe

    Some sharks, such as makos and great whites, rely on ram ventilation. They keep swimming so water flows over their gills. Others, like nurse sharks, can pump water while lying still. SHARQ gives its forward command neurons a constant small input, so the brain idles at a slow cruise and never stops. That baseline is why temperature rarely drops much below 0.5.

    How the model works

    There are 240 integrate-and-fire neurons in ten regions. Each one adds up incoming spikes, leaks a little every step, and fires when it crosses a threshold. Wiring comes from 17 rules of the form "olfactory bulb connects to telencephalon on the same side with probability 0.30". A fixed random seed turns those rules into about 1,300 synapses, the same set every time. The sensory regions take input. The motor neurons on the left and right are read out as drive (how hard the tail beats) and turn (left minus right).

    Four settings come out:

    temperature = 0.45 + 0.75 × drive top_p = 0.70 + 0.28 × sense repeat_penalty = 1.00 + 0.30 × |turn| num_predict = 64 + 448 × (1 − drive)

    A striking shark writes short, hot answers. A cruising shark writes long, calm ones.

    Does the wiring matter?

    The comparison panel runs the same stimulus through two brains. One has the rule-based wiring. The other keeps every neuron's outgoing synapses and weights but sends each one to a random target. With the rules, a smell on the left produces a left turn and an electric field on the right produces a right turn. Shuffled, the brain still speeds up but loses its sense of direction.

    That shows the steering depends on the structure. It doesn't show the structure is right, because we wrote the rules.

    What it can't tell you

    • No shark connectome exists. A real shark brain has vastly more than 240 neurons. These are a sketch with the right regions in roughly the right places.
    • The step from words to senses is a keyword list. It doesn't understand the prompt.
    • Nobody has measured whether shark-steered sampling makes text better or worse. It changes the settings in a way you can watch, and that's all it claims.
    • The sense ranges are rough illustrations, not measurements.

    Sources

    • Lorenzini, S. (1678). Osservazioni intorno alle torpedini. Florence.
    • Kalmijn, A. J. (1971). The electric sense of sharks and rays. Journal of Experimental Biology 55, 371–383.
    • Carrier, J. C., Musick, J. A. and Heithaus, M. R. (eds.). Biology of Sharks and Their Relatives. CRC Press.
    • Ollama, the /api/chat endpoint and its options field: github.com/ollama/ollama