{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/ehragent-code-empowers-large-language-models","title":"EHRAgent: Code Empowers Large Language Models for Few-shot Complex Tabular Reasoning on Electronic Health Records","arxiv_id":"2401.07128","date":"2024-01-13","proceeding":null,"authors":["Wenqi Shi","ran Xu","Yuchen Zhuang","Yue Yu","Jieyu Zhang","Hang Wu","Yuanda Zhu","Joyce Ho","Carl Yang","May D. Wang"],"abstract":"Large language models (LLMs) have demonstrated exceptional capabilities in planning and tool utilization as autonomous agents, but few have been developed for medical problem-solving. We propose EHRAgent, an LLM agent empowered with a code interface, to autonomously generate and execute code for multi-tabular reasoning within electronic health records (EHRs). First, we formulate an EHR question-answering task into a tool-use planning process, efficiently decomposing a complicated task into a sequence of manageable actions. By integrating interactive coding and execution feedback, EHRAgent learns from error messages and improves the originally generated code through iterations. Furthermore, we enhance the LLM agent by incorporating long-term memory, which allows EHRAgent to effectively select and build upon the most relevant successful cases from past experiences. Experiments on three real-world multi-tabular EHR datasets show that EHRAgent outperforms the strongest baseline by up to 29.6% in success rate. EHRAgent leverages the emerging few-shot learning capabilities of LLMs, enabling autonomous code generation and execution to tackle complex clinical tasks with minimal demonstrations.","url_abs":"https://arxiv.org/abs/2401.07128v3","url_pdf":"https://arxiv.org/pdf/2401.07128v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"ehragent-code-empowers-large-language-models","repo_url":"https://github.com/wshi83/ehragent","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}}],"tasks":[{"task_slug":"code-generation","task_name":"Code Generation"},{"task_slug":"few-shot-learning","task_name":"Few-Shot Learning"},{"task_slug":"question-answering","task_name":"Question Answering"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2401.07128","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2401.07128"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wshi83/ehragent","reach":{"status":"ok"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/wshi83/EhrAgent","reach":{"status":"ok"}}],"summary":{"ran":3,"unverified":1},"by_repo_kind":{"official":{"samples":4,"ran":3,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":4,"samples":[{"code_sha256_prefix":"bcc19e0a980e5fb7","entry":"judge","repo":"wshi83/EhrAgent","repo_kind":"official","path":"ehragent/evaluate.py","file_url":"https://github.com/wshi83/EhrAgent/blob/HEAD/ehragent/evaluate.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bcc19e0a980e5fb7"}},{"code_sha256_prefix":"8beae56ad4c558c3","entry":"llm_config_list","repo":"wshi83/EhrAgent","repo_kind":"official","path":"ehragent/config.py","file_url":"https://github.com/wshi83/EhrAgent/blob/HEAD/ehragent/config.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8beae56ad4c558c3"}},{"code_sha256_prefix":"e58f72edbe4166a5","entry":"openai_config","repo":"wshi83/EhrAgent","repo_kind":"official","path":"ehragent/config.py","file_url":"https://github.com/wshi83/EhrAgent/blob/HEAD/ehragent/config.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e58f72edbe4166a5"}},{"code_sha256_prefix":"b9a38df731f966c8","entry":"run_code","repo":"wshi83/EhrAgent","repo_kind":"official","path":"ehragent/toolset_high.py","file_url":"https://github.com/wshi83/EhrAgent/blob/HEAD/ehragent/toolset_high.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b9a38df731f966c8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}