M ed A dapter: Efficient Test-Time Adaptation of Large Language Models Towards Medical Reasoning (2024)

Abstract: Despite their improved capabilities in generation and reasoning, adapting large language models (LLMs) to the biomedical domain remains challenging due to their immense size and privacy concerns. In this study, we propose MedAdapter, a unified post-hoc adapter for test-time adaptation of LLMs towards biomedical applications. Instead of fine-tuning the entire LLM, MedAdapter effectively adapts the original model by fine-tuning only a small BERT-sized adapter to rank candidate solutions generated by LLMs. Experiments on four biomedical tasks across eight datasets demonstrate that MedAdapter effectively adapts both white-box and black-box LLMs in biomedical reasoning, achieving average performance improvements of 18.24% and 10.96%, respectively, without requiring extensive computational resources or sharing data with third parties. MedAdapter also yields enhanced performance when combined with train-time adaptation, highlighting a flexible and complementary solution to existing adaptation methods. Faced with the challenges of balancing model performance, computational resources, and data privacy, MedAdapter provides an efficient, privacy-preserving, cost-effective, and transparent solution for adapting LLMs to the biomedical domain.

## introduction large language models (llms) @xcite @xcite have demonstrated superior generation and reasoning capabilities compared to traditional bert-sized language models, primarily due to the massive number of parameters and extensive pre-training on vast textual corpora. in the biomedical domain, researchers have developed llms that are either pre-trained @xcite 2023b; @xcite or fine-tuned @xcite on large-scale domain-specific corpora to enhance performance on biomedical natural language processing (nlp) tasks. however, tuning biomedical domain-specific llms triggers additional considerations due to their immense size and corporate privacy, especially given (1) the resource constraints in academic institutions and medical centers and (2) the sensitive nature of clinical data. although fine-tuning llms accelerates biomedical discovery and improves patient care @xcite @xcite , it usually necessitates complete access to internal parameters, which is currently limited to white-box llms like llama-series models @xcite . however, a significant performance discrepancy still exists between larger blackbox llms (e.g., gpt-3.5-turbo) and smaller whitebox llms (e.g., llama-2) @xcite @xcite , even when the latter are fine-tuned on biomedical-specific corpora (figure 1 ). moreover, fine-tuning even a moderately-sized llm with 7b parameters requires substantial computational resources @xcite , often exceeding the capabilities of many academic and medical centers. such intrinsic limitations of white-box llms intuitively motivate the exploration of adapting blackbox llms to the biomedical domain. while it is possible to fine-tune black-box llms like gpt-3.5 (openai, 2022) via third-party apis @xcite without direct access to internal parameters, this approach presents several unique challenges within the field of biomedicine: (1) uploading patient data via apis poses significant risks of privacy leakage and potential conflicts with health insurance portability and accountability act (hipaa) compliance, including unauthorized third-party access to personally identifiable information (pii) @xcite @xcite ; (2) fine-tuning api services could incur prohibitively high financial and environmental costs @xcite , exceeding typical academic or clinical budgets; (3) the opaque fine-tuning process, limited to very few adjustable hyperparameters within a specific range, often results in suboptimal performance in downstream tasks @xcite , whereas medical applications often demand precise outcomes. in this study, we rethink the trade-off between model performance concerns in white-box llms and data privacy issues in black-box llms for biomedical tasks from a new perspective. we introduce medadapter, a unified test-time adapter that fine-tunes a lightweight bert-sized language model (110m) to facilitate the adaptation of both white-box and black-box llms for medical reasoning. instead of updating the parameter for the entire llm, medadapter fine-tunes a small outcome-supervised adapter that ranks candidate solutions generated by llms, effectively and efficiently adapting the original llm to the target domain. in addition, it also eliminates the need to (1) access the large-scale internal model parameters or (2) share any private patient information with third parties through fine-tuning apis. extensive experiments on four biomedical reasoning tasks across eight datasets demonstrate that medadapter effectively adapts both whitebox and black-box llms for medical reasoning, achieving average performance improvements of 18.24% and 10.96%, respectively. for white-box llms, medadapter reaches 99.35% of supervised fine-tuning performance using only 14.75% of the gpu memory on bioasq. for black-box llms, it achieves comparable performance or even surpasses fine-tuning apis at only 15.59% of the budget, while also eliminating the risks associated with private data sharing. we summarize our contributions as follows: ## related works train-time adaptation of llms for biomedical domains. to enhance the biomedical capabilities of llms, prior research has employed largescale domain-specific corpora to customize whitebox llms for medical reasoning, including: (1) pre-training, such as biogpt @xcite , meditron @xcite , biomistral @xcite and biomedlm @xcite ; ## conclusion in this study, we propose medadapter to address a unique challenge in adopting llms in realworld clinical scenarios with limited computational resources and strict privacy requirements. medadapter strikes a balance between effective model adaptation and reasonable computational costs by employing a bert-sized language model as an adapter to select candidate solutions generated by larger llms, thereby obviating the need to fine-tune the entire llms. medadapter may offer a unified and generalizable practical solution for effectively, privacy-preservingly, cost-effectively, and transparently adapting llms to real-world biomedical research and practice.