agentsclimarketplace

Transformer model inference

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/gc-ms/skills/transformer-model-inference

Use when you have electron ionization mass spectrum data (m/z and intensity pairs) and a pre-trained transformer model checkpoint, and you need to predict molecular weight directly from the spectrum without manual feature engineering or rule-based methods.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill transformer-model-inference

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.1 KB, 954 tokens by cl100k_base, as published. Nobody here has run it

Transformer Model Inference

Summary

Load a pre-trained transformer model and execute forward inference on structured input data to generate predictions. This skill applies deep learning transformer architectures to produce direct output predictions from raw instrumental data without post-processing.

When to use

You have electron ionization mass spectrum data (m/z and intensity pairs) and a pre-trained transformer model checkpoint, and you need to predict molecular weight directly from the spectrum without manual feature engineering or rule-based methods.

When NOT to use

  • Input spectrum is already a feature vector or hand-engineered descriptor (model expects raw m/z–intensity pairs).
  • You need uncertainty quantification or confidence intervals; the model outputs only a point prediction.
  • The mass spectrum was acquired by ionization methods other than electron ionization (e.g., ESI, MALDI).

Inputs

  • electron ionization mass spectrum (m/z values and intensity values)
  • pre-trained transformer model checkpoint (.pth or equivalent)
  • spectrum tensor formatted to model input specification

Outputs

  • predicted molecular weight (scalar numeric value)
  • molecular mass prediction

How to apply

Set up a Python 3.9 environment with PyTorch 1.12 and necessary dependencies (rdkit). Clone and load the pre-trained MWFormer model from the repository. Parse your EI-MS spectrum as m/z and intensity arrays. Prepare the spectrum as a PyTorch tensor matching the model's expected input shape and format. Execute a forward pass through the transformer model. The model outputs a direct prediction of molecular mass; extract and record this scalar value. Verify the predicted mass is positive and within physically plausible range for the input spectrum's m/z range.

Related tools

Evaluation signals

  • Predicted molecular weight is a positive scalar (mass must be > 0).
  • Predicted mass is physically plausible given the input spectrum's maximum m/z value (molecular ion typically dominates or appears near spectrum upper bound).
  • Model inference executes without CUDA/tensor shape errors, indicating correct input formatting.
  • Output value is deterministic across repeated runs on identical input (reproducibility).
  • Predicted mass aligns with known or reference molecular weights for validation spectra, if available.

Limitations

  • Model is trained and validated specifically on electron ionization mass spectra; performance on other ionization methods is unknown.
  • The transformer outputs only a point estimate without calibrated uncertainty; high-stakes applications may require ensemble methods or Bayesian alternatives.
  • Predictions depend critically on correct preprocessing and tensor formatting; malformed input silently produces incorrect output.
  • No changelog or versioning information is documented in the repository, limiting reproducibility across time.
  • Model generalization to novel or out-of-distribution spectra (e.g., from new instruments or rare chemical classes) is not characterized.

Evidence

  • [intro] MWFormer enables direct prediction of molecular mass from electron ionization mass spectrum using transformer architecture: "MWFormer: Direct Prediction of Molecular Mass from Electron lonization Mass Spectrum by Transformer"
  • [other] Parse the input EI-MS spectrum data (m/z and intensity values). Prepare the spectrum as a tensor input matching the model's expected input format. Run forward inference through the MWFormer transformer to generate the predicted molecular weight.: "Parse the input EI-MS spectrum data (m/z and intensity values). Prepare the spectrum as a tensor input matching the model's expected input format. Run forward inference through the MWFormer"
  • [intro] Create and activate conda environment with Python 3.9, PyTorch 1.12, and rdkit dependencies: "conda create -n MWFormer python=3.9"
  • [readme] Load the pre-trained MWFormer model from the repository and execute forward pass: "You can download the trained model on Github. Then refer to the example to use the model for prediction, and directly obtain the molecular weight from EI-MS."
  • [intro] Install PyTorch with CUDA 11.8 support for GPU acceleration: "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.