Skip to main content

SAIL: A Framework for Rigorous AI-Assisted Scientific Coding

Setting SAIL: Leveraging Scientist-AI-Loops for Rigorous Visualization Tools

Nico Schuster, Andrés N. Salcedo, Simon Bouchard, Dennis Frei, Alice Pisani, Julian E. Bautista, Julien Zoubian, Stephanie Escoffier, Wei Liu, Georgios Valogiannis & Pauline Zarrouk
Key figure for SAIL: A Framework for Rigorous AI-Assisted Scientific Coding

The recent explosion in generative AI and Large Language Models (LLMs) offers a powerful opportunity to accelerate software development and create new tools, such as interactive scientific visualizations. Yet this also introduces a significant risk: the tendency for AI to “hallucinate” or simplify scientific laws to satisfy coding tasks or context limits. Moreover, these LLMs often lack the specialized intuition needed to distinguish between a functional script and a rigorously sound model, showcasing the need for expert guidance.

To address this risk, we developed the “Scientist-AI-Loop” (SAIL) framework, a workflow that keeps the researcher at the helm of the development process. SAIL structurally decouples domain logic and scientific concepts from the code syntax, allowing researchers to serve as strict project “Architects” while delegating code implementation to AI. By maintaining this human-in-the-loop oversight, scientists can verify that their software adheres to fundamental principles while still benefiting immensely from AI assistance.

This workflow is illustrated through our two case studies, including the gravitational lensing visualization depicted above. While this image displays distortions from a point mass lens, the tool also models complex structures like cosmic voids. You can try both visualizations here. These tools successfully balance high-performance rendering with physical fidelity. More importantly, by establishing a framework to identify and fix AI “failure modes”, such as an algorithm naively inverting mass distributions to model voids, scientists across all disciplines can ensure their code remains robust throughout rapid development.

Consequently, the SAIL methodology allows researchers to condense development time from months to days. It empowers experts to independently build interactive applications, fundamentally changing how we share and communicate scientific concepts and discoveries.

Official abstract
Scientists across all disciplines share a common challenge: the divide between their theoretical knowledge and the specialized skills and time needed to build interactive tools to communicate this expertise. While large language models (LLMs) offer unparalleled acceleration in code generation, they frequently prioritize functional syntax over scientific accuracy, risking visually convincing but scientifically invalid results. This work advocates the Scientist-AI-Loop (SAIL), a framework designed to harness this speed without compromising rigor. By separating domain logic from code syntax, SAIL enables researchers to maintain strict oversight of scientific concepts and constraints while delegating code implementation to AI. We illustrate this approach through two open-source, browser-based astrophysics tools: an interactive gravitational lensing visualization and a large-scale structure formation sandbox, both publicly available. Our methodology condensed development to mere days while maintaining scientific integrity. We specifically address failure modes where AI-generated code neglects phenomenological boundaries or scientific validity. While cautioning that research-grade code requires stringent protocols, we demonstrate through two examples that SAIL provides an effective code generation workflow for outreach, teaching, professional presentations, and early-stage research prototyping. This framework contributes to a foundation for the further development of AI-assisted scientific software.