SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_32596 · AAAI · 2025

HC-LLM: Historical-Constrained Large Language Models for Radiology Report Generation

Xiaojun Chang, Junbin Gao, Mingjie Li, Yongli Hu, Baocai Yin, Tengfei Liu, Jiapu Wang, Junfei Yi

Open in the Atlas

Code that ran

9 of 11 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 8 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/aaai_32596.json · badge: /api/ran/aaai_32596.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
TengfeiLiu966/HC-LLM canonical (classifier label)
classifier basis: census
9 ran · 2 no recorded run
FunctionStatusWhere it lives
clean_reports Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/MS-CXR-T-processor.py
code served (permissive licence) · get_code("f8caa5c18bc41b57")
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

def clean_reports(report):
    report_cleaner = lambda t: t.replace('\n', ' ').replace('__', '_').replace('__', '_').replace('__', '_').replace('__', '_').replace('__', '_').replace('__', '_').replace('__', '_').replace('  ', ' ').replace('  ', ' ').replace('  ', ' ').replace('  ', ' ').replace('  ', ' ').replace('  ', ' ').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('1. ', '').replace('. 2. ', '. ').replace('. 3. ', '. ').replace('. 4. ', '. ').replace('. 5. ', '. ').replace(' 2. ', '. ').replace(' 3. ', '. ').replace(' 4. ', '. ').replace(' 5. ', '. ').strip().lower().split('. ')
    sent_cleaner = lambda t: re.sub('[.,?;*!%^&_+():-\\[\\]{}]', '', t.replace('"', '').replace('/', '').replace('\\', '').replace("'", '').strip().lower())
    tokens = [sent_cleaner(sent) for sent in report_cleaner(report) if sent_cleaner(sent) != []]
    report = ' . '.join(tokens) + ' .'
    return report

ARGS = {
    "report": "This is a medical report.\n\nFindings: 1. Patient shows normal results. 2. No abnormalities detected. 3. Follow-up recommended. 4. Additional testing not needed. 5. Patient cleared for discharge."
}
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
cook_refs Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/cider/cider_scorer.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from wenhuchen/data-to-text-evaluation-metric, is pointer only (licence: NOASSERTION) · get_code("4c1b107103b7c856")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from wenhuchen/data-to-text-evaluation-metric, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

cook_refs Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/bleu/bleu_scorer.py
code served (permissive licence) · get_code("7586e1d32f7325f7")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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.

from collections import defaultdict

ARGS = {
    'refs': [
        'the quick brown fox jumps over the lazy dog',
        'a quick brown fox leaps over a lazy dog'
    ],
    'eff': 'shortest',
    'n': 4
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
cook_test Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/cider/cider_scorer.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from wenhuchen/data-to-text-evaluation-metric, is pointer only (licence: NOASSERTION) · get_code("3573c4bc85f65dfd")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from wenhuchen/data-to-text-evaluation-metric, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

cook_test Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/bleu/bleu_scorer.py
code served (permissive licence) · get_code("bc5342cb883ef9da")
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.

from collections import defaultdict

# First, let's understand what cook_test needs:
# - test: a string (test sentence)
# - refs: a tuple of (reflen, refmaxcounts) where reflen is a list and refmaxcounts is a dict
# - eff: optional string parameter (can be 'closest' or None)
# - n: integer for n-gram size (default 4)

# Build refs by calling precook on reference sentences
def precook(s, n=4, out=False):
    """Takes a string as input and returns an object that can be given to
    either cook_refs or cook_test. This is optional: cook_refs and cook_test
    can take string arguments as well."""
    words = s.split()
    counts = defaultdict(int)
    for k in range(1, n + 1):
        for i in range(len(words) - k + 1):
            ngram = tuple(words[i:i + k])
            counts[ngram] += 1
    return (len(words), counts)

# Create reference data
# refs should be a tuple of (reflen, refmaxcounts)
# reflen is a list of reference lengths
# refmaxcounts is a dict of max counts across all references

ref1_len, ref1_counts = precook("the cat sat on the mat", n=4)
ref2_len, ref2_counts = precook("a cat is sitting on a mat", n=4)

# Create refmaxcounts by taking max of counts for each ngram
refmaxcounts = defaultdict(int)
for ngram, count in ref1_counts.items():
    refmaxcounts[ngram] = max(refmaxcounts[ngram], count)
for ngram, count in ref2_counts.items():
    refmaxcounts[ngram] = max(refmaxcounts[ngram], count)

# refs format: (list_of_reflengths, dict_of_maxcounts)
refs = ([ref1_len, ref2_len], refmaxcounts)

# Create test sentence
test = "the cat sat on the mat"

# Create parameters
ARGS = {
    'test': test,
    'refs': refs,
    'eff': None,
    'n': 4
}
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
get_linear_schedule_with_warmup Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/lightning_tools/optim.py
code served (permissive licence) · get_code("b2cebd35fd97df2a")
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 LambdaLR. 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 torch.nn as nn
from torch.optim import SGD

torch.manual_seed(0)

# Create a simple model
model = nn.Linear(4, 3)

# Create an optimizer
optimizer = SGD(model.parameters(), lr=0.1)

# Define arguments for get_linear_schedule_with_warmup
ARGS = {
    "optimizer": optimizer,
    "num_warmup_steps": 100,
    "num_training_steps": 1000,
    "last_epoch": -1,
}
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 LambdaLR — a LambdaLR output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LambdaLR 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
lr_lambda Ran
ran, honoured the contract we drafted
TengfeiLiu966/HC-LLM/lightning_tools/optim.py
code served (permissive licence) · get_code("d5b1a71db63d18e1")
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 float, 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.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "current_step": 5,
    "num_warmup_steps": 10,
    "num_training_steps": 100
}
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 float, 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
precook Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/bleu/bleu_scorer.py
code served (permissive licence) · get_code("ec4448373d72d636")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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.

