Towards Adapting Open-Source Large Language Models for Expert-Level Clinical Note Generation
Authors: Hanyin Wang, Chufan Gao, Bolun Liu, Qiping Xu, Guleid Hussein, Mohamad El Labban, Kingsley Iheasirim, Hariprasad Reddy Korsapati, Chuck Outcalt, Jimeng Sun
Accepted at: acl25

Towards Adapting Open-Source Large Language Models for Expert-Level Clinical Note Generation

Hanyin Wang1,2, Chufan Gao2, Bolun Liu1, Qiping Xu1, Guleid Hussein1, Mohamad El Labban1, Kingsley Iheasirim1, Hariprasad Korsapati1, Chuck Outcalt 3, Jimeng Sun2,4

1 Mayo Clinic Health System, 2 School of Computing and Data Science, UIUC
3 Mayo Clinic Rochester, 4 Carle Illinois College of Medicine, UIUC
wang.hanyin@mayo.edu, jimeng@illinois.edu

Abstract

Proprietary Large Language Models (LLMs) such as GPT-4 and Gemini have demonstrated promising capabilities in clinical text summarization tasks. However, due to patient data privacy concerns and computational costs, many healthcare providers prefer using small, locally-hosted models over external generic LLMs. This study presents a comprehensive domain- and task-specific adaptation process for the open-source LLaMA-2 13 billion parameter model, enabling it to generate high-quality clinical notes from outpatient patient-doctor dialogues. Our process incorporates continued pretraining, supervised fine-tuning, and reinforcement learning from both AI and human feedback. We introduced a new approach, DistillDirect, for performing on-policy reinforcement learning with Gemini 1.0 Pro as the teacher model. Our resulting model, LLaMA-Clinic, can generate clinical notes comparable in quality to those authored by physicians. In a blinded physician reader study, the majority (92.8%) of individual evaluations rated the notes generated by LLaMA-Clinic as “acceptable” or higher across three criteria: real-world readiness, completeness, and accuracy. In the more challenging “Assessment and Plan” section, LLaMA-Clinic matched physician-authored notes in real-world readiness score. We highlight key considerations for future clinical note-generation tasks, emphasizing the importance of pre-defining a “best practice” note format, rather than relying on LLMs to determine this for clinical practice. 1

1 Introduction

Recent advancements in LLMs have transformed the field of natural language processing (NLP). However, the application of LLMs in the medical domain is still in its early stages (He et al., 2023; Zhou et al., 2023b). Proprietary LLMs, such as GPT-4 and Med-PaLM, have demonstrated impressive capabilities in medical knowledge and clinical NLP tasks (Nori et al., 2023; Singhal et al., 2023; Van Veen et al., 2023). However, most proprietary LLMs have limited flexibility for domain-specific fine-tuning, primarily due to restricted access to model weights. Additionally, proprietary LLMs raise several concerns pertinent to the healthcare sector, including HIPAA compliance, data security, cost, and transparency of training data (Marks and Haupt, 2023; Clusmann et al., 2023; Adimi, 2024; Michael M. Grynbaum, 2023).

The emergence of powerful open-source LLMs has opened up opportunities for domain-specific fine-tuning within the clinical field, yielding promising results (Han et al., 2023; Wang et al., 2023; Yunxiang et al., 2023; Wu et al., 2023a; Toma et al., 2023; Chen et al., 2023). However, most research on open-source models has concentrated on medical knowledge injection rather than practical applications in real-world clinical workflow such as clinical note generation.

In this work, we address a practical question clinicians face in their everyday routine: How can we best adapt an open-source LLM for the specific use case of clinical note generation? Clinical note documentation represents a significant burden for healthcare practitioners (Ammenwerth and Spötl, 2009) and appears to be a natural application for LLMs, given their remarkable generative capabilities (Lee et al., 2023). Recent research on LLMs for clinical text summarization found that LLM-generated outputs are preferred over human summaries for their completeness and accuracy (Van Veen et al., 2023).

The 2023 ACL ClinicalNLP and CLEFImage workshops explored the generation of clinical notes from patient-doctor conversations using the newly released Ambient Clinical Intelligence Benchmark (ACI-BENCH) dataset (Abacha et al., 2023; Yim et al., 2023a). The most notable results were
Figure 1: Overview of Study Design. We conducted a comprehensive domain- and task-specific adaptation process for the LLaMA-2-13B model. This process included continued pretraining, supervised fine-tuning, and reinforcement learning from AI and human feedback. Finally, we evaluated our model’s outputs against those created by physicians and Gemini Pro through a blinded expert evaluation. We used Gemini 1.0 Pro as the teacher model in this study.

achieved using GPT-4 along with few-shot in-context learning (Giorgi et al., 2023; Van Veen et al., 2023). However, these initial exploratory studies for clinical note generation with LLMs revealed significant limitations:

• Issue with metrics: The evaluation relied solely on automatic metrics of lexical similarity to the “reference” notes, such as ROUGE scores, which may not accurately reflect human preferences (Moramarco et al., 2022; Van Veen et al., 2023).

• Variation in ground-truth quality: There was considerable variation in the quality, format, and style of “reference notes”, suggesting that a note similar to a reference note might not necessarily be of high quality for real-world clinical applications.

• Limited fine-tuning datasets: Previous studies conducted only limited supervised fine-tuning (SFT) of open-source LLMs using small training datasets, thereby not fully exploring their potential for domain- and task-specific adaptation (Abacha et al., 2023; Yim et al., 2023a; Van Veen et al., 2023).

• Lack of advanced training strategy: The potential of data augmentation and reinforcement learning remains unexplored.

In this study, we revisit the task of outpatient note generation, focusing on adapting an open-source LLM—the LLaMA-2 13 billion parameter model. We thoroughly evaluated techniques for domain- and task-specific adaptation, ranging from continued pretraining and SFT to reinforcement learning informed from both AI and human feedback (Figure 1). This work makes several specific contributions:

1. Clinical LLM fine-tuning playbook: Our relatively compact, open-source LLM demonstrated expert-level performance, achieving the same quality as physician-authored notes in the “Assessment and Plan” section. We provide a comprehensive guide for healthcare organizations to fine-tune local LLMs on their own data.

2. DistillDirect: We are among the first groups to explore the role of reinforcement learning in clinical note generation. We proposed DistillDirect, a strategy to ensure on-policy learning during direct preference optimization (DPO) for model distillation.

3. Open datasets: We have made our newly created synthetic clinic dialogue-note dataset and physician feedback dataset publicly available.

4. Key considerations for future clinical note-generation tasks: We underscored the importance of pre-defining a “best practice” note format, rather than relying on LLMs to determine this for clinical practice. We also recommend a workflow for physicians to work with AI-generated notes in real-world practice, ensuring
physicians’ full oversight and ultimate accountability for the AI-generated content.

2 Background and Related Work

2.1 Problem Formation

Given a recorded dialogue from a patient-doctor clinic encounter, we task LLMs to generate a high-quality outpatient note akin to one written by a clinician. This scenario is becoming increasingly prevalent due to the rising popularity of ambient AI scribe products (Yim et al., 2023b; Barr et al., 2024). Our research focus is on generating the “Subjective” and “Assessment and Plan” sections of outpatient notes. This decision is based on feedback from our physician coauthors, which indicates that discussing all details of the “Objective” section, such as physical examination results, is impractical during real-world clinical encounters. Furthermore, much of the objective data, including lab and imaging results, are directly integrated into Electronic Medical Records (EMR), making clinical notes generation for those sections easy and sometimes unnecessary. Our research is also related to prior work on generating clinical assessments within notes (Yang and Yu, 2020) and on generating doctor-patient conversations (Wang et al., 2024c).

2.2 ACI-BENCH

ACI-BENCH represents the largest clinic dialogue-note dataset publicly available to date, comprising 207 cases (Yim et al., 2023b). The dataset’s dialogues were crafted by a team with medical expertise, and its clinical notes were initially generated using an automatic note generation system, then reviewed and revised by domain experts (Yim et al., 2023b). The ACI-BENCH dataset was previously utilized to benchmark the performance of outpatient note generation systems using automatic metrics that evaluate lexical similarity (Abacha et al., 2023; Yim et al., 2023a). Importantly, we observed notable variation in the format, style, and quality of the “reference notes” within ACI-BENCH, especially in the section of “Assessment and Plan”. While this diversity mirrors the reality of clinical practice, where different doctors may produce vastly different notes, it presents a challenge to use these notes as a “gold standard” for training an LLM to replicate.

2.3 Distilled DPO

DPO begins by collecting a preference dataset \( \mathbb{D} = \{ (\mathbf{x}_i, y^+_i, y^-_i) \}_{i=1}^N \), where for each prompt \( \mathbf{x} \), there is a preferred answer \( y^+ \) and a rejected answer \( y^- \) (Rafailov et al., 2023). Following the notations as in (Guo et al., 2024), DPO optimizes the language model (target policy \( \pi_\theta \)) using the following loss function:

\[
- \log \sigma \left( \beta \log \frac{\pi_\theta(y^+|\mathbf{x}) \pi_{\theta^0}(y^-|\mathbf{x})}{\pi_{\theta^0}(y^+|\mathbf{x}) \pi_\theta(y^-|\mathbf{x})} \right)
\]

Here, \( \pi_{\theta^0} \) represents the SFT baseline used as a reference, \( \sigma \) denotes the logistic function, and \( \beta \) is introduced as a scalar hyperparameter.

Given the significant time and financial costs associated with collecting preference data, utilizing pre-collected preference datasets, such as those employed in distilled DPO, is a common practice. Distilled DPO involves generating a collection of responses for each prompt from various LLMs (Figure 2A) (Tunstall et al., 2023). These responses are then evaluated by a teacher model (e.g., GPT-4) to provide preference feedback. Applying reinforcement learning with AI feedback (RLAIF) with distilled DPO has yielded encouraging outcomes (Tunstall et al., 2023). However, distilled DPO’s reliance on a pre-collected preference dataset renders it suboptimal due to the off-policy and offline characteristics.

3 DistillDirect

3.1 Comparison of Online vs. Offline and On-Policy vs. Off-Policy Training

When creating a preference dataset \( \mathbb{D} \), for any given prompt \( \mathbf{x} \), initially, two responses \( y^1 \) and \( y^2 \) are generated from an LLM denoted as \( \rho \). These responses are then assessed for preference by humans or AI, being labeled as \( y^+ \) (preferred) and \( y^- \) (rejected). In this context, training is considered on-policy if \( \rho = \pi_{\theta^0} \), or when the generated responses are sampled from the latest version of the LLM during RLAIF training. Off-policy training indicates otherwise. Learning is deemed online if the preference labeling and training is conducted in real-time, directly on the outputs from the currently trained policy. It is considered offline if preference labeling and training are performed in separate, discrete steps.

A critical caveat of employing a pre-collected preference dataset for offline and off-policy training, such as Distilled DPO, is distribution shifts
(Guo et al., 2024). More specifically, distribution shifts arise at time step \( t \) because the preferred and rejected response is sampled from a policy \( \rho \), where \( \rho \neq \pi_{\theta^t} \). Research has shown that online RLAIF systems, which are designed to mitigate these distribution shifts, significantly surpass the effectiveness of offline DPO methodologies (Guo et al., 2024).

3.2 RLAIF with DistillDirect
We introduce an improved approach based on distilled DPO, termed DistillDirect, specifically designed to ensure on-policy learning on a distilled dataset. This approach is inspired by recent developments in adversarial preference optimization (Cheng et al., 2023), online AI feedback (Guo et al., 2024), iterative DPO (Pang et al., 2024; Xiong et al., 2024) and SPIN (Chen et al., 2024). In each training cycle, we begin by sampling a response from the current policy \( \pi_{\theta^t} \), ensuring that the learning process remains strictly on-policy. This sampled response is then designated as the rejected response, while a reference response from Gemini Pro (the teacher model) is considered the preferred outcome (Figure 2B). This approach implicitly assumes that the response from \( \pi_{\theta^t} \) is generally less favored than that from the teacher model—an assumption that we validated through manual review in each round of training.

In our study, we employed RLAIF with DistillDirect, followed by Reinforcement Learning from Human Feedback (RLHF), which provides several advantages. First, for each iteration of DistillDirect, we used the target policy’s outputs as “reject samples” to inform feedback, ensuring on-policy learning as opposed to the off-policy training in previous work (Tunstall et al., 2023). Second, during the RLHF phase, we gathered human preferences on responses generated by the target policy, promoting online and on-policy training (Figure 2C).

4 Experiments

4.1 Experimental Design
Model Selection: We selected Meta’s LLaMA-2-13B and conducted experiments using both the base and chat models (Touvron et al., 2023). Gemini 1.0 Pro (hereafter referred to as Gemini Pro) by Google was selected as the teacher model for generating reference notes (Team et al., 2023).
Experiments Overview: We demonstrated the experiments pipeline in Figure 1. First, we undertook domain-specific adaptation of LLaMA-2-13B through continued pretraining on discharge summaries from MIMIC-IV. This was followed by task-specific fine-tuning with SFT through instruction tuning. Next, we conducted RLAIF using DistillDirect, our enhanced approach to performing DPO on a distilled dataset. We then selected the model that performed best after SFT and RLAIF,

![Comparison of Distilled DPO, DistillDirect, and RLHF. A. Distilled DPO: Preference dataset is generated and labeled by external LLMs rather than by the target policy, resulting in off-policy and offline training. B. DistillDirect: A response is generated from the target policy for each prompt, thereby making training on-policy. Additionally, another response is generated from an external LLM serving as the teacher model. C. RLHF: All responses are generated by the target policy, and preference labeling is completed by humans. Consequently, the training process is on-policy and online. In our study, we utilized DistillDirect for on-policy learning of RLAIF followed by further online and on-policy learning using RLHF.](page_1016_180_377_1012.png)

Figure 2: Comparison of Distilled DPO, DistillDirect, and RLHF. A. Distilled DPO: Preference dataset is generated and labeled by external LLMs rather than by the target policy, resulting in off-policy and offline training. B. DistillDirect: A response is generated from the target policy for each prompt, thereby making training on-policy. Additionally, another response is generated from an external LLM serving as the teacher model. C. RLHF: All responses are generated by the target policy, and preference labeling is completed by humans. Consequently, the training process is on-policy and online. In our study, we utilized DistillDirect for on-policy learning of RLAIF followed by further online and on-policy learning using RLHF.
as measured by ROUGE scores against reference notes, for RLHF via DPO. Finally, a panel of physicians conducted a blinded evaluation of the notes authored by our LLaMA-Clinic model, Gemini Pro, and other physicians. All training was performed using low-rank adaptation (LoRA).

4.2 Dataset and Preprocessing

Modified ACI-BENCH: Given above mentioned limitation of ACI-BENCH, we established a simple yet specific note format, recognized as a “best practice” by a panel of licensed internal medicine physicians, to standardize our training approach. For model training, we retained only the dialogue section from ACI-BENCH and employed Gemini Pro to generate notes based on the “best practice” format, serving as our reference notes. We demonstrated two examples of clinical notes before and after the change in Appendix Figure 7.

Dialogue-G: We created a synthetic dataset of clinical dialogue-note pairs using Gemini Pro. This dataset, named Dialogue-G, comprises 1,291 cases. We first compiled transcribed outpatient notes from the publicly available synthetic MTSamples dataset (MTSamples; Hu et al., 2024) and utilized Gemini Pro to transform these notes into dialogues. Subsequently, we used these dialogues as inputs for Gemini Pro once again, this time to generate clinical notes based on the “best practice” format.

MIMIC-IV: MIMIC-IV encompasses 431,231 unique hospital admissions from Beth Israel Deaconess Medical Center in Boston, Massachusetts (Johnson et al., 2023). We utilized discharge summaries from MIMIC-IV for continued pretraining. Notably, the “brief hospital course” section of the discharge summaries is structurally akin to the “assessment and plan” section in outpatient notes. We compiled a subset of discharge summaries with only the “brief hospital course” using methods detailed in (Wang et al., 2024a), referred to as Discharge-short. We denoted the complete discharge summaries dataset as Discharge-long.

