SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.03172 · 2024

Accurate and Well-Calibrated ICD Code Assignment Through Attention Over Diverse Label Embeddings

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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; 6 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2402.03172.json · badge: /api/ran/2402.03172.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
gecgomes/icd_coding_msam canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
calculate_total_score Ran
ran, honoured the contract we drafted
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/helper_funcs.py
code served (permissive licence) · get_code("f1f98245b321a6a1")
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 int, ndim 0, dtype family int, 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

torch.manual_seed(0)

# Construct instances_dict with multiple instances, each containing 'instance_score'
instances_dict = {
    "instance_1": {"instance_score": 10},
    "instance_2": {"instance_score": 20},
    "instance_3": {"instance_score": 15},
}

ARGS = {
    "instances_dict": instances_dict,
}
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 int, ndim 0, dtype family int, 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
create_instances_dict Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/helper_funcs.py
code served (permissive licence) · get_code("5194faebf573a9a9")
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 random

# Set seed for reproducibility
random.seed(0)

# X should be an iterable (the function iterates over it)
# y should be indexable by instance_id (integers)
X = [1, 2, 3, 4]  # Simple iterable with 4 elements
y = [0, 1, 0, 1]  # Labels corresponding to each instance

# target_test_size should be a float between 0 and 1
target_test_size = 0.3

ARGS = {
    'X': X,
    'y': y,
    'target_test_size': target_test_size
}
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
create_labels_dict Ran
ran; our contract draft was wrong, not the code
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/helper_funcs.py
code served (permissive licence) · get_code("a8b2ef209164ac11")
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 numpy as np

torch.manual_seed(0)

# Build a valid instances_dict that matches the expected structure
instances_dict = {
    'instance_1': {
        'train_or_test': 'train',
        'labels': ['label_a', 'label_b']
    },
    'instance_2': {
        'train_or_test': 'test',
        'labels': ['label_a', 'label_c']
    },
    'instance_3': {
        'train_or_test': 'train',
        'labels': ['label_b', 'label_c']
    },
    'instance_4': {
        'train_or_test': 'test',
        'labels': ['label_a']
    }
}

ARGS = {
    'instances_dict': instances_dict
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
get_mimiciii_notes Ran
ran; our contract draft was wrong, not the code
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/utils_edin.py
code served (permissive licence) · get_code("8e06017f02a98e0f")
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 DataFrame. 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 logging
from pathlib import Path
import pandas as pd
import tempfile
import os

# Set up logging
logging.basicConfig(level=logging.INFO)

# Create a temporary directory to work with
temp_dir = tempfile.mkdtemp()
temp_path = Path(temp_dir)

# Create a mock NOTEEVENTS.csv.gz file
# First, create a sample CSV
sample_data = pd.DataFrame({
    'ROW_ID': [1, 2, 3],
    'SUBJECT_ID': [100, 101, 102],
    'HADM_ID': [1000, 1001, 1002],
    'CHARTDATE': ['2100-01-01', '2100-01-02', '2100-01-03'],
    'CHARTTIME': ['2100-01-01 12:00:00', '2100-01-02 13:00:00', '2100-01-03 14:00:00'],
    'STORETIME': ['2100-01-01 12:30:00', '2100-01-02 13:30:00', '2100-01-03 14:30:00'],
    'CATEGORY': ['Discharge summary', 'Physician', 'Nursing'],
    'DESCRIPTION': ['Discharge Summary', 'Physician Note', 'Nursing Note'],
    'CGID': [1, 2, 3],
    'ISERROR': [0, 0, 0],
    'TEXT': ['Patient discharged', 'Patient stable', 'Vitals normal']
})

# Save as gzipped CSV
csv_gz_path = temp_path / 'NOTEEVENTS.csv.gz'
sample_data.to_csv(csv_gz_path, compression='gzip', index=False)

# Define ARGS for get_mimiciii_notes
ARGS = {
    'download_dir': temp_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
iterative_stratification Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/stratify.py
code served (permissive licence) · get_code("6bfb3a3a58728e8f")
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 list, ndim 2, 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.

import random
from collections import Counter

# Set seed for reproducibility
random.seed(0)

# Create sample data
data = ["item_0", "item_1", "item_2", "item_3", "item_4", "item_5"]

# Create multilabel labels (each item can have multiple labels)
labels = [
    ["label_a", "label_b"],
    ["label_a"],
    ["label_b", "label_c"],
    ["label_c"],
    ["label_a", "label_c"],
    ["label_b"]
]

# Create ratios for stratification (train, val, test)
ratios = [0.5, 0.3, 0.2]

ARGS = {
    "data": data,
    "labels": labels,
    "ratios": ratios
}
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 list, ndim 2, dtype family float — a list 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
make_version_dir Ran
ran; our contract draft was wrong, not the code
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/utils_edin.py
code served (permissive licence) · get_code("3ed9f9a840e4cabb")
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 PosixPath. 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 tempfile
from pathlib import Path

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()
output_dir = Path(temp_dir) / "test_output"

ARGS = {
    "output_dir": output_dir
}
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 PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath 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
unique Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
gecgomes/icd_coding_msam/MIMIC-III-Preprocess/Helpers/utils_edin.py
code served (permissive licence) · get_code("70834a46f93a4007")
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 list, ndim 1, dtype family int; 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.

import torch
import numpy as np

torch.manual_seed(0)

# The function takes a list and removes duplicates while preserving order
# It checks membership with 'in' operator and appends to a list
# Works with any hashable or comparable items

list1 = [1, 2, 2, 3, 1, 4, 3, 5]

ARGS = {
    "list1": list1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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
unique 1 other paper
1 dated earlier
2022.findings-acl.116 (2022 (year only))
Thai Nested Named Entity Recognition Corpus

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

Although the International Classification of Diseases (ICD) has been adopted worldwide, manually assigning ICD codes to clinical text is time-consuming, error-prone, and expensive, motivating the development of automated approaches. This paper describes a novel approach for automated ICD coding, combining several ideas from previous related work. We specifically employ a strong Transformer-based model as a text encoder and, to handle lengthy clinical narratives, we explored either (a) adapting the base encoder model into a Longformer, or (b) dividing the text into chunks and processing each chunk independently. The representations produced by the encoder are combined with a label embedding mechanism that explores diverse ICD code synonyms. Experiments with different splits of the MIMIC-III dataset show that the proposed approach outperforms the current state-of-the-art models in ICD coding, with the label embeddings significantly contributing to the good performance. Our approach also leads to properly calibrated classification results, which can effectively inform downstream tasks such as quantification.

For agents

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

get_harvested_code_for_paper("2402.03172")
get_code_for_paper("2402.03172")
have("2402.03172")

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

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

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

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

Connect an agent — have() is free.