← Back to marginalia

Teaching an LLM to Think Like an RNN

Notes from my research in the Wenqi Lab, where we're getting LLMs to reason over patient data without ever retraining them.

Contents · 8 sections
  1. 1.the short version
  2. 2.what is LLM-as-RNN?
  3. 3.getting the environment running
  4. 4.why was the reward signal broken?
  5. 5.rewriting the rubric
  6. 6.the other thing I'm working on
  7. 7.what i learned
  8. 8.what's next
Teaching an LLM to Think Like an RNN

I thought the hard part would be the memory. It was the grader.

I'm an undergraduate research assistant in Prof. Wenqi Shi's lab, and the main thing we're building is a system called LLM-as-RNN. The question behind it is simple: can you get an LLM to act like a recurrent neural network, keeping and updating a "hidden state" over time, with no gradient updates at all, only prompting?

the short version#

  • The idea: an LLM predicts a patient's discharge diagnosis, a judge scores it, and the LLM rewrites a text summary of what it knows. No weights change. The memory lives in the text.
  • The problem I found: the judge's rewards were almost all very high or very low, and about 31% of its outputs were broken. Training on that was training on noise.
  • The fix: I rewrote the grading rubric twice.
  • The result: a checkpoint trained with the new rubric reached Acc@1 = 0.80 and Acc@5 = 0.94 on 100 patients, ahead of our previous best, a Sonnet-based baseline around 0.79.

what is LLM-as-RNN?#

An RNN reads a sequence one step at a time and carries a hidden state forward, where each step updates what it remembers. Normally that state is a vector of numbers learned through training.

We replace the vector with plain text. We test it on hospital discharge diagnosis prediction using MIMIC-IV data, where the model gets a patient's notes and history and has to predict what they'll be diagnosed with when they leave.

Instead of one guess, the model runs a loop:

  1. Predict. Make a diagnosis prediction.
  2. Evaluate. A judge model scores it against a rubric.
  3. Rewrite. The model rewrites its "state" (a text summary, not weights) based on that feedback.
  4. Repeat.

Take for example a student who keeps a notebook during a semester. They don't get a new brain after each quiz. They just update their notes based on what the grader marked wrong. The same way, the model's notes get better while the model itself stays the same.

It's a clean idea on paper. In practice, most of my work went into making sure step 2 actually meant something.

getting the environment running#

First task was not exciting but had to happen: getting our training pipeline running on TACC's Lonestar6 cluster, with Apptainer containers and a verl submodule. Fifteen out of fifteen unit tests passing felt way more satisfying than it should have for something that doesn't touch the research question.

why was the reward signal broken?#

Once GRPO training was running, I went digging into the reward signal. GRPO learns by comparing several answers to the same question and pushing the model toward the ones that score higher, so the scores have to be meaningful.

They weren't. The distribution was nearly binary, where almost everything scored very high or very low with almost nothing in between. Digging further, about 31% of the judge's outputs were degenerate: cut off, repeating, or otherwise broken instead of real evaluations.

This is Goodhart's Law in a small form. The reward model wasn't measuring "is this diagnosis reasoning good." It was measuring something closer to "did the judge output something parseable." So training on that signal was training on noise.

The thing I keep relearning. A model can only be as good as the signal it's trained against. A sloppy judge quietly poisons everything built on top of it, and you only see it if you go look at the reward distribution.

rewriting the rubric#

So I rewrote the grading rubric, twice. The second version changed four things:

  • A new clinical_objectivity dimension, so the judge scored the medical reasoning itself.
  • Contrastive examples, so the judge had good and bad answers to compare against instead of grading in a vacuum.
  • Explicit formatting rules, so the judge stopped looping on itself.
  • A lower max-token limit, to cut off runaway outputs before they turned degenerate.

Each one goes after a specific failure. The examples give the scores a middle, so the rewards stop being all or nothing. The format rules and token limit go after the broken 31%.

CheckpointAcc@1Acc@5
Previous best (Sonnet-based baseline)~0.79
Trained with the new rubric (100 patients)0.800.94

the other thing I'm working on#

Alongside this, I've been reproducing and comparing rubric-based LLM grading methods on OpenAI's HealthBench benchmark. The interesting finding so far isn't about any one method. It's that the size of the judge model affects the final score more than the grading method does.

So if you don't control for grader size, you can easily mistake "we used a bigger judge" for "our method works better." I'm not posting numbers on this one yet since it's still active, but it's changing how I think about evaluating evaluators.

what i learned#

  • Rewards: look at the reward distribution before trusting anything trained on it.
  • Judges: a judge needs examples to compare against, or its scores collapse to the extremes.
  • Comparisons: when two grading methods use different judge sizes, you're mostly comparing judge sizes.
  • Infrastructure: the HPC debugging was its own kind of hard, just a much less interesting one.

what's next#

We're running a sweep over nine checkpoints (three rubric variants × three training epochs) to see which combination generalizes best. There's also an open question from my mentor about whether per-patient rubrics, made for the specific case instead of one fixed rubric for everyone, would beat what we have now. I'd guess yes, but I don't have the eval to back that up yet.

Thus the fanciest architecture doesn't save you from a bad reward signal. Before you trust what your model learned, go look at what it was actually rewarded for. If you have any questions, feel free to reach out. Thanks for reading!