4.3 Experiment setup

Continued pretraining: We explored both the Discharge-long dataset (1.2 billion tokens) and the Discharge-short dataset (0.2 billion tokens).

Dataset Split for SFT, RLAIF and RLHF: We combined the training subsets from ACI-BENCH (dialogue n = 67) and Dialogue-G (dialogue n = 1291), then split this data equally for SFT and RLAIF, stratified by the data source. For RLHF, we utilized dialogues from the training, test2, and test3 subsets of ACI-BENCH (dialogue n = 147).

Physician Preference Data Collection: In each round of RLHF, for a specific prompt \( x \), three responses are generated from \( \pi_{\theta} \) and evaluated by our physician reviewers. Three licensed internal medicine physicians are tasked with providing preference feedback by selecting the most and least preferred responses, with criteria focusing on clinical readiness, correctness, and adherence to the desired format. A notable adaptation in our approach is that reviewers are also instructed to make adjustments to improve the quality of the preferred responses, such as correcting factual inaccuracies.

Physician Reader Study: The three internal medicine physicians engaged in preference data collection were tasked with writing clinical notes based on conversations from the ACI-BENCH test1 subset (dialogue n = 40), adhering to the pre-defined “best practice” format. The physician-authored notes, alongside those generated by Gemini Pro and LLaMA-Clinic, were reviewed by another four physicians, who were not involved in the preference labeling.

5 Results

5.1 Analysis of Continued Pretraining

We presented the training loss curve in Figure 3. Across all experiments, the training loss rapidly decreased after the initial few hundred steps, then leveled off, showing minimal improvement thereafter. The lowest training loss achieved with the Discharge-long dataset is approximately 0.9, whereas, with the Discharge-short dataset, it remained around 1.4. The trajectories of training loss were similar for both the chat and base models. When experimenting with various training strategies and hyperparameters, we frequently observed loss spikes that were slow to recover, as shown in Appendix Figure 1. We proceeded with checkpoints that did not exhibit loss spikes for SFT and RLAIF.

5.2 Analysis of SFT and RLAIF

Since the primary objective of SFT and RLAIF is to align LLaMA-2’s output with Gemini Pro, we evaluated ROUGE scores—a measure of lexical similarity—against reference notes generated by Gemini Pro. We reported ROUGE scores (Lin, 2004) post-SFT and RLAIF, alongside those from baseline models in Table 1. Interestingly, at baseline, med-
<table>
  <tr>
    <th rowspan="2">Model</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>ROUGE-1</th>
    <th>ROUGE-2</th>
    <th>ROUGE-L</th>
    <th>ROUGE-LSUM</th>
    <th>ROUGE-1</th>
    <th>ROUGE-2</th>
    <th>ROUGE-L</th>
    <th>ROUGE-LSUM</th>
  </tr>
  <tr>
    <td colspan="9"><b>Baseline: Out-of-Box LLaMA-2 and Medical LLMs</b></td>
  </tr>
  <tr>
    <td>13B</td><td>0.0329</td><td>0.0033</td><td>0.0211</td><td>0.0268</td><td>0.0100</td><td>0.0006</td><td>0.0058</td><td>0.0085</td>
  </tr>
  <tr>
    <td>13B-chat</td><td>0.3585</td><td>0.1281</td><td>0.2103</td><td>0.2890</td><td>0.4543</td><td>0.1778</td><td>0.2898</td><td>0.4361</td>
  </tr>
  <tr>
    <td>Meditron-7B</td><td>0.1249</td><td>0.0052</td><td>0.0678</td><td>0.0957</td><td>0.0895</td><td>0.0032</td><td>0.0527</td><td>0.0810</td>
  </tr>
  <tr>
    <td>LLaMA3-Med42-8B</td><td>0.2496</td><td>0.0662</td><td>0.1392</td><td>0.2056</td><td>0.2372</td><td>0.0577</td><td>0.1426</td><td>0.2187</td>
  </tr>
  <tr>
    <td>MeLLaMA-13B-chat</td><td>0.2756</td><td>0.1268</td><td>0.1925</td><td>0.2329</td><td>0.2655</td><td>0.0964</td><td>0.1865</td><td>0.2522</td>
  </tr>
  <tr>
    <td colspan="9"><b>SFT + RLAIF Models (No Pretraining)</b></td>
  </tr>
  <tr>
    <td>13B<br>SFT</td><td>0.2813</td><td>0.1166</td><td>0.1975</td><td>0.2248</td><td>0.2977</td><td>0.1059</td><td>0.1963</td><td>0.2677</td>
  </tr>
  <tr>
    <td>13B<br>SFT + DistillDirect</td><td>0.4994</td><td>0.2633</td><td>0.3425</td><td>0.3964</td><td>0.4941</td><td>0.2398</td><td>0.3476</td><td>0.4650</td>
  </tr>
  <tr>
    <td>13B-chat<br>SFT</td><td>0.2874</td><td>0.1179</td><td>0.2022</td><td>0.2285</td><td>0.3301</td><td>0.1191</td><td>0.2231</td><td>0.2992</td>
  </tr>
  <tr>
    <td>13B-chat<br>SFT + DistillDirect</td><td>0.4783</td><td>0.2472</td><td>0.3252</td><td>0.3738</td><td>0.4893</td><td>0.2411</td><td>0.3674</td><td>0.4599</td>
  </tr>
  <tr>
    <td colspan="9"><b>Continued Pretraining + SFT + RLAIF Models</b></td>
  </tr>
  <tr>
    <td>13B-long<br>CP</td><td>0.1612</td><td>0.0139</td><td>0.0754</td><td>0.1378</td><td>0.1289</td><td>0.0108</td><td>0.0598</td><td>0.1178</td>
  </tr>
  <tr>
    <td>13B-long<br>CP + SFT</td><td>0.2525</td><td>0.1034</td><td>0.1714</td><td>0.2044</td><td>0.2565</td><td>0.0775</td><td>0.1651</td><td>0.2276</td>
  </tr>
  <tr>
    <td>13B-long<br>CP + SFT + DistillDirect</td><td>0.4494</td><td>0.2471</td><td>0.3224</td><td>0.3618</td><td>0.4578</td><td>0.2086</td><td>0.3272</td><td>0.4241</td>
  </tr>
  <tr>
    <td>13B-short<br>CP</td><td>0.1488</td><td>0.0106</td><td>0.0712</td><td>0.1149</td><td>0.0899</td><td>0.0060</td><td>0.0449</td><td>0.0806</td>
  </tr>
  <tr>
    <td>13B-short<br>CP + SFT</td><td>0.2463</td><td>0.0858</td><td>0.1638</td><td>0.1951</td><td>0.2277</td><td>0.0619</td><td>0.1396</td><td>0.1960</td>
  </tr>
  <tr>
    <td>13B-short<br>CP + SFT + DistillDirect</td><td>0.4775</td><td>0.2561</td><td>0.3452</td><td>0.3842</td><td>0.4956</td><td>0.2328</td><td>0.3526</td><td>0.4663</td>
  </tr>
  <tr>
    <td>13B-chat-long<br>CP</td><td>0.1708</td><td>0.0151</td><td>0.0792</td><td>0.1321</td><td>0.1536</td><td>0.0130</td><td>0.0746</td><td>0.1424</td>
  </tr>
  <tr>
    <td>13B-chat-long<br>CP + SFT</td><td>0.3463</td><td>0.1591</td><td>0.2525</td><td>0.2837</td><td>0.3620</td><td>0.1237</td><td>0.2401</td><td>0.3290</td>
  </tr>
  <tr>
    <td>13B-chat-long<br>CP + SFT + DistillDirect</td><td>0.4601</td><td>0.2504</td><td>0.3325</td><td>0.3773</td><td>0.4662</td><td>0.2395</td><td>0.3484</td><td>0.4498</td>
  </tr>
  <tr>
    <td>13B-chat-short<br>CP</td><td>0.1520</td><td>0.0116</td><td>0.0725</td><td>0.1085</td><td>0.1162</td><td>0.0107</td><td>0.0630</td><td>0.1032</td>
  </tr>
  <tr>
    <td>13B-chat-short<br>CP + SFT</td><td>0.3475</td><td>0.1310</td><td>0.2230</td><td>0.2711</td><td>0.3055</td><td>0.1036</td><td>0.2009</td><td>0.2824</td>
  </tr>
  <tr>
    <td>13B-chat-short<br>CP + SFT + DistillDirect</td><td>0.4878</td><td>0.2613</td><td>0.3410</td><td>0.3883</td><td>0.5182</td><td>0.2689</td><td>0.3933</td><td>0.4915</td>
  </tr>
</table>

Table 1: ROUGE Scores Following Continued Pretraining (CP), Supervised Fine-Tuning (SFT), and Reinforcement Learning from AI Feedback (RLAIF). All evaluations were conducted on the validation subset of the modified ACI-BENCH. The “13B” models represent the LLaMA-2 base models, while the “13B-chat” models correspond to the LLaMA-2 chat models. Models with the suffix “long” were pretrained using the Discharge-long dataset, and those with the suffix “short” were pretrained using the Discharge-short dataset. Bolded scores represent the top two scores for each metric. Continued pretraining with MIMIC-IV discharge summaries initially resulted in performance deterioration, whereas SFT and DistillDirect significantly improved the performance across all models.

ical LLMs fine-tuned on biomedical literature or clinical notes (Chen et al., 2023; Christophe et al., 2024; Xie et al., 2024) underperform compared to the vanilla LLaMA-2 chat model. This suggests that generating notes aligned with our “best practice” format presents an out-of-distribution challenge for medical LLMs. As expected, continued pretraining with MIMIC-IV discharge summaries compromised the chat model’s capacity to follow instructions. SFT notably enhanced performance, particularly for the chat model compared to the base model. The application of RLAIF with DistillDirect significantly boosted performance across all models. In many cases, the gains achieved through RLAIF surpassed those from SFT, as reflected by the delta improvement in ROUGE scores (e.g., 13B-short). Notably, our training with DistillDirect frequently encountered instability—a well-known challenge in reinforcement learning (Ding and Dong, 2020). With carefully selected training hyperparameters, DistillDirect could achieve performance improvements without overfitting, despite the limited training data and repetitive use of the same prompts in each training cycle (see Appendix Table 4). We have detailed our experiments, including ablation studies, to find a stable training setup in Appendix Method A.3.

When comparing models pretrained with Discharge-long and Discharge-short, the latter consistently achieved higher ROUGE scores, despite exhibiting higher training loss during the pretraining phase. The chat model pretrained with the Discharge-short dataset (13B-chat-short) emerged as the top performer for the final RLHF stage. Interestingly, the model trained with SFT and RLAIF, without continued pretraining, demonstrated strong
Figure 3: Training Loss Curve from Continued Pre-training. A. Training with the Discharge-long dataset (1.2 billion tokens). B. Training with the Discharge-short dataset (0.2 billion tokens). The X-axis represents processed training tokens, and the Y-axis represents training loss. The figures illustrate results from mixed precision training with a cosine learning rate scheduler. All experiments were trained for 1 epoch on their respective training datasets. The loss curve in the solid line was smoothed with an exponential moving average and a window size of 250 steps. The original loss values are shown as the faded background.

performance, including the highest score for “Subjective.” This raises questions about the benefits of continued pretraining, particularly considering its substantial computational demands (Appendix Figure 6A).

5.3 Analysis of RLHF
We collected quantitative feedback from physician reviewers, who identified inaccurate information and hallucinations as the most common issues in the LLM-generated notes. Two out of three reviewers noted a significant improvement in the quality of the notes, with fewer hallucinations after one round of DPO. Consequently, we conducted only two rounds of DPO, mindful of its time-intensive nature (Appendix Figure 6A). We present a qualitative analysis of a specific case across different stages of model training, as shown in Appendix Figure 5. This example illustrates that RLHF introduced more granular changes, building on the outcomes of RLAIF while preserving the original style and structure. We named the model after our RLHF step as LLaMA-Clinic.

5.4 Analysis of Physician Reader Study
We presented the results from the physician reader study in Figure 4. Gemini Pro achieved the highest scores across all three criteria (Figure 4B). Remarkably, the majority (92.8%) of the individual evaluations rated the notes generated by LLaMA-Clinic as “acceptable” or higher across all three criteria (Figure 4C). Furthermore, the overall distribution of scores was also similar among the three groups. This aligns with qualitative feedback from three out of four reviewers, who stated that the quality of notes was, for the majority of the time, indistinguishable among the groups, particularly in the “Subjective” section.

The metric of real-world readiness yielded intriguing observations. Physicians were asked to evaluate the notes as though they would be utilized in everyday clinical practice, assuming the physicians would proofread and make necessary edits. LLaMA-Clinic achieved comparable overall readiness scores to physician-authored notes, including in the more complex “Assessment and Plan” section, as shown in Figure 4B. Overall, LLaMA-Clinic received higher completeness scores but lower accuracy scores compared to physician-authored notes. This finding suggests that physicians might be more tolerant of minor factual inaccuracies in a real-world setting if the notes require fewer edits.

5.5 Cost Analysis for Model Development and Inference
As shown in Appendix Figure 6A, the majority of compute hours for developing LLaMA-Clinic were required during the continued pretraining stage. However, unsurprisingly, the most time-consuming step overall involved physician labeling during RLHF. Based on pricing information from May 2024, LLaMA-Clinic showed a 3.75-fold reduction in inference costs compared to its teacher model, Gemini 1.0 Pro (Appendix Figure 6B).

6 Discussion
Our methodology for adapting LLMs to clinical note generation revealed several key considerations. We initiated this process by establishing a “best practice” note format informed by a consensus among our physician authors. This approach tackles the variability in the style, format, and quality
A.

<table>
  <tr>
    <th colspan="6">For every note, please provide score for each question:</th>
  </tr>
  <tr>
    <td colspan="6"><b>Real-World Readiness:</b> How well is the note ready for clinical use in the real-world scenario?</td>
  </tr>
  <tr>
    <td colspan="6"><b>Completeness:</b> How well does the note cover the important information from the dialogue?</td>
  </tr>
  <tr>
    <td colspan="6"><b>Accuracy:</b> Does the factual information from clinical note accurately match that from the dialogue?</td>
  </tr>
  <tr>
    <td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>
    <td>Very poor<br>Poor<br>Acceptable<br>Good<br>Very good</td>
  </tr>
</table>

B.

![Bar charts displaying mean scores by note sections and model](page_184_370_1080_312.png)

C.

![Bar charts displaying distribution of scores by metric and model](page_184_690_1080_312.png)

Figure 4: Physician Reader Study. A. Survey questions assessing each clinical note on three criteria: real-world readiness, completeness, and accuracy. B. Bar charts displaying the mean score among evaluators across different sections of the note. The error bars represent standard errors. The X-axis represents various metrics, and the Y-axis shows the mean scores. The subfigure labeled “All” displays the combined results. C. Bar charts displaying the distribution of scores across all criteria. The X-axis represents different scores, and the Y-axis shows total counts.

of physician notes, which could otherwise compromise the training of LLMs. Instead of relying on the LLM to identify the most effective note structure, we advocate for healthcare providers to set these standards themselves. It is important to acknowledge that the “best practice” note format employed in this study reflects the consensus of a group of internal medicine physicians within a single organization. This format may not be generalizable to other specialties or other organizations, such as orthopedic surgery. Furthermore, we examined a workflow in which providers critically review and refine AI-generated notes prior to their filing. Under such a workflow, physician preferences may shift toward notes requiring fewer revisions and edits, with a higher tolerance for minor inaccuracies.

7 Conclusions

