Mass Spectrometry Skills Package: How Lightweight Models Match Frontier Accuracy

    This article explains why mass spectrometry produces signals that instruments can measure but cannot identify, and how a skills-plus-agent architecture addresses the resulting annotation gap. It covers the layered design (reasoning, skills, data, orchestration, and review layers), why lightweight models reach roughly 97% identification and verification accuracy once deterministic tools are externalized, how to build a more persuasive evaluation suite, the capability boundaries that belong in product documentation, and a practical rollout sequence for implementing similar capabilities in your own environment.

    1. Where the Problem Starts: Measurable but Unrecognizable Spectra

    Modern mass spectrometers sample far faster than any human can interpret. A single sample can produce tens of thousands of molecular signals at once. The instrument records the mass-to-charge ratio of charged ions and the distribution of fragment ions produced when those ions break apart. The catch: these values are physical quantities, not structural descriptions. One signal at a given mass-to-charge ratio may correspond to entirely different molecular skeletons, and similar fragmentation patterns can come from structurally close isomers.

    This leads to a widely discussed phenomenon in the field: a large share of signals in measured spectra carry no annotation. Public databases typically annotate only single-digit percentages of routine measured spectra, and even complex biological samples sit around ten percent. The unannotated signals are often described as the “dark matter” of mass spectrometry: real, reproducibly measurable, but impossible to map to known molecules.

    Three traditional approaches exist, each with clear limitations:

    • Library matching: depends on existing annotations, cannot cover new molecules, and is highly sensitive to instrument type, collision energy, and ionization method.
    • Formula inference: yields candidate elemental compositions, but the candidate count often explodes combinatorially and never converges on a structure.
    • Manual interpretation: the highest accuracy, but extremely low throughput and heavily dependent on individual experience, making it hard to standardize or reuse.

    What is actually missing is not compute. It is a workflow that organizes computational capability together with the domain toolchain.

    2. The Abstraction: A Skills-Enhanced General Architecture

    The original practice can be abstracted into a layered design of “Skills + agent runtime.” The point is not to make the model memorize more chemistry. It is to teach the model to call the right tool at the right moment and to treat tool output as evidence.

    A reusable layered structure looks like this:

    1. Reasoning layer: generates hypotheses, ranks candidates, identifies conflicting evidence, and outputs an explainable judgment path.
    2. Skills layer: packages mature mass spectrometry algorithms, spectrum preprocessing, isotope distribution calculation, and fragment assignment analysis as standardized capabilities.
    3. Data layer: public chemical databases and internal spectral libraries are exposed through a unified query interface supporting formula, structure, and known fragment pattern lookup.
    4. Orchestration layer: the platform handles step scheduling, intermediate result integration, and retries automatically, so no one has to shuttle data between tools by hand.
    5. Review layer: outputs a complete evidence chain and annotation table for final confirmation by domain experts.

    A sketch of the skill definitions (pseudocode, showing organization only):

    1. skill: formula_candidates
    2. input: precursor_mz, tolerance_ppm, adduct
    3. output: ranked_formula_list(with isotope_score)
    4. skill: fragment_annotation
    5. input: formula, fragment_peaks, collision_energy
    6. output: substructure_evidence[] # each fragment -> supported structural substructure
    7. skill: library_lookup
    8. input: formula | spectrum_fingerprint
    9. output: candidates[] | empty
    10. workflow:
    11. f = formula_candidates(...)
    12. if library_lookup(f) is empty:
    13. e = fragment_annotation(f, ...)
    14. return {predicted_formula: f, evidence: e, status: "needs_expert"}
    15. else:
    16. return {structure: best_match, evidence: e, status: "verified"}

    The key benefit: the model no longer answers “from memory.” Conclusions rest on reproducible tool output, which improves accuracy and explainability at the same time.

    3. Why Lightweight Models Get Pulled Level

    The most notable finding in the original material: with no network access and no additional skills, models of several different sizes all scored under four percent on molecule identification. After connecting the skill set, both identification and verification accuracy rose to roughly ninety-seven percent. Lightweight models matched frontier models, while token consumption per interaction round dropped significantly.

    None of this is unusual from an engineering standpoint. Three reasons:

    • The task changes shape. A bare model is asked to “guess the structure directly,” which is high-entropy reasoning in a closed domain. With tools attached, the task becomes “propose a hypothesis, retrieve and verify, align evidence.” The search space is constrained by the tools, so difficulty drops sharply.
    • Capability moves outside the model. Database queries and spectral algorithms are deterministic. Once externalized, they no longer depend on parametric memory, which weakens the influence of model size on results.
    • Interaction efficiency improves. Lightweight models are good enough at instruction-following tasks like selecting tools, parsing structured returns, and organizing evidence. Smaller models bring shorter contexts and lower per-round cost, producing a win on both cost and accuracy.

    The engineering takeaway is direct: in a vertical domain, tool-ify deterministic capabilities first, then evaluate whether a larger model is actually needed. That usually beats simply adding parameters.

    4. Designing an Evaluation That Is Convincing

    Reproducing the findings above requires more granularity than a single accuracy number. Cover at least these dimensions:

    • Formula inference accuracy and candidate convergence rate (Top-k hit rate).
    • Structure verification accuracy, split into subsets for catalogued molecules and uncatalogued new molecules.
    • Evidence chain completeness: whether each conclusion carries verifiable fragment assignments and retrieval sources.
    • Stability: consistency of results for the same spectrum across random seeds and prompts.
    • Cost metrics: tokens per round, average number of interaction turns, end-to-end latency.
    • Abstention rate and error type distribution: expressing “uncertain” explicitly is more valuable than forcing out a wrong structure.

    A minimal runnable evaluation skeleton:

    1. def evaluate(sample, agent):
    2. r = agent.run(sample.spectrum)
    3. return {
    4. "formula_top1": r.predicted_formula == sample.formula,
    5. "structure_ok": r.status == "verified" and r.structure == sample.structure,
    6. "evidence_ratio": r.evidence_count / max(1, sample.expected_fragments),
    7. "tokens": r.tokens,
    8. "turns": r.turns,
    9. "abstained": r.status == "needs_expert",
    10. }

    One point deserves emphasis: any concrete number should come from real runs on your own evaluation set, not from unverified marketing claims.

    5. Capability Boundaries Belong in the Product Documentation

    A responsible technical solution states plainly what it cannot do. This class of method has at least three clear boundaries:

    • Spectra cannot distinguish enantiomers, and some structurally similar isomers are hard to separate on fragmentation patterns alone.
    • Entirely new molecules absent from databases cannot have their structures independently confirmed.
    • Results depend on spectrum quality and metadata completeness; missing ionization method or collision energy significantly affects conclusions.

    So the sensible product positioning is “a starting point for analysis,” not “a final verdict”: output a predicted formula, candidate structures, and a detailed annotation table, shifting expert time from repetitive labor to the decisions that matter.

    6. Implementation Advice and Alternative Paths

    To build similar capability in your own environment, a workable order:

    1. Connect internal spectral libraries and public chemical data to a unified query layer, with clear fields and confidence values.
    2. Package spectrum preprocessing, formula inference, and fragment annotation as stateless skills so they are easy to replace and roll out gradually.
    3. Use an agent orchestration layer for multi-step calls and result integration, retaining all intermediate artifacts for auditing.
    4. Establish an expert-in-the-loop review process, feeding human corrections back into the evaluation set and fine-tuning corpus.
    5. Deploy inference and data services on a container platform with object storage, plus logging and monitoring/alerting to observe cost and quality.

    On the cloud, general-purpose capabilities are enough: a container platform hosts inference services, object storage keeps spectra and intermediate artifacts, a message queue decouples long-running tasks, and logging plus monitoring track token consumption and failure rates. If you use the relevant general capabilities from Baidu AI Cloud, the same layered approach applies, with no dependency on any proprietary interface.

    7. Conclusion

    The core problem of mass spectrometry dark matter is the gap between measurement and semantics. Externalizing domain tools and public data as a skills package, moving the model from memory-based answers to evidence-based reasoning, is currently the most cost-effective path to convergence. What it delivers is not only a jump in accuracy, but a restructuring of cost, explainability, and how experts collaborate. And clearly labeling capability boundaries is what lets such systems enter routine workflows in research and quality control.