Your question is Semantic Similarity Scoring Function. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Adobe Firefly evaluation pipelines need a deterministic score for comparing generated captions with reference text. Implement a custom similarity function that handles case differences, punctuation, stop words, and a small synonym vocabulary without using external NLP libraries.
Normalize both strings by lowercasing, extracting alphanumeric word tokens, removing common stop words, and mapping known synonyms to a canonical token. Then calculate:
2 * intersection_count / (generated_count + reference_count) using token frequencies.1.0 when both normalized texts contain no bigrams.0.7 * unigram_score + 0.3 * bigram_score, rounded to four decimal places.Treat two empty normalized texts as identical with a score of 1.0. If only one is empty, return 0.0.
Implement score_similarity(generated, reference), where both inputs are strings. Return a floating-point number in [0.0, 1.0]. The synonym mapping must include car/automobile/vehicle, image/picture/photo, buy/purchase, create/creates/created/generate/generated, and quick/fast/rapidly.
def score_similarity(generated, reference):