Our research highlights the potential of training an open-source LLM for outpatient note generation, showing strong promise for real-world clinical applications. Healthcare institutions are in a privileged position to undertake such endeavors, given their access to extensive EMR data and a wealth of domain expertise critical for implementing RLHF. Our work was based on fewer than 1,500 patient-doctor dialogues and limited physician preference data. When implementing a similar project in a healthcare institution, the training data could be scaled up significantly, potentially leading to further performance improvements. Lastly, the prospect of extending this work to other clinical note-generation tasks, such as creating discharge summaries for hospitalized patients, is particularly exciting.
8 Acknowledgments

This research was supported by NSF awards SCH-2205289. The funder played no role in the study design, data collection, analysis, and interpretation of data, or the writing of this manuscript. This research is also supported by the Protected Research Time Grant from the Southwest Minnesota Region of the Mayo Clinic Health System.

9 Ethical Considerations

We followed the same approach as in (Van Veen et al., 2023; Walsh et al., 2017) to assess the potential consequences of factual errors. One physician evaluated the likelihood and severity of harm associated with notes that received an accuracy or completeness score below 5 in his review (n = 22, 31 and 39 for Gemini Pro, LLaMA-Clinic, and Physician, respectively). All notes within the LLaMA-clinic and physician groups were assigned scores of “None” for the extent of harm and “Low”, for the likelihood of harm. In contrast, the Gemini Pro group contained a single case rated with “Mild to Moderate” extent of harm and a “Medium” likelihood of harm.

10 Limitations

Our study serves as a proof of concept and encounters limitations, notably the scarcity of publicly available patient-doctor dialogues for model training, with the largest ACI-BENCH dataset comprising fewer than 300 cases. Additionally, the effectiveness of outpatient note generation is fundamentally linked to the content of patient-doctor dialogues. Although the ACI-BENCH data may have synthesized dialogues to encapsulate all necessary information for composing a comprehensive note, such ideal conditions may not always reflect real-world scenarios. For instance, time constraints may prevent physicians from discussing every detail of medical reasoning with patients, potentially degrading the quality of the generated notes due to the suboptimal input dialogue. Our research was also constrained by limited availability of physician evaluators, which restricted our ability to conduct extensive hyperparameter searches or additional rounds of RLHF. Our final evaluation was conducted with only four physicians due to the task’s time-intensive nature.

References

2024. Artificial analysis ai models. https://artificialanalysis.ai/models. Accessed: May, 2024.

2024. Fireworks.ai pricing. https://fireworks.ai/pricing. Accessed: May, 2024.

2024. Google ai developer pricing. https://ai.google.dev/pricing. Accessed: May, 2024.

2024. Openai api pricing. https://openai.com/api/pricing. Accessed: May, 2024.

Asma Ben Abacha, Wen-wai Yim, Griffin Adams, Neal Snider, and Meliha Yetisen-Yildiz. 2023. Overview of the mediqua-chat 2023 shared tasks on the summarization & generation of doctor-patient conversations. In Proceedings of the 5th Clinical Natural Language Processing Workshop, pages 503–513.

Alaa Dania Adimi. 2024. Comparison & cost analysis: Should we invest in open-source or closed-source llms? https://medium.com/@ja_adimi. Accessed: March, 2024.

Elske Ammenwerth and H-P Spötl. 2009. The time needed for clinical documentation versus direct patient care. Methods of information in medicine, 48(01):84–91.

Paul J Barr, Robert Gramling, and Soroush Vosoughi. 2024. Preparing for the widespread adoption of clinic visit recording.

Zeming Chen, Alejandro Hernández Cano, Angelika Romanou, Antoine Bonnet, Kyle Matoba, Francesco Salvi, Matteo Pagliardini, Simin Fan, Andreas Köpf, Amirkeivan Mohtashami, et al. 2023. Meditron-70b: Scaling medical pretraining for large language models. arXiv preprint arXiv:2311.16079.

Zixiang Chen, Yihe Deng, Huizhuo Yuan, Kaixuan Ji, and Quanquan Gu. 2024. Self-play fine-tuning converts weak language models to strong language models. arXiv preprint arXiv:2401.01335.

Pengyu Cheng, Yifan Yang, Jian Li, Yong Dai, and Nan Du. 2023. Adversarial preference optimization. arXiv preprint arXiv:2311.08045.

Clément Christophe, Praveen K Kanithi, Prateek Munjal, Tathagata Raha, Nasir Hayat, Ronnie Rajan, Ahmed Al-Mahrooqi, Avani Gupta, Muhammad Umar Salman, Gurpreet Gosal, et al. 2024. Med42-evaluating fine-tuning strategies for medical llms: Full-parameter vs. parameter-efficient approaches. arXiv preprint arXiv:2404.14779.

Jan Clusmann, Fiona R Kolbinger, Hannah Sophie Muti, Zumamys I Carrero, Jan-Niklas Eckardt, Narmin Ghaffari Laleh, Chiara Maria Lavinia Löfler, Sophie-Caroline Schwarzkopf, Michaela Unger, Gregory P Veldhuizen, et al. 2023. The future landscape of large language models in medicine. Communications medicine, 3(1):141.
Zihan Ding and Hao Dong. 2020. Challenges of reinforcement learning. Deep Reinforcement Learning: Fundamentals, Research and Applications, pages 249–272.

John Giorgi, Augustin Toma, Ronald Xie, Sondra Chen, Kevin An, Grace Zheng, and Bo Wang. 2023. Wanglab at medica-chat 2023: Clinical note generation from doctor-patient conversations using large language models. In Proceedings of the 5th Clinical Natural Language Processing Workshop, pages 323–334.

Shangmin Guo, Biao Zhang, Tianlin Liu, Tianqi Liu, Misha Khalmans, Felipe Llinares, Alexandre Rame, Thomas Mesnard, Yao Zhao, Bilal Piot, et al. 2024. Direct language model alignment from online ai feedback. arXiv preprint arXiv:2402.04792.

Kilem L Gwet. 2014. Handbook of inter-rater reliability: The definitive guide to measuring the extent of agreement among raters. Advanced Analytics, LLC.

Kilem L Gwet and Maintainer Kilem L Gwet. 2019. Package “irracc”.

Tianyu Han, Lisa C Adams, Jens-Michalis Papaioannou, Paul Grundmann, Tom Oberhauser, Alexander Löser, Daniel Truhn, and Keno K Bressem. 2023. Medalpaca—an open-source collection of medical conversational ai models and training data. arXiv preprint arXiv:2304.08247.

Kai He, Rui Mao, Qika Lin, Yucheng Ruan, Xiang Lan, Mengling Feng, and Erik Cambria. 2023. A survey of large language models for healthcare: from data, technology, and applications to accountability and ethics. arXiv preprint arXiv:2310.05694.

Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685.

Yan Hu, Qingyu Chen, Jingcheng Du, Xueqing Peng, Vipina Kuttiichi Keloth, Xu Zuo, Yujiu Zhou, Zehan Li, Xiaoqian Jiang, Zhiyong Lu, et al. 2024. Improving large language models for clinical named entity recognition via prompt engineering. Journal of the American Medical Informatics Association, page ocad259.

Intel Analytics Software. 2023. The practice of supervised finetuning and direct preference optimization on habana gaudi2. https://medium.com/intel-analytics-software. Accessed: Feb, 2024.

Hamish Ivison, Yizhong Wang, Valentina Pyatkin, Nathan Lambert, Matthew Peters, Pradeep Dasigi, Joel Jang, David Wadden, Noah A Smith, Iz Beltagy, et al. 2023. Camels in a changing climate: Enhancing lm adaptation with tulu 2. arXiv preprint arXiv:2311.10702.

Alistair EW Johnson, Lucas Bulgarelli, Lu Shen, Alvin Gayles, Ayad Shammout, Steven Horng, Tom J Pollard, Sicheng Hao, Benjamin Moody, Brian Gow, et al. 2023. Mimic-iv, a freely accessible electronic health record dataset. Scientific data, 10(1):1.

Sunjun Kweon, Junu Kim, Jiyoung Kim, Sujeong Im, Eunbyeol Cho, Seongsu Bae, Jungwoo Oh, Gyubok Lee, Jong Hak Moon, Seng Chan You, et al. 2023. Publicly shareable clinical large language model built on synthetic clinical notes. arXiv preprint arXiv:2309.00237.

Peter Lee, Sebastien Bubeck, and Joseph Petro. 2023. Benefits, limits, and risks of gpt-4 as an ai chatbot for medicine. New England Journal of Medicine, 388(13):1233–1239.

Eric Lehman, Evan Hernandez, Diwakar Mahajan, Jonas Wulff, Micah J Smith, Zachary Ziegler, Daniel Nadler, Peter Szolovits, Alistair Johnson, and Emily Alsentzer. 2023. Do we still need clinical language models? arXiv preprint arXiv:2302.08091.

Chin-Yew Lin. 2004. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out, pages 74–81.

Yizhen Luo, Jiahuan Zhang, Siqi Fan, Kai Yang, Yushuai Wu, Mu Qiao, and Zaiqing Nie. 2023. Biomedgpt: Open multimodal generative pretrained transformer for biomedicine. arXiv preprint arXiv:2308.09442.

Mason Marks and Claudia E Haupt. 2023. Ai chatbots, health privacy, and challenges to hipaa compliance. Jama.

meta-llama. Llama recipes. https://github.com/meta-llama/llama-recipes. Accessed: Mar, 2024.

Ryan Mac Michael M. Grynbaum. 2023. The times sues openai and microsoft over a.i. use of copyrighted work. https://www.nytimes.com/2023/12/27/business/media/new-york-times-open-ai-microsoft-lawsuit.html. Accessed: Jan, 2024.

Francesco Moramarco, Alex Papadopoulos Korfiatis, Mark Perera, Damir Juric, Jack Flann, Ehud Reiter, Anya Belz, and Aleksandar Savkov. 2022. Human evaluation and correlation with automatic metrics in consultation note generation. arXiv preprint arXiv:2204.00447.

MTSamples. Transcribed medical transcription sample reports and examples. https://mtsamples.com/. Accessed: Nov, 2023.

Harsha Nori, Nicholas King, Scott Mayer McKinney, Dean Carignan, and Eric Horvitz. 2023. Capabilities of gpt-4 on medical challenge problems. arXiv preprint arXiv:2303.13375.
Oded Ovadia, Menachem Brief, Moshik Mishaeli, and Oren Elisha. 2023. Fine-tuning or retrieval? comparing knowledge injection in llms. arXiv preprint arXiv:2312.05934.

Richard Yuanzhe Pang, Weizhe Yuan, Kyunghyun Cho, He He, Sainbayar Sukhbaatar, and Jason Weston. 2024. Iterative reasoning preference optimization. arXiv preprint arXiv:2404.19733.

Cheng Peng, Xi Yang, Aokun Chen, Kaleb E Smith, Nima PourNejatian, Anthony B Costa, Cheryl Martin, Mona G Flores, Ying Zhang, Tanja Magoc, et al. 2023. A study of generative large language model for medical research and healthcare. arXiv preprint arXiv:2305.13523.

Rafael RafaIlov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D Manning, and Chelsea Finn. 2023. Direct preference optimization: Your language model is secretly a reward model. arXiv preprint arXiv:2305.18290.

Karan Singhal, Tao Tu, Juraj Gottweis, Rory Sayres, Ellery Wulczyn, Le Hou, Kevin Clark, Stephen Pfohl, Heather Cole-Lewis, Darlene Neal, et al. 2023. Towards expert-level medical question answering with large language models. arXiv preprint arXiv:2305.09617.

Nisan Stiennon, Long Ouyang, Jeffrey Wu, Daniel Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, and Paul F Christiano. 2020. Learning to summarize with human feedback. Advances in Neural Information Processing Systems, 33:3008–3021.

Gemini Team, Rohan Anil, Sebastian Borgeaud, Yonghui Wu, Jean-Baptiste Alayrac, Jiahui Yu, Radu Soricut, Johan Schalkwyk, Andrew M Dai, Anja Hauth, et al. 2023. Gemini: a family of highly capable multimodal models. arXiv preprint arXiv:2312.11805.

Augustin Toma, Patrick R Lawler, Jimmy Ba, Rahul G Krishnan, Barry B Rubin, and Bo Wang. 2023. Clinical camel: An open-source expert-level medical language model with dialogue-based knowledge encoding. arXiv preprint arXiv:2305.12031.

Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. 2023. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288.

Quoc Duyet Tran, Anil Dolgun, and Haydar Demirhan. 2021. The impact of grey zones on the accuracy of agreement measures for ordinal tables. BMC Medical Research Methodology, 21:1–19.

Lewis Tunstall, Edward Beeching, Nathan Lambert, Nazneen Rajani, Kashif Rasul, Younes Belkada, Shengyi Huang, Leandro von Werra, Clémentine Fourrier, Nathan Habib, et al. 2023. Zephyr: Direct distillation of lm alignment. arXiv preprint arXiv:2310.16944.

Dave Van Veen, Cara Van Uden, Louis Blankemeier, Jean-Benoit Delbrouck, Asad Aali, Christian Bluthgen, Anuj Pareek, Malgorzata Polacin, William Collins, Neera Ahuja, et al. 2023. Clinical text summarization: Adapting large language models can outperform human experts. arXiv preprint arXiv:2309.07430.

Pauli Virtanen, Ralf Gommers, Travis E Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, et al. 2020. Scipy 1.0: fundamental algorithms for scientific computing in python. Nature methods, 17(3):261–272.

Leandro von Werra, Younes Belkada, Lewis Tunstall, Edward Beeching, Tristan Thrush, and Nathan Lambert. TRL: Transformer Reinforcement Learning. https://github.com/stas00/ml-engineering. Accessed: Dec, 2023.

Kathleen E Walsh, Polina Harik, Kathleen M Mazor, Deborah Perfetto, Milena Anatchkova, Colleen Biggins, Joann Wagner, Pamela J Schoettker, Cassandra Firnemo, Robert Klugman, et al. 2017. Measuring harm in health care: optimizing adverse event review. Medical care, 55(4):436–441.

Hanyin Wang, Chufan Gao, Christopher Dantona, Bryan Hull, and Jimeng Sun. 2024a. Drg-llama: tuning llama model to predict diagnosis-related group for hospitalized patients. npj Digital Medicine, 7(1):16.

Hanyin Wang, Chufan Gao, and Jimeng Sun. 2024b. A reflection and outlook on clinical adaption of large language models. In AAAI 2024 Spring Symposium on Clinical Foundation Models.

Haochun Wang, Chi Liu, Nuwa Xi, Zewen Qiang, Sendong Zhao, Bing Qin, and Ting Liu. 2023. Huatuo: Tuning llama model with chinese medical knowledge. arXiv preprint arXiv:2304.06975.

Junda Wang, Zonghai Yao, Zhichao Yang, Huixue Zhou, Rumeng Li, Xun Wang, Yucheng Xu, and Hong Yu. 2024c. Notechat: a dataset of synthetic patient-physician conversations conditioned on clinical notes. In Findings of the Association for Computational Linguistics ACL 2024, pages 15183–15201.

Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierre Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, et al. 2019. Huggingface’s transformers: State-of-the-art natural language processing. arXiv preprint arXiv:1910.03771.

Chaoyi Wu, Xiaoman Zhang, Ya Zhang, Yanfeng Wang, and Weidi Xie. 2023a. Pmc-llama: Further fine-tuning llama on medical papers. arXiv preprint arXiv:2304.14454.
Shijie Wu, Ozan Irsoy, Steven Lu, Vadim Dabrovolski, Mark Dredze, Sebastian Gehrmann, Prabhanjan Kam-badur, David Rosenberg, and Gideon Mann. 2023b. Bloomberggpt: A large language model for finance. arXiv preprint arXiv:2303.17564.

