Tool-Augmented Mass Spectrometry Structure Elucidation with LLMs

    Reliable molecular structure elucidation from mass spectra requires more than a language model interpreting peak lists. This article explains how auditable tools for preprocessing, molecular formula enumeration, spectral matching, and evidence-based abstention can constrain the search, and outlines an implementation approach centered on data provenance, quality control, and analyst review.

    Mass spectrometry can fragment molecules and record ion intensities by mass-to-charge ratio. For an experienced analyst, a spectrum contains structural clues. For a language model receiving only a peak list, it is closer to a sequence of numbers with little context.

    Industry discussions repeatedly highlight the same contrast: without reference materials or chemical computation, general-purpose models struggle to infer molecular formulas and connectivity reliably from peaks alone. Accuracy can be low enough to make the results practically unusable. Once models can access chemical knowledge and validation tools, the proportion of acceptable candidate structures can rise substantially.

    This does not mean the model has suddenly learned chemistry. It means the task has changed—from unconstrained generation to a search governed by physical and chemical constraints.

    Why Structure Elucidation Is Difficult

    Inferring a structure from a peak list is not a single classification step. It requires answering several questions:

    • Does a major ion represent the molecular ion or a quasi-molecular ion?
    • Does the isotope pattern support a particular elemental composition?
    • Which functional groups could explain the observed neutral losses?
    • Are the fragments consistent with one another?
    • Can the proposed structure explain all major peaks, rather than just the most conspicuous ones?

    Every step introduces ambiguity. The same mass-to-charge ratio can correspond to different compositions. A single composition can have many structural isomers, and similar fragmentation patterns can arise through different cleavage pathways. Soft or hard ionization, matrix effects, and instrument resolving power all influence how a spectrum appears.

    Language models are good at pattern association. Having encountered descriptions linking compound classes to characteristic fragments, they can propose structures that sound chemically plausible. But association is not quantitative consistency. Without calculations for exact elemental masses, valence rules, degrees of unsaturation, and isotope abundances, a model may mistake a convincing explanation for a correct answer.

    Very low accuracy without external capabilities points to a lack of computable constraints—not a weakness in writing.

    Define Tool Augmentation as Auditable Capabilities

    A more reliable approach is to expose chemical capabilities as tools that the model can call and an analyst can inspect. Adding “analyze carefully” to a prompt is not a substitute. Four capabilities are particularly relevant.

    1. Peak List Normalization

    Standardize mass-to-charge representation, normalize intensities, apply deisotoping and noise thresholds, and retain references to the original spectrum.

    If input processing is inconsistent, subsequent claims of high accuracy are not comparable.

    2. Candidate Molecular Formula Enumeration

    Enumerate elemental compositions using an exact-mass window, allowed element ranges, and degree-of-unsaturation constraints. Do not simply ask the model to produce a molecular formula.

    The mass window should reflect instrument resolving power and the calibration method. It should not be a fixed magic number.

    3. Candidate Structure Matching

    Evaluate fragment explanations within the candidate set. Check whether molecular ions, characteristic losses, and isotope clusters are consistent, and penalize candidates that leave strong peaks unexplained.

    Matching can use rule-based scoring or searches against validated spectral libraries. In either case, record the evidence supporting each match.

    4. Contradiction Checks and Abstention

    When several isomers have similar scores, key ions are missing, or mass errors exceed the threshold, the system should return “insufficient evidence” rather than force a structure assignment.

    Abstention is part of a reliable workflow, not a failure.

    The following pseudocode illustrates the process without depending on any vendor interface:

    1. peaks = normalize(raw_peaks)
    2. formulas = enumerate_formulas(peaks, mass_tolerance, element_limits)
    3. candidates = retrieve_or_generate_structures(formulas)
    4. for c in candidates:
    5. score[c] = explain_peaks(c, peaks) - penalty_unexplained(c, peaks)
    6. ranked = sort(score)
    7. if top_gap(ranked) < margin or mass_error_too_large:
    8. return INSUFFICIENT_EVIDENCE
    9. return ranked[:k] with explanations

    Why Tools Can Produce a Large Accuracy Gain

    When a model reads a peak list on its own, the search space is open-ended. It can invent unsupported functional groups or ignore contradictory fragments.

    Tools narrow that space to candidates that are plausible in terms of mass, valence, and fragmentation. If the correct structure is in this set, ranking becomes a more manageable discrimination task. If it is absent, abstention can prevent unsupported guessing.

    Figures cited in public discussions—such as an increase from roughly 4% to roughly 97%—should be treated as reminders of the difference between constrained and unconstrained experiments, not as transferable product benchmarks. Results will change with the instrument, ionization method, and compound distribution.

    A reproducible report should disclose at least:

    • Whether the samples include structural isomers.
    • Whether spectral library access is allowed.
    • The mass tolerance used.
    • Whether results receive final human review.
    • The distribution of error types.

    How to Implement the Workflow

    Establish the Data Layer First

    Keep raw spectra, processed peak lists, calibration records, and sample metadata separate. Object storage is suitable for raw files, while a structured database is suitable for peak lists and annotations.

    Record the processing version for every analysis. Otherwise, the same spectrum processed with different thresholds may incorrectly be treated as the same input.

    Let the Model Propose and the Tools Validate

    The model can suggest functional-group hypotheses and identify peaks that need checking. Tools should calculate mass errors, assess isotope fits, and detect rule conflicts.

    The model must not override numerical tool results. Retain conversation logs alongside detailed scores so that decisions can be audited later.

    Design Quality Control Around Error Costs

    Overall accuracy alone is insufficient. Divide compounds into three categories:

    • Known compounds represented in the library: prioritize consistency with library retrieval results.
    • Compounds outside the library with an established molecular formula: emphasize formula consistency and coherent fragment explanations.
    • Completely unknown compounds: default to a candidate list with uncertainty, rather than a single structure.

    Monitoring should include the abstention rate, structural-isomer confusion rate, and rate of analyst corrections. When these metrics become abnormal, investigate calibration and preprocessing before blaming the model.

    Keep Analysts in the Loop

    Mass spectrometry structure elucidation often supports synthesis confirmation, impurity identification, and regulatory testing. Automated outputs should therefore consist of candidates and evidence, not final sign-off.

    Analysts need to see which peaks were explained and which were not—not just a fluent chemical narrative.

    Common Pitfalls

    Treating a larger general-purpose model as the solution often makes incorrect answers sound more credible without resolving the underlying constraints.

    Enabling web search without recording sources mixes memorized information, retrieved evidence, and speculation, making results difficult to reproduce.

    Reporting only the highest-ranked structure without the score gap can systematically overstate confidence when distinguishing isomers.

    Likewise, demonstrations using a small set of easy samples do not establish performance on complex matrices or low-resolution data.

    Conclusion

    Reliable mass spectrometry structure elucidation is not primarily about making a model remember more compound names. It is about turning mass, composition, fragmentation, and spectral-library evidence into enforceable constraints—and allowing the system to stop when the evidence is insufficient.

    Tool augmentation improves verifiability: each step can be traced back to peaks, formulas, and rules. By standardizing data and tolerances first, then asking the model to explain candidates within a constrained set rather than generate structures freely, teams can replace plausible-sounding chemistry with an analysis workflow that can be calculated, checked, and trusted to abstain.