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

arXiv:2608.30910v1cs.LGcs.CL

TL;DR

Spectrum-to-structure elucidation remains difficult because direct spectrum-to-SMILES methods do not explicitly model spectroscopists’ evidence-based analytical workflow. S3C-LLM addresses this by retrieving spectroscopy skills, executing code, and integrating peak evidence and formula constraints before prediction; it outperforms reported baselines across diverse spectra with less than 1/10th of SpectraLLM’s training corpus.

  • Problem

    Existing LLM-based spectrum-to-structure methods largely predict molecular strings directly and do not explicitly model diagnostic peak, fragment, formula, and chemical-consistency reasoning.

  • Method

    S3C-LLM retrieves modality-specific skills, executes spectrum-specific analysis code, integrates explicit skill-code evidence, and trains with SFT followed by step-level RL.

  • Results

    S3C-LLM outperforms modality-specific baselines and SpectraLLM across optical, MS/MS, and NMR spectra while using substantially fewer training samples.

  • Takeaways & Limitations

    The framework provides an agentic approach that combines spectroscopy skills, executable code, peak evidence, formula constraints, and intermediate computations for structure prediction.

  • Takeaways & Limitations

    Evaluation uses compact peak-level representations, while future work must extend the framework to noisier raw-spectrum inputs and additional experimental conditions.

Abstract

from arXiv · show

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 reframes spectrum-to-structure elucidation as skill-guided, code-grounded reasoning that models spectroscopic analysis before structure generation. Its self-evolving skills, executable analysis, and two-stage training yield strong benchmark performance with substantially fewer training samples.

  • Existing LLM methods directly predict molecular strings from spectra without explicitly modeling diagnostic peak, fragment, formula, and chemical-consistency reasoning.
  • S3C-LLM retrieves reusable spectroscopy skills and executes analysis code to extract peak-level evidence and perform quantitative chemical-consistency checks.Mass-spectra code can compute mass differences and derive molecular-formula candidates.
  • The framework constructs interpretable agentic prediction trajectories that record how spectral evidence and computational results support molecular predictions.
  • Training first uses SFT to imitate skill-code trajectories, then applies step-level RL to improve intermediate reasoning and tool-use ability.
  • Experiments show state-of-the-art performance across multiple spectral benchmarks while requiring substantially fewer training samples than SpectraLLM.

2 Related Work

Prior work spans chemically constrained candidate search, data-driven spectrum-to-structure modeling, and increasingly explicit tool-using scientific agents. These lines of work motivate combining domain spectroscopy skills, executable computation, and validation in a unified system.

  • Conventional and learning-based elucidation: Conventional elucidation systems use chemical shifts, correlations, databases, molecular fingerprints, formula hypotheses, and fragmentation rules to constrain or rank candidate structures.
  • Conventional and learning-based elucidation: Learning-based methods model spectrum–structure relations through candidate ranking, direct structure elucidation, structure-to-spectrum prediction, and molecular generation.
  • Scientific and chemistry agents: Scientific LLM agents make reasoning more explicit by interleaving language-model reasoning with environment actions, tool invocation, and executable symbolic computation.
  • Scientific and chemistry agents: Persistent, validated skill libraries extend generic tool use by packaging reusable executable skills with verifier feedback and self-evolution.
  • Scientific and chemistry agents: Chemistry agents combine domain operations with search, code execution, documentation reading, and laboratory automation.

3 Method