Qianqian Xie, Qingyu Chen, Aokun Chen, Cheng Peng, Yan Hu, Fongci Lin, Xueqing Peng, Jimin Huang, Jeffrey Zhang, Vipina Keloth, et al. 2024. Me llama: Foundation large language models for medical applications. arXiv preprint arXiv:2402.12749.

Wei Xiong, Hanze Dong, Chenlu Ye, Ziqi Wang, Han Zhong, Heng Ji, Nan Jiang, and Tong Zhang. 2024. Iterative preference learning from human feedback: Bridging theory and practice for rlhf under kl-constraint. In Forty-first International Conference on Machine Learning.

Zhichao Yang and Hong Yu. 2020. Generating accurate electronic health assessment from medical graph. In Proceedings of the Conference on Empirical Methods in Natural Language Processing-Conference on Empirical Methods in Natural Language Processing, volume 2020, page 3764.

Wen-wai Yim, A Ben Abacha, N Snider, G Adams, and Meliha Yetisgen. 2023a. Overview of the mediqu-sum task at imageclef 2023: Summarization and classification of doctor-patient conversations. In CLEF.

Wen-wai Yim, Yujuan Fu, Asma Ben Abacha, Neal Snider, Thomas Lin, and Meliha Yetisgen. 2023b. Aci-bench: a novel ambient clinical intelligence dataset for benchmarking automatic visit note generation. Scientific Data, 10(1):586.

Li Yunxiang, Li Zihan, Zhang Kai, Dan Ruilong, and Zhang You. 2023. Chatdoctor: A medical chat model fine-tuned on llama model using medical domain knowledge. arXiv preprint arXiv:2303.14070.

Pedram Zamirai, Jian Zhang, Christopher R Aberger, and Christopher De Sa. 2020. Revisiting bfloat16 training.

Yanli Zhao, Andrew Gu, Rohan Varma, Liang Luo, Chien-Chin Huang, Min Xu, Less Wright, Hamid Shojanazeri, Myle Ott, Sam Shleifer, et al. 2023. Pytorch fsdp: experiences on scaling fully sharded data parallel. arXiv preprint arXiv:2304.11277.

Chunting Zhou, Pengfei Liu, Puxin Xu, Srini Iyer, Jiao Sun, Yuning Mao, Xuezhe Ma, Avia Efrat, Ping Yu, Lili Yu, et al. 2023a. Lima: Less is more for alignment. arXiv preprint arXiv:2305.11206.

Hongjian Zhou, Boyang Gu, Xinyu Zou, Yiru Li, Sam S Chen, Peilin Zhou, Junling Liu, Yining Hua, Chengfeng Mao, Xian Wu, et al. 2023b. A survey of large language models in medicine: Progress, application, and challenge. arXiv preprint arXiv:2311.05112.
A  Experiment Chronicles

A.1 Overview

Our objective is to perform domain- and task-specific adaptation of LLaMA-2 for generating outpatient clinical notes based on patient-physician dialogues. This process is structured around four sequential steps: continued pretraining (CP), supervised finetuning (SFT), reinforcement learning from AI feedback (RLAIF), and reinforcement learning from human feedback (RLHF). Here, we detailed the trial-and-error process throughout our experiments.

A.2 Continued Pretaining (CP)

A.2.1 CP Experiment 1
Models: LLaMA-2-13B base and chat models with Low-Rank Adaptation (LoRA).
Dataset: We conducted experiments on two datasets: the complete discharge summary from MIMIC-IV (Discharge-long) and the extracted “Hospital Course” section from discharge summaries (Discharge-short).
Approach: In this experiment, we evaluated the efficacy of pure bf16 training while adhering to the majority of the default hyperparameters specified in the LLaMA-recipes. We used a learning rate (LR) of 3e-4 without a scheduler. Other hyperparameters were selected based on computing resource available at the time of experiments (4 x A6000 or 4 x A100 GPUs), including a global batch size of 16 without gradient accumulation.
Results: We ran into training loss spike on 13B base model that never fully recovered (Appendix Figure 1 A).
Solution: Restarted pretraining using a mixed precision strategy.

A.2.2 CP Experiment 2
Models and Dataset: Same as experiment 1.
Approach: In this experiment, we implemented mixed precision training, wherein weights and gradients were stored in bf16 format, and optimizer states in fp32. This decision was based on the hypothesis that training with pure bf16 might pose challenges in achieving convergence (Zamirai et al., 2020). The remaining setup parameters were consistent with those outlined in Experiment 1.
Results: During the course of training the 13B-base model, we encountered another spike in training loss, notably in the early stages of the training process (Appendix Figure 1B). Although the loss quick recovered, it did not revert to its baseline level. For runs that were completed successfully, the outcomes were comparable to those observed in Experiment 1.
Solution: Restarted pretraining using a LR scheduler.

A.2.3 CP Experiment 3
Models and Dataset: Same as experiment 1.
Approach: The standard LLaMA-recipes library does not incorporate a LR scheduler at the time

Appendix Figure 1: Training Loss Spikes for 13B Models during Continued Pretraining. A. Loss curve for base model with bf16 training on vanilla LLaMA-recipes without a LR scheduler. B. Loss curve for base model with mixed precision training without a LR scheduler. C. Loss curve for chat model with a LR scheduler and bf16 training. All experiments were performed on Discharge-long dataset. The X-axis represents processed training tokens, and the Y-axis represents training loss. Original loss curves were shown without smoothing.
of our work, resulting in a constant LR for each epoch in the previous two experiments. In this iteration, we maintained mixed precision training and introduced a cosine LR scheduler with 200 warm-up steps, followed by a decay to 0% of the peak LR.

Results: All runs were completed successfully, with the loss curve presented in Figure 3. We observed a significant reduction in training loss when using the Discharge-long dataset, with losses dropping to the 0.9 range. Conversely, for the Discharge-short dataset, the training loss plateaued around 1.4. We utilized checkpoints from this experiment for SFT and RLAIF.

A.2.4 CP Experiment 4
Models and Dataset: Same as experiment 1.
Approach: In this experiment, we explored the implementation of pure bf16 training, utilizing the same cosine scheduler as in Experiment 3. Our aim was to ascertain whether this approach could stabilize pure bf16 training, which offers the advantage of reduced VRAM requirements.
Results: A spike in training loss was observed in the 13B-chat model during training with the Discharge-Long dataset (Appendix Figure 1C).

A.2.5 CP Experiment 5
Models: LLaMA-2-7B base and chat models with full parameter training.
Dataset: Same as experiment 1.
Approach: Motivated by the inferior performance of LoRA compared to full parameter training across various benchmarks (Han et al., 2023), we explored the implementation of full parameter training on 7B models, considering their similar VRAM requirements (compared to LoRA training on the 13B models).
Results: In the 7B-chat model runs, we observed a spike in training loss for both mixed precision and pure bf16 training modalities, despite employing a cosine LR scheduler.
Solution: Lowered LR.

A.2.6 CP Experiment 6
Models: Same as experiment 5.
Dataset: Same as experiment 1.
Approach: We reduced LR to 2e-5, down from 3e-4 in the previous experiment. Of note, the vanilla LLaMA-2 7B model’s used a LR of 3e-4 for pre-training (Touvron et al., 2023).
Results: With the adjusted LR, along with the implementation of pure BF16 training and a cosine LR scheduler, we were able to successfully complete all runs. Checkpoints from these runs were utilized for SFT and RLAIF.

A.3 SFT and RLAIF
A.3.1 SFT Experiment 1
Models: We utilized the four 13-B checkpoints (base-model/chat-model trained with Discharge-long/Discharge-short) from CP Experiment 3 employing LoRA, and the four 7-B checkpoints from CP Experiment 6 with full parameter training.
Dataset: We combined the training subsets from ACI-BENCH (dialogue n = 67) and Dialogue-G (dialogue n = 1291), then split this data equally for SFT and RLAIF, stratified by data source. Notably, for each dialogue we ask model to generate “Subjective” and “Assessment and Plan” in two separate prompts (therefore two data points per dialogue).
Approach: Instruction tuning was applied to the SFT dataset over 3 epochs, with a LR of 2e-5 for all models, maintaining a fixed LR.
Results: The performance metrics post-SFT are presented in Appendix Table 1, under the column labeled “RO”. Interestingly, the models, after undergoing pretraining and SFT, exhibited inferior performance compared to the out-of-the-box LLaMA-2-chat models. This decline in performance may be attributed to catastrophic forgetting observed during the CP phase.

A.3.2 RLAIF Experiment 1
Models: We continued with the eight checkpoints derived from SFT Experiment 1. For the 13B models, LoRA was employed, while full parameter training was applied to the 7B models.
Dataset: The RLAIF split of the training dataset as mentioned above.
Approach: RLAIF was conducted using DistillDirect over three rounds. In each round, we first generated notes using our training models, which were designated as “rejected” notes. For ACI-BENCH, the “preferred notes” were the original reference notes in ACI-BENCH. For Dialogue-G, the preference notes were generated by Gemini-pro. For subsequent rounds, we sampled from the newly updated model checkpoint to produce a new set of “rejected” notes, while maintaining the same “preferred” notes. Each round consisted of three epochs, with a LR of 2e-5 in addition to a cosine scheduler.
Results: Performance metrics following RLAIF Experiment 1 are presented in Appendix Table 1.
<table>
  <tr>
    <th rowspan="2">Models</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
  </tr>
  <tr>
    <th colspan="9"><i>Models underwent continued pretraining, SFT and RLAIF</i></th>
  </tr>
  <tr>
    <td>7B-short</td>
    <td>0.2332</td>
    <td>0.3373</td>
    <td>0.3163</td>
    <td>0.2730</td>
    <td>0.2259</td>
    <td>0.2209</td>
    <td>0.3164</td>
    <td>0.3410</td>
  </tr>
  <tr>
    <td>7B-long</td>
    <td>0.2308</td>
    <td>0.3619</td>
    <td>0.0875</td>
    <td>0.3262</td>
    <td>0.2030</td>
    <td>0.1992</td>
    <td>0.2357</td>
    <td>0.3205</td>
  </tr>
  <tr>
    <td>7B-chat-short</td>
    <td>0.2644</td>
    <td>0.3471</td>
    <td>0.0292</td>
    <td><b>0.4465</b></td>
    <td>0.2531</td>
    <td>0.2670</td>
    <td>0.3370</td>
    <td><b>0.4436</b></td>
  </tr>
  <tr>
    <td>7B-chat-long</td>
    <td>0.2322</td>
    <td>0.4270</td>
    <td>0.4072</td>
    <td>0.2639</td>
    <td>0.2305</td>
    <td>0.2841</td>
    <td>0.3193</td>
    <td>0.3916</td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.1335</td>
    <td>0.3472</td>
    <td>0.2353</td>
    <td>0.3757</td>
    <td>0.1586</td>
    <td>0.1873</td>
    <td>0.0540</td>
    <td>0.3079</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.1929</td>
    <td>0.3329</td>
    <td>0.2234</td>
    <td>0.2949</td>
    <td>0.1816</td>
    <td>0.2602</td>
    <td>0.2367</td>
    <td>0.2918</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.2161</td>
    <td>0.3703</td>
    <td>0.4168</td>
    <td>0.2297</td>
    <td>0.2411</td>
    <td>0.3901</td>
    <td>0.3629</td>
    <td>0.3202</td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.1797</td>
    <td>0.3617</td>
    <td>0.3342</td>
    <td>0.4065</td>
    <td>0.2337</td>
    <td>0.3381</td>
    <td>0.3944</td>
    <td>0.3903</td>
  </tr>
  <tr>
    <th colspan="9"><i>Out-of-box models</i></th>
  </tr>
  <tr>
    <td>7B</td>
    <td colspan="4">0.0305</td>
    <td colspan="4">0.000</td>
  </tr>
  <tr>
    <td>7B-chat</td>
    <td colspan="4">0.2808</td>
    <td colspan="4">0.3538</td>
  </tr>
  <tr>
    <td>13B</td>
    <td colspan="4">0.0249</td>
    <td colspan="4">0.0049</td>
  </tr>
  <tr>
    <td>13B-chat</td>
    <td colspan="4">0.3114</td>
    <td colspan="4">0.3693</td>
  </tr>
</table>

Appendix Table 1: ROUGE-1 Score after RLAIF Experiment 1. Performance reported on validation subset of original ACI-BENCH. R0 represent the model after SFT, with or without CP. R1 to R3 represents performance after respective rounds of DistillDirect. Models ended in long were pretrained using Discharge-long dataset, while models ended in short were pretrained using Discharge-short dataset. <b>Bolded scores</b> denote the best performance with respect to the task. The experimental setup includes training on the original reference notes from ACI-BENCH with a LR of 2e-5, and 3 epochs per training round. The temperature is set at 1.0 during generation time to calculate ROUGE-1.

Although we achieved commendable performance by the third round of DistillDirect (notably the best performance came from the 7B-chat_short model), the training process exhibited instability. For instance, the performance in the second round of DistillDirect for the 7B-chat-short model showed a significant decline from the previous round. Across all models, we did not observe a consistent enhancement in performance (as assessed by the ROUGE-1 score on the validation set) with additional rounds of DPO training. Notably, training accuracy reached 100% prematurely, during the first epoch for all models with a high reward margin (as shown in Appendix Figure 2), indicating potential overfitting.

Solution: Recognizing the instability of the current DistillDirect setup, we considered several potential causes, including issues with data quality/distribution shift, an inappropriate LR leading to overfitting, and reward hacking, among others. Our initial step towards addressing these concerns involved a thorough examination of the training data.

A.3.3 SFT Experiment 2
Models: We restarted SFT using the eight checkpoints after CP as discussed in SFT experiment 1.
Dataset: Upon closely examining the ACI-BENCH and our synthetic dataset, we observed several key points:

1. The quality of reference notes within ACI-BENCH is markedly variable. Certain notes are of poor quality (for example, overly brief), and others adopt syntax or styles not typically found in real clinical notes (for instance, explicitly including a “medical reasoning” section).

2. Additionally, notes from different subspecialties exhibit significant variations in style and format (e.g., a note from internal medicine versus one from orthopedics). While the heterogeneity observed in ACI-BENCH likely mirrors the diversity encountered in clinical practice (where different physicians may write notes very differently), it poses a challenge to use these notes as a “gold standard” for training a language model to replicate such documentation.
Appendix Figure 2: Example Training Set Accuracy and Reward Margin during DPO with a LR of 2e-5. Examples taken from 13B-chat-short_R3, and all other runs have similar training curve with high accuracy and reward margin early on with this LR.

3. Similar issues were also noted in our augmented Dialogue-G dataset created using Gemini-pro. Despite employing prompts with clear instructions regarding note format, minor inconsistencies still emerged.

Approach: Through discussions with our physician co-authors, we concluded that before AI can assist physicians in generating notes, the physicians themselves must determine what constitutes a “best practice” note format. It’s acknowledged that the “best practice” might diverge from existing notes for valid reasons (notably, recognizing that physicians can also produce suboptimal notes). With this perspective, we revised our prompts and provided a single-shot example to Gemini-pro to foster “constrained” note generation tailored towards a specific style. This new note style was collectively endorsed by our physician authors as superior to many examples within ACI-BENCH. Consequently, we directed Gemini-pro to generate new reference notes from the dialogues in ACI-BENCH, resulting in a dataset we named Modified ACI-BENCH. At this stage, we also regenerated reference notes for Dialogue-G using Gemini Pro. Initially, we considered having our physicians edit Gemini-pro’s notes before employing them for training. However, we abandoned this idea due to the time-intensive nature of the task and the satisfactorily high quality of outputs from Gemini-pro with our revised prompt.

Results: Utilizing the newly formulated modified ACI-BENCH dataset, we performed SFT for 3 epochs, adhering to the same parameters as before. The performance metrics post-SFT are detailed in Appendix Table 2, under the column labeled “R0”.

