skills/cv/sentence-transformer-target-encoding/SKILL.md
Encode text prompts into fixed-length dense vectors using SentenceTransformer for cosine-similarity evaluation in image-to-text retrieval tasks
npx skillsauth add wenmin-wu/ds-skills cv-sentence-transformer-target-encodingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In image-to-prompt competitions, the target is not raw text but its SentenceTransformer embedding. Models predict embedding vectors and are scored by cosine similarity against the ground-truth prompt embeddings. Understanding this encoding step is essential: predictions must live in the same embedding space as the evaluation targets.
from sentence_transformers import SentenceTransformer
import numpy as np
st_model = SentenceTransformer("all-MiniLM-L6-v2")
prompts = ["a painting of a sunset over mountains", "cyberpunk city at night"]
embeddings = st_model.encode(prompts, normalize_embeddings=True)
# embeddings.shape: (2, 384)
# Cosine similarity between two prompt embeddings
similarity = np.dot(embeddings[0], embeddings[1])
np.dot(pred, target) / (norm(pred) * norm(target))all-MiniLM-L6-v2 (384-dim) is common; check competition descriptionnormalize_embeddings=True to simplify cosine similarity to dot productbatch_size=32 for large datasets to avoid OOMdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF