SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.06183 · 2026

CRIMSON: A Clinically-Grounded LLM-Based Metric for Generative Radiology Report Evaluation

Pranav Rajpurkar, Sung Kim, Oishi Banerjee, Hassan Alomaish, Mohammed Baharoon, Thibault Heintz, Siavash Raissi, Mahmoud Alabbad, Mona Alhammad

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 6 failures of our instrument; 1 no recorded run), measured 2026-11-22; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2603.06183.json · badge: /api/ran/2603.06183.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
rajpurkarlab/CRIMSON community
Papers with Code archive
7 ran · 1 no recorded run
FunctionStatusWhere it lives
_dedupe_keys Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("1747bb70759afda9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import json

# This function is designed to be used as an object_pairs_hook for json.loads()
# It takes a list of (key, value) pairs and deduplicates by keeping first occurrence
# We need to construct a realistic pairs argument that would come from JSON parsing

# Create a list of (key, value) pairs with some duplicate keys
# This simulates what json.loads(..., object_pairs_hook=_dedupe_keys) would receive
pairs = [
    ("name", "Alice"),
    ("age", 30),
    ("name", "Bob"),  # duplicate key - should be ignored
    ("city", "NYC"),
    ("age", 25),  # duplicate key - should be ignored
    ("country", "USA")
]

ARGS = {
    "pairs": pairs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_fix_orphan_keys Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("c147779e7c469428")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

_ORPHAN_KEY_AFTER_COMMA_RE = re.compile(',\\s*"[^"]*"\\s*(?=\\s*[,}])(?!\\s*:)')

_ORPHAN_KEY_AT_START_RE = re.compile('(?<=\\{)\\s*"[^"]*"\\s*,\\s*(?=")')

def _fix_orphan_keys(text):
    """Remove bare string values inside JSON objects (orphan keys with no value).

    The model sometimes hallucinates partial key fragments (e.g. ``"pred_old"``)
    that appear as bare values in objects, producing invalid JSON like::

        {"ref_id":"R3","pred_old","pred_id":"P2"}

    This function strips them so the JSON becomes parsable.
    """
    text = _ORPHAN_KEY_AFTER_COMMA_RE.sub('', text)
    text = _ORPHAN_KEY_AT_START_RE.sub('', text)
    return text


# Test cases with invalid JSON containing orphan keys
test_text_1 = '{"ref_id":"R3","pred_old","pred_id":"P2"}'
test_text_2 = '{"key1","key2":"value2","key3":"value3"}'
test_text_3 = '{"a":"1","orphan","b":"2"}'

ARGS = {
    "text": test_text_1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_fix_unescaped_quotes Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("1efa336b854c3ceb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json

def _dedupe_keys(pairs):
    """JSON object_pairs_hook that keeps the first occurrence of duplicate keys."""
    result = {}
    for key, value in pairs:
        if key not in result:
            result[key] = value
    return result

def _is_structural_quote(text, i):
    """Check if the quote at position *i* is likely a JSON structural delimiter.

    Returns True for quotes that delimit JSON keys/values (after ``:``, before
    ``:`` etc.) and False for quotes that are part of prose inside a string
    value (e.g. the model quoting a phrase in an explanation).
    """
    before = text[i - 1] if i > 0 else ''
    after = text[i + 1] if i + 1 < len(text) else ''
    if before in (':', '[', '{'):
        return True
    if after in (':', ']', '}'):
        return True
    if before == ',':
        pre_comma = text[i - 2] if i >= 2 else ''
        return pre_comma in ('"', ']', '}') or pre_comma.isdigit()
    if after == ',':
        post_comma = text[i + 2] if i + 2 < len(text) else ''
        return post_comma in ('"', '[', '{') or post_comma.isdigit()
    return False

def _loads(text):
    """json.loads with duplicate-key handling (keeps first occurrence)."""
    return json.loads(text, object_pairs_hook=_dedupe_keys)

def _fix_unescaped_quotes(text, max_attempts=50):
    """Iteratively escape unescaped double-quotes that break JSON parsing.

    When the model uses literal " inside a JSON string value (e.g. to quote
    a phrase in an explanation), the JSON parser sees it as a string
    terminator.  This function locates each offending quote by parsing,
    catching the error position, searching backwards for a non-structural
    quote, escaping it, and retrying.
    """
    for _ in range(max_attempts):
        try:
            return _loads(text)
        except json.JSONDecodeError as e:
            pos = e.pos
            search_start = max(0, pos - 5)
            found = False
            for i in range(pos, search_start - 1, -1):
                if i < len(text) and text[i] == '"' and (i == 0 or text[i - 1] != '\\'):
                    if _is_structural_quote(text, i):
                        continue
                    text = text[:i] + '\\"' + text[i + 1:]
                    found = True
                    break
            if not found:
                raise
    raise json.JSONDecodeError('Max quote-fix attempts reached', text, 0)


ARGS = {
    "text": '{"key": "value with " quote inside", "other": 123}',
    "max_attempts": 50,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_is_structural_quote Ran
ran, violated the contract we drafted
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("2b8f0547ec80f17c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

# Analyze the function to understand what parameters it needs
# _is_structural_quote(text, i)
# - text: a string to be searched
# - i: an integer index position in the string

# The function checks characters before and after position i in the text string
# and determines if a quote at that position is a JSON structural delimiter

# Setup: Create test cases for both parameters
text_test_1 = '{"key": "value"}'
text_test_2 = '[1, 2, "test"]'
text_test_3 = '{"nested": {"quote": "phrase about \\"something\\""}}'

# Test indices that point to structural quotes
i_structural_1 = 1   # Position of " after { in '{"key"'
i_structural_2 = 7   # Position of " after : in '{"key": "'
i_structural_3 = 14  # Position of " before } in '...value"}'

# Test indices that point to prose quotes
i_prose_1 = 5    # Position of " inside string value
i_prose_2 = 28   # Position inside quoted phrase

# Choose one representative case for ARGS
ARGS = {
    "text": '{"key": "value"}',
    "i": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
_loads Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("89f17e458e239d31")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json

def _dedupe_keys(pairs):
    """JSON object_pairs_hook that keeps the first occurrence of duplicate keys."""
    result = {}
    for key, value in pairs:
        if key not in result:
            result[key] = value
    return result

def _loads(text):
    """json.loads with duplicate-key handling (keeps first occurrence)."""
    return json.loads(text, object_pairs_hook=_dedupe_keys)

# Test case 1: Simple JSON with duplicate keys
text_with_dupes = '{"key1": "first", "key2": 42, "key1": "second", "key3": true}'

ARGS = {
    "text": text_with_dupes
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_json_response Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("78e54daaf9f90526")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json

# The function parse_json_response takes two parameters:
# 1. response: str - a raw model output string to parse as JSON
# 2. batch_idx: Optional[int] - optional index for error context

# Let's create test arguments that cover the happy path and error cases

# Test case 1: A valid JSON response that should parse cleanly
valid_response = '{"key": "value", "number": 42}'

# Test case 2: A response with some quirks that need fixing
quirky_response = '{"ref_id":"R3","pred_old","pred_id":"P2"}'

# Test case 3: A response with unescaped quotes inside values
unescaped_quotes_response = '{"explanation": "The model said \\"hello\\""}'

# For the batch_idx parameter, we can pass None or an integer
batch_idx_value = 0

# Create the ARGS dictionary with all parameters
ARGS = {
    'response': valid_response,
    'batch_idx': batch_idx_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
resolve_model_for_vllm Ran
ran; our contract draft was wrong, not the code
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("f513d251021c4f04")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import json

# Create a temporary directory to simulate a local model path
temp_dir = tempfile.mkdtemp()

# Test case 1: Local path (simplest case - directory already exists)
local_model_path = temp_dir

ARGS = {
    "model_name": local_model_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
huggingface_hub — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
CRIMSONScore Not yet run
unverified (harvested, no recorded run)
rajpurkarlab/CRIMSON/CRIMSON/generate_score.py
code served (permissive licence) · get_code("0beb1cae2f2b9fc0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We introduce CRIMSON, a clinically grounded evaluation framework for chest X-ray report generation that assesses reports based on diagnostic correctness, contextual relevance, and patient safety. Unlike prior metrics, CRIMSON incorporates full clinical context, including patient age, indication, and guideline-based decision rules, and prevents normal or clinically insignificant findings from exerting disproportionate influence on the overall score. The framework categorizes errors into a comprehensive taxonomy covering false findings, missing findings, and eight attribute-level errors (e.g., location, severity, measurement, and diagnostic overinterpretation). Each finding is assigned a clinical significance level (urgent, actionable non-urgent, nonactionable, or expected/benign), based on a guideline developed in collaboration with attending cardiothoracic radiologists, enabling severity-aware weighting that prioritizes clinically consequential mistakes over benign discrepancies. CRIMSON is validated through strong alignment with clinically significant error counts annotated by six board-certified radiologists in ReXVal (Kendall's τ = 0.61-0.71; Pearson's r = 0.71-0.84), and through two additional benchmarks that we introduce. In RadJudge, a targeted suite of clinically challenging pass-fail scenarios, CRIM-SON shows consistent agreement with expert judgment. In RadPref, a larger radiologist preference benchmark of over 100 pairwise cases with structured error categorization, severity modeling, and 1-5 overall quality ratings from three cardiothoracic radiologists, CRIMSON achieves the strongest alignment with radiologist preferences. We release the metric, the evaluation benchmarks, RadJudge and RadPref, and a fine-tuned MedGemma model to enable reproducible evaluation of report generation, all available at https://github.com/rajpurkarlab/CRIMSON.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2603.06183")
get_code_for_paper("2603.06183")
have("2603.06183")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2603.06183.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2603.06183.svg)](https://syntology.ai/paper/2603.06183)

Connect an agent — have() is free.