CLEVRMath_RS_think / README.md
Hon-Wong's picture
rejection-sampled CLEVRMath (CLEVRMath_RS_think)
be46d62 verified
|
Raw History Blame Contribute Delete
9.81 kB
metadata
license: other
task_categories:
  - visual-question-answering
language:
  - en

CLEVRMath — CLEVRMath_RS_think

Rejection-sampled from the CLEVRMath train split. This split holds the accepted items, with the model's reasoning trace.

rows 206,753
QA pairs 1,952,429
shards 1395
accepted / rejected (whole family) 1,952,429 / 71,057
accept rate 96.5%
verifier relaxed

How the data was produced

A VLM answers every question at temperature 0 with reasoning enabled. Its answer is compared with the official ground truth by the verifier described below; matches go to CLEVRMath_RS_think and CLEVRMath_RS_nothink, non-matches go to CLEVRMath_rejected with the ground truth preserved.

The question field is byte-identical to the prompt the model actually received, including any appended instruction, so the stored training text and the inference-time input cannot drift apart.

How a match is decided

Every rule below is stated with its exact constants and a runnable reference implementation, so any accept/reject decision in this dataset can be recomputed. All snippets assume:

def levenshtein(a, b):
    if a == b: return 0
    if not a: return len(b)
    if not b: return len(a)
    prev = list(range(len(b) + 1))
    for i, ca in enumerate(a, 1):
        cur = [i] + [0] * len(b)
        for j, cb in enumerate(b, 1):
            cur[j] = min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (ca != cb))
        prev = cur
    return prev[len(b)]

relaxed — ChartQA relaxed accuracy

The official ChartQA metric. If both sides parse as numbers, the answer is correct within 5% relative tolerance — chart values are read off axes, so exact digit agreement is not a fair requirement. Otherwise the strings must match exactly after lowercasing, trimming and dropping a trailing period.

_NUM = re.compile(r"^[-+]?\$?\s*([0-9]*\.?[0-9]+)\s*%?$")

def relaxed_pair(pred, gt, tol=0.05):
    p, q = pred.strip().lower().rstrip("."), gt.strip().lower().rstrip(".")
    mp, mq = _NUM.match(p.replace(",", "")), _NUM.match(q.replace(",", ""))
    if mp and mq:
        a, b = float(mp.group(1)), float(mq.group(1))
        return 1.0 if abs(a - b) <= tol * max(abs(b), 1e-9) else 0.0
    return 1.0 if p.replace(",", "") == q.replace(",", "") else 0.0

Shared pre-processing (applies to every verifier below)

Both sides are expanded into a small set of candidate strings and the best-scoring pair decides. The prediction contributes: the raw string; its first line; its first paragraph; the text after the last Answer: marker; the span between Answer: and Rationale:; the stated final answer of a worked solution (recognised from \boxed{…}, Answer:, the final answer is …, the answer is …, so the answer is …, 故选X); and a markdown-stripped variant. The reference contributes the same forms.

When the reference is a wrapper around the real answer (The answer is Red), the raw string is replaced by the extracted answer rather than kept beside it: the wrapper text is shared by every wrong answer too, so The answer is Blue would otherwise score 0.78 against it.

import re

def final_answer(gt):
    """Stated answer of a worked solution, or None."""
    pats = [r"\\boxed\{([^{}]{1,80})\}",
            r"(?is)\banswer\s*[::]\s*(.{1,80}?)\s*$",
            r"(?is)\b(?:the\s+)?final\s+answer\s+is\s*[::]?\s*(.{1,80}?)\s*[.。]?\s*$",
            r"(?is)\b(?:the\s+)?answer\s+is\s*[::]?\s*(.{1,80}?)\s*[.。]?\s*$",
            r"(?s)故\s*选\s*[::]?\s*\(?([A-H])\)?"]
    for p in pats:
        ms = list(re.finditer(p, (gt or "").strip()))
        if ms:
            v = re.sub(r"\s+", " ", ms[-1].group(1).strip().strip("$ \t.。,,;:"))
            if v and len(v) <= 80:
                return v
    return None

Second pass: model-as-judge

String verifiers cannot judge free-form answers at all, and they under-credit answers that are correct but differently phrased. Every item the verifier rejected is therefore re-examined by the same VLM in a text-only pass that sees the question, the reference and the candidate — no image, no re-generation, it only grades text that was already produced.

