agentsclimarketplace

Embedding similarity matching

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/embedding-similarity-matching

Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill embedding-similarity-matching

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

  • 14 stars14 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 author says it does

Copied from the file, not written here

Use when after a CNN model has generated predicted molecular embeddings from mass spectrometry data, and you need to identify the most likely candidate molecules from a reference database.

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

7.4 KB, as published. Nobody here has run it

embedding-similarity-matching

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Match CNN-predicted molecular embeddings against a reference database using pairwise similarity metrics to rank and filter candidate molecules by confidence score. This skill bridges model predictions to actionable molecular identification in mass spectrometry metabolite workflows.

When to use

After a CNN model has generated predicted molecular embeddings from mass spectrometry data, and you need to identify the most likely candidate molecules from a reference database. Applies when query embeddings and reference database embeddings are both available in numeric vector form and a ranked candidate list with match confidence scores is the desired output.

When NOT to use

  • Query or reference embeddings are not in a comparable vector space (e.g., from different model architectures or training sets).
  • Reference database is empty or contains fewer molecules than the minimum threshold needed for meaningful ranking.
  • Input data are already pre-filtered candidate lists rather than embeddings—re-ranking is not necessary.

Inputs

  • CNN-predicted embeddings for query molecules (numeric vectors, typically from spectra data)
  • Reference database embeddings (pre-computed numeric vectors from reference molecules)
  • Query metadata (molecule identifiers, precursor m/z, adduct type)
  • Reference database metadata (molecule identifiers, SMILES or structure information)

Outputs

  • Ranked candidate list (CSV or structured table)
  • Match similarity scores (cosine similarity or distance metric values)
  • Reference molecule identifiers paired with each candidate
  • Top-N candidate molecules per query compound

How to apply

Load the CNN-predicted embeddings for query molecules and reference database embeddings from trained model outputs. Compute pairwise similarity scores between each query embedding and all reference embeddings using cosine similarity (or Euclidean distance). Rank reference molecules by descending similarity score for each query. Apply a similarity threshold to filter matches and retain only high-confidence candidates—typical thresholds depend on the embedding space properties but the README examples suggest filtering by top-N ranking (e.g., top 5). Generate a ranked candidate list with match scores and reference molecule identifiers. The rationale is that structurally and spectroscopically similar molecules will cluster in embedding space, so high similarity scores indicate plausible molecular identifications.

Related tools

Examples

# After loading query and reference embeddings:
from scipy.spatial.distance import cdist
similarity_scores = 1 - cdist(query_embeddings, reference_embeddings, metric='cosine')
top_indices = np.argsort(similarity_scores, axis=1)[:, ::-1][:, :5]
results = pd.DataFrame({'query_id': query_ids, 'top_candidates': [reference_ids[idx] for idx in top_indices]})

Evaluation signals

  • Similarity scores fall within the expected range for the chosen metric (e.g., 0–1 for cosine similarity, 0–∞ for Euclidean distance).
  • Top-ranked candidates have higher similarity scores than lower-ranked candidates for each query (monotonic rank-score alignment).
  • Number of candidates returned per query does not exceed the configured top_n_candidates threshold.
  • Candidate match results include both similarity scores and reference molecule identifiers for traceability.
  • Threshold filtering removes candidates below the similarity cutoff and retains only high-confidence matches (validate by spot-checking a sample of results against known metabolites if available).

Limitations

  • Matching quality depends entirely on CNN embedding quality; poor embeddings will produce false candidates regardless of similarity metric.
  • Cosine similarity and Euclidean distance may not equally weight structural features; choice of metric should be validated for the specific metabolite domain.
  • Reference database coverage affects recall—candidate identification fails for query molecules with no structurally similar compound in the reference database.
  • Threshold selection is user-configurable but not data-driven; inappropriate thresholds can either over-filter (missing true candidates) or under-filter (returning too many false positives).
  • The skill does not account for adduct state or ionization mode differences; query and reference embeddings must be from the same ionization polarity.

Evidence

  • [other] Compute pairwise similarity scores between query embeddings and all reference database embeddings using a distance metric (e.g., cosine similarity or Euclidean distance).: "Compute pairwise similarity scores between query embeddings and all reference database embeddings using a distance metric (e.g., cosine similarity or Euclidean distance)."
  • [other] Rank reference molecules by similarity score in descending order for each query.: "Rank reference molecules by similarity score in descending order for each query."
  • [other] Filter candidate matches by applying a similarity threshold to retain only high-confidence matches.: "Filter candidate matches by applying a similarity threshold to retain only high-confidence matches."
  • [readme] Matches predicted embeddings with a reference database to find top candidate molecules based on cosine similarity.: "Matches predicted embeddings with a reference database to find top candidate molecules based on cosine similarity."
  • [readme] top_n_candidates: Number of top candidate molecules to retrieve from the reference database. (default: 5): "top_n_candidates: Number of top candidate molecules to retrieve from the reference database. (default: 5)"

Keep looking

Skills are one crate of 328,083. 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.