Command Palette
Search for a command to run...
Based on Large Model Inference and the Use of the MCP Tool, AI X-ray Scientists at Stanford University Autonomously Completed single-crystal Diffraction Alignment at a Synchrotron Radiation source.

Experimental science typically follows a closed loop of "hypothesis-experiment-analysis-iteration," but this process has long been limited by the efficiency of manual operation, expert experience, and data processing capabilities. In fields such as materials, chemistry, and condensed matter physics, large-scale scientific research facilities such as synchrotron radiation sources and neutron spallation sources can reveal the structure and dynamics at the atomic and molecular scale, but they also generally suffer from problems such as limited time, complex operation, and high dependence on senior researchers.
The development of artificial intelligence has provided new possibilities for improving experimental efficiency. In the past, machine learning was mainly used for predicting material properties, optimizing experimental parameters, and data analysis; now, with the continuous advancement of active learning, robotics, and large language models, AI is beginning to move from being a post-experimental auxiliary tool to an active participant in the experimental process. With the help of structured tool invocation mechanisms, AI can not only analyze data but also invoke instruments, adjust parameters, and decide on the next step based on real-time feedback.
This capability is particularly important for large-scale facilities such as X-ray scattering. As light source brightness and detection speed continue to increase, the amount of experimental data grows rapidly, and problems such as sample bias, equipment drift, and signal fluctuations become more prominent. Traditional fixed scripts can handle standard procedures, but they struggle to cope with experimental situations that deviate from expectations.
Based on this,A research team from Stanford University and SLAC National Accelerator Laboratory has developed an "AI X-ray Scientist" system and deployed it on a real beamline at the Stanford synchrotron radiation source.The research team first completed system debugging in a virtual beamline, and then migrated to real equipment to test whether the AI could autonomously complete multi-step experiments and handle sudden deviations in the real environment by solving the single-crystal orientation matrix.
The related research findings, titled "An agentic artificially intelligent X-ray scientist," have been published in Nature Machine Intelligence.

View the paper:
https://www.nature.com/articles/s42256-026-01261-5
Dataset: Basic parameters, virtual simulation and actual beamline measurements
The data required by researchers mainly falls into three categories: basic parameters of the crystal and instrument, simulation data generated from virtual beamlines, and experimental data acquired from real beamlines.
The core verification sample was a magnetic Weyl half-metal, Co3Sn2S2. The system required prior acquisition of information such as crystal structure, X-ray wavelength, diffractometer motor travel, and detector geometry. This data helped the AI calculate the theoretical positions of the diffraction peaks and also defined the physical and safety boundaries for instrument operation. The study also used single-crystal silicon for supplementary verification.
To minimize the time commitment to the actual machine, the research team built a virtual beamline.The simulation platform generates diffraction images based on the geometry of the six-circle diffractometer, and adds peak broadening, hardware noise, and signal distortion to make the output as close as possible to the results of the real detector.
The researchers also deliberately introduced motor offset and lattice parameter errors into the simulation. The AI cannot simply copy theoretical values; it must infer the actual state from observations and continuously correct its judgments. In addition, the team set up more challenging scenarios, such as larger motor offsets, multi-grain interference, and limited inference resources, to test the system's stability.
After completing the virtual test, the system was deployed to the Stanford Synchrotron Radiation Facility SSRL BL17-2 beamline. Real-world data included detector images, scan curves, equipment status, and experimental logs. Compared to the simulation environment, the real experiment also introduced clamping errors, equipment misalignment, and random noise—problems not pre-modeled—which were crucial for testing the AI's adaptability.
An autonomous diffraction experimental system based on large model inference and MCP tool invocation
The "AI X-ray Scientist" consists of three parts: a large model responsible for analysis and decision-making, a tool interaction layer responsible for transmitting instructions, and experimental equipment for performing actual operations.

