animacy
A tiny autoregressive transformer, trained on trajectories of fish and flies, that samples each next step from a Gaussian mixture.
How it works
A trajectory is read like text. Each token is an animal's displacement over 1/30 s, and a decoder-only transformer of 0.8 million parameters predicts the next one as a mixture of five bivariate Gaussians, from which the step is sampled. The animal's 16 nearest neighbours are encoded by a small network and pooled with attention into its input.
Three versions were trained on idtracker.ai (opens in a new tab) recordings: about 100 hours of fish, 60 of fruit flies, and both pooled. With negative log-likelihood alone, simulated schools drifted apart. Adding the squared error of the mixture's mean step keeps more of each school together.
Rocks, food, walls and the predator never enter the model. At each step it proposes 16 moves, and one is drawn with probability proportional to exp(s), where s scores the move by rules from studies of real fish, such as turning away from a wall ahead (Calovi et al., 2018) or fleeing a predator that looms (McKee and McHenry, 2020). Every move is therefore one the model proposed.