Mass Spectrometry Annotation: How AI Skill Packages Improve Molecular Identification

    This article explains how attaching a domain skill package to a general-purpose large language model improves mass spectrometry annotation, the process of assigning chemical meaning to spectral signals. It covers why public databases label only about 5% of peaks, a four-layer architecture that connects natural language tasks to spectral tools and chemical databases, and reported results of roughly 97% accuracy with lower token cost and auditable reports. It also provides a five-step adoption guide, the method's known limits, and a layered evaluation approach for teams working with data-rich, label-poor analytical chemistry problems.

    1. The Problem: Mass Spectrometry’s “Dark Matter”

    A single mass spectrometry run can capture tens of thousands of molecular signals, yet public databases annotate only a small fraction of spectra—on average about 5%. That leaves more than 90% of signals in a state of “peaks without explanations,” a gap often described as the dark matter of mass spectrometry. These signals are not noise; they contain real chemical information that has not been decoded. What is missing is not measurement capability, but the reasoning ability to align measurement results with chemical knowledge.

    Traditional workflows rely on manual library matching, literature searches, and experience-based interpretation of fragmentation patterns. They face three bottlenecks:

    • Limited annotation throughput: manual review cannot cover tens of thousands of signals.
    • Fragmented cross-library knowledge: spectral libraries, molecular structure databases, and reaction and fragmentation rules are scattered across different sources.
    • Poor reproducibility: manual judgment is difficult to turn into an auditable chain of evidence.

    2. The Approach: Connecting Chemical Reasoning to Tools and Databases

    One engineering pattern that has proven effective is adding a domain skill package to a general-purpose large language model. The goal is not to make the model memorize more spectra, but to teach it to call mature spectral processing tools and public chemical databases, translating a task described in natural language into an executable analysis pipeline. The design can be abstracted into four layers:

    1. Semantic layer: the user states the task goal and instrument tolerances in natural language, such as mass accuracy, retention time window, and allowable molecular formula error.
    2. Orchestration layer: an AI coding tool or agent automatically chains skills together, deciding to run peak extraction first, then candidate formula enumeration, then library matching and scoring.
    3. Tool layer: established algorithm components are invoked for deconvolution, peak alignment, isotope distribution simulation, and fragment annotation.
    4. Knowledge layer: public chemical databases and literature evidence are retrieved to cross-validate candidate structures.

    An illustrative skill declaration (pseudocode that expresses orchestration logic only):

    1. skill: mass_spec_annotation
    2. inputs:
    3. spectrum: "mzML/JSON"
    4. tolerance_ppm: 5
    5. task: "formula_and_structure_candidates"
    6. pipeline:
    7. - peak_picking
    8. - deconvolution
    9. - isotope_pattern_match
    10. - formula_enumeration(constraints=[C,H,N,O,P,S])
    11. - library_search(score_threshold=0.8)
    12. - fragmentation_annotation
    13. - cross_check(public_chem_db=true)
    14. output:
    15. - ranked_candidates
    16. - annotation_table
    17. - audit_report

    3. Key Benefits: Accuracy, Cost, and Auditability

    Under public evaluation settings, models of different sizes all reach roughly 97% accuracy on molecular identification tasks after the skill package is connected, and lightweight models perform on par with frontier models. This suggests the bottleneck on this task is whether the model can call tools and retrieve knowledge, rather than parameter count alone.

    Costs improve as well: lightweight models consume nearly 4x fewer tokens per round. The reason is that the pipeline hands the heavy work to deterministic tools and database retrieval, leaving the model responsible only for intent understanding, parameter filling, and result explanation. This reduces long-context reasoning and repeated trial and error.

    Auditability is the less obvious value of this pattern. The system can produce a complete report recording which tools were called at each step, which tolerances were used, and which database entries were matched, making review and compliance record-keeping straightforward.

    4. Implementation: A Five-Step Adoption Guide

    1. Define task boundaries: separate three goals—formula prediction, candidate structure ranking, and fragment annotation—and avoid asking the model for a single definitive structure in one pass.
    2. Configure tolerances and constraints: express instrument accuracy, scan mode, and element ranges as structured parameters to reduce ambiguity.
    3. Select the tool combination: prefer established peak processing and library matching components, and keep the pipeline replaceable.
    4. Build an evaluation set: use annotated spectra for regression testing, tracking three curves: accuracy, false positive rate, and token cost.
    5. Persist audit reports: write intermediate results to object storage, and combine them with logging services and monitoring alerts to make runs traceable.

    5. Capability Limits: Three Things to State Clearly

    • Enantiomers cannot be distinguished: conventional mass spectrometry is insensitive to stereochemistry, and a single spectrum cannot separate enantiomers; chiral separation or orthogonal methods are required.
    • Entirely new molecules cannot have their structures confirmed: for species absent from databases, the system can only return predicted formulas and an annotation table, which is not equivalent to structural confirmation.
    • Outputs are candidates and evidence: results should be understood as a scored set of candidates with a supporting evidence chain, not a single answer.

    6. Evaluation and Best Practices

    A layered evaluation is recommended: the first layer measures formula hit rate, the second measures Top-k coverage of candidate structures, and the third measures the reduction in manual review effort. In engineering practice, tolerances, database versions, and tool versions should be brought under configuration management to keep experiments reproducible. Keep human review for high-value samples, and use confidence thresholds to route routine batch samples automatically.

    7. Conclusion

    Moving a large language model from “able to chat” to “able to perform experimental analysis” depends on packaging capabilities as skills and orchestrating the tool chain. With natural language as the entry point, deterministic tools as the backbone, and public knowledge bases as evidence, it is possible to raise the decoding rate of mass spectrometry dark matter from single digits to over 90% without relying on enormous parameter counts, while substantially lowering inference cost and preserving a complete audit trail. The same pattern applies to other analytical chemistry scenarios that are rich in data but poor in labels.