mlsanityData to 14 Oct 2026

Improving Medical Calculation of LLMs with Embedded Coding

arXiv 2609.31908 ↗First posted 25 Sep 2026cs.AI cs.CLcited by 0

Not on the map. Why?

Abstract (arXiv)

Large Language Models (LLMs) perform well on medical examinations and question-answering benchmarks, but remain unreliable on medical calculation tasks that require exact numerical outputs. These calculations support high-stakes decisions such as medication dosing, organ-function assessment, and prognostic scoring, for which even small errors can have serious clinical consequences. We introduce MedCode, a framework that improves medical calculation by training LLMs to generate embedded executable code. Given a clinical context, the model identifies the relevant calculator, extracts its input variables, and produces a script that delegates arithmetic operations to a deterministic interpreter. Executing the script returns the calculated value together with an explanation and the appropriate unit. We construct supervised fine-tuning (SFT) and preference datasets from the MedCalc benchmark and additionally curate a dataset for calculation tasks in Intensive Care Unit (ICU) scenarios. We further propose weighted Direct Preference Optimization (wDPO), which adaptively emphasizes preference pairs that are difficult for the model to distinguish. Experiments with LLaMA3-8B, Qwen2.5-7B, and Mistral-7B show absolute accuracy gains of 20--30 percentage points, demonstrating the effectiveness of embedded code generation for medical calculation.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 18 of its 26 references that are in the map. First posted on arXiv 25 Sep 2026.

Builds on

18 of 26 references.

References · 18

  1. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
  2. 2020Measuring Massive Multitask Language Understandingcited by 7,963
  3. 2024LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Modelscited by 1,464
  4. 2020What Disease does this Patient Have? A Large-scale Open Domain Question Answering Dataset from Medical Examscited by 1,356
  5. 2019PubMedQA: A Dataset for Biomedical Research Question Answeringcited by 1,288
  6. 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,076
  7. 2023Solving Challenging Math Word Problems Using GPT-4 Code Interpreter with Code-based Self-Verificationcited by 166
  8. 2024Provably Robust DPO: Aligning Language Models with Noisy Feedbackcited by 135
  9. 2023Chain of Code: Reasoning with a Language Model-Augmented Code Emulatorcited by 123
  10. 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 93
  11. 2023HuatuoGPT-II, One-stage Training for Medical Adaption of LLMscited by 92
  12. 2024MedCalc-Bench: Evaluating Large Language Models for Medical Calculationscited by 70
6 more
  1. 2025LLM Agents Making Agent Toolscited by 48
  2. 2023Taiyi: A Bilingual Fine-Tuned Large Language Model for Diverse Biomedical Taskscited by 36
  3. 2023OphGLM: Training an Ophthalmology Large Language-and-Vision Assistant based on Instructions and Dialoguecited by 34
  4. 2024AgentMD: Empowering Language Agents for Risk Prediction with Large-Scale Clinical Tool Learningcited by 33
  5. 2023Leveraging Medical Knowledge Graphs Into Large Language Models for Diagnosis Prediction: Design and Application Studycited by 30
  6. 2024ReflecTool: Towards Reflection-Aware Tool-Augmented Clinical Agentscited by 20

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2025From Scores to Steps: Diagnosing and Improving LLM Performance in Evidence-Based Medical Calculations
  2. 2026MedCalc-Pro: Solving Complex Medical Calculations with LLM Agents
  3. 2025MedCalc-Eval and MedCalc-Env: Advancing Medical Calculation Capabilities of Large Language Models
  4. 2025MedHELM: Holistic Evaluation of Large Language Models for Medical Tasks
  5. 2024MeNTi: Bridging Medical Calculator and LLM Agent with Nested Tool Calling
  6. 2026Medmarks: A Comprehensive Open-Source LLM Benchmark Suite for Medical Tasks
  7. 2025Stabilizing Reasoning in Medical LLMs with Continued Pretraining and Reasoning Preference Optimization
  8. 2024Biomedical Large Languages Models Seem not to be Superior to Generalist Models on Unseen Medical Data