AmadeusGPT: a natural language interface for interactive animal behavioral analysis

Shaokai Ye, Jessy Lauer, Mu Zhou, Alexander Mathis, Mackenzie W Mathis

Introduction

Quantifying animal behavior is a cornerstone of neuroscience and ethology, yet it remains a significant technical bottleneck. Traditionally, researchers observing animal subjects must choose between manual annotation—which is slow and subjective—or developing custom machine learning classifiers, which requires advanced programming expertise. AmadeusGPT bridges this gap by providing a natural language interface that allows researchers to analyze behavior simply by describing it in plain English. By combining Large Language Models (LLMs) with a novel dual-memory mechanism and a suite of computer vision tools, the system turns descriptive observations into executable Python code.

The Technical Gap in Ethology

Life scientists often possess deep biological insights but lack the coding skills necessary to implement complex spatio-temporal reasoning. While general-purpose LLMs like GPT-4 are capable of generating code, they are prone to "hallucinations" (generating non-existent functions) and possess limited context windows. These limitations make them unreliable for the long, complex sessions required for behavioral analysis. AmadeusGPT was developed to address these specific reliability and memory constraints.

System Architecture and Methods

AmadeusGPT is an augmented LLM system specifically designed for behavioral analysis. Its architecture consists of three primary components:

  • The Core API: A specialized library of "atomic" functions for computer vision (including pose estimation via SuperAnimals and object segmentation via SAM), kinematics (speed, acceleration), and spatio-temporal reasoning.
  • Dual-Memory Mechanism: To overcome the token limits of standard LLMs, the system utilizes a short-term memory (a dynamic "deque" of recent chat history) and a long-term memory (a dictionary in RAM). This allows users to "save" specific behavioral definitions (e.g., <|head dips|>) and recall them hours later.
  • The Reflection Module: This module includes a Rephraser to translate messy human queries into API-compatible logic, a Self-correction loop that identifies and fixes Python runtime errors, and an Explainer that provides the rationale behind the generated results.

Experimental Evaluation

The researchers evaluated AmadeusGPT across three distinct scenarios to test its versatility and accuracy:

  1. Elevated Plus Maze (EPM): A standard neuroscience assay used to study anxiety in mice.
  2. MausHaus: A long-form video (108,000 frames) of a mouse in an enriched home-cage environment.
  3. MABe 2022 Behavior Challenge: A rigorous multi-agent benchmark involving three mice performing social behaviors such as chasing, huddling, and watching.

Key Insights and Results

AmadeusGPT demonstrates that natural language can effectively serve as a compiler for biological concepts. A key finding was that rule-based "task programs" generated by the LLM often outperformed complex, end-to-end machine learning models. On the MABe 2022 challenge, AmadeusGPT achieved state-of-the-art F1 scores, notably in the "Chase" category (0.274 vs. 0.050 for the next best model) and "Watching" (0.600 vs. 0.191).

In the EPM tasks, the system’s automated counts were statistically indistinguishable from those provided by three expert human raters, proving its utility as a reliable replacement for manual scoring. Furthermore, the Reflection Module proved vital; without the Rephraser, the success rate on varied user queries dropped significantly from 88% to 32%.

Limitations and Future Directions

While AmadeusGPT represents a significant leap forward, the authors note several areas for improvement. The system currently only supports English and relies on the underlying logic of GPT-3.5/4, which may inherit certain biases. Additionally, the computational cost of frequent API calls can be high for large-scale processing. Future work will focus on making the system more "proactive," enabling it to suggest relevant behavioral modules to researchers rather than simply responding to queries.

Summary updated

BibTeX
@inproceedings{ye2023amadeusgpt,
  author = {Shaokai Ye and Jessy Lauer and Mu Zhou and Alexander Mathis and Mackenzie W Mathis},
  title = {{AmadeusGPT: a natural language interface for interactive animal behavioral analysis}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=9AcG3Tsyoq},
}
Figure