A.3.4 RLAIF Experiment 2
Models: The eight checkpoints from SFT experiment 2. We used LoRA for 13B models and full parameter training for 7B models.
Dataset: New dataset as described in SFT experiment 2.
Approach: Similar to RLAIF Experiment 1, but this iteration utilized the newly generated notes by Gemini-pro as “preferred” notes. Additionally, to mitigate concerns of overfitting, we limited the training to 1 epoch for each round, as opposed to the 3 epochs per round in RLAIF Experiment 1.
Results: Several intriguing observations emerge from this iteration (Appendix Table 2).

• 7B vs 13B models: With the current LR, the 7B models exhibited significant instability during DistillDirect. For instance, the 7B-short model demonstrated a notable performance degradation from round 1 to round 2. Upon manual evaluation of its outputs, the model incorrectly generated “Subjective” sections when tasked with producing “Assessment and Plan” and frequently returned null outputs. Given the more stable training observed with 13B models utilizing LoRA, along with their superior performance and reduced storage requirements compared to full parameter training for 7B models, we have decided to proceed exclusively with 13B models henceforth.

• Best Performer by ROUGE-1 : Among our CP models, the 13B-chat model pre-trained with the Discharge-short dataset emerged as the top performer. However, the overall best model was the 13B-chat model following SFT and three rounds of DistillDirect, but without CP. It achieved ROUGE-1 scores of 0.5452 for “Subjective” and 0.5597 for “Assessment and Plan”. Naturally, this led us to question the value of CP in our specific task. Such skepticism seemed justified, particularly given the differences between our training corpus of discharge summaries and that of outpatient
<table>
  <tr>
    <th rowspan="2">Models</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
  </tr>
  <tr>
    <th colspan="9">Models underwent continued pretraining, SFT and RLAIF</th>
  </tr>
  <tr>
    <td>7B-short</td>
    <td>0.1998</td>
    <td>0.4894</td>
    <td>0.5198</td>
    <td>0.3792</td>
    <td>0.2617</td>
    <td>0.4885</td>
    <td>0.0917</td>
    <td>0.4100</td>
  </tr>
  <tr>
    <td>7B-long</td>
    <td>0.1949</td>
    <td>0.4688</td>
    <td>0.0594</td>
    <td>0.3920</td>
    <td>0.2446</td>
    <td>0.3705</td>
    <td>0.3053</td>
    <td>0.4040</td>
  </tr>
  <tr>
    <td>7B-chat-short</td>
    <td>0.2961</td>
    <td>0.4816</td>
    <td>0.4946</td>
    <td>0.0586</td>
    <td>0.3157</td>
    <td>0.5201</td>
    <td>0.4763</td>
    <td>0.3867</td>
  </tr>
  <tr>
    <td>7B-chat-long</td>
    <td>0.3067</td>
    <td>0.5051</td>
    <td>0.0964</td>
    <td>0.0773</td>
    <td>0.2988</td>
    <td>0.4907</td>
    <td>0.4275</td>
    <td>0.3628</td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.2463</td>
    <td>0.5064</td>
    <td>0.4904</td>
    <td>0.4066</td>
    <td>0.2277</td>
    <td>0.5252</td>
    <td>0.4059</td>
    <td>0.4493</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.2525</td>
    <td>0.4199</td>
    <td>0.5113</td>
    <td>0.3309</td>
    <td>0.2565</td>
    <td>0.4840</td>
    <td>0.4610</td>
    <td>0.3566</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.3475</td>
    <td>0.5115</td>
    <td>0.5030</td>
    <td><b>0.5441</b></td>
    <td>0.3055</td>
    <td>0.5277</td>
    <td>0.4422</td>
    <td><b>0.5422</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.3463</td>
    <td>0.4856</td>
    <td>0.5308</td>
    <td>0.3863</td>
    <td>0.3620</td>
    <td>0.4752</td>
    <td>0.4730</td>
    <td>0.4633</td>
  </tr>
  <tr>
    <th colspan="9">Models underwent SFT and RLAIF without continued pretraining</th>
  </tr>
  <tr>
    <td>13B</td>
    <td>0.2813</td>
    <td>0.5303</td>
    <td>0.3967</td>
    <td>0.5108</td>
    <td>0.2977</td>
    <td>0.5265</td>
    <td>0.3510</td>
    <td>0.5060</td>
  </tr>
  <tr>
    <td>13B-chat</td>
    <td>0.2874</td>
    <td>0.5073</td>
    <td>0.5287</td>
    <td><b>0.5452</b></td>
    <td>0.3301</td>
    <td>0.5069</td>
    <td>0.4895</td>
    <td><b>0.5597</b></td>
  </tr>
  <tr>
    <th colspan="9">Out-of-box models</th>
  </tr>
  <tr>
    <td>13B</td>
    <td colspan="4">0.0329</td>
    <td colspan="4">0.0100</td>
  </tr>
  <tr>
    <td>13B-chat</td>
    <td colspan="4">0.3585</td>
    <td colspan="4">0.4543</td>
  </tr>
</table>

Appendix Table 2: ROUGE-1 Score after RLAIF Experiment 2. Performance reported on validation subset of modified ACI-BENCH. R0 represent the model after SFT, with or without CP. R1 to R3 represents performance after respective rounds of DistillDirect. Models ended in long were pretrained using Discharge-long dataset, while models ended in short were pretrained using Discharge-short dataset. Bolded scores denote the best performance with respect to the task. The experimental setup includes training on the new reference notes (modified ACI-BENCH) with a LR of 2e-5, and 3 epochs per training round. The temperature is set at 1.0 during generation time to calculate ROUGE-1.

clinical notes, which could be deemed out-of-distribution for our task.

• Possible Best Performer by Physician Review: The quality of the notes generated by the top-performing models (e.g., 13B-chat_R3, 13B-short_R1, 13B-chat-short_R3, 13B-chat-long_R2) appears nearly indistinguishable to our physician author. Overall, we find the “Subjective” sections of these notes to be satisfactory and potentially suitable for clinical application. However, the primary deficiency in achieving clinical-ready notes lies within the “Assessment and Plan” sections, particularly regarding medical reasoning and certain linguistic nuances. Although somewhat subjective, we felt the outputs from 13B-short_r1 bear the greatest resemblance to an actual provider’s note. This finding underscores the limitations of quantitative metrics in tasks involving domain-specific language generation.

• Persistent DistillDirect Training Instability: Despite the creation of a more uniform dataset, DistillDirect training remained susceptible to fluctuations. This instability was more pronounced for 7-billion parameter models but was also observed in 13-billion parameter models (Appendix Table 2). The 13B-long model serves as an example, where the ROGUE-1 score dropped from 0.5113 in round 2 to 0.3309 in round 3 for the “Subjective” section. Reducing the number of epochs per DistillDirect round from three to one did not mitigate this issue. In all DistillDirect rounds, training set accuracy rapidly reached a perfect score of 1.0 halfway through the first epoch, accompanied by a high reward margin (as illustrated in the initial third of the curve shown in Appendix Figure 2). This observation again suggests potential overfitting. Interestingly, similar rapid accuracy increases were reported during Zephyr training, and overfitting did not negatively impact performance on downstream tasks (Tunstall et al., 2023).

• Reflection on LR Selection: The optimal LR for DPO has yet to be established in literature, with only a limited number of LLMs having undergone DPO training to date. Notably, given the small size of our training set,
our initial LR choice of 2e-5 is larger than those selected in Zephyr and Tulu-2, where both models opted for an LR of 5e-7 (Ivison et al., 2023; Tunstall et al., 2023). The Tulu-2 paper mentioned that a “slow LR... is required for stable and effective DPO training.” Conversely, in another study, Gaudi-2 employed a significantly higher LR (5e-4, compared to an LR of 1e-4 during its SFT), despite using the same training data as Zephyr, and still achieved a favorable response (Intel Analytics Software, 2023).

• Generative Parameter Matters: We investigated the influence of generative parameters on model performance. Specifically, we experimented with a lower temperature setting of 0.6 compared to the baseline of 1.0 (Appendix Table 3), while maintaining other parameters the same (multinomial sampling with top-k = 50, top-p = 1.0, and repetition penalty = 1.2). Lowering the temperature resulted in a consistent increase in ROUGE-1 scores across all models. This finding suggests that optimizing generation-related hyperparameters through a dedicated search process has the potential to further enhance performance.

Solution: Conduct a limited LR search specifically for DistillDirect.

A.3.5 RLAIF Experiment 3
Models: 13B model checkpoints from SFT experiment 2.
Dataset: New dataset as described in SFT experiment 2.
Approach: We evaluated an LR of 5e-6 and 5e-7 and compared the effects of 1 epoch versus 3 epochs in each round across three rounds. After each round of training, we resampled outputs from the updated model checkpoint to serve as “rejected” samples for the subsequent round of DPO, while continuing to use notes produced by Gemini-pro as the “preferred” samples.
Results:
• LR of 5e-7: Training set accuracy reached 0.98 by the end of the second epoch. After three epochs, the reward margin only attained a level of 0.25 (Appendix Figure 3). This very small, albeit popular, LR was found to be insufficient in our experimental setup, yielding very slow performance improvements regardless of whether we conducted 1 epoch per round or 3 epochs per round of training (Appendix Table 4).

![Example Training Set Accuracy and Reward Margin during DPO with a LR of 5e-7. Examples taken from 13B-chat-short_R1. Training set accuracy reaches 0.98 at the end of 2nd epoch. After 3 epochs, the reward margin only reaches a level of 0.25.](page_1012_186_388_312.png)

Appendix Figure 3: Example Training Set Accuracy and Reward Margin during DPO with a LR of 5e-7. Examples taken from 13B-chat-short_R1. Training set accuracy reaches 0.98 at the end of 2nd epoch. After 3 epochs, the reward margin only reaches a level of 0.25.

![Example Training Set Accuracy and Reward Margin During DPO with a LR of 5e-6. Examples taken from 13B-chat-short_R1. Training set accuracy reaches 0.98 at the end of 2nd epoch. After 3 epochs, the reward margin only reaches a level of 0.25.](page_1012_1012_388_312.png)

Appendix Figure 4: Example Training Set Accuracy and Reward Margin During DPO with a LR of 5e-6. Examples taken from 13B-chat-short_R1. Training set accuracy reaches 0.98 at the end of 2nd epoch. After 3 epochs, the reward margin only reaches a level of 0.25.
<table>
  <tr>
    <th rowspan="2">Models</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
  </tr>
  <tr>
    <th colspan="9"><i>Models underwent continued pretraining, SFT and RLAIF</i></th>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.4006</td>
    <td>0.5423</td>
    <td>0.5186</td>
    <td>0.4702</td>
    <td>0.4032</td>
    <td>0.5683</td>
    <td>0.4039</td>
    <td>0.5242</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.3570</td>
    <td>0.4799</td>
    <td><b>0.5779</b></td>
    <td>0.3981</td>
    <td>0.4298</td>
    <td>0.5266</td>
    <td>0.4688</td>
    <td>0.3780</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.4390</td>
    <td>0.5455</td>
    <td>0.5248</td>
    <td>0.5560</td>
    <td>0.4825</td>
    <td>0.5565</td>
    <td>0.5236</td>
    <td><b>0.5694</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.4272</td>
    <td>0.5149</td>
    <td>0.5423</td>
    <td>0.4188</td>
    <td>0.4459</td>
    <td>0.5487</td>
    <td>0.5322</td>
    <td>0.4852</td>
  </tr>
  <tr>
    <th colspan="9"><i>Models underwent SFT and RLAIF without continued pretraining</i></th>
  </tr>
  <tr>
    <td>13B</td>
    <td>0.3671</td>
    <td>0.5469</td>
    <td>0.4216</td>
    <td>0.5508</td>
    <td>0.4335</td>
    <td>0.5804</td>
    <td>0.3833</td>
    <td>0.4913</td>
  </tr>
  <tr>
    <td>13B-chat</td>
    <td>0.4077</td>
    <td>0.5351</td>
    <td><b>0.5582</b></td>
    <td>0.5466</td>
    <td>0.4383</td>
    <td>0.5522</td>
    <td>0.4907</td>
    <td><b>0.5847</b></td>
  </tr>
</table>

Appendix Table 3: ROUGE-1 Score after RLAIF Experiment 2 with Lower Temperature. Performance reported on validation subset of modified ACI-BENCH. R0 represent the model after SFT, with or without CP. R1 to R3 represents performance after respective rounds of DistillDirect. Models ended in long were pretrained using Discharge-long dataset, while models ended in short were pretrained using Discharge-short dataset. Bolded scores denote the best performance with respect to the task. The experimental setup includes training on the new reference notes (modified ACI-BENCH) with a LR of 2e-5, and 1 epoch per training round. The temperature is set at 0.6 during generation time to calculate ROUGE-1, using the same model checkpoints as in Appendix Table 2.

• **LR of 5e-6**: Training set accuracy reached 0.95 midway through the second epoch. After three epochs, the reward margin achieved a level of 12 (refer to Appendix Figure 4). Although the training curve bears resemblance to that associated with a LR of 2e-5 (see Appendix Figure 4 and Appendix Figure 2), this lower LR demonstrated greater stability. This was particularly evident in the experiments conducted with 1 epoch per round of training, where performance across all models either exhibited steady improvement or achieved convergence, devoid of the abrupt declines observed with an LR of 2e-5 (Appendix Table 4). Notably, several models reached their performance peak in round 2, indicating that 2 to 3 rounds of training might be an optimal range for our experiment setup.

• **Impact of Temperature**: Consistent with previous experiments, model performance improves when a lower temperature was applied during generation (see Appendix Table 5).

Solution: We identified the LR of 5e-6 with a 1-epoch per round as the stable setup for DistillDirect in our experiment. Upon manual examination of outputs from all model checkpoints within this configuration, we selected the 13B-chat-short model from round 3 for the next stage of RLHF (Appendix Table 4).

A.4 RLHF

