Calculate the CIDEr score used to evaluate image captioning model outputs.
CIDEr (Consensus-based Image Description Evaluation) measures image captioning quality by computing TF-IDF weighted n-gram vectors for candidate and reference captions, then calculating their cosine similarity. It rewards captions that use words common in references but rare across the corpus, capturing consensus among annotators.
CIDEr
CIDEr_n = (1/M) * sum(cos_sim(tfidf_candidate, tfidf_ref_j)) * 10
TF-IDF downweights common words (like 'the', 'a') and upweights informative words (like 'surfboard', 'sunset'), so CIDEr rewards captions that capture the distinctive content of an image rather than just generic descriptions.
The scaling factor of 10 is a convention to make scores more readable — raw cosine similarities are typically between 0 and 1, so multiplying by 10 gives a more intuitive range.