Source-linked AI summary
S3C-LLM: Skill-Code Guided Agentic Language Models for Spectrum-to-Structure Elucidation
Xuanle Zhao, Xinyuan Cai, Xiang Cheng, Bo Xu
TL;DR
Recent LLM-based spectrum-to-structure methods largely predict molecular strings directly, without explicitly modeling spectroscopic analysis. S3C-LLM uses spectroscopy skills and executable analysis code to reason over spectral evidence, and outperforms baselines across spectra with substantially fewer training samples.
Problem
Recent LLM-based methods largely predict molecular strings directly rather than explicitly modeling spectroscopic analysis from diagnostic peaks through fragments and formula constraints.
Source: §1 · p. 1Method
S3C-LLM retrieves spectroscopy skills, executes analysis code, and uses the resulting evidence and formula constraints to guide structure prediction.
Source: §1 · p. 1, §3.1 · p. 3Results
Across three single-spectrum settings, S3C-LLM outperforms modality-specific baselines and SpectraLLM while using less than 1/10th of SpectraLLM’s paired-spectra corpus.
Source: §4.3 · p. 7, §5 · p. 8Takeaways & Limitations
The results suggest S3C-LLM can effectively exploit peak information through skills and code while using substantially fewer paired spectra.
Source: §4.3 · p. 7Evaluation uses compact peak-level representations, and the current skill library covers common optical, NMR, and MS/MS modalities.
Source: Limitations · p. 9
Abstract
from arXiv · showhide
Spectroscopic structure elucidation is central to molecular analysis, but recent Large Language Model (LLM)-based methods mostly formulate it as direct spectrum-to-SMILES generation. Although this paradigm can leverage paired spectral data, it does not explicitly model the analytical workflow used by spectroscopists, such as diagnostic peak interpretation, fragment reasoning, formula constraints, and chemical consistency checking. In this paper, we introduce S3C-LLM, a skill-guided and code-grounded agentic LLM for spectrum-to-structure elucidation. Rather than directly predicting a molecule, S3C-LLM retrieves modality-specific spectroscopy skills, executes analysis code to instantiate these skills on the input spectra, and integrates the resulting peak-level evidence and formula constraints before generating SMILES. Specifically, we contribute a self-evolving spectroscopy skill library, a thinking-augmented skill-code trajectory construction pipeline, and a two-stage training strategy that teaches Qwen3-4B through supervised fine-tuning (SFT) followed by our proposed step-level reinforcement learning (RL). Experiments on diverse benchmarks show that S3C-LLM consistently outperforms current general LLMs and spectrum-specific models across spectra, while using less than 1/10th of SpectraLLM's training corpus.
1 Introduction
S3C-LLM replaces direct spectrum-to-SMILES prediction with skill-guided, code-grounded reasoning that reflects spectroscopic analysis. It combines a self-evolving skill library and executable analysis with SFT and step-level RL, and reports strong benchmark performance with less training data than SpectraLLM.
1 Introduction
- Unlike direct-answer LLM methods, which predict molecular strings from spectra without explicitly modeling analysis, S3C-LLM follows expert reasoning from diagnostic peaks to functional groups, fragments, formula constraints, and a consistent structure.Spectroscopy agents LUMIR and IR-Agent also analyze evidence before prediction, but remain limited by spectroscopy-specific chemical grounding (Xie et al., 2025; Noh et al., 2025).Source: §1 · p. 1
- S3C-LLM uses a self-evolving spectroscopy skill library and executable code to extract spectral evidence, perform quantitative checks, and build interpretable prediction trajectories.Skills encode reusable links between diagnostic peak regions and functional groups, fragments, or substructure constraints; mass-spectral code can compute mass differences and derive formula candidates under chemical-consistency constraints.Source: §1 · pp. 1–2
- The training pipeline constructs agentic trajectories from evolved skills and code outputs, adds thinking traces by reverse-engineering reasoning from history and reference actions, then trains with SFT followed by step-level RL.Step-level RL optimizes intermediate reasoning steps rather than only the final answer.Source: §1 · pp. 1–2
- 500K SFT examples—less than one-tenth of SpectraLLM’s reported paired-spectra corpus—support state-of-the-art performance across molecular structure elucidation metrics and outperform existing baselines.The paper reports these results across multiple spectral benchmarks.Source: §1 · p. 2
2 Related Work
Prior spectrum-elucidation work spans chemically constrained search and data-driven structure prediction, while scientific and chemistry agents extend LLMs with tools, executable code, and reusable skills.
2.1 Spectrum Elucidation Methods
- Conventional CASE and MS/MS systems constrain candidate structures with spectral evidence or fragmentation rules, but often depend on hand-designed rules, libraries, or spectrum-specific search.Examples include NMR CASE and database methods, CSI:FingerID, SIRIUS, MetFrag, MS-FINDER, and CFM-ID.Source: §2.1 · p. 2
- Learning-based methods span NMR ranking and elucidation, MS/MS prediction and generation, and formula-aware transformer or diffusion approaches, alongside emerging multi-spectral benchmarks and foundation models.The cited work includes NEIMS, MassFormer, DarkNPS, MSNovelist, Spec2Mol, MIST, DiffMS, the Multimodal Spectroscopic Dataset, MassSpecGym, SpectraLLM, and SpecMol.Source: §2.1 · p. 2
2.2 Scientific LLM Agents
- Scientific LLM agents couple reasoning with actions and tools; program-aided models delegate symbolic computation to code, while skill-agent systems build persistent, validated, and evolving skill libraries.Examples include ReAct (Yao et al., 2023), Toolformer (Schick et al., 2023), program-aided language models (Gao et al., 2023), SkillFoundry, and CoEvoSkills (Shen et al., 2026; Zhang et al., 2026).Source: §2.2 · pp. 2–3
- Chemistry agents apply domain operations and validation, with Chem-Crow supporting molecular search and synthesis tasks and Coscientist combining search, code, documentation, and laboratory automation.Chem-Crow; Coscientist (Boiko et al., 2023; Zhao et al., 2026b,a).Source: §2.2 · p. 3
3 Method
S3C-LLM turns spectrum-to-structure prediction into a skill-guided, code-grounded process that conditions molecular predictions on explicit analysis evidence. It builds modality-specific skills, constructs executable skill-code trajectories, and trains Qwen3-4B with supervised fine-tuning followed by step-level reinforcement learning.
3.1 Overview
- S3C-LLM predicts molecular structures from processed spectra by retrieving spectroscopy skills, executing analysis code, and integrating peak evidence with formula constraints.Its intermediate trajectory comprises retrieved skill content, generated code, and execution output, so the model learns to predict both the analysis trajectory and target structure rather than only the structure from the input.Source: §3.1 · p. 3
3.2 Skill Library Construction
- A self-evolving skill library formalizes spectroscopic interpretation as modality-specific rules linking diagnostic signals to chemical hypotheses.Claude Opus 4.6 with Claude Code (Anthropic, 2026b,a) runs 20 evolution iterations per modality with 50 samples each, revising skills through prediction, verification, diagnosis, and revision; the process yields eight skills.Source: §3.2 · p. 3
3.3 Agentic Data Construction
- The data pipeline generates executable spectrum analyses and 500K tool-use trajectories, augmenting about 100K with filtered explicit thinking traces.Code performs modality-specific evidence extraction and quantitative checks; trajectories use read_skill and run_code, with one skill retrieval per single-modality input or multiple retrievals followed by one joint analysis for multimodal inputs. GPT-5.4 (OpenAI, 2026a) generates thinking traces, and the remaining 400K trajectories retain empty thinking blocks.Source: §3.3 · pp. 3–4
3.4.2 Step-Level RL
- Step-level GRPO assigns verifiable rewards to skill retrieval, code execution, and final SMILES prediction, localizing feedback while allowing downstream structure quality to inform earlier actions.The final step is scored by Morgan fingerprint Tanimoto similarity; malformed calls, missing skills, execution failures, and invalid SMILES receive zero reward. The method addresses heterogeneous failures, most of which follow valid tool execution and reflect incorrect SMILES.Source: §3.4.2 · p. 5
4 Experiments
S3C-LLM outperforms reported baselines across optical, MS/MS, and NMR evaluations while using less than one-tenth of SpectraLLM’s paired-spectra corpus. Ablations indicate that its skill-and-code workflow and staged training contribute to performance.
4.1 Experimental Setup
- Evaluation uses shared splits across optical, NMR, and MS/MS benchmarks, and compares structure-level similarities rather than exact-match accuracy.Inputs are peak-level text, and the model generates SMILES; the evaluation includes general LLMs and spectrum-specific baselines.Source: §4.1 · p. 6
4.2 Implementation details.
- The Qwen3-4B model is fine-tuned on 500K agentic trajectories with read_skill and run_code, followed by step-level RL.Both stages use full-parameter fine-tuning for one epoch on eight H800 GPUs.Source: §4.2 · p. 6
4.3 Main Results
- S3C-LLM outperforms the reported baselines on QM9S optical spectra, both MS/MS benchmarks, and single and combined NMR settings.It uses less than one-tenth of SpectraLLM’s paired-spectra corpus.Source: §4.3 · pp. 6–7, Table 3 · p. 7, Table 4 · p. 7
- MS/MS skills and code enumerate and rank formula candidates from fragment-ion and mass-difference evidence before the model predicts a structure.Performance gains are especially large on the simulated Multimodal Spectroscopic Dataset; noise and peak shifts make mass matching less exact on experimental MassSpecGym spectra.Source: §4.3 · p. 7, Table 3 · p. 7
4.4.1 Skill Quality Analysis
- Skill evolution improves precision across the three NMR modalities, with HSQC converging earlier than 13C NMR and 1H NMR.Precision measures correctness of explicit skill-supported claims, not recall of all functional groups; skills include only deterministic or high-confidence rules.Source: Figure 2 · p. 7, §4.4.1 · p. 8
4.4 Ablation Study
- The ablation study examines evolved-skill reliability, training-stage contributions, and the effects of different tool configurations.Its three analyses cover skill quality, training stages, and toolset choices.Source: §4.4 · p. 7, §4.4.1 · p. 8, §4.4.2 · p. 8
4.4.2 Training Stage Ablation
- SFT establishes agentic tool use, and step-level RL further improves performance across spectrum types; RL without SFT yields almost no effective learning.Trajectory-level RL produces smaller and less stable gains, supporting localized rewards for skill reading, code execution, and final prediction.Source: Table 5 · p. 8, §4.4.2 · p. 8
4.4.3 Toolset Ablation
- Adding read_skill improves over chat-only models, while adding run_code further improves results, especially on HSQC and MS/MS.The proposed explanation is that executable computation helps with cross-peak relations and mass constraints.Source: Figure 3 · p. 8, §4.4.3 · p. 8
5 Conclusion
S3C-LLM combines spectroscopy skills with executable code to reason over spectral evidence and formula constraints before predicting structures. Across optical, MS/MS, and NMR spectra, it outperforms modality-specific baselines and SpectraLLM while using a smaller backbone and fewer training samples.
5 Conclusion
- S3C-LLM is a skill-code guided agentic LLM that executes spectroscopy skills to reason over peak evidence, formula constraints, and intermediate computations before predicting structures.Source: §5 · p. 8
- Across optical, MS/MS, and NMR spectra, S3C-LLM outperforms modality-specific baselines and SpectraLLM while using a smaller Qwen3-4B backbone and substantially fewer training samples.Source: §5 · p. 8
- Ablations confirm the value of agentic training, step-level RL, retrieved skills, and code execution.Source: §5 · p. 8
- Future work will extend S3C-LLM to noisier experimental spectra.Source: §5 · p. 8
Limitations
S3C-LLM is evaluated on established benchmarks using compact peak-level representations, while its skill coverage and tool-use efficiency leave clear directions for extension.
Limitations
- S3C-LLM is evaluated on established spectrum-to-structure benchmarks using compact peak-level representations, following prior work to enable fair comparisons.Future work could extend the framework to richer raw-spectrum inputs and additional experimental conditions.Source: Limitations · p. 9
- The skill library covers common optical, NMR, and MS/MS modalities, and could expand to specialized spectra as datasets become available.Source: Limitations · p. 9
- Because inference uses tool-call trajectories, improving tool-call scheduling and execution efficiency could support large-scale deployment.Source: Limitations · p. 9
Ethics Statement
S3C-LLM is intended to support scientific molecular structure elucidation, not hazardous synthesis or safety-critical chemical decisions without screening and human oversight.
Ethics Statement
- The work uses public or benchmark spectroscopy datasets without human subjects or private data, provides no wet-lab protocols, and requires oversight for hazardous or safety-critical uses.The paper also states that the system does not optimize molecules for biological activity or toxicity.Source: Ethics Statement · p. 9
A Appendix
The appendix describes a box format that preserves the full conversation trajectory used to produce a prediction.
A Appendix
- Each box preserves user input, assistant reasoning, tool calls and responses, code observations, and the final prediction.The box matches the reference structure.Source: A Appendix · p. 12
A.1 Dataset and Split Details
S3C-LLM uses established benchmark splits, represents spectra as compact peak-level text, and confines reference-structure-assisted construction to training data. Held-out splits are reserved for final evaluation of the learned tool-use process and SMILES output.
A.1 Dataset and Split Details
- Evaluation uses QM9S Raman, UV-Vis, and IR tasks; the Multimodal Spectroscopic Dataset’s NMR and MS/MS settings; and MassSpecGym experimental MS/MS, with no additional splits.The Multimodal settings include 13C NMR, 1H NMR, HSQC, MS/MS, and combined NMR.Source: §A.1 · p. 12
- All spectra are converted into compact peak-level textual representations before serving as model inputs.Source: §A.1 · p. 12
- Reference-structure-assisted skill evolution, code and trace generation, SFT construction, and RL sampling use only training data; held-out spectra are reserved for final evaluation.At evaluation, S3C-LLM receives spectrum input and tool configuration, uses read_skill and run_code, and outputs a final SMILES.Source: §A.1 · p. 12
A.2 Comparison with SpectraLLM
S3C-LLM and SpectraLLM differ in backbone scale, training data, and how they use spectra: S3C-LLM learns a skill-and-code analysis workflow, whereas SpectraLLM fine-tunes on direct spectrum-to-SMILES examples.
A.2 Comparison with SpectraLLM
- SpectraLLM uses a Qwen3-32B backbone with LoRA fine-tuning on direct spectrum-to-SMILES examples.Source: §A.2 · p. 12
- Its constructed corpus combines multiple spectral datasets and contains more than 5.5 million paired spectra.Source: §A.2 · p. 12
- S3C-LLM uses Qwen3-4B and trains on 500K skill-code trajectories to retrieve spectroscopy skills, execute analysis code, and predict SMILES.Source: §A.2 · p. 12
A.3 Skill Examples
The subsection presents skill-library examples that encode reusable spectral priors for downstream code-grounded reasoning.
A.3 Skill Examples
- Figures 4 and 5 show complete Markdown skill files selected from the HSQC and MS/MS skills.The examples illustrate how the skill library stores reusable spectral priors for downstream code-grounded reasoning.Source: §A.3 · p. 12
A.4 Correct Rollout Trajectories
These parts illustrate skill-guided, code-grounded NMR rollouts in which the agent interprets spectra and executes analysis code, including 13C peak classification and analysis combining 13C, 1H, and HSQC evidence. The examples are labeled exact molecular matches.
A.4 Correct Rollout Trajectories
- The included MS/MS skill outlines precursor-mass formula enumeration, fragment-based element constraints, RDBE checks, and neutral-loss analysis.It specifies a typical 5 ppm tolerance for high-resolution MS formula enumeration.Source: §A.4 · p. 15
- The HSQC skill interprets direct 1H–13C bonds and nH multiplicity, using aromatic CH counts to infer substitution and absent cross-peaks to flag quaternary carbons.Source: §A.4 · pp. 17–18
- In the HSQC rollout, the agent retrieves the skill and runs code to classify correlations and aggregate peak-group and CH3/CH2/CH counts.Source: §A.4 · p. 18
- Figure 6 presents an HSQC tool-use rollout with an exact molecular match, within three successful trajectories whose final SMILES are described as exact.Source: §A.4 · p. 12, Figure 6 · p. 19
- For a combined-spectrum example, the agent loads 13C NMR, 1H NMR, and HSQC skills to interpret carbon shifts and link aliphatic protons to carbons.Source: §A.4 · p. 20
Correct Rollout Trajectories
- The 1H skill interprets shifts alongside multiplicity and J-coupling, reporting multiple structural possibilities when chemical-shift ranges overlap.Diagnostic patterns include a 3H triplet at 0.8–1.5 ppm for an ethyl methyl and a large-J doublet for a trans alkene.Source: §A.4 · pp. 21–22
- HSQC links each 1H signal to its directly bonded 13C, classifies CH, CH2, and CH3, and leaves quaternary carbons invisible.Aromatic CH counts inform substitution patterns, while hydrogen absent from HSQC may indicate exchangeable NH or OH.Source: §A.4 · pp. 22–23
- The combined-NMR rollout trajectory achieves an exact molecular match; its 1H NMR analysis reports 6 total peaks, while HSQC analysis reports 5 correlations and 7 total H.Source: §A.4 · p. 25, Figure 7 · p. 26
- The 13C skill uses chemical-shift ranges and peak counts to infer carbon types, symmetry, and structural features such as aromatic rings and carbonyl groups.Its guidance treats overlapping ranges as multiple possibilities rather than a unique assignment.Source: §A.4 · pp. 27–28
A.4 Correct Rollout Trajectories
- The analysis matches each peak shift against ranges in functional-group rules and assigns “Unknown” when no rule matches.Source: §A.4 · p. 28
- 12 peaks are reported in the 13C NMR analysis, with assignments spanning carbonyl/aromatic C=N, aromatic unsaturated or substituted carbon, and C-N/C-O types.The output lists one peak at 165.39 ppm, nine aromatic-associated peaks from 141.96 to 129.44 ppm, and two C-N/C-O peaks at 57.56 and 56.04 ppm.Source: §A.4 · p. 28
- Figure 8 labels the full 13C NMR rollout trajectory as producing an exact molecular match.Source: Figure 8 · p. 29