Manuscript Offprint

arXiv:2609.04415

REFINE: LLM Refinement over Budgeted Text-Attributed Graphs for Personalized Medical Concept Representation

Mohsen Nayebi Kerdabadi, Arya Hadizadeh Moghaddam, Dongjie Wang, Zijun Yao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Learning rich medical concept representations is essential for EHR prediction. Text-attributed knowledge graphs (TKGs) provide a natural foundation by organizing heterogeneous medical relations together with textual semantics. However, most existing encoders process concepts uniformly across patients, despite the fact that a code's meaning and predictive value depend on patient-specific clinical context and trajectory. Learning patient-personalized concept representations from TKGs introduces two key challenges: (1) deciding how much KG context to incorporate for each observed code, and (2) aligning semantic information with the patient-specific relational structure. We propose REFINE, a KG-aware budgeted LLM graph refinement framework for patient-personalized medical concept encoding. Starting from a global TKG, REFINE constructs patient-specific temporal graphs. A sequential reinforcement learning policy selects a personalized KG expansion budget for each observed code. The resulting patient graph is processed by a heterogeneous GNN to capture relation-aware structural dependencies, while a frozen LLM uses graph-aware soft prompts to semantically refine concept representations. Experiments on MIMIC-III and MIMIC-IV show that REFINE consistently improves diverse EHR backbones, outperforms strong baselines, and demonstrates robust gains across component ablation, KG selection, and data insufficiency.

1 Introduction

Electronic health records (EHRs) provide a longitudinal view of patient health through high-dimensional sequences of diagnosis, medication, and procedure codes, enabling a wide range of clinical prediction tasks (Nayebi Kerdabadi et al., 2023; Jiang et al., 2023). A central challenge in EHR mining is to learn medical concept representations that capture both rich clinical semantics and heterogeneous relational dependencies among codes, such as treatment patterns and comorbidities. Text-attributed knowledge graphs (TKGs) provide a natural way to organize these semantic and relational signals by linking medical concepts through typed relations and textual attributes. However, most existing concept encoders learn codes in a static manner across patients, overlooking that the same concept can have different clinical meaning and predictive value depending on patient history, visit context, and treatment trajectory. The same diagnosis may reflect a stable chronic condition in one patient but signal acute deterioration in another; likewise, a medication may be routine in one trajectory but highly informative when paired with specific comorbidities or procedures. Thus, beyond learning general concept semantics from TKGs, medical concept representations should be personalized to each patient's local clinical context. Personalizing concept representations, however, is non-trivial and raises two challenges.

The first challenge concerns the relational aspect of the TKG: how much KG context should be attached to each observed code in a patient's history. Existing KG-based EHR models (Jiang et al., 2023; Kerdabadi et al., 2026) often apply fixed expansion rules, retrieving the same hop depth or neighbor budget for every code across patients. This uniform strategy ignores that the value of relational context varies across patients and concepts. A code may be self-explanatory in one trajectory but require richer multi-hop evidence in another to reveal comorbidities, treatment dependencies, or medication interactions. Conversely, unnecessary neighbors can introduce noise, increase computation, and dilute salient clinical signals. Therefore, personalized concept representation requires a graph-budgeting mechanism that adaptively determines how much relational context to retrieve for each observed code within a patient's history, rather than committing to a single global expansion budget.

*Corresponding author.

The second challenge concerns the semantic text aspect of the TKG: how to use LLMs as patient-personalized semantic refiners rather than generic text encoders. Although LLMs can encode concept semantics, isolated encoding is insufficient because a code's meaning depends on co-occurring codes, visit position, temporal history, and selected KG context. We therefore define refinement as adapting a code's general semantics to the patient's specific clinical context, enabling patient-specific representations of the same code. To refine semantic knowledge in interaction with patient-specific EHR and TKG structure, the key question is how to expose such structure to the LLM. Directly serializing the full patient history and all KG neighbors into text is inefficient, redundant, and does not explicitly preserve the relational scaffold. Thus, patient-personalized semantic refinement requires a compact mechanism that lets the LLM jointly reason over textual semantics, longitudinal EHR context, and selected relational evidence.

In this work, we propose a medical concept encoder for EHR prediction named REFINE: KG-Aware LLM Refiner for Budgeted Patient-Personalized Concept Encoding. Starting from a global TKG over EHR codes, REFINE constructs a personalized graph for each patient's EHR history. For every observed code, a sequential reinforcement learning policy selects a code-specific KG expansion budget, allowing the same medical code to receive rich multi-hop context for one patient but minimal context for another. The policy makes these decisions sequentially, accounting for interactions among observed codes and the cumulative relational context already added to the patient graph. The resulting graph is encoded by two parallel branches: a heterogeneous GNN captures relation-aware structural dependencies, while a frozen LLM refiner uses graph-aware mixed prompts to refine code semantics through interactions among hard text tokens, code soft tokens, and KG-context soft tokens. The hard tokens describe the task and visit-code structure, while the soft tokens compactly represent observed codes and their selected KG context. Finally, the two representations are fused into patient-personalized medical concept embeddings for downstream EHR prediction. Our contributions are:

  • We introduce REFINE, a patient-personalized medical concept encoder that learns context-dependent representations for EHR codes by adapting general TKG knowledge to each patient's clinical context.

  • We develop a patient-specific graph construction and budgeting framework that extracts patient graphs from a global TKG and uses sequential reinforcement learning to select code- and patient-specific relational context.

  • We propose a graph-aware LLM refinement mechanism that encodes observed codes and selected KG neighborhoods as soft prompt tokens, enabling semantic refinement through interactions with the patient-specific visit-code scaffold.

  • We integrate the resulting personalized concept representations into standard EHR prediction backbones and evaluate their effectiveness on sequential diagnosis prediction.