deep-learning-model-inference
Summary
Execute forward inference pass on preprocessed mass spectrometry data using a pre-trained deep learning model to generate predictions with confidence scores. This skill applies learned model weights to new inputs to produce classification results and per-class probability distributions without retraining.
When to use
You have preprocessed mass spectrometry spectra (tokenized m/z and intensity pairs or feature matrices) and a trained deep learning model checkpoint, and you need to classify unknown compounds or generate prediction confidence scores for structural novelty analysis. Use this skill when the input data schema matches the model's training format and you require ranked predictions with per-class probabilities rather than model parameter updates.
When NOT to use
- Input spectra have not been preprocessed or normalized according to the model's training requirements — preprocess first before inference.
- You have raw, untokenized mass spectrometry data (e.g., raw vendor instrument files) — execute feature extraction and normalization workflow before inference.
- The goal is to retrain, fine-tune, or evaluate model parameters — use model training/evaluation workflows instead of inference.
Inputs
- Preprocessed mass spectrometry feature matrices or tokenized m/z–intensity pair vectors
- Pre-trained deep learning model weights (e.g., PyTorch .pt or TensorFlow .h5 checkpoint)
- Model architecture definition and input schema specification
- Spectrum identifiers or sample metadata (for result annotation)
Outputs
- Structured prediction table with spectrum identifiers, predicted NPS class labels, and per-class probabilities
- Confidence scores or softmax probability distributions for each prediction
- Optionally: prediction uncertainties or model uncertainty estimates for filtering
How to apply
Load the pre-trained deep learning model weights from the repository (e.g., jhhung/PS2MS). Ensure input spectra conform to the model's expected preprocessing format (normalization, tokenization/vectorization of m/z–intensity pairs). Execute the forward pass on the entire batch of preprocessed spectra. Extract raw model outputs (e.g., softmax probabilities, prediction uncertainties) and apply a confidence threshold to filter low-confidence predictions. Post-process by assigning class labels and generating structured output tables mapping spectrum identifiers to predicted NPS classes and per-class probabilities. Validate output schema consistency and probability distributions (softmax probabilities must sum to 1.0 per spectrum).
Related tools
- PS2MS (Pre-trained deep learning system for NPS classification from mass spectrometry; executes inference to generate predictions and confidence scores) — https://github.com/jhhung/PS2MS
- NEIMS (Predicts mass spectrum features for synthetic database compounds used in PS2MS comparison pipeline)
- DeepEI (Predicts chemical fingerprints for unknown analytes and synthetic database compounds for similarity scoring)
- PyTorch or TensorFlow (Deep learning framework for loading model checkpoints and executing forward inference passes)
Evaluation signals
- All output probabilities per spectrum sum to 1.0 (softmax constraint satisfied)
- Prediction confidence scores fall within the expected range (e.g., [0.0, 1.0] for probability-based scores)
- Output table schema matches specification: each row has spectrum ID, predicted class label, and per-class probability columns with no missing values
- Predictions for positive control compounds (if available) match expected NPS classes or known structural analogues
- Confidence scores are lower for structurally novel compounds than for training-distribution-similar compounds (when validated against structural novelty stratification)
Limitations
- Model predictions are limited to NPS classes present in the training dataset; compounds with core structures absent from training may receive low confidence scores
- Inference accuracy depends critically on input preprocessing conformance to the training normalization and tokenization scheme; any deviation will degrade predictions
- The system is designed for novel psychoactive substance detection and may not generalize to other chemical classification tasks or non-spectrometry modalities
- Confidence scores do not directly measure chemical novelty; they measure similarity to training-set prediction distributions — novel structural analogues may receive low confidence even if correctly classified
Evidence
- [other] Load the pre-trained PS2MS deep learning model from the jhhung/PS2MS repository. Execute forward inference pass on preprocessed spectra to generate NPS classification predictions and confidence scores.: "Load the pre-trained PS2MS deep learning model from the jhhung/PS2MS repository. Execute forward inference pass on preprocessed spectra to generate NPS classification predictions and confidence"
- [other] Preprocess spectra according to PS2MS normalization and feature extraction requirements (tokenization/vectorization of m/z and intensity pairs).: "Preprocess spectra according to PS2MS normalization and feature extraction requirements (tokenization/vectorization of m/z and intensity pairs)."
- [other] Post-process predictions to assign NPS class labels and filter by model confidence threshold. Export results as a structured prediction table with spectrum identifiers, predicted NPS classes, and per-class probabilities.: "Post-process predictions to assign NPS class labels and filter by model confidence threshold. Export results as a structured prediction table with spectrum identifiers, predicted NPS classes, and"
- [other] Extract or compute prediction confidence scores (e.g., softmax probabilities, prediction uncertainties) for each compound in the evaluation set using the PS2MS model.: "Extract or compute prediction confidence scores (e.g., softmax probabilities, prediction uncertainties) for each compound in the evaluation set using the PS2MS model."
- [readme] The system will compare the spectrum and chemical fingerprint between compounds and generate a list of the hundred most similar compounds which are ranked by similarity score.: "The system will compare the spectrum and chemical fingerprint between compounds and generate a list of the hundred most similar compounds which are ranked by similarity score."
1---2name: deep-learning-model-inference3description: Use when you have preprocessed mass spectrometry spectra (tokenized m/z and intensity pairs or feature matrices) and a trained deep learning model checkpoint, and you need to classify unknown compounds or generate prediction confidence scores for structural novelty analysis.4license: CC-BY-4.05---67# deep-learning-model-inference89## Summary1011Execute forward inference pass on preprocessed mass spectrometry data using a pre-trained deep learning model to generate predictions with confidence scores. This skill applies learned model weights to new inputs to produce classification results and per-class probability distributions without retraining.1213## When to use1415You have preprocessed mass spectrometry spectra (tokenized m/z and intensity pairs or feature matrices) and a trained deep learning model checkpoint, and you need to classify unknown compounds or generate prediction confidence scores for structural novelty analysis. Use this skill when the input data schema matches the model's training format and you require ranked predictions with per-class probabilities rather than model parameter updates.1617## When NOT to use1819- Input spectra have not been preprocessed or normalized according to the model's training requirements — preprocess first before inference.20- You have raw, untokenized mass spectrometry data (e.g., raw vendor instrument files) — execute feature extraction and normalization workflow before inference.21- The goal is to retrain, fine-tune, or evaluate model parameters — use model training/evaluation workflows instead of inference.2223## Inputs2425- Preprocessed mass spectrometry feature matrices or tokenized m/z–intensity pair vectors26- Pre-trained deep learning model weights (e.g., PyTorch .pt or TensorFlow .h5 checkpoint)27- Model architecture definition and input schema specification28- Spectrum identifiers or sample metadata (for result annotation)2930## Outputs3132- Structured prediction table with spectrum identifiers, predicted NPS class labels, and per-class probabilities33- Confidence scores or softmax probability distributions for each prediction34- Optionally: prediction uncertainties or model uncertainty estimates for filtering3536## How to apply3738Load the pre-trained deep learning model weights from the repository (e.g., jhhung/PS2MS). Ensure input spectra conform to the model's expected preprocessing format (normalization, tokenization/vectorization of m/z–intensity pairs). Execute the forward pass on the entire batch of preprocessed spectra. Extract raw model outputs (e.g., softmax probabilities, prediction uncertainties) and apply a confidence threshold to filter low-confidence predictions. Post-process by assigning class labels and generating structured output tables mapping spectrum identifiers to predicted NPS classes and per-class probabilities. Validate output schema consistency and probability distributions (softmax probabilities must sum to 1.0 per spectrum).3940## Related tools4142- **PS2MS** (Pre-trained deep learning system for NPS classification from mass spectrometry; executes inference to generate predictions and confidence scores) — https://github.com/jhhung/PS2MS43- **NEIMS** (Predicts mass spectrum features for synthetic database compounds used in PS2MS comparison pipeline)44- **DeepEI** (Predicts chemical fingerprints for unknown analytes and synthetic database compounds for similarity scoring)45- **PyTorch or TensorFlow** (Deep learning framework for loading model checkpoints and executing forward inference passes)4647## Evaluation signals4849- All output probabilities per spectrum sum to 1.0 (softmax constraint satisfied)50- Prediction confidence scores fall within the expected range (e.g., [0.0, 1.0] for probability-based scores)51- Output table schema matches specification: each row has spectrum ID, predicted class label, and per-class probability columns with no missing values52- Predictions for positive control compounds (if available) match expected NPS classes or known structural analogues53- Confidence scores are lower for structurally novel compounds than for training-distribution-similar compounds (when validated against structural novelty stratification)5455## Limitations5657- Model predictions are limited to NPS classes present in the training dataset; compounds with core structures absent from training may receive low confidence scores58- Inference accuracy depends critically on input preprocessing conformance to the training normalization and tokenization scheme; any deviation will degrade predictions59- The system is designed for novel psychoactive substance detection and may not generalize to other chemical classification tasks or non-spectrometry modalities60- Confidence scores do not directly measure chemical novelty; they measure similarity to training-set prediction distributions — novel structural analogues may receive low confidence even if correctly classified6162## Evidence6364- [other] Load the pre-trained PS2MS deep learning model from the jhhung/PS2MS repository. Execute forward inference pass on preprocessed spectra to generate NPS classification predictions and confidence scores.: "Load the pre-trained PS2MS deep learning model from the jhhung/PS2MS repository. Execute forward inference pass on preprocessed spectra to generate NPS classification predictions and confidence"65- [other] Preprocess spectra according to PS2MS normalization and feature extraction requirements (tokenization/vectorization of m/z and intensity pairs).: "Preprocess spectra according to PS2MS normalization and feature extraction requirements (tokenization/vectorization of m/z and intensity pairs)."66- [other] Post-process predictions to assign NPS class labels and filter by model confidence threshold. Export results as a structured prediction table with spectrum identifiers, predicted NPS classes, and per-class probabilities.: "Post-process predictions to assign NPS class labels and filter by model confidence threshold. Export results as a structured prediction table with spectrum identifiers, predicted NPS classes, and"67- [other] Extract or compute prediction confidence scores (e.g., softmax probabilities, prediction uncertainties) for each compound in the evaluation set using the PS2MS model.: "Extract or compute prediction confidence scores (e.g., softmax probabilities, prediction uncertainties) for each compound in the evaluation set using the PS2MS model."68- [readme] The system will compare the spectrum and chemical fingerprint between compounds and generate a list of the hundred most similar compounds which are ranked by similarity score.: "The system will compare the spectrum and chemical fingerprint between compounds and generate a list of the hundred most similar compounds which are ranked by similarity score."