S3C-LLM reformulates spectrum-to-structure prediction as skill-guided, code-grounded reasoning. It constructs analyzable trajectories from retrieved spectroscopy skills, executable code, synthesized thinking traces, and staged SFT followed by step-level RL.

  • 3.1 Overview: S3C-LLM learns pθ(τ, y | x) by conditioning molecular-structure prediction on retrieved skills, generated analysis code, and execution outputs.The trajectory is represented as τ = ⟨S, c, o⟩, where S is skill content, c is code, and o is execution output.
  • 3.2 Skill Library Construction: A self-evolving external LLM agent repeatedly applies, verifies, diagnoses, and revises modality-specific skills against spectral and chemical consistency.The process uses 20 iterations with 50 samples per iteration for each modality and yields eight Markdown skills.
  • 3.3 Agentic Data Construction: The optimized skills guide executable code that extracts peak-level evidence and performs quantitative checks, including mass differences and molecular-formula candidate generation for MS/MS.For IR, Raman, UV-Vis, and NMR, code parses peak or shift lists, matches diagnostic regions, and summarizes supported functional groups.
  • 3.3 Agentic Data Construction: Skill retrieval and code execution are wrapped into tool-use trajectories using read_skill and run_code, producing structured observations for final SMILES prediction.Single-modality trajectories call read_skill once followed by one run_code step; multimodal trajectories retrieve multiple skills before joint analysis.
  • 3.4 Training: Training first applies SFT to 500K trajectories, then uses GRPO-based step-level RL on 20K trajectories with stage-specific verifiable rewards.Rewards separately assess skill-modality matching, code execution without tool errors, and final prediction using Morgan fingerprint Tanimoto similarity.
  • 3.3 Agentic Data Construction: The pipeline synthesizes thinking traces that connect spectra, retrieved skills, code outputs, and step-by-step SMILES derivation.These traces address uncertainty in the final prediction step and provide skill-code supervision for training.

4 Experiments

S3C-LLM is evaluated across optical, MS/MS, and NMR benchmarks using compact peak-level representations and structure-level similarity metrics. Ablations examine skill quality, training stages, and tool configurations, showing benefits from step-level RL, retrieved skills, and executable code.

  • Benchmarks and metrics: The evaluation covers Raman, UV-Vis, IR, 13C NMR, 1H NMR, HSQC, and MS/MS spectra across QM9S, the Multimodal Spectroscopic Dataset, and MassSpecGym.Inputs are converted into peak-level textual representations, and molecular similarity is measured with metrics including Tanimoto, cosine, MACCS Tanimoto, and Fraggle similarities.
  • Main results: S3C-LLM performs best across all three QM9S single-spectrum settings while using less than 1/10th of SpectraLLM's paired-spectra corpus.The evaluated optical modalities are Raman, UV-Vis, and IR.
  • Main results: S3C-LLM consistently outperforms SpectraLLM across single-NMR settings and achieves the best performance when complementary 13C NMR, 1H NMR, and HSQC evidence is combined.The modalities provide carbon-skeleton, local-proton-environment, and proton-carbon cross-peak information.
  • Training-stage ablation: Step-level RL consistently improves SFT across NMR and MS/MS, whereas applying RL directly to Qwen3-4B without SFT brings almost no effective learning.SFT first teaches the tool-use format and spectrum-analysis procedure required by the later RL stage.
  • Training-stage ablation: Replacing step-level with trajectory-level credit assignment yields smaller and less stable gains, supporting localized rewards for skill reading, code execution, and final prediction.The RL reward design scores intermediate agentic actions as well as the final prediction.
  • Toolset ablation: Adding read_skill improves over chat across evaluated spectra, while run_code provides further gains especially on HSQC and MS/MS.Explicit spectral priors help interpret peak evidence, whereas executable computation benefits cross-peak relations and mass constraints.

5 Conclusion

S3C-LLM reformulates spectrum-to-structure elucidation as skill-guided, code-grounded reasoning over peak evidence, formula constraints, and intermediate computations. Across optical, MS/MS, and NMR spectra, it outperforms the cited baselines while using a smaller backbone and fewer training samples.

  • Conclusion: S3C-LLM combines spectroscopy skills with executable code before predicting molecular structures.The framework reasons over peak evidence, formula constraints, and intermediate computations.
  • Conclusion: Experiments across optical, MS/MS, and NMR spectra show that S3C-LLM outperforms modality-specific baselines and SpectraLLM.The conclusion also reports a smaller Qwen3-4B backbone and substantially fewer training samples.
  • Conclusion: Ablations confirm the value of agentic training, step-level RL, retrieved skills, and code execution.These components are evaluated through training-stage and toolset comparisons.

