# Large Language Model-Informed X-ray Photoelectron Spectroscopy Data Analysis
## 4 Materials and Methodology
### LLM Interpretation  
Post curve fitting, the resultant parameters of each peak are analyzed using OpenAI's GPT-3.5 Turbo, as described previously. The model receives as input a formatted string containing the parameters of each fitted peak, as well as some auxiliary information about the sample, to generate an output that simulates a consultation with a domain expert. The process is implemented with the OpenAI API. We use the \"openai.ChatCompletion.create\" function, passing in an array of message objects. The first message sets the role of the assistant and the second message provides the content which includes the fitted peak parameters. For instance, the content may look as follows:\"Given that peak 1 has a mean at 532.5 eV with a standard deviation of 1.2 eV and an amplitude of 0.75, peak 2 has a mean at 533.5 eV with a standard deviation of 1.1 eV and an amplitude of 0.80, can you help me interpret the potential chemical states?\"  
The model then generates a response that interprets the peaks in terms of potential chemical states and other relevant factors. The output is parsed, and the extracted information is presented to the user. This process introduces a layer of expert-like analysis, allowing for an accessible and insightful understanding of the fitted XPS data, which can be especially useful for those lacking extensive background in the field. For instance, an example query using OpenAI GPT-3.5-turbo is the following:  
[\"role\": \"system\", \"content\": \"You are an expert in X-ray Photoelectron Spectroscopy (XPS) and can provide insightful analysis of peak data.\"), {\"role\": \"user\", \"content\": f\"Given that {parameters_string}, what chemical states could these represent and what should I do next?\"]  
That produces the next LLM-informed analysis:  
Based on the information provided, it is likely that these peaks represent different chemical states of atoms or molecules in the sample being analyzed. Peak 1, with a center at 530 eV and the highest amplitude, may represent an element or compound that is present in high abundance in the sample. The relatively broad standard deviation of 1 suggests that this peak may be a composite of multiple chemical species with slightly different binding energies. Peak 2, with a center at 532 eV and a lower amplitude than peak 1, may represent a less abundant chemical state in the sample. The smaller standard deviation of 0.8 suggests that this peak may be a pure chemical species, as opposed to a composite of multiple species. Peak 3, with a center at 528 eV and the lowest amplitude, may represent a minor chemical species or a surface contamination. The small standard deviation of 0.5 indicates that this peak is likely a pure chemical state. In order to gain more insight into the chemical identity of these peaks, it would be helpful to compare the peak positions and shapes to known binding energies and spectra for different chemical elements and compounds. Further analysis, such as peak fitting and deconvolution, may also be necessary to separate components within the composite peak 1 and to quantify the relative amounts of each chemical species. Overall, the information provided by the XPS peaks can provide important information about the chemical composition and surface properties of the sample being analyzed. Proper interpretation and analysis of the spectra can help inform future experiments or materials design. In Algorithm 2, we present the pseudocode representation of the LLM peak analysis function, an integral part of our LLM-informed XPS analysis methodology. This function defines the core logic for interfacing with the LLM, handling the submission of XPS peak parameters, managing communication retries, and processing the LLM's response.