The three are connected via the Model Context Protocol, also known as MCP. AI can read sample and instrument information, view detector images and scanning curves, and generate instructions for motor control, peak scanning, and data fitting. To ensure safety, AI does not directly access the underlying hardware but interacts with the device through restricted interfaces.
In the virtual test, the research team compared Claude Sonnet 4 and Gemini 2.5 Flash;The real beamline experiment uses the Claude Opus 4, which has stronger reasoning capabilities.The system does not require retraining the model; it primarily relies on prompts, experimental manuals, and tool instructions to guide the large model in understanding the task. These prompts do not pre-define every step of the operation but rather inform the AI of the experimental objective, available tools, and safety rules. The selection of which diffraction spot, the size of the scanning range, and how to handle abnormal signals are determined automatically by the AI based on real-time results.
The entire process forms a continuous loop: the AI first reads the information and calculates the theoretical position, then controls the equipment to scan, subsequently analyzes the observation results, and adjusts the next strategy accordingly. The difference between this and a fixed script is that if the experimental results deviate from expectations, the AI can re-evaluate the cause, rather than mechanically continuing the original process.
Orientation error <5°, successful installation corrected 1.22° offset.
This study chose to solve the single-crystal orientation matrix as the test task. Simply put, this work determines the relationship between the crystal coordinate system and the laboratory coordinate system, a prerequisite step in most single-crystal scattering experiments. Completing this task typically requires finding at least two diffraction spots and continuously calibrating the peak positions through the coordinated movement of multiple motors. The experiment involves dealing with complex spatial geometry and identifying noise and anomalous signals, thus heavily relying on the operator's experience.
In the virtual foundation test, multiple experiments were conducted using Claude Sonnet 4 and Gemini 2.5 Flash respectively. The results are shown in the figure below.All tests successfully located the target diffraction spot, and the orientation error of the vast majority of experiments was less than 5°;More than half of the tests kept the error of the lattice constant c within 0.01 Å. System performance degraded when motor offset increased, polycrystalline interference occurred, or the available inference resources for the model decreased. The impact of limited inference resources was the most significant. This indicates that autonomous experiments depend not only on whether the model "knows" the experimental knowledge, but also on its ability to perform sufficient and continuous analysis.

The real beamline experiment adopts an "AI decision-making, human intermediary" model. AI is responsible for generating experimental instructions, and on-site personnel are only responsible for inputting the instructions into the equipment as is, without participating in peak position determination or strategy selection.
In the Co3Sn2S2 experiment, the AI first selected the (0,0,6) diffraction spot for searching. After scanning, it found a significant deviation between the actual peak position and the theoretical position, and further determined that the deviation might be due to unevenness of the sample holder. The system then corrected the η-axis shift by approximately 1.22° and recalibrated the peak center.

After locking onto the first diffraction spot, the AI selected (1,0,10) as the second target and determined the in-plane orientation of the crystal by expanding the φ-axis scanning range. During the experiment, diffraction ring interference appeared in the detector image, but the AI did not misjudge it as the target single crystal peak and finally completed the orientation matrix solution.

In single-crystal silicon experiments, the system successfully completed the search and alignment even with sharper diffraction peaks and an η-axis shift of approximately 1.5°. Due to time constraints with real-world equipment, this study has not yet been replicated on a large scale, and therefore cannot yet demonstrate the system's applicability to all samples and beamlines. However, the experiments have completed a crucial proof of concept:Large language models can detect biases, adjust strategies, and maintain experimental closed loops in real-world environments not fully covered by simulations through continuous observation, reasoning, and tool calls.
This means that the role of large language models in scientific research may no longer be limited to literature retrieval, code generation, and offline data analysis. By combining with specialized tools, secure interfaces, and physical rules, it is expected to further become a research collaborator capable of participating in equipment operation, experimental decision-making, and anomaly handling.
Final Thoughts
The significance of "AI X-ray scientists" lies not in replacing laboratory personnel, but in allowing AI to move beyond data analysis tools and into the experimental field, participating in equipment operation, status assessment, and strategy adjustment. Although currently limited by sample size, actual machine time, and the need for human safety intermediaries, this research has demonstrated that large models can complete experimental loops through continuous observation and reasoning in complex, non-ideal real-world environments.
In the future, as models, robots, and scientific instruments are further integrated, AI is expected to become an important collaborating partner in large-scale scientific research facilities, helping researchers reduce repetitive operations and devote more energy to the scientific questions themselves.








