CHAIR-i and CHAIR-s Hallucination Rates
Problem Statement
CHAIR measures caption hallucination two ways: per-instance (what fraction of mentioned objects are wrong) and per-sentence (what fraction of captions contain any hallucination). Compute both over a set of captions.
Background
For each caption you get the set of objects the model mentioned and the set of objects actually present (the ground truth). An object is hallucinated if it was mentioned but is not present. Then:
Lower is better for both. A caption that mentions nothing contributes 0 to both numerators (and 0 mentions to the CHAIR-i denominator).
Your Task
Implement:
def chair(mentioned, present):
- mentioned[c], present[c]: lists of object names (treat as sets) for caption c.
Return a dict with "chair_i" and "chair_s", each rounded to 4 decimals. If total mentions is 0, chair_i is 0.0.
Input Format
- mentioned: list of lists of object names.
- present: list of lists of object names, same length.
Output Format
- A dict of two floats.
Sample
m = [["dog", "cat"], ["car"]]
p = [["dog"], ["car", "tree"]]
print(chair(m, p))
Output:
{'chair_i': 0.3333, 'chair_s': 0.5}
Example
m = [["dog", "cat"], ["car"]] p = [["dog"], ["car", "tree"]] print(chair(m, p))
{'chair_i': 0.3333, 'chair_s': 0.5}Caption 0 mentions {dog,cat}, present {dog}: cat hallucinated (1 of 2). Caption 1 mentions {car}, present {car,tree}: 0 hallucinated. CHAIR-i = 1/3 = 0.3333; CHAIR-s = 1 of 2 captions = 0.5.
Constraints
len(mentioned) == len(present),1 <= num_captions <= 100000.- Treat each list as a set (ignore duplicates within a caption).
- A hallucinated object is mentioned but not present.
- Round both to 4 decimals;
chair_iis0.0when there are no mentions.