Agent-Driven Mass Spectrometry Interpretation: A Practical Approach

    This article explains why mass spectrometry interpretation cannot rely on language models alone and how an agent-driven design solves the problem. It summarizes measured results under three运行 conditions, outlines a four-layer architecture built from domain skills, an orchestration runtime, an evidence store, and an interaction layer, and walks through two typical workflows for known and novel compounds. Engineering guidance on tolerances, retries, evidence storage, and evaluation metrics is included.

    1. Why Mass Spectrometry Interpretation Cannot Rely on Language Models Alone

    Mass spectrometry (MS) is a routine technique for molecular identification. Its output is essentially a sequence of “mass-to-charge ratio — relative intensity” values, plus metadata such as fragmentation mode and instrument tolerance. Getting from those numbers back to a molecular structure requires three kinds of hard computation:

    1. Exact mass matching and molecular formula constraints based on elemental isotope masses.
    2. Nearest-neighbor retrieval across compound libraries containing millions of entries.
    3. Simulating bond cleavage pathways based on fragmentation rules to determine whether a given fragment can be produced by a candidate structure.

    None of these capabilities comes naturally to language modeling. Models are good at pattern induction and hypothesis generation, whereas MS interpretation demands reproducible numerical decisions and exhaustive verification. The more sensible engineering positioning is therefore to let the model handle planning and reasoning orchestration, delegate deterministic computation to mature tools and public chemistry data resources, and have the two work together in a closed loop.

    2. Measured Capability Boundaries: A Comparison of Three Operating Conditions

    The source material provides a clear comparison across three conditions, which directly informed the design:

    • Fully offline, with no additional skills: three general-purpose and lightweight models all scored below 4% accuracy in molecular identification, showing that guessing structures directly from a peak list is not viable.
    • Restricted network access only: frontier models missed roughly one quarter to one third of the spectra, while lightweight models missed more than three quarters. Network access yields scattered clues, but without a systematic computation and retrieval pipeline, recall remains unstable.
    • With a domain skill set connected: all three models reached about 97% accuracy in identification and verification, with the lightweight model matching the frontier model. At the same time, generated token consumption per interaction round dropped significantly — close to a 4x reduction for the lightweight tier, about half for the mid tier, and nearly one fifth for the high tier.

    The key implication is that the accuracy gain comes mainly from “completing the toolchain,” while the token reduction comes from “offloading the reasoning burden.” The model no longer needs to reason at length about masses and fragmentation inside the context; it only needs to issue calls, read structured results, and make trade-offs.

    3. Overall Architecture: Skill Set, Orchestration Layer, and Evidence Chain

    A practical implementation typically has four layers:

    1. Skills layer: exact mass calculation, isotope distribution validation, library search, bond cleavage simulation, spectrum denoising, peak annotation, and isomer comparison are each packaged as independently callable atomic capabilities.
    2. Orchestration layer (Agent Runtime): the agent selects skills automatically from a natural-language task description, decides the call order, and handles failures and retries.
    3. Evidence layer (Evidence Store): records the input, parameters, output, and decision basis of every step, forming an auditable chain.
    4. Interaction layer: researchers only describe the task and instrument tolerance, with no need to configure underlying tools manually.

    Illustrative skill descriptions (pseudocode, expressing orchestration semantics only):

    1. skill: formula_from_precursor
    2. input: { precursor_mz, tolerance_ppm, charge }
    3. output: { candidates: [formula], score }
    4. skill: library_search
    5. input: { formula, tolerance_ppm, top_k }
    6. output: { hits: [structure_id, similarity] }
    7. skill: bond_cleavage_sim
    8. input: { structure_id, fragment_mzs, tolerance_ppm }
    9. output: { explained_peaks, unexplained_peaks }
    10. plan = agent.plan("Interpret this unlabeled tandem mass spectrum, tolerance 5 ppm")
    11. for step in plan:
    12. result = registry.call(step)
    13. evidence.append(step, result)
    14. report = evidence.to_auditable_report()

    4. Two Typical Pipelines: Known Compounds and Entirely New Compounds

    Known compound (library hit): denoise and annotate peaks first, generate a candidate molecular formula set from the precursor ion exact mass, retrieve candidate structures from the library, then explain each fragment one by one with bond cleavage simulation. The evidence chain explicitly states which peaks were explained and which were not, so chemists can review quickly.

    Entirely new compound (no library hit): the flow shifts to “shrinking the search space.” Exact mass and isotope constraints first compress the molecular formula range, then substructure inference uses structurally supported fragments, producing several directional conclusions rather than an arbitrary single structure. This kind of “explainable convergence” fits scientific review requirements better than handing over an answer outright.

    5. Reusable Sub-Workflows

    The approach does not have to be used end to end; each stage can be called on its own to cover everyday small tasks: spectrum denoising and baseline processing, peak annotation and assignment, isomer candidate comparison, tolerance sensitivity analysis, and rule-based preprocessing of spectra in batches. For platform providers, this means one skill set can serve both “fully automated interpretation” and “human-assisted analysis” modes.

    6. Engineering Implementation Notes

    • Tolerances and metadata must be passed explicitly; do not let the model assume units or charge on its own.
    • Retrieval and computation need timeout, retry, and fallback strategies; on failure, preserve partial evidence instead of rolling everything back.
    • Store the evidence chain in a structured form (object storage and logging services work well) to support auditing and secondary analysis.
    • Run stateless skills on a container platform, use a message queue to smooth batch task peaks, and track call success rate and latency with monitoring and alerting.
    • Evaluation should cover at least three dimensions: identification accuracy, miss rate, and generated tokens per round plus end-to-end latency.

    7. Conclusion

    The bottleneck in mass spectrometry structure interpretation is not “whether the model can reason” but “whether it can call the right deterministic tools and explain the process clearly.” Using a domain skill set to supply computation and retrieval, with an agent handling orchestration and integration, can hold accuracy at about 97% while pushing reasoning cost down by an order of magnitude and bringing lightweight models to a usable level. Baidu AI Cloud offers general product categories in agent orchestration, containerized skill hosting, and observability, and can serve as an infrastructure reference for this type of solution.