ARGS = {
    "s": "the quick brown fox jumps over the lazy dog",
    "n": 4,
    "out": False
}
Setup block drafted by
a language model, Claude Sonnet 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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
precook Ran
ran; our contract draft was wrong, not the code
TengfeiLiu966/HC-LLM/pycocoevalcap/cider/cider_scorer.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from wenhuchen/data-to-text-evaluation-metric, is pointer only (licence: NOASSERTION) · get_code("9560e3e3e41bc1b2")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from wenhuchen/data-to-text-evaluation-metric, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

add_callbacks Not yet run
unverified (harvested, no recorded run)
TengfeiLiu966/HC-LLM/lightning_tools/callbacks.py
code served (permissive licence) · get_code("19fe2eef2172c7b6")
How it ran

no invocation recorded.

create_datasets Not yet run
unverified (harvested, no recorded run)
TengfeiLiu966/HC-LLM/dataset/data_helper.py
code served (permissive licence) · get_code("562ab9bef0c7f834")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 0 the same month, 1 later) and 1 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.

FunctionAlso present inEarliest-datedOthers named
cook_refs 25 other papers
23 dated earlier, 1 later, 1 same year, order not determinable
1411.5726 (2014-11)
CIDEr: Consensus-based Image Description Evaluation
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1503.01817 (2015-03)
YFCC100M: The New Data in Multimedia Research
and 22 more not named here
cook_test 22 other papers
21 dated earlier, 1 same year, order not determinable
1411.5726 (2014-11)
CIDEr: Consensus-based Image Description Evaluation
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1503.01817 (2015-03)
YFCC100M: The New Data in Multimedia Research
and 19 more not named here
precook 22 other papers
22 dated earlier
1411.4555 (2014-11)
Show and Tell: A Neural Image Caption Generator
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1611.09268 (2016-11)
MS MARCO: A Human Generated MAchine Reading COmprehension Dataset
and 19 more not named here
cook_refs 21 other papers
21 dated earlier
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1611.09268 (2016-11)
MS MARCO: A Human Generated MAchine Reading COmprehension Dataset
1611.09571 (2016-11)
Predicting Human Eye Fixations via an LSTM-based Saliency Attentive Model
and 18 more not named here
precook 14 other papers
13 dated earlier, 1 same year, order not determinable
1411.5726 (2014-11)
CIDEr: Consensus-based Image Description Evaluation
1502.03044 (2015-02)
Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
1806.00807 (2018-06)
Learning Semantic Sentence Embeddings using Sequential Pair-wise Discriminator
and 11 more not named here
add_callbacks 1 other paper
1 dated earlier
2309.09812 (2023-09)
R2GenGPT: Radiology Report Generation with Frozen LLMs
cook_test 1 other paper
1 dated earlier
2004.09167 (2020-04)
CheXbert: Combining Automatic Labelers and Expert Annotations for Accurate Radiology Report Labeling Using BERT
create_datasets 1 other paper
1 dated earlier
2309.09812 (2023-09)
R2GenGPT: Radiology Report Generation with Frozen LLMs
get_linear_schedule_with_warmup 1 other paper
1 dated earlier
2309.09812 (2023-09)
R2GenGPT: Radiology Report Generation with Frozen LLMs
lr_lambda 1 other paper
1 dated earlier
2309.09812 (2023-09)
R2GenGPT: Radiology Report Generation with Frozen LLMs

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-23.

Repositories linked to this paper

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

Abstract

Radiology report generation (RRG) models typically focus on individual exams, often overlooking the integration of historical visual or textual data, which is crucial for patient follow-ups. Traditional methods usually struggle with long sequence dependencies when incorporating historical information, but large language models (LLMs) excel at in-context learning, making them well-suited for analyzing longitudinal medical data. In light of this, we propose a novel Historical-Constrained Large Language Models (HC-LLM) framework for RRG, empowering LLMs with longitudinal report generation capabilities by constraining the consistency and differences between longitudinal images and their corresponding reports. Specifically, our approach extracts both timeshared and time-specific features from longitudinal chest Xrays and diagnostic reports to capture disease progression. Then, we ensure consistent representation by applying intramodality similarity constraints and aligning various features across modalities with multimodal contrastive and structural constraints. These combined constraints effectively guide the LLMs in generating diagnostic reports that accurately reflect the progression of the disease, achieving state-of-the-art results on the Longitudinal-MIMIC dataset. Notably, our approach performs well even without historical data during testing and can be easily adapted to other multimodal large models, enhancing its versatility.

For agents

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

get_harvested_code_for_paper("aaai_32596")
get_code_for_paper("aaai_32596")
have("aaai_32596")

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

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

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

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

Connect an agent — have() is free.