Medical coding assigns each hospital stay a set of diagnosis codes drawn from a list of thousands (about 8,900 ICD-9 codes in MIMIC-III, and more than 70,000 in ICD-10). The hardest decisions are rarely about the broad disease. They are about the final digits: which side, acute or chronic, with or without a complication. The fact that settles a final digit often sits in a different note than the one that named the disease. A discharge summary says "pneumonia," and the radiology report says which lobe. This is the same failure that breaks one-shot retrieval in multi-hop question answering. The second piece of evidence cannot be found from the first query, because nothing in the starting text says what to search for.
We propose that in coding, unlike open-domain question answering, the code hierarchy itself says what the next hop should look for. Once a model is confident about a parent category, the sibling codes beneath it differ along a small number of named attributes, such as laterality, acuity, or a coexisting condition. Those attributes can be read automatically from the official code descriptions and turned into targeted searches over every note in the chart. When a search finds nothing, the coder assigns the explicitly "unspecified" child code, which ICD provides for exactly this case. That gives the loop a principled stopping rule instead of a fixed number of hops. The core claim is that generating queries from the ontology, rather than from free-text reasoning, recovers specific codes that single-pass classifiers and feed-forward agent pipelines miss. We expect it to do so at a fraction of the cost of reasoning-model agents.
Where this sits
Two lines of work motivate the proposal. In multi-hop question answering, IRCoT alternates one sentence of reasoning with a retrieval that uses that sentence as the query, gaining 11–21 points of recall over one-step retrieval. ITER-RETGEN feeds each draft answer back as a query and plateaus after 2–3 rounds. Both build their queries from generated free text and stop after a fixed or heuristic number of hops. Neither has been applied to a label taxonomy. In coding, Code Like Humans (CLH) chains four language-model agents: one extracts evidence, one searches the ICD index, one checks the guidelines, and one reconciles the final codes. CLH reaches Macro-F1 0.28 on MDACE against 0.25 for PLM-ICD. However, its pipeline runs strictly forward, so a missed mention in the first step is never recovered.
Two pieces of prior work supply the method. The two-stage decoder predicts a parent code and then a child code, and gains 25% relative on rare codes. We reuse that factorization, but the child step is conditioned on newly retrieved evidence rather than on the same document encoding. PLM-ICD provides label-wise attention, meaning a separate attention pattern for each code over the document. We use it as the high-recall parent proposer.
Three findings constrain the design. MDACE documents that professional-fee coding needs "complete" evidence spread across physician, nursing, and radiology notes, which is where we expect hops to matter. Long-context LLMs Struggle with Long In-context Learning shows that putting a large label inventory into a prompt fails: most models score near 0% on 174 classes, while fine-tuned BERT scores 87%. We therefore never ask a language model to choose among thousands of labels. It only chooses among the few siblings under one parent. Finally, the intervention-based audit shows that models can score well on multi-hop benchmarks while ignoring the evidence. We adopt its evidence-removal test so that our gains cannot come from metadata priors.
Research Program
The system has four parts.
Parent proposal. A PLM-ICD-style model with label-wise attention, trained on all notes of the admission, proposes parent categories at the three-character level with a high-recall threshold.
Attribute extraction. For each proposed parent whose children are not yet determined, we compute the discriminating attributes offline. We align the child code descriptions and extract the phrases on which they differ, for example "left/right/bilateral" or "with/without acute exacerbation." We add any inclusion and exclusion notes from the tabular list. This is a one-time, deterministic pass over the ontology.
Hops. Each unresolved attribute becomes a query, consisting of the parent name plus the attribute question. A sentence-level retriever (BM25 combined with a clinical dense encoder) searches over every note in the admission. A small reader, a fine-tuned clinical encoder or a 7–8B instruction model, labels each attribute as one of three things: resolved to a value with a cited span, contradicting the parent (for example "ruled out" or "history of"), or unsupported. A contradiction removes the parent, and this is our form of backtracking. An unsupported attribute maps to the unspecified child. Resolved values can raise new attributes from a deeper level, so the number of hops adapts to the depth of the hierarchy. Hops are capped at the hierarchy depth.
Output. The output is a set of codes, each with the spans that justified each digit. This makes the system directly scorable against MDACE evidence annotations.
The question we are testing is narrow. Does deriving queries from sibling differences beat deriving them from generated reasoning, from the original note, or from simply reading everything at once? Most of the experimental design exists to isolate that comparison.
Baselines
The naive reference is PLM-ICD run on the discharge summary alone, followed by the most frequent child under each predicted parent. This shows how much of the specificity problem is already solved by priors.
The strongest flat classifier is PLM-ICD retrained on the concatenation of all admission notes, with segment pooling. It sees the same text our retriever searches, so any gain we show cannot come from access to more data. The strongest reported flat result on MIMIC-III-Full in our file is the multi-stage retrieve-and-re-rank model, at Micro-F1 0.603 and Precision@8 0.775. That model uses structured EHR signals such as medications, DRG, and CPT codes. We report it as published and also rerun it with and without those signals, because the audit question is whether such signals substitute for reading the text.
The strongest agentic competitor is CLH, at Macro-F1 0.28 on MDACE (Code Like Humans). We run it with the same reader model as ours where possible, and also with its original reasoning model. We report results at matched token budgets.
The key ablation replaces ontology-derived queries with IRCoT-style queries, where the reader writes one reasoning sentence and that sentence becomes the query. Everything else stays fixed: the parent proposer, the retriever, the reader, and the hop cap. A second ablation removes hops entirely and has the reader pick a child from the discharge summary alone. A third uses the two-stage decoder's child head in place of retrieval.
Every system gets the same splits, the same number of tuning runs on a shared dev set, and thresholds tuned for Micro-F1 on dev. Beating the baselines means two things. First, the method must exceed all-notes PLM-ICD and compute-matched CLH on macro-F1 and rare-code F1 for MDACE Profee, the split where evidence is spread across notes. Second, it must beat the IRCoT-query ablation by a margin outside bootstrap confidence intervals. The file contains no reported result on Lacuna for MDACE Profee coding F1 specifically, so those numbers will be established by our reruns.
Why not just…?
Why not just give a label-wise attention model all the notes? This is the real threat. If all notes fit in the encoder, label-wise attention can in principle find the radiology sentence on its own. The all-notes PLM-ICD baseline tests this directly. Our bet is that label-wise attention is weakest on rare children, where there are too few examples to learn what each child's attention should target. The two-stage decoder's rare-code gains suggest that structure helps exactly there. If all-notes PLM-ICD matches us on rare-child F1, the hop mechanism adds nothing, and we will report that.
Why not just run IRCoT or ITER-RETGEN on the chart? These methods build queries from generated text, which works when the bridging entity appears in the reasoning. In coding, the missing fact is often an attribute that the model has no reason to mention unless something tells it the attribute matters. The query-source ablation settles this question with everything else held fixed. A fixed-hop variant of ITER-RETGEN, with 2–3 rounds following its reported plateau, checks whether our stopping rule matters.
Why not just run CLH with a larger model or more passes? CLH's errors cascade from its first extraction step, and adding passes does not change what that step searches for. We compare at equal tokens and also give CLH extra self-consistency samples. If CLH plus sampling matches us, the contribution reduces to a cost saving, which we would still report.
Decisive Checks
All experiments use MIMIC-III-Full and both MDACE splits, Inpatient and Profee. We report micro-F1 and macro-F1, F1 on codes with 1–10 training examples, and the hierarchical Information Contrast Model, which penalizes sibling errors less than distant errors. We also report the rate of over-specified and under-specified codes, along with MDACE token-match and exact-span F1 against the EffectiveCAN reference of 43.0 and 27.8.
Three outcomes would be decisive. First, gains should concentrate in the final digits and on Profee rather than Inpatient. If gains are uniform across all digits, the improvement is not coming from hops. Second, following the intervention audit, deleting the retrieved spans should flip the affected child codes to "unspecified" while leaving the flat baselines unchanged. If predictions survive deletion, the system is reading priors, not evidence. Third, on a sample of admissions, structured metadata alone should predict fewer of our correctly specified children than of the parents. That would show the hops supply information the metadata cannot.
References
- Interleaving Retrieval with Chain-of-Thought Reasoning for Knowledge-Intensive Multi-Step Questions
- Enhancing Retrieval-Augmented Large Language Models with Iterative Retrieval-Generation Synergy
- Code Like Humans: A Multi-Agent Solution for Medical Coding
- A Two-Stage Decoder for Efficient ICD Coding
- PLM-ICD: Automatic ICD Coding with Pretrained Language Models
- MDACE: MIMIC Documents Annotated with Code Evidence
- Long-context LLMs Struggle with Long In-context Learning
- Metadata Predictability Is Not Evidence Dependence: An Intervention-Based Audit for Weak-Label Benchmarks
- Multi-stage Retrieve and Re-rank Model for Automatic Medical Coding Recommendation
- Evaluating Extreme Hierarchical Multi-label Classification