The judge is instructed to compare against the reference and never to solve the question itself, so an answer is not promoted merely because the model believes it is true. It answers CORRECT, WRONG, or UNSURE; numbers must agree, and UNSURE is reserved for references that are themselves unusable or ambiguous. UNSURE is never counted as correct — only a CORRECT verdict moves a row into the accepted splits. WRONG and UNSURE both remain in the rejected split, so an unresolved case is never silently promoted to a pass.

Calibration: run over items the string verifier had already accepted, the judge agreed on 59/60. Spot-checking its overturns shows it discriminates rather than rubber-stamps — it keeps \frac{L}{n} rejected against a reference of \frac{L}{n-1}, and returns UNSURE when the model argues no finite answer exists against a numeric reference.

What answer holds

In the accepted splits answer is the model's own verified output — the text that passed the verifier — so it agrees with the reasoning in think. The original reference annotation is kept beside it as org_answer. Train on answer; use org_answer when you need the source label.

The two differ more often than one would guess: the verifier accepts on meaning, not on characters, so casing, spacing and formatting routinely differ (bridgestone vs Bridgestone, ( n x m ) vs (n x m)). Storing the reference in the answer slot would pair a model's reasoning with someone else's wording.

In the rejected split the roles are different: answer is the official ground truth and wrong_vlm is what the model said instead.

Schema

  • image — HF Image() — renders directly in the dataset viewer
  • qa — list of {question, answer, org_answer, think}
  • clean_meta — per-row provenance and the cleaning policy that admitted it
  • image_sha256 — content hash of the image

Examples

Three rows taken straight from this split. Images are the original files as stored in the dataset, and long fields are shown in full.

Example 1

case1

field value
question Subtract 1 balls. How many balls are left?
Answer in short without any other content.
answer 3
org_answer 3
think (937 chars)
The user wants me to count balls in the image, subtract one, and provide the result.

Let me look at the image carefully and identify all the objects.

I see:
1. A red metal cube on the left.
2. A blue rubber sphere (ball) in the back left.
3. A cyan metal sphere (ball) in the back middle.
4. A green rubber sphere (ball) in the back right.
5. A yellow rubber sphere (ball) in the center (large).
6. A purple rubber cylinder.
7. A blue rubber cube on the right.
8. A yellow rubber cylinder in the front.

So the balls (spheres) are: blue, cyan, green, yellow. That's 4 balls.

Let me double-check by scanning each object.

- Red cube: not a ball.
- Blue sphere: ball 1.
- Cyan sphere: ball 2.
- Green sphere: ball 3.
- Yellow large sphere: ball 4.
- Purple cylinder: not a ball.
- Blue cube: not a ball.
- Yellow cylinder: not a ball.

Total balls = 4.

Subtract 1 = 3.

The answer should be just the number, short.

So the answer is 3.

Example 2

case2

field value
question Add 3 brown cylinders. How many objects exist?
Answer in short without any other content.
answer 6
org_answer 6
think (439 chars)
The user wants me to count objects after a hypothetical addition. Let me look at the image carefully.

Current objects:
1. A yellow cylinder (left)
2. A brown cylinder (middle)
3. A purple sphere (right)

So there are 3 objects currently.

The instruction says "Add 3 brown cylinders." So 3 + 3 = 6.

The question asks "How many objects exist?" after the addition.

So the answer is 6.

The user wants a short answer without other content.

Example 3

case3

field value
question Question: Subtract all shiny cylinders. How many cylinders are left?
Answer in short without any other content.
answer 1
org_answer 1
think (391 chars)
The user wants me to count cylinders after removing the shiny ones. Let me look at the image carefully.

I see three cylinders: a blue one (matte), a red one (shiny/metallic), and a gray one (shiny/metallic).

Shiny cylinders: red and gray. That's two.

Total cylinders: 3.

Subtract shiny cylinders (2) from total (3) = 1.

The remaining cylinder is the blue matte one.

So the answer is 1.

Cleaning applied before rejection sampling

  • Provenance check. Each QA item records where it came from; items whose recorded source does not resolve to the image they are attached to are dropped.
  • Task purity. The pool's InfinityMM slice assigns samples to a family by image match rather than by dataset origin, which pulls unrelated general-VQA questions into benchmark families. Families where that content measured off-task keep only their genuine benchmark QA.
  • Multiple-choice normalisation. Where options had been flattened into prose, they are re-rendered as a lettered block and the reference is rewritten to the bare letter, so the task is well posed and the answer is unambiguous.