# Poster 27657

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/27657

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hi, my name is Michael and I'm excited to be presenting our work Context Clues, evaluating long context models for clinical prediction tasks on EHR data. But first, what is EHR data? Well, the EHR, or electronic health record, is essentially all of the information that the hospital knows about you, the patient. This is what the EHR might look like to a doctor who's treating you.
Abstractly, however, we can think of the EHR as simply a timeline of clinical events that happen to a patient. In this case, you can see that a number of diagnoses, medications, lab tests, and procedures are occurring to this patient over time.
We can then serialize the EHR into a sequence of tokens where each token represents a unique clinical event. The representation for this patient might look like what you see at the bottom of the slide here. Now that we have a sequence of tokens, we can apply the latest and greatest methods from the world of large language models and learn representations for patients that we can then use for arbitrary downstream prediction tasks that might be of interest to a hospital. Here, we'll recycle a lot of the machinery.
from foundation models such as training objectives like autoregressive pre-training as well as fine-tuning procedures for arbitrary downstream tasks.
Now, one distinct property of foundation models that has been of interest within the larger world of machine learning has been context length. In other words, how many tokens can you fit in the model at once? Longer contexts are especially of interest to us in the healthcare space because, as you can see in the plot in the top left, most patient timelines can have tens of thousands of clinical events, sometimes even hundreds of thousands. However, most prior work on training foundation models for EHR data.
to have context lengths of at most 512 tokens. That means that we're going to be ignoring the vast majority of a patient's medical history when making clinical predictions for them. This led to the two guiding questions of the context clues work. One, if we train models with longer context, do they outperform models with shorter context lengths? And secondly, are there unique properties of EHR data which might impact model efficacy which are distinct from other domains such as natural language?
In short, the answer to the first question was yes. For most model architectures, we see that performance increases by modeling longer contexts, with the exception of the Haina architecture that we test shown in red. Here we show results on the earshot clinical benchmark, which is a collection of diverse prediction tasks, such as long length of stay prediction, 30-day readmissions risk, as well as anticipating new diagnoses within the next year. The best model that we trained was a Mamba -based model.
with a context length of 16,000 tokens as shown in the green on the plot here.
And to answer the second question, we were able to uncover three properties that were distinct to the electronic health record data we were looking at compared to domains like natural language, which actually tended to reduce model performance at higher levels of when these properties were exhibited. I unfortunately won't have time to go through all these, but please reference the paper for additional details. We open source all of the models that we train on roughly two and a half.
a half million deidentified patient EHRs at Stanford Hospital and make those available through a data use agreement on Hugging Face. And with that, I will hand it off to my co-author Suhana to walk through an example of how to actually download and use these models for your own use cases.
Hi everybody, I'm going to give you a quick overview into how to use our models that are openly available on Hugging Face. So let's get straight into it. So if you haven't applied for access yet and you go to this page, you're going to see this big dialogue box asking you to provide information around some training. And once you do give us that information, you should see something like this, which means you have been granted access to the model.
So let's go through a quick tutorial. I have pre-run all these cells just for the interest of time. All these steps are also available on the Hugging Face page in case you run into issues replicating or remembering it. So go ahead and install PipInstaller package if you haven't already. Make some necessary imports. Then we're going to load the model and tokenizer. Here I'm using the Mamba 16K model, which was deemed the best and most robust across three EHR properties in our paper. And we're going to use our custom tokenizer where each token is basically a medical code. Then we're going to instantiate a simple patient. As you can see, it has.
This event data class, which is nothing but representing a medical occurrence in a patient's health timeline. So at the time of birth, there was a birth code assigned, as denoted here. We have a vitamin D measurement and there are millions of events in a patient's timeline.
Here we're sticking with four. Then we're going to look into this convert events to token function, which just lets us see the actual text representation of each token, which, as I described before, would be something like this because we're using our custom tokenizer. You can see here how numerical values get transformed into ranges. This is because the model bins the continuous values into discrete ranges during training, which helps to generalize across multiple patients. Then we're just going to feed our tokenized patient data through the model to get embeddings.
And you can see the shape here. One represents one patient, seven is the sequence length, which is the number of events or tokens plus padded tokens. And then this is our vocab size. Then we're going to extract our patient representation. And here what we're doing is simply extracting the embedding at the last token position and hoping that would be a very, it would be a good enough representation of the patient's entire medical history. And we're just printing out the first 10 values to see how this looks. So you can go ahead, create more patients, compare them. You can use this model off the shelf for your own task.
I see readmission prediction for your own data set, or you can continue continuously pre-train some of these models and make them work for your use case. Awesome. Thank you, Suhana. With that, I'd like to thank all of our co-authors, lab mates, advisors, collaborators, and funding agencies. And if you're interested in learning more, please check out the links on the slide. Thank you.