The model checkpoints selected for RLHF have undergone training through a sequence of stages: CP Experiment 3, followed by SFT Experiment 2, and then RLAIF Experiment 3. During the RLHF phase, we experimented with different temperature settings and observed that physicians tend to prefer outputs generated at lower temperatures. Consequently, we decided to adopt more deterministic generation parameters for the physician reader study.
<table>
  <tr>
    <th rowspan="2">Models</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-6, 3 epochs per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.2463</td>
    <td>0.5124</td>
    <td>0.4820</td>
    <td>0.5310</td>
    <td>0.2277</td>
    <td>0.5123</td>
    <td>0.4547</td>
    <td>0.4808</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.2525</td>
    <td>0.4406</td>
    <td><b>0.5423</b></td>
    <td>0.2974</td>
    <td>0.2565</td>
    <td>0.4652</td>
    <td>0.4984</td>
    <td>0.3316</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.3475</td>
    <td>0.4633</td>
    <td>0.4727</td>
    <td>0.5422</td>
    <td>0.3055</td>
    <td><b>0.5293</b></td>
    <td>0.5012</td>
    <td>0.5086</td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.3463</td>
    <td>0.4936</td>
    <td>0.5097</td>
    <td>0.5327</td>
    <td>0.3620</td>
    <td>0.5290</td>
    <td>0.5008</td>
    <td>0.5247</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-6, 1 epoch per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.2463</td>
    <td>0.3708</td>
    <td>0.4794</td>
    <td>0.4775</td>
    <td>0.2277</td>
    <td>0.4318</td>
    <td>0.4995</td>
    <td>0.4956</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.2525</td>
    <td>0.3730</td>
    <td>0.4427</td>
    <td>0.4494</td>
    <td>0.2565</td>
    <td>0.3609</td>
    <td>0.4750</td>
    <td>0.4578</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.3475</td>
    <td>0.4254</td>
    <td>0.4804</td>
    <td><b>0.4878</b></td>
    <td>0.3055</td>
    <td>0.4329</td>
    <td>0.5140</td>
    <td><b>0.5182</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.3463</td>
    <td>0.4135</td>
    <td>0.4600</td>
    <td>0.4601</td>
    <td>0.3620</td>
    <td>0.4642</td>
    <td>0.4843</td>
    <td>0.4662</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-7, 3 epochs per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.2463</td>
    <td>0.2546</td>
    <td>0.2655</td>
    <td>0.2744</td>
    <td>0.2277</td>
    <td>0.2618</td>
    <td>0.2573</td>
    <td>0.3002</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.2525</td>
    <td>0.2151</td>
    <td>0.2382</td>
    <td>0.2115</td>
    <td>0.2565</td>
    <td>0.2458</td>
    <td>0.3149</td>
    <td>0.2755</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.3475</td>
    <td>0.3518</td>
    <td><b>0.3718</b></td>
    <td>0.3428</td>
    <td>0.3055</td>
    <td>0.3398</td>
    <td>0.3449</td>
    <td><b>0.3840</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.3463</td>
    <td>0.3311</td>
    <td>0.2984</td>
    <td>0.3296</td>
    <td>0.3620</td>
    <td>0.3310</td>
    <td>0.3719</td>
    <td>0.3747</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-7, 1 epoch per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.2463</td>
    <td>0.2864</td>
    <td>0.2921</td>
    <td>0.2644</td>
    <td>0.2277</td>
    <td>0.2599</td>
    <td>0.2731</td>
    <td>0.2735</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.2525</td>
    <td>0.2600</td>
    <td>0.2333</td>
    <td>0.1839</td>
    <td>0.2565</td>
    <td>0.2473</td>
    <td>0.2216</td>
    <td>0.2453</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td><b>0.3475</b></td>
    <td>0.3117</td>
    <td>0.3388</td>
    <td>0.3356</td>
    <td>0.3055</td>
    <td>0.3303</td>
    <td>0.3370</td>
    <td>0.3231</td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.3463</td>
    <td>0.3090</td>
    <td>0.2943</td>
    <td>0.3134</td>
    <td>0.3620</td>
    <td>0.3174</td>
    <td>0.3194</td>
    <td><b>0.3693</b></td>
  </tr>
</table>

Appendix Table 4: ROUGE-1 Score after RLAIF Experiment 3. Performance reported on validation subset of modified ACI-BENCH. R0 represent the model after CP and SFT. DistillDirect R1 to R3 represents performance after respective rounds of DistillDirect. Models ended in long were pretrained using Discharge-long dataset, while models ended in short were pretrained using Discharge-short dataset. <b>Bolded scores</b> denote the best performance with respect to the task. The experimental setup includes training on the new reference notes (modified ACI-BENCH) with a variable learning rates and training epochs. The temperature is set at 1.0 during generation time to calculate ROUGE-1.
<table>
  <tr>
    <th rowspan="2">Models</th>
    <th colspan="4">Subjective</th>
    <th colspan="4">Assessment and Plan</th>
  </tr>
  <tr>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
    <th>R0</th>
    <th>R1</th>
    <th>R2</th>
    <th>R3</th>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-6, 3 epochs per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.4006</td>
    <td>0.5165</td>
    <td>0.5143</td>
    <td>0.5349</td>
    <td>0.4032</td>
    <td>0.5471</td>
    <td>0.4996</td>
    <td>0.5246</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.3570</td>
    <td>0.5049</td>
    <td>0.5679</td>
    <td>0.4289</td>
    <td>0.4298</td>
    <td>0.5064</td>
    <td>0.5102</td>
    <td>0.3976</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.4390</td>
    <td>0.5343</td>
    <td>0.5309</td>
    <td>0.5614</td>
    <td>0.4825</td>
    <td>0.5524</td>
    <td>0.5266</td>
    <td><b>0.5575</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.4272</td>
    <td>0.4815</td>
    <td><b>0.5759</b></td>
    <td>0.5605</td>
    <td>0.4459</td>
    <td>0.5299</td>
    <td>0.5510</td>
    <td>0.5294</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-6, 1 epoch per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.4006</td>
    <td>0.4971</td>
    <td>0.5145</td>
    <td>0.5200</td>
    <td>0.4032</td>
    <td>0.4950</td>
    <td>0.5464</td>
    <td>0.5222</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.3570</td>
    <td>0.4449</td>
    <td>0.5126</td>
    <td>0.5000</td>
    <td>0.4298</td>
    <td>0.5123</td>
    <td>0.5190</td>
    <td>0.5285</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.4390</td>
    <td>0.5155</td>
    <td>0.5167</td>
    <td><b>0.5352</b></td>
    <td>0.4825</td>
    <td>0.5380</td>
    <td>0.5392</td>
    <td><b>0.5411</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.4272</td>
    <td>0.4863</td>
    <td>0.4980</td>
    <td>0.5077</td>
    <td>0.4459</td>
    <td>0.5094</td>
    <td>0.5255</td>
    <td>0.5346</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-7, 3 epochs per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.4006</td>
    <td>0.3760</td>
    <td>0.3771</td>
    <td><b>0.4573</b></td>
    <td>0.4032</td>
    <td>0.4390</td>
    <td>0.4281</td>
    <td>0.4315</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.3570</td>
    <td>0.4022</td>
    <td>0.3909</td>
    <td>0.3693</td>
    <td>0.4298</td>
    <td>0.4154</td>
    <td>0.4428</td>
    <td>0.4411</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.4390</td>
    <td>0.4434</td>
    <td>0.4482</td>
    <td>0.4394</td>
    <td>0.4825</td>
    <td>0.4761</td>
    <td>0.4625</td>
    <td><b>0.4833</b></td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.4272</td>
    <td>0.4398</td>
    <td>0.4058</td>
    <td>0.4282</td>
    <td>0.4459</td>
    <td>0.4763</td>
    <td>0.4633</td>
    <td>0.4545</td>
  </tr>
  <tr>
    <td colspan="9"><i>Lr: 5e-7, 1 epoch per round</i></td>
  </tr>
  <tr>
    <td>13B-short</td>
    <td>0.4006</td>
    <td>0.4241</td>
    <td>0.4112</td>
    <td>0.4140</td>
    <td>0.4032</td>
    <td>0.4345</td>
    <td>0.4172</td>
    <td>0.4107</td>
  </tr>
  <tr>
    <td>13B-long</td>
    <td>0.3570</td>
    <td>0.4099</td>
    <td>0.4175</td>
    <td>0.4039</td>
    <td>0.4298</td>
    <td>0.3671</td>
    <td>0.3865</td>
    <td>0.4285</td>
  </tr>
  <tr>
    <td>13B-chat-short</td>
    <td>0.4390</td>
    <td>0.4291</td>
    <td><b>0.4541</b></td>
    <td>0.4337</td>
    <td>0.4825</td>
    <td>0.4569</td>
    <td><b>0.4826</b></td>
    <td>0.4450</td>
  </tr>
  <tr>
    <td>13B-chat-long</td>
    <td>0.4272</td>
    <td>0.4188</td>
    <td>0.4048</td>
    <td>0.3986</td>
    <td>0.4459</td>
    <td>0.4606</td>
    <td>0.4552</td>
    <td>0.4446</td>
  </tr>
</table>

Appendix Table 5: ROUGE-1 Score after RLAIF Experiment 3 with a Lower Temperature. Performance reported on validation subset of modified ACI-BENCH. R0 represent the model after CP and SFT. R1 to R3 represents performance after respective rounds of DistillDirect. Models ended in long were pretrained using Discharge-long dataset, while models ended in short were pretrained using Discharge-short dataset. Bolded scores denote the best performance with respect to the task. The experimental setup includes training on the new reference notes (modified ACI-BENCH) with a variable learning rates and training epochs. The temperature is set at 0.6 during generation time to calculate ROUGE-1 using the same model checkpoints as in Appendix Table 4.
B  Details on Datasets

B.1 ACI-BENCH Subsets

ACI-BENCH comprises five data subsets: train, validation, test1, test2 and test3 (Yim et al., 2023b). Test1 and test2 corresponds to the test sets from ACL ClinicalNLP MEDIQA-Chat 2023 TaskB and TaskC, respectively (Abacha et al., 2023). Test3 corresponds to TaskC of CLEF MEDIQA-SUM 2023 (Yim et al., 2023a). Given the scarcity of publicly available clinical dialogue-note datasets, we used the train, test2, and test3 subsets for various stages of model development in our study. The blinded clinical reader study was performed on the test1 subset.

B.2 MIMIC-IV

The publicly available MIMIC-IV dataset comprises 431,231 unique hospital admissions from 299,712 patients admitted to an ICU or the ED of the Beth Israel Deaconess Medical Center in Boston, Massachusetts (Johnson et al., 2023). MIMIC-IV is deidentified according to the Health Insurance Portability and Accountability Act (HIPAA) Safe Harbor provision (Johnson et al., 2023). Access to MIMIC-IV can be requested at https://physionet.org/content/mimiciv/, which requires a signed safe usage agreement.

C  Implementation Details for Final Experimental Steps

C.1 LoRA

We used LoRA to train LLaMA-2-13B models for all phases of training. LoRA is a method that involves freezing the pre-trained model weights and only training a small percentage (<1%) of the model weights, i.e., by incorporating trainable rank decomposition matrices into each layer of the transformer architecture (Hu et al., 2021). As a quick summary, let us assume that we have the original weight matrix \( W_0 \in \mathbb{R}^{d \times k} \). LoRA works by adding a low-rank matrix to the original weight matrix: \( \Delta W + W_0, \Delta W = BA \) where \( B \in \mathbb{R}^{d \times r} \) and \( A \in \mathbb{R}^{r \times k}, r << d \), so the matrices \( B, A \) are limited by a lower rank \( r \), reducing the need to train all the parameters. Training is only performed on this \( \Delta W \), and original model weights are kept the same. We then scale \( \Delta W \) by \( \frac{\alpha}{r} \), where \( \alpha \) is a constant in \( r \).

In all training steps, LoRA parameters were configured with \( r \) set to 8, an \( \alpha \) of 32, and a dropout rate of 0.05. All attention blocks were included in the LoRA target modules.

C.2 Medical LLMs Evaluation

We evaluated state-of-the-art medical and clinical LLMs fine-tuned on biomedical literature and clinical notes: Medtron-7B (Chen et al., 2023), LLaMA-3-Med42-8B (Christophe et al., 2024), and MeLLaMA-13B-chat (Xie et al., 2024). The same generation configurations with one-shot prompting from our main experiments were applied, except for MeLLaMA, for which we used its default generation settings to achieve better performance.

C.3 Continued Pretraining

We followed the training scripts outlined in Meta’s official LLaMA recipe repository (meta-llama). We employed mixed-precision training with a batching strategy of packing and a context length of 4096 tokens. We utilized Fully Sharded Data Parallel (FSDP) on either 4 Nvidia A6000 or 4 Nvidia A100 GPUs. We maintained a batch size of 4 during training with a gradient accumulation step of 1. Consistent with LLaMA-2, we set a peak learning rate of 3e-4 for the continued pretraining stage. The AdamW optimizer with a cosine learning rate scheduler was used, and the model was trained for one epoch. The exponential moving average of training loss as shown in Figure 3 was calculated using the pracma package from R with a window size of 250.

C.4 SFT

We used a similar experiment setup as continued pretraining, including following LLaMA-recipes to perform mixed precision training on 4 GPUs using FSDP (Zhao et al., 2023). For SFT, we selected the batching strategy of padding and trained on 3 epochs. Consistent with LLaMA-2, we set a peak learning rate of 2e-5. We truncate prompt (including instruction and dialogue) at a max length of 3000 tokens, and truncate note to 1000 tokens. We set a value of -100 for labels on prompt tokens to zero out losses from prompts.

C.5 RLAIF

We utilized the trl library from Huggingface to conduct DistillDirect (von Werra et al.). Due to
computational limitations, experiments were conducted on a single Nvidia A100 GPU with 80GB of graphics memory. To optimize memory usage, pure BF16 training was utilized with a micro-batch size of 1 and gradient accumulation steps of 8. Following a limited learning rate search detailed in Appendix A.3 and Appendix Table 4, a learning rate of 5e-6 was chosen. The optimizer used was paged_adamw_32bit. Within the DPOTrainer class, we set the beta hyperparameter to 0.1 and passed None to ref_model. Three rounds of DistillDirect were performed, with each round involving one epoch of training.

Text generation was implemented using the Transformers library (Wolf et al., 2019). When generating “rejected” samples from the latest model checkpoint, we consistently applied do_sample=True, top_p=1.0, temperature=1.0, top_k=50, repetition_penalty=1.2, and use_fast_kernels=False. The maximum number of newly generated tokens was set to 1000.

C.6 RLHF
For RLHF, we employed an experimental setup analogous to that described in RLAIF. We conducted two rounds of DPO on human preference data. Diverging from the approach taken in RLAIF, we executed three epochs of training in each DPO round due to the limited size of the dataset.

Based on the findings from ablation studies detailed in Appendix A.3 and Appendix Table 5, we opted for a lower temperature setting at this stage. In the initial round of DPO, we generated three responses using the same configuration, including a temperature setting of 0.6, for preference labeling. In the second round of DPO, we diversified the temperature settings, resulting in three responses with temperatures set at 0.6, 0.4, and 0.2, respectively, for preference labeling.

Of note, we excluded data from Dialogue-G to ensure in-distribution training during this final stage of model development. This decision was based on the observed perplexity of 2.79 for Dialogue-G, in contrast to 5.62 for ACI-BENCH, as calculated using the LLaMA-2 chat model after continued pretraining.

C.7 Physician Reader Study
LLM-generated notes were produced by LLaMA-Clinic and Gemini Pro, employing identical generation-related hyperparameters (temperature of 0.2, top_p of 0.7 and top_k of 40). To ensure consistency in presentation across all notes, we implemented a basic post-processing step. This step standardized aspects like style, spacing, and capitalization to minimize any formatting discrepancies between human-authored and model-generated notes.

Four licensed physician evaluators, who specialize in general internal medicine or family medicine, boast rich experience in outpatient practice. The notes were presented in a random order, anonymized to remove any identifying information, and labeled as note 1, note 2, and note 3 to mask the origin of each note from the evaluators. Before assessing the notes, evaluators were instructed to read the entire patient-provider conversation. They were then asked to rate the quality of each note across three criteria: “accuracy,” “completeness,” and “real-world readiness.” For each criterion, a scoring system from 1 to 5 was used, ranging from very poor to very good, with higher scores reflecting superior quality. Specifically for “real-world readiness,” evaluators were prompted to consider the scenario of integrating AI-generated clinical notes into their daily practice, including the necessity to proofread and potentially edit these notes before filing them into medical records.

C.8 Statistical Analysis
The non-parametric Kruskal-Wallis H test was selected to compare differences in word counts among the three-note groups, utilizing the scipy package in Python (Virtanen et al., 2020). We measured IRR using Gwet’s AC2 statistics implemented through the irrCAC package in R (Gwet, 2014; Gwet and Gwet, 2019). We reported results with quadratic weights for Gwet’s AC2, as this approach is reliable for ordinal data against the grey zones (Tran et al., 2021). Due to our relatively small reviewer pool, we chose not to conduct statistical significance testing on the physician reader study, aligning with practices observed in the deep learning community (Touvron et al., 2023; Stienon et al., 2020).

C.9 Model Development Cost Estimation
In Appendix Figure 6A, we provide cost estimations for the training steps directly involved in the development of LLaMA-Clinic. These costs should be viewed as minimal estimates and will likely fall short of the actual budget requirements since they do not include the trial-and-error expenses from various experiments, such as trialing different models,
conducting hyperparameter searches, and debugging. The hours for continued pretraining are based on training using the Discharge-short dataset. For GPU hours, we accounted for the total number of Nvidia A100 GPU hours utilized. For example, if the continued pretraining stage requires 12 hours using FSDP on four A100 GPUs, we calculate this step as requiring 48 hours. For physician labeling hours, we asked physicians to estimate the average time they spent on the tasks.