Limitations

The current evaluation uses established benchmarks with compact peak-level representations rather than richer raw-spectrum inputs.

  • Scope boundary: S3C-LLM is evaluated on compact peak-level representations, leaving richer raw-spectrum inputs and additional experimental conditions for future extension.The skill library currently covers common optical, NMR, and MS/MS modalities.

Ethics Statement

S3C-LLM is intended as scientific support for molecular structure elucidation, not as a standalone basis for hazardous, controlled-substance, or safety-critical chemical decisions.

  • Outputs require appropriate screening and human oversight before use in hazardous synthesis, controlled-substance discovery, or safety-critical chemical decisions.The paper does not provide wet-lab protocols or optimize molecules for biological activity or toxicity.

A Appendix

The appendix preserves agentic interaction records as conversation trajectories, including reasoning, tool use, code observations, and final predictions.

  • Each recorded box preserves user input, assistant reasoning, tool calls, tool responses, code observations, and the final prediction.

A.1 Dataset and Split Details

Evaluation uses established benchmark sources without additional splits, covering single-spectrum, multimodal, and experimental MS/MS settings. Data construction with reference structures is confined to training splits, while held-out data is reserved for final evaluation.

  • Dataset coverage: No additional evaluation splits are introduced beyond the benchmark sources described in Section 4.1.
  • Dataset coverage: The evaluation covers QM9S, the Multimodal Spectroscopic Dataset, and MassSpecGym across Raman, UV-Vis, IR, NMR, and MS/MS settings.All spectra are converted into compact peak-level textual representations before model input.
  • Dataset splits: Reference-structure-assisted construction stages use only training data, excluding evaluation molecules and spectra.These stages include skill evolution, code and thinking-trace generation, SFT trajectory construction, and RL trajectory sampling.
  • Dataset splits: Held-out benchmark splits are reserved for final evaluation after construction stages are completed.

A.2 Comparison with SpectraLLM

S3C-LLM uses a smaller backbone and a substantially smaller skill-code trajectory corpus than SpectraLLM, while learning an analysis process rather than direct spectrum-to-SMILES prediction.

  • Model and training comparison: SpectraLLM uses Qwen3-32B with LoRA fine-tuning on more than 5.5 million paired spectra.Its corpus combines multiple spectral datasets and uses direct spectrum-to-SMILES examples.
  • Model and training comparison: S3C-LLM uses Qwen3-4B and trains on 500K skill-code trajectories.The model retrieves spectroscopy skills, executes analysis code, and then proceeds toward molecular prediction.

A.3 Skill Examples

Figures 4 and 5 provide complete Markdown skill files for HSQC and MS/MS, showing how reusable spectral priors are stored for downstream code-grounded reasoning.

  • Figures 4 and 5 show complete Markdown skill files used by read_skill.
  • The examples come from the HSQC and MS/MS skills.
  • The skill library stores reusable spectral priors for downstream code-grounded reasoning.

A.4 Correct Rollout Trajectories

The rollout trajectories combine modality-specific spectroscopy skills with code-grounded analysis, using peak-level evidence, formula constraints, and chemical assignments to support structure predictions.

  • HSQC analysis: HSQC correlates each 1H signal with its directly bonded 13C, while quaternary carbons remain invisible.
  • MS/MS analysis: Formula analysis enumerates candidates within mass tolerance, applies fragment-derived element constraints, and evaluates RDBE and chemical plausibility.
  • MS/MS analysis: Neutral loss analysis computes precursor m/z minus fragment m/z and maps losses to structural features.
  • Trajectory workflow: S3C-LLM retrieves modality-specific skills before analyzing spectra with code.The supplied examples include HSQC and MS/MS skills.
  • HSQC analysis: HSQC assignments use 1H and 13C chemical shifts together with nH to classify carbon environments and resolve ambiguities.
  • Correct rollout example: The example 13C interpretation identifies twelve non-equivalent carbon environments, including a carbonyl, two heteroatom-desheilded sp3 carbons, and an extensive aromatic system.
Loading 2608.30910v1…