SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.00815 · ACL · 2024

RAM-EHR: Retrieval Augmentation Meets Clinical Predictions on Electronic Health Records

Carl Yang, Joyce Ho, Yuchen Zhuang, Ran Xu, Jin Bowen, Yu Yue, Wenqi Shi, May Wang

arXiv · PDF · Open in the Atlas

Code that ran

11 of 13 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, 0 violated it and 2 have no contract verdict; 9 failures of our instrument; 2 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/2403.00815.json · badge: /api/ran/2403.00815.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
ritaranx/RAM-EHR canonical (classifier label)
classifier basis: census
11 ran · 2 no recorded run
FunctionStatusWhere it lives
acc_and_f1 Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ritaranx/RAM-EHR/model_src/trainer.py
code served (permissive licence) · get_code("0aa551fedb8479cb")
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
from sklearn.metrics import f1_score

torch.manual_seed(0)

# Create sample predictions and labels
# The function expects array-like objects that support:
# - equality comparison (preds == labels)
# - .mean() method
# - can be passed to f1_score()

preds = np.array([0, 1, 2, 1, 0, 2])
labels = np.array([0, 1, 1, 1, 0, 2])

ARGS = {
    'preds': preds,
    'labels': labels,
    'average': 'macro'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, 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
clean_str Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/prompt_gpt_def.py
code served (permissive licence) · get_code("2fd46a9fc43fa059")
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 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.

ARGS = {
    "string": "Hello,  World!   This is a test string with   multiple   spaces and special characters: @#$%^&*"
}
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 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
clean_str Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/model_src/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from audqhsid/-Review-CNN-for-Sentence-Classification, is pointer only (licence: NONE) · get_code("efe1a86fd9a2468e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from audqhsid/-Review-CNN-for-Sentence-Classification, and GitHub detected no licence in that repository when it was checked. 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.

clean_string Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/query_drugbank.py
code served (permissive licence) · get_code("3e5d94b331e392fe")
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_string(s):
    s = s.replace('NEO*IV*', '')
    s = s.replace('*NF*', '')
    s = re.sub('\\d+(\\.\\d+)?%', '', s)
    s = re.sub('\\(.*?\\)', '', s)
    return s.strip()

# Set up test arguments
test_string = "NEO*IV* Some text *NF* with 42% discount and (notes here) remaining"

ARGS = {
    's': test_string
}
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
compute_metrics Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ritaranx/RAM-EHR/model_src/trainer.py
code served (permissive licence) · get_code("d851686037df7aca")
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 numpy as np
from sklearn.metrics import f1_score

torch_available = True
try:
    import torch
except ImportError:
    torch_available = False

# Analyze the function:
# - compute_metrics takes preds and labels
# - It asserts len(preds) == len(labels)
# - It calls acc_and_f1(preds, labels)
# - acc_and_f1 uses (preds == labels).mean() which needs array-like with == operator
# - acc_and_f1 calls f1_score(labels, preds, average='macro') from sklearn
# - f1_score expects 1D array-like inputs of equal length

# Create valid predictions and labels for a classification task
# Using numpy arrays for simplicity, small batch size of 4
preds = np.array([0, 1, 2, 1])
labels = np.array([0, 1, 1, 1])

ARGS = {
    'preds': preds,
    'labels': labels
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, 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
compute_metrics_rel Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ritaranx/RAM-EHR/model_src/trainer.py
code served (permissive licence) · get_code("22baf81366f31381")
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 Counter

# Analyzing the function:
# - key: iterable of length, accessed by index row
# - prediction: iterable of length, accessed by index row
# - Each element should be an integer (0 or non-zero relation ID)
# - Function computes precision, recall, F1 based on relation prediction accuracy

# Create simple test data
# key: ground truth relation IDs (0 means no relation)
# prediction: predicted relation IDs

key = [0, 1, 2, 1, 0, 3, 1, 2]
prediction = [0, 1, 1, 1, 0, 3, 2, 2]

ARGS = {
    'key': key,
    'prediction': prediction
}
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
dispatch_openai_requests Ran
ran on a synthesized input
ritaranx/RAM-EHR/prompt_gpt_def.py
code served (permissive licence) · get_code("784fab13cc021028")
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 coroutine. 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 openai
import asyncio
from typing import List, Dict, Any

# Set up mock for openai.ChatCompletion.acreate to avoid actual API calls
class MockChatCompletion:
    @staticmethod
    async def acreate(**kwargs):
        await asyncio.sleep(0.001)  # Simulate async work
        return {"choices": [{"message": {"content": "Mock response"}}]}

openai.ChatCompletion = MockChatCompletion()

# Construct arguments
messages_list = [
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2+2?"}
    ],
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"}
    ]
]

temperature = 0.7

max_tokens = 256

ARGS = {
    "messages_list": messages_list,
    "temperature": temperature,
    "max_tokens": max_tokens
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine 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_abstract_text Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/query_pubmed.py
code served (permissive licence) · get_code("8f552d4571c2d406")
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 torch

# Test case 1: subrec with Abstract
subrec_with_abstract = {
    'Abstract': {
        'AbstractText': [
            'This is the first line of the abstract.',
            'This is the second line of the abstract.',
            'This is the third line of the abstract.'
        ]
    }
}

# Test case 2: subrec without Abstract
subrec_without_abstract = {
    'Title': 'Some title',
    'Authors': 'Some authors'
}

ARGS = {
    'subrec': subrec_with_abstract
}
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 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
load_keywords Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/query_pubmed.py
code served (permissive licence) · get_code("8289c17adc33ed63")
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. 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
import tempfile
import os

# Create a temporary directory and a mock JSON file
temp_dir = tempfile.mkdtemp()
original_cwd = os.getcwd()
os.chdir(temp_dir)

# Create the mock data file that the function expects
mock_data = {
    "1": "aspirin",
    "2": "metformin",
    "3": "lisinopril"
}

file_name = 'mimic_prescription_name.json'
with open(file_name, 'w') as f:
    json.dump(mock_data, f)

# Define ARGS
ARGS = {
    'field_name': 'prescription'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
load_tokenizer Ran
ran on a synthesized input
ritaranx/RAM-EHR/model_src/utils.py
code served (permissive licence) · get_code("dd27c40f658addad")
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 MockTokenizer. 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
from transformers import AutoTokenizer

class Args:
    def __init__(self):
        self.tokenizer = "bert-base-uncased"

ARGS = {"args": Args()}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MockTokenizer — a MockTokenizer output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockTokenizer 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
split_ids Ran
ran; our contract draft was wrong, not the code
ritaranx/RAM-EHR/query_pubmed.py
code served (permissive licence) · get_code("8a2260e6189c2d07")
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 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 torch

def split_ids(ids_strings):
    pubmed = []
    pmc = []
    for id_string in ids_strings:
        if id_string.startswith('PMC'):
            pmc.append(id_string[3:])
        else:
            pubmed.append(id_string)
    return (pubmed, pmc)

ARGS = {
    'ids_strings': [
        'PMID12345',
        'PMC98765',
        'PMID54321',
        'PMC11111'
    ]
}
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 tuple, ndim 2, 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
call_api_async Not yet run
unverified (harvested, no recorded run)
ritaranx/RAM-EHR/prompt_gpt_def.py
code served (permissive licence) · get_code("68745016c3fd4fb8")
How it ran

no invocation recorded.

clean_doc Not yet run
unverified (harvested, no recorded run)
ritaranx/RAM-EHR/model_src/utils.py
code served (permissive licence) · get_code("99a40c2d6e975af6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 7 are also present in other papers whose code we hold (7 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
clean_str 9 other papers
9 dated earlier
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1510.03820 (2015-10)
A Sensitivity Analysis of (and Practitioners' Guide to) Convolutional Neural Networks for Sentence Classification
1608.06019 (2016-08)
Domain Separation Networks
and 6 more not named here
compute_metrics 4 other papers
4 dated earlier
1905.08284 (2019-05)
Enriching Pre-trained Language Model with Entity Information for Relation Classification
2010.07835 (2020-10)
Fine-Tuning Pre-trained Language Model with Weak Supervision: A Contrastive-Regularized Self-Training Approach
2301.03726 (2023-01)
Neighborhood-Regularized Self-Training for Learning with Few Labels
and 1 more not named here
clean_str 3 other papers
2 dated earlier, 1 same year, order not determinable
2306.15895 (2023-06)
Large Language Model as Attributed Training Data Generator: A Tale of Diversity and Bias
2311.00287 (2023-11)
Knowledge-Infused Prompting: Assessing and Advancing Clinical Text Data Generation with Large Language Models
2024.findings-acl.916 (2024 (year only))
Knowledge-Infused Prompting: Assessing and Advancing Clinical Text Data Generation with Large Language Models
clean_doc 2 other papers
2 dated earlier
2301.03726 (2023-01)
Neighborhood-Regularized Self-Training for Learning with Few Labels
2306.15895 (2023-06)
Large Language Model as Attributed Training Data Generator: A Tale of Diversity and Bias
acc_and_f1 1 other paper
1 dated earlier
2306.15895 (2023-06)
Large Language Model as Attributed Training Data Generator: A Tale of Diversity and Bias
compute_metrics_rel 1 other paper
1 dated earlier
2306.15895 (2023-06)
Large Language Model as Attributed Training Data Generator: A Tale of Diversity and Bias
load_tokenizer 1 other paper
1 dated earlier
2306.15895 (2023-06)
Large Language Model as Attributed Training Data Generator: A Tale of Diversity and Bias

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 present RAM-EHR, a Retrieval AugMentation pipeline to improve clinical predictions on Electronic Health Records (EHRs). RAM-EHR first collects multiple knowledge sources, converts them into text format, and uses dense retrieval to obtain information related to medical concepts. This strategy addresses the difficulties associated with complex names for the concepts. RAM-EHR then augments the local EHR predictive model co-trained with consistency regularization to capture complementary information from patient visits and summarized knowledge. Experiments on two EHR datasets show the efficacy of RAM-EHR over previous knowledge-enhanced baselines (3.4% gain in AUROC and 7.2% gain in AUPR), emphasizing the effectiveness of the summarized knowledge from RAM-EHR for clinical prediction tasks. The code will be published at https://github.com/ritaranx/RAM-EHR. Table 3: The 25 pre-defined phenotypes in MIMIC-III. Phenotype Type Acute and unspecifed renal failure acute Acute cerebrovascular disease acute Acute myocardial infarction acute Cardiac dysrhythmias mixed Chronic kidney disease chronic Chronic obstructive pulmonary disease chronic Complications of surgical/medical care acute Conduction disorders mixed Congestive heart failure; nonhypertensive mixed Coronary atherosclerosis and related chronic Diabetes mellitus with complications mixed Diabetes mellitus without complication chronic Disorders of lipid metabolism chronic Essential hypertension chronic Fluid and electrolyte disorders acute Gastrointestinal hemorrhage acute Hypertension with complications chronic Other liver diseases mixed Other lower respiratory disease acute Other upper respiratory disease acute Pleurisy; pneumothorax; pulmonary collapse acute Pneumonia acute Respiratory failure; insufficiency; arrest acute Septicemia (except in labor) acute acute

For agents

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

get_harvested_code_for_paper("2403.00815")
get_code_for_paper("2403.00815")
have("2403.00815")

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

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

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

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

Connect an agent — have() is free.