C.10 Model Inference Cost Estimation

A complex array of factors influences the total cost of deploying a model for production. These include hardware and software configurations, labor costs associated with constructing, validating, and refining the model, and the implementation of comprehensive security measures to mitigate misuse and enhance threat detection. To ensure a fair and apples-to-apples comparison, we calculated the inference costs for both proprietary and open-source models based on API calls. In this context, the total annual inference cost is calculated as follows:

\[
C = (p_i \times n_i + p_o \times n_o) \times R
\]

Here, \( C \) represents the total annual inference cost. \( p_i \) denotes the price per input token, while \( n_i \) refers to the average number of input tokens per request. Similarly, \( p_o \) indicates the price per output token, and \( n_o \) represents the average number of output tokens per request. The term \( R \) stands for the total number of annual requests.

For open-source models, we assumed deployment on Fireworks.ai, a company that offers serverless inference for customized LLMs. We sourced pricing information from the websites of Google AI, OpenAI, and Fireworks.ai in May 2024 for on-demand API calls. Detailed pricing information can be found in Appendix Table 11. We assumed an average of 3,000 input tokens and 1,000 output tokens per request for clinical note generation. This estimation likely contains redundancy and leaves room for prompt engineering, given that in a cohort of real-world family medicine clinical encounters, the average lengths per dialogue and note are 1505 and 683 tokens, respectively (Yim et al., 2023b).

An important consideration for production is ensuring adequate throughput for LLMs. As an example, Gemini 1.0 Pro has a rate limit of 360 requests per minute, while LLaMA-Clinic, deployed with the “Developer” plan from Fireworks.ai, allows 600 requests per minute. We consider this default rate limit acceptable for our calculations, as shown in Figure 5. For example, 1 million annual requests translate into an average of approximately 5.7 requests per minute (RPM), using the formula:

\[
\text{Average RPM} = \frac{\text{Annual Requests}}{365 \times 8 \times 60}
\]

assuming an 8-hour workday. However, this calculation does not account for peak demand, which would necessitate system redundancy in a production environment. In addition, there are other technical factors to consider for deployment in production, such as latency and throughput variance (Art, 2024), which were not included in our analysis.

D Additional Results

D.1 Performance of LLM-as-a-Judge in Predicting Physician Preference

We evaluated Gemini 1.0 as an LLM-as-a-judge on our RLHF dataset. We observed a low accuracy of 43.8% in predicting physician preferences (from three candidate notes), underscoring the challenges LLMs encounter in predicting expert preferences in complex domains such as medicine.

D.2 Qualitative Analysis of Model Outputs

Qualitative analysis for a specific case at different stages of model training is presented in Appendix Figure 5. Continued pretraining effectively adopted the style and peculiarities from discharge summaries but at the expense of diminished instruction-following ability and increased hallucinations. The quality of outputs significantly improved post-SFT but remained overly verbose, while RLAIF effectively refined outputs to adhere to the format of reference notes, assisting in reducing hallucinations. Upon manually reviewing outputs from all model checkpoints post-RLAIF, our physician author noted that the “Subjective” sections were generally of high quality and nearly indistinguishable from notes authored by clinicians. However, the “Assessment and Plan” sections could be improved to more accurately and concisely reflect medical reasoning.

D.3 Physician Reader Study

Four internal medicine physicians and one family medicine physician, in a blinded review, evaluated notes authored by physicians, LLaMA-Clinic, and Gemini Pro based on three criteria: real-world
readiness, completeness, and accuracy (Figure 4A). The median word counts and interquartile ranges (IQR) for notes authored by physicians, LLaMA-Clinic, and Gemini Pro were 118 (IQR: 94-150), 128 (IQR: 108-145), and 128 (IQR: 100-164), respectively. No statistically significant differences in word counts were observed among the three groups (Kruskal-Wallis H test: \( p = 0.292 \)). We assessed inter-rater reliability (IRR) utilizing Gwet’s AC2 statistics. The AC2 scores for the three metrics ranged from 0.80 to 0.82, signifying a high degree of agreement among reviewers.

D.4 Cost Analysis for Model Development and Inference

We provided our estimations of both GPU and human costs, measured in hours, for developing LLaMA-Clinic in Appendix Figure 6A. For inference cost, we calculated the cost of deploying open-source models in a serverless cloud environment provided by a third-party vendor. We compared these with the costs of using the proprietary models’ APIs (Appendix Figure 6B). Overall, proprietary models are more expensive than the open-source options. For proprietary models, costs significantly increase with the more advanced models. Similarly, for open-source models, costs increase with larger model sizes, as measured by the number of parameters. LLaMA-Clinic demonstrates a price advantage compared to its teacher model, Gemini 1.0 Pro, with a 3.75-fold cost reduction based on pricing information from May 2024. Assuming one million requests for clinical note generation, the estimated annual inference cost for LLaMA-Clinic is $800 USD, compared to $3,000 USD for Gemini 1.0 Pro. Moreover, the amount mentioned is for the inference cost for one type of note. The total cost of supporting all types of notes will be significantly higher, but the relevant cost difference should remain the same.

E Additional Discussion

E.1 Continued Pretraining vs. Supervised Finetuning

Continued pretraining of an LLM using a domain-specific corpus is recognized for enhancing performance on downstream tasks (Wu et al., 2023b). This phase is considered a knowledge injection process, given that LLMs acquire the vast majority of their knowledge during the pretraining phase (Ovadia et al., 2023; Zhou et al., 2023a). Several clinical LLMs that underwent continued pretraining with medical corpora, such as PubMed literature, combined with SFT have shown significant improvements in medical knowledge benchmarks (Chen et al., 2023; Wu et al., 2023a; Luo et al., 2023).

However, a critical distinction exists between tasks focused on medical knowledge (e.g., answering USMLE questions) and those aimed at clinical note generation. Notably, GatorTronGPT (Peng et al., 2023), the only LLM trained from scratch using EMR data from real patients to date, performed lower in both MedQA and PubMedQA compared to other clinical LLMs (Chen et al., 2023; Wu et al., 2023a; Kweon et al., 2023; Wang et al., 2024b). This outcome indicates that EMR data alone may lack comprehensive medical knowledge. For the task of note generation, we hypothesized that continued pretraining with clinical notes could offer benefits by introducing greater lexical variance, unique semantic patterns, and diverse formatting similar to prior work (Lehman et al., 2023). Our experiments did not conclusively demonstrate the anticipated benefits of continued pretraining. Interestingly, the LLaMA-2 model without continued pretraining achieved the highest ROUGE-1 scores after SFT and RLAIF in our early experiments (see Appendix Table 2). We opted to proceed with the continued pretrained model for RLHF due to subtle peculiarities observed upon manual inspection. Given the significant time and computational resources required for continued pretraining, its utility, particularly with clinical notes, merits further exploration in future work.

E.2 Data Selection for Continued Pretraining

Another potential factor in the less impressive improvement from continued pretraining may be attributed to the variance in data distribution between discharge summaries and outpatient notes. To address this, we performed experiments focused on a condensed version of discharge summaries (Discharge-short), hypothesizing that the “brief hospital course” section would contain data of higher quality than the complete discharge summary. Indeed, models trained on the Discharge-short outperformed those trained on the full summaries (Table 1). Interestingly, we observe that during the pretraining stage, models trained on full summaries achieved lower training losses (see Figure 3). However, this did not lead to better performance in the downstream task. We speculate
that the structured nature of the full discharge summaries, which include sections such as laboratory results and medication lists, presents more straightforward learning targets for the model. This allows it to achieve lower training losses, which do not necessarily translate into improved task performance. This observation underscores the necessity for thorough analysis of the data used for pretraining.

F  Prompts to Gemini Pro for Dialogue-G Creation

We presented the prompt sent to Gemini Pro for generating dialogues of Dialogue-G in Appendix Table 6.

G  Prompts to Gemini Pro for Reference Note Generation

We presented the prompt used by Gemini Pro to create reference notes in Appendix Table 7. We demonstrated two examples of clinical notes before and after the change in Appendix Figure 7.

H  Instructions for Collecting Preference Data

We presented the instructions used for collecting physician preference data for RLHF in Appendix Table 8.

I  Instructions and Scoring Rubric for Physician Reader Study

We presented the instructions used for the final physician reader study in Appendix Table 9.

J  Instructions for Harm Evaluation

We presented the instructions used for the harm evaluation in Appendix Table 10.

K  An Example of Patient-Doctor Dialogue

We presented an example of doctor-patient dialogue from ACI-BENCH in Appendix Table 12.
Stage 0: vanilla LLMa-2-chat
Suraj: Here's the Assessment and Plan section of the clinical note based on the patient's dialogue:
Assessment:
* Iron deficiency anemia (IDA)
* History of heavy menstrual Bleeding
Plan:
- Order upper endoscopy and colonoscopy to evaluate for possible GI bleeding
- Ask patient to take ferrous sulfate with orange juice (to improve absorption) for the next 12 weeks
- Refer to Hematology for further evaluation and management of IDA
- Consider capsule endoscopy if initial tests are negative

Stage 1: s/p continued pretraining
Okay. Based upon conversation with ... from today's hospital stay, patient denies drug use or history of trauma sustained, both of which could precipitate aneurysms.
Patient reports recent work-up revealing mild thrombophilic gene mutation (Factor V Leiden), and he underwent left upper extremity arteriogram previously showing patency. The patient had ultralow circulatory volume pressure values concerning for chronically impaired venous/arterial reflexes contributing to increased risk of thromboembolic events. He also described a prior right carotid artery stenosis thought to be possible source of embolism formation causing patient symptoms prior to his vascular intervention in patient earlier in ... He currently reports stable pain free status of 3 months followed consistently throughout most recent period. He received angioplasty to two distal graft lesions near the bifurcation of the right and left common iliac arteries.
...

Stage 3: s/p RLAIF
ASSESSMENT AND PLAN:
1. Iron Deficiency Anemia
Assessment: Patient has a history of iron deficiency anemia, which has been persistent despite trying to donate blood. Physical exam reveals mild menorrhagia. She denies any rectal trauma or hematochezia. Her ferritin level is low.
Plan:
- Recommend ferrous sulfate 25mg TID for 8-12 weeks. Encourage absorption with orange juice.
- Schedule an EGD and colonoscopy to evaluate for GI bleed. If the test results are negative order a capsule endoscopy.
- Refer to hematology for further evaluation.
...

Stage 4: s/p RLHF
ASSESSMENT AND PLAN:
1. Iron Deficiency Anemia
Assessment: The patient has a history of iron deficiency anemia, started iron pills, but stopped due to side effects. She has been experiencing fatigue, fevers, chills, shortness of breath, headaches, and chillsing sensations.
Plan:
- Will obtain CBC, iron, ferritin, B12, and folate levels to evaluate the effectiveness of current treatment.
- Continue ferrous sulfate 25mg TID with Vitamin C 1 glass of OJ in AM and PM for the next 12 weeks.
- Arranged for EGD and Colonoscopy to rule out GI bleed or other causes of anemia.
- Referred to Hematology for further evaluation.

Stage 2: s/p SFT
ASSESSMENT AND PLAN:
1. Iron Deficiency Anemia
Assessment: The patient's symptoms, including fatigue, chills, and shortness of breath suggest iron deficiency anemia (IDA). Her medical history includes hypothyroidism, chronic kidney disease and she has had several hysterectomies before her menses became regularly absent after her surgery. ... Differential diagnosis should include chronic kidney disease, hypothyroidism, thalassemia trait, and sickle cell trait.
Plan:
- Will obtain CBC, MCV index, iron studies, BUN, Cr, reticulocyte count, serum electrolytes, and liver function tests. If results are supportive of IDA, will initiate iron therapy (IV vs PO depending on response).
- Referred patient to GI due to concern for gastrointestinal bleeding or occult cancer. Colon cancer screening and polyp removal, gastritis and dyspeptic symptoms ...
...

Reference note
ASSESSMENT AND PLAN:
1. Iron deficiency anemia
Assessment: Patient has long-standing iron deficiency anemia, with low hemoglobin and low ferritin. She has taken ferrous sulfate 25mg BID and over-the-counter vitamin B12.
Plan:
- Continue ferrous sulfate 25mg BID with orange juice for 8-12 weeks, then recheck CBC, iron, ferritin, B12, and folate.
- Refer to Hematology for further evaluation and management.
- Schedule EGD and colonoscopy to assess for potential sources of anemia or GI bleed. If inconclusive, capsule endoscopy will be considered.
...

Appendix Figure 5: An Example of Model Outputs Progression with Training Steps. Case number D2N073 from ACI-BENCH validation set. The figure illustrates the model’s outputs for the same case following each training step. Continued pretraining adopted the style of discharge summaries but impaired the model’s ability to follow instructions. Post-SFT, output quality improved, though it remained verbose. RLAIF and RLHF effectively refined outputs to match the format of reference notes and helped reduce hallucinations.
Appendix Figure 6: Cost Estimation for Model Development and Inference. A. Model development cost for LLaMA-Clinic. The Y-axis of the horizontal bar chart represents different stages of model development, while the X-axis indicates costs, measured in total Nvidia A100 GPU hours or physician man hours. Importantly, the displayed costs only consider the training steps directly involved in developing LLaMA-Clinic and do not include the trial-and-error expenses from all experiments. B. Estimated inference costs for 1 million annual requests by proprietary and open-source models. The horizontal bar chart displays the annual inference cost estimation for both proprietary and open-source models, assuming 1 million requests for clinical note generation per year. The Y-axis represents the model names, and the X-axis indicates the total annual inference cost in US dollars. These calculations are based on the pricing per input and output tokens when using APIs on-demand. For proprietary models, pricing information was obtained from the websites of OpenAI and Google. For open-source models, pricing information was based on deploying models on Fireworks.ai with serverless inference. All pricing information was obtained in May 2024. In our study, Gemini 1.0 Pro served as the teacher model, while LLaMA-Clinic was the student model based on the LLaMA-2 13B.
A.

ACI-BENCH notes

Encounter ID: D2N030
ASSESSMENT
• Follow-up bilateral breast cysts.
• PAP smear.
PLAN
Follow-up bilateral breast cysts

Newly created reference notes

Encounter ID: D2N030
ASSESSMENT AND PLAN:
1. Breast mass.
Assessment: The patient is concerned about the size of her breast mass, which has not decreased with progesterone therapy. She has a history of fibroadenoma and increased breast cancer risk due to family history.
Plan:
- Will obtain bilateral mammogram.
- Will refer to a breast specialist for further evaluation and consideration of biopsy.
2. Anxiety.
Assessment: The patient's anxiety is improved with buspar. She has not experienced anxiety since starting the medication.
Plan:
- Continue buspar 5mg Daily.
- Will assess response at next visit.

B.

ACI-BENCH notes

Encounter ID: D2N005
IMPRESSION
Right middle finger distal phalanx fracture.
PLAN
At this point, I discussed the diagnosis and treatment options with the patient. I recommend a prescription for Tramadol 50 mg every 8 hours as needed for 7 more days. She is provided a finger splint and will return in 2 weeks for a follow-up visit. All questions were answered.

Newly created reference notes

Encounter ID: D2N005
ASSESSMENT AND PLAN:
1. Dorsal fracture of the right middle finger.
Assessment: Pain and tenderness over the distal phalanx of the right middle finger, with a history of motor vehicle accident. X-ray confirmed the fracture.
Plan:
- Prescribe tramadol 50mg every 6 hours as needed for pain for 2 days.
- Apply a splint to the finger.
- Schedule a follow-up visit in 2 weeks for X-ray.
2. Atrial fibrillation.
Assessment: The patient has a history of atrial fibrillation and takes digoxin.
Plan:
- Continue digoxin.
- Ensure tramadol is safe to take with digoxin.
- ...

Appendix Figure 7: Comparison of Newly Created Reference Notes with ACI-BENCH Notes. A. Example with the encounter ID D2N030. B. Example with the encounter ID D2N005. We compared newly generated reference notes using Gemini Pro with the original reference notes from two cases in ACI-BENCH. The newly created reference notes adhere more closely to our defined “best practice” format and contain more relevant medical information.
<table>
  <tr>
    <th>Category</th>
    <th>Prompt</th>
  </tr>
  <tr>
    <td><i>Dialogue</i></td>
    <td>Generate a synthetic patient-physician clinical dialogue encounter based on the clinical note below. Make sure all pertinent details are represented in the generated dialogue, so that a physician can easily write up the provided note. Pay close attention to make sure all details in the ‘ASSESSMENT AND PLAN’, ‘HISTORY OF PRESENT ILLNESS’ and ‘SUBJECTIVE’ parts of the note are reflected in the dialogue. You may expand details to make the dialogue resemble a real clinical encounter. Denote doctor as [doctor] and patient as [patient].</td>
  </tr>
</table>

Appendix Table 6: Prompts to Gemini Pro for Dialogue-G Creation.

<table>
  <tr>
    <th>Category</th>
    <th>Prompt</th>
  </tr>
  <tr>
    <td><i>Subjective</i></td>
    <td>You are a physician writing a clinical note based on a dialogue with the patient. Only write the “SUBJECTIVE” part of note, which include the section of [CHIEF COMPLAINT] and [HISTORY OF PRESENT ILLNESS]. Only include information contained in the dialogue. Follow the format as the example below:

SUBJECTIVE

CHIEF COMPLAINT

Annual health maintenance examination.

HISTORY OF PRESENT ILLNESS

The patient is a pleasant [age]-year-old male who presents for his annual health maintenance examination. He reports no new complaints today. He denies any recent changes in his hearing. He continues to take macin for his dyslipidemia; and he has had no problems with hemorrhoids in the last 6 months. He also denies any problems with concha bullosa of the left nostril or septal deviation.</td>
  </tr>
  <tr>
    <td><i>Assessment and Plan</i></td>
    <td>You are a physician writing a clinical note based on a dialogue with the patient. Only write the “ASSESSMENT AND PLAN” section of note. List each medical problem separately. Under each problem, include assessment (such as medical reasoning) and plan (both diagnostic and therapeutic ). At the end, may include a short section on follow up instruction when applicable. Only include information contained in the dialogue. Follow the format as the example below:

ASSESSMENT AND PLAN:

1. Possible COPD exacerbation
Assessment: Increased work of breathing with wheezing on exam, suggesting COPD exacerbation. He does have frequent COPD exacerbation in the past. Differential diagnosis include pneumonia (though no fever or cough), PE (though no risk factors) or simple viral infection.
Plan:
- Will obtain CXR.
- Will start duoneb therapy and oral prednisone 30mg Qday.

2. Hypertension
Assessment: The patient’s blood pressure is well controlled.
Plan:
- Continue lisinopril 20mg Qday.

Follow-up instructions:
- return to clinic in 1 week, or sooner of failed to response with current treatment.</td>
  </tr>
</table>

Appendix Table 7: Prompts to Gemini Pro for Reference Note Generation.
Instructions

1. Please first read the dialogue and then pick your most and least preferred notes. Most conversation occurred in the outpatient setting.

2. We will only look at the “Subjective” and “Assessment and Plan” parts of a note. There will be a separate row for “Subjective” and “Assessment and Plan”, respectively.

3. On each row, you will be given three notes generated by LLMs. Pick the MOST preferred note, and the LEAST preferred note by selecting the corresponding note number in the columns of “Preferred” and “Rejected”.

4. Focus on whether the clinical note accurately reflected information from the conversation. Ignore any error related to medical knowledge, as long as the information was mentioned in the conversation.

5. Base your preference on factors like clinical readiness, correctness, and adherence to the desired format, including:

   a. Clinical readiness: Is the note ready for clinical use and does it capture important information?
   b. Correctness: Does the note include less false information?
   c. Adherence to format: Does the “Subjective” section include “Chief complaints” and “History of present illness”? Does the “Assessment and Plan” section list each problem separately and include “Assessment:” and “Plan:” with the required details?

6. Make your preference judgement from a clinician’s perspective, considering which note would be most/least helpful to you.

Appendix Table 8: Clinician Note Preference Instruction.
Instruction and rubrics

1. In each row you will be given a synthetic outpatient patient-provider dialogue from ACI-BENCH, and three clinical notes based on the same dialogue. Two notes are generated by large language model, and one note is written by real physician. We have performed randomization of the notes (so that notes from the column of note_1 are from different sources) and simple processing to unify the format of notes.

2. The dialogues from ACI-BENCH include conversations with (a) calls to a virtual assistant (b) unconstrained directions or discussions with a scribe, and (c) natural conversations between a doctor and patient.

3. There are 40 dialogues. For each dialogue, we will evaluate “Subjective” and “Assessment and Plan” parts of the note in separate rows. Therefore, there are 80 rows in total.

4. For each row, you will first read the entire dialogue and then read the 3 notes. You will subsequently score the quality of each note for the 3 axes of “accuracy”, “completeness” and “readiness for real-world use”. For each axis, you will give a score of 1 to 5 (very poor, poor, acceptable, good, or very good), where higher number suggests better quality. It is OK to give the same score for different notes if you feel they are of similar quality. For each row since there are 3 notes, you will give total 9 scores. In each row there is a section of “Comment” for you to free text any feedback if you feel like to.

5. Accuracy: For this axis, answer the question “does the factual information from clinical note accurately match that from the dialogue?” A note is accurate if it doesn’t say things that aren’t in the dialogue, it doesn’t mix up facts, and generally is not misleading. It might be acceptable if the note contains reasonable medical reasoning in the section of “Assessment”, for example in describing differential diagnosis. Please ignore any medical knowledge error, as long as the information was discussed in the dialogue.

Rubric:

• Score of 1 (very poor): The note contains a significant amount of content that is either factually incorrect, fabricated, or disconnected from the dialogue.
• Score of 3 (acceptable): The note contains some minor content that is either factually incorrect, fabricated, or disconnected from the dialogue.
• Score of 5 (very good): The note has no incorrect statements or misleading implications.

6. Completeness: For this axis, answer the question “how well does the note cover the important information from the dialogue?” An ideal clinical note would contain all clinically important information represented in the dialogue. Also, just as in real-world scenario, a good clinical note could be short but pertinent. A note has poor coverage if someone reading only the note would be missing several important pieces of information about the clinical encounter. Give your score based on what is typically expected from a clinical note.

Rubric:

• Score of 1 (very poor): The note is missing a significant amount of important clinical information from the dialogue.
• Score of 3 (acceptable): The note is missing some minor piece of clinical information from the dialogue.
• Score of 5 (very good): The note covers all important clinical information from the dialogue, as you would expect from a real-world note.

7. Readiness for real-world use: For this axis, answer the question "which note is most ready for clinical use in the real-world scenario?" Answer this question imagine you are adopting AI-generated clinical notes for your everyday clinical work, and you will proofread and make edits to these notes before file into medical record. In this workflow, which note would you prefer the most? For example, this might be the note that meet your style and carries the most pertinent information without note bloating. Or a best note for you might be the one that requires the least amounts of edits from you (even if it contains some minor error). In other words, you can think of this as scoring the overall quality of the note for the workflow.

Rubric:

• Score of 1(very poor): The note is impossible to use or would require significant edits from you.
• Score of 3 (acceptable): The note requires some edits from you.
• Score of 5 (very good): The note is ready for clinical use without any further edits from you.

Appendix Table 9: Instructions for Physician Reader Study.
Instructions

For those notes that you gave a score of less than 5 for “Accuracy” or “Completeness”, please answer two questions: Suppose the note is used in the standard clinical workflow, what would be:

1. “… extent of possible harm?”

Rubric:
• Score of 1: None.
• Score of 2: Mild or moderate harm.
• Score of 3: Severe harm or death.

2. “… likelihood of possible harm?”

Rubric:
• Score of 1: Low.
• Score of 2: Medium.
• Score of 3: High.

Appendix Table 10: Harm Evaluation Instruction.

<table>
  <tr>
    <th>Type</th>
    <th>Models</th>
    <th>Cost / 1 Million Input Tokens (USD)</th>
    <th>Cost / 1 Million Output Tokens (USD)</th>
  </tr>
  <tr>
    <td rowspan="4">Proprietary</td>
    <td>Gemini 1.5 Pro</td>
    <td>3.5</td>
    <td>10.5</td>
  </tr>
  <tr>
    <td>Gemini 1.0 Pro</td>
    <td>0.5</td>
    <td>1.5</td>
  </tr>
  <tr>
    <td>GPT-4 Turbo</td>
    <td>10.0</td>
    <td>30.0</td>
  </tr>
  <tr>
    <td>GPT-3.5 Turbo</td>
    <td>1.0</td>
    <td>2.0</td>
  </tr>
  <tr>
    <td rowspan="3">Open-Source</td>
    <td>LLaMA-Clinic</td>
    <td>0.2</td>
    <td>0.2</td>
  </tr>
  <tr>
    <td>LLaMA-2 70B</td>
    <td>0.9</td>
    <td>0.9</td>
  </tr>
  <tr>
    <td>Mixtral 8x7B</td>
    <td>0.5</td>
    <td>0.5</td>
  </tr>
  <tr>
    <td></td>
    <td>Mixtral 8x22B</td>
    <td>1.2</td>
    <td>1.2</td>
  </tr>
</table>

Appendix Table 11: Pricing Information for Inference Cost Estimation. We sourced pricing information from the websites of Google AI (Goo, 2024), OpenAI (Ope, 2024), and Fireworks.ai (Fir, 2024) in May 2024 for on-demand API calls. The price of GPT-3.5 Turbo is based on the model gpt-3.5-turbo-1106. Fireworks.ai charges the same price for both input and output tokens.
Dialogue

Doctor: Hi, Martha. How are you?
Patient: I’m doing okay. How are you?
Doctor: I’m doing okay. So, I know the nurse told you about DAX. I’d like to tell DAX a little bit about you, okay?
Patient: Okay.
Doctor: Martha is a 50-year-old female with a past medical history significant for congestive heart failure, depression, and hypertension who presents for her annual exam. So, Martha, it’s been a year since I’ve seen you. How are you doing?
Patient: I’m doing well. I’ve been traveling a lot recently since things have, have gotten a bit lighter. And I got my vaccine, so I feel safer about traveling. I’ve been doing a lot of hiking. Uh, went to Washington last weekend to hike in northern cascades, like around the Mount Baker area.
Doctor: Nice. That’s great. I’m glad to hear that you’re staying active, you know. I just love this weather. I’m so happy the summer is over. I’m definitely more of a fall person.
Patient: Yes, fall foliage is the best.
Doctor: Yeah. Um, so tell me, how are you doing with the congestive heart failure? How are you doing watching your diet? I know we’ve talked about watching a low sodium diet. Are you doing okay with that?
Patient: I’ve been doing well with that. I resisted, as much, as I could, from the tater tots, you know, the soft pretzels, the salty foods that I, I love to eat. And I’ve been doing a really good job.
…
Doctor: Hey, Dragon, show me the blood pressure. So, yeah, looking at your blood pressure today here in the office, it is a little elevated. You know, it could just, you could just be nervous. Uh, let’s look at some of the past readings. Hey, Dragon, show me the blood pressure readings. Here we go. Uh, so they are running on the higher side. Um, you know, I, I do think that, you know, I’d like to see you take your medication a little bit more, so that we can get that under control a little bit better, okay?
Patient: Okay.
Doctor: So, I’m just gonna check out your heart and your lungs. And you know, let you know what I find, okay?
Patient: Okay.
Doctor: Okay. So, on your physical examination, you know, everything looks good. On your heart exam, I do appreciate a three out of six systolic ejection murmur, which I’ve heard in the past, okay? And on your lower extremities, I do appreciate one plus pitting edema, so you do have a little bit of fluid in your legs, okay?
Patient: Okay.
Doctor: Let’s go ahead, I wanna look at some of your results, okay? Hey, Dragon, show me the echocardiogram. So, this is the result of the echocardiogram that we did last year. It showed that you have that low-ish pumping function of your heart at about 45%. And it also shows some mitral regurgitation, that’s that heart murmur that I heard, okay?
…
Doctor: Um, so I wanna just go over a little bit about my assessment and my plan for you, okay? So, for your first problem your congestive heart failure, um, I wanna continue you on your current medications. But I do wanna increase your lisinopril to 40 milligrams a day, just because your blood pressure’s high. And you know, you are retaining a little bit of fluid. I also wanna start you on some Lasix, you know, 20 milligrams a day. And have you continue to watch your, your diet, okay?
Patient: Okay.
Doctor: I also wanna repeat another echocardiogram, okay?
Patient: All right.
Doctor: Hey, Dragon, order an echocardiogram. From a depression standpoint, it sounds like you’re doing really well with that. So, I’m, I’m really happy for you. I’m, I’m glad to see that you’re in therapy and you’re doing really well. I don’t feel the need to start you on any medications this year, unless you feel differently.
Patient: No, I feel the same way.
…

Appendix Table 12: An Example of Patient-Doctor Dialogue from ACI-BENCH with Encounter ID D2N001.
We corrected minor grammatical and spelling errors for display purposes.

Reviewer paper summaries: This work presents a comprehensive adaptation process for LLaMA-2 13B, incorporating continued pretraining on medical datasets, SFT, RLAIF, and RLHF. A novel DistillDirect method is proposed to ensure effective on-policy learning. The extensive experimental results demonstrate the final LLaMA-Clinic model achieves physician-level note quality across different scores.
Summary of strengths: 1. The authors propose a comprehensive adaptation pipeline for open-source LLMs with a novel on-policy reinforcement learning technique for aligning model outputs with physician standards on clinical note generation tasks. The pipeline is clearly illustrated in Figure 1, enhancing the application of LLMs in this particular domain.
2. The method achieves expert-level clinical note generation with strong empirical results supported by quantitative benchmarks (ROUGE scores) and qualitative physician evaluations, providing comprehensive validation. The experimental results are easy to read, as shown in the tables and figures. 
3. The authors systematically evaluate domain-specific adaptation using multiple datasets. The final model, LLaMA-Clinic, performs on par with physician-authored notes, demonstrating practical viability for deployment in healthcare institutions. 
4. The paper is thoroughly structured, with clear motivation, methodology, evaluation, and discussion, making it accessible and valuable for researchers and practitioners.
Summary of weaknesses: 1. The study relies on a relatively small dataset (<1,500 patient-doctor dialogues) for fine-tuning and evaluation. While the modified ACI-BENCH and the synthetic Dialogue-G dataset provide useful training signals, the lack of access to a larger real-world dataset limits the generalizability of the results.
2. The blinded physician evaluation is based on only 40 test cases, which may not fully represent real-world clinical variability.
3. While the study aims to promote open-source models, it still relies on Gemini 1.0 Pro as the teacher model in the DistillDirect approach. 
4. The authors acknowledge HIPAA compliance concerns but do not sufficiently address the broader ethical and legal challenges of using LLMs in clinical settings.
Comments, suggestions and typos: 1. It is not clear how to get the distilled dataset as discussed in Line 288. 
2. For this statement, "When comparing models pretrained with Discharge-long and Discharge-short, the latter consistently achieved higher ROUGE scores, despite exhibiting higher training loss during the pretraining phase.", the authors should have provided detailed and deeper analysis or discussions. What is the reason behind this? 
3. It is unclear how DistillDirect addresses the "frequently encountered instability" issues during training, as discussed in Line 409.
Overall assessment scores: 3.5