Fine-Tuning of Apertus for Biomedical Applications

LoRA and full-parameter fine-tuning of the open Apertus 8B and 70B language models on MedQA medical exam questions, run with DeepSpeed on the ALPS cluster.

Code on GitHub · Large Scale AI Engineering, ETH Zürich (autumn 2025) · Advisor: Dr. Imanol Schlag

Group members: Linus Baumberger, Wiona Glänzer, Andrei Girjoaba and Omkar Nitsure.

Introduction

Fine-tuning of Apertus

Domain specific fine-tuning adapts general-purpose language models to a specific context by continuing training with examples from this context. By focusing post-training on a particular domain, even smaller open-source models may reach performances comparable to those of larger proprietary models in specialized tasks. An example of such fine-tuning of open models in the biomedical domain is Clinical Camel, which was fine-tuned from LLaMA-2 and surpassed GPT-3.5 in performance on several benchmarks within clinical research [1].

The recently published Apertus model is a fully open-source large language model, which was trained with a focus on representing multiple languages. Both model weights and data preparation pipelines for pretraining data have been made publicly available [2]. This allows users insight into the specific data the model was trained on and may aid in the study of biases introduced in model training. It may make Apertus particularly suited for critical domains such as healthcare and law, where biases in model outputs could have catastrophic effects. However, domain-specific performance will still remain the most important criterion for model-selection and therefore the goal of our project was to fine-tune Apertus for a task within the biomedical domain.

To efficiently fine-tune the model we apply Low-Rank Adaptation (LoRA). Instead of optimizing entire full-rank weight matrices, LoRA uses low-rank decomposition. Let \(W_0 \in \mathbb{R}^{d,k}\) be a pre-trained weight matrix. Then the updated weight matrix becomes \(W_0 + \Delta W = W_0 + BA\) with \(B \in \mathbb{R}^{d,r}\), \(A \in \mathbb{R}^{r,k}\) and \(r \ll \min(d,k)\) [3]. Fine-tuning significantly fewer weights allows faster fine-tuning using smaller GPU-setups.

The task and dataset we chose for fine-tuning is described in the next section.

The MedQA dataset

The MedQA dataset is a collection of free-form multiple choice questions in the medical domain [4]. The 61,097 questions consist of case reports and answer choices such as a next step in the diagnostic process, a most likely diagnosis or a treatment suggestion. Each question has one correct and three incorrect answer choices. While the original dataset was collected from National Medical Board Exams in the US, China and Taiwan and accordingly contains questions in English, simplified Chinese, and traditional Chinese, we only used the English subset of the dataset for now. Extending the fine-tuning also to other languages would be an interesting extension of the project because the Apertus model was developed with a focus on multilingual performance. An example question is shown in Figure 1.

<|user_start|>
Answer the following multiple choice question about medical knowledge.

A 37-year-old female with a history of type II diabetes mellitus presents to
the emergency department complaining of blood in her urine, left-sided flank
pain, nausea, and fever. [...] Which of the following is the next best step in
management?

Options:
A: Obtain an abdominal CT scan
B: Obtain a urine analysis and urine culture
C: Begin intravenous treatment with ceftazidime
D: No treatment is necessary

Answer:
<|user_end|><|assistant_start|>
B: Obtain a urine analysis and urine culture
Figure 1: MedQA instruction tuning format. A training data instance shows the format in which the multiple choice question is delivered to Apertus (the user turn) and where the answer is expected (the assistant turn).

We chose to use this dataset for our project, because MedQA is a relatively difficult benchmark in the biomedical domain. Although it was already published in 2020, even relatively advanced language models still struggle with the questions. This also gives the Apertus model room to improve through fine-tuning. In an analysis by vals.ai, the best performing proprietary model o1 (OpenAI) reached an accuracy of 96.5% and the best open weight model DeepSeek V3.2 (Thinking) reached an accuracy of 93.92%, while GPT 3.5 only had an accuracy of 51.13% [5].

We used this version of the dataset published on Hugging Face.

Fine-tuning setup on the ALPS cluster

We based our fine-tuning setup on previous work by Kaustubh Ponkshe and Raghav Singhal, who have made fine-tuning recipes for Apertus available on GitHub [6]. They provide scripts for fine-tuning both the 8 billion and 70 billion parameter versions of Apertus either with LoRA or by fine-tuning all weights.

We use a standard data loader from the datasets library to load the raw MedQA dataset. Then, we apply a custom formatter that adheres to the standard Chat API shown in Figure 1. The formatter is easily extendable to other datasets. While the training objective is the next token prediction loss, we focused on the multiple-choice accuracy, i.e. what percentage of questions in the evaluation dataset were answered correctly, for evaluation.

LoRA fine-tuning of the 8 billion parameter model is possible with just 1 GPU. However for the full fine-tuning of the 8B model, we use a multi-GPU setup and LoRA fine-tuning of the 70 billion parameter model also requires a multi-GPU setup due to a large parameter size leading to substantial increase in the VRAM requirements to maintain optimizer states.

We used DeepSpeed for this multi-GPU training setup where we used 4 nodes with 4 GPUs each. There are 4 processes running on each node, one per GPU. We used mixed-precision training (bfloat16) and stage 3 optimization to minimize GPU memory usage and communication overhead. This allowed us to efficiently use the available memory to fit model parameters, optimizer states and a large enough training batch for stable learning. Additionally, we disable offloading to CPU to reduce transfer latency and make optimal use of the GPU. Contiguous gradients are used to avoid fragmentation during gradient reduction and gradient communication overlap with computation improves throughput.

To track training and evaluation metrics, we set up a connection to Weights and Biases. We logged all standard metrics, as well as the MedQA loss. We also performed hyperparameter optimization with Weights and Biases Sweeps. For optimization, we limited the number of steps to at most 200. One training run with 100 steps took about 15 minutes and we ran 50 training runs, modifying the learning rate (between 5e-6 and 5e-4), the warmup ratio (0.0 to 0.1), the LoRA r (8, 16, 32, 64), LoRA \(\alpha\) (16, 32, 64, 128, 256), LoRA dropout (0.0, 0.05, 0.1) and gradient accumulation steps (1, 2, 4, 8).

Parallel-coordinates plot of all 50 sweep runs: gradient accumulation, learning rate, LoRA alpha, dropout, r, warmup ratio and validation accuracy
Validation accuracy against LoRA alpha
Validation accuracy against LoRA r
Validation accuracy against LoRA dropout
Figure 2: Hyperparameter tuning for LoRA fine-tuning of Apertus-8B; each model was trained for 100 steps with an effective batch size of 16. (a) Overview of all tested parameters (top left), (b) accuracy vs. LoRA alpha (top right), (c) accuracy vs. LoRA r (bottom left), (d) accuracy vs. LoRA dropout (bottom right).

As can be seen in Figure 2 (a), there was no clear trend that showed stronger effects of certain parameters or much better performance for specific combinations. The best performing model used learning rate = 3.07e-4, LoRA dropout = 0.05, LoRA r = 64, LoRA alpha = 128, gradient accumulation steps = 8, warmup ratio = 9.29e-2 and is indicated by the dark purple dot in Figure 2 (b)–(d). It is quite intuitive that the largest value of r = 64 (rank of the low-rank matrix adapter used for fine-tuning) achieved the best performance among the values we tried, as it has the largest number of trainable parameters (hence highest compute requirements). A reduction in performance for the highest value of alpha (256) might indicate that giving too much weight to adapter weights compared to the original weights caused a large enough divergence from the original model to degrade some of its knowledge-base.

Results

For training and evaluation of models, we use a fixed 80/10/10 train/test/eval split. Without fine-tuning, the base Apertus 8B model reached a multiple-choice accuracy of 46.7%, while the larger Apertus 70B base model achieved 51.2% on the held-out test set. These baseline results are consistent with the expectation that larger models generally perform better on knowledge-intensive tasks, though both remain substantially below state-of-the-art proprietary models.

Afterwards, we evaluate fine-tuning with three distinct setups. We train for 500 steps and report the best achieved validation accuracy:

  1. 8B LoRA fine-tuning @ step 500 (56.8% acc.)
  2. 8B full parameter fine-tuning @ step 300 (60.6% acc.)
  3. 70B LoRA fine-tuning @ step 125 (65.8% acc.)

Hyperparameter optimization was only performed for LoRA fine-tuning of the 8B model and the same training parameters also improved the performance of 70B LoRA fine-tuning compared to default parameters.

In Figure 3 we report the Weights and Biases runs for the three setups described above. In Figure 4 we report the loss and the mean token accuracy during training. We note that the 70B model and the full parameter fine-tuning rapidly risk overfitting on the data. This can be seen from the training loss that is still decreasing and the mean token accuracy that is still increasing at step 500, while the validation accuracy stops improving early on.

Validation MedQA accuracy over 500 training steps for 8B full fine-tuning, 8B LoRA and 70B LoRA
Figure 3: MedQA MCQ accuracy metric during validation across 500 training steps.
Training loss over 500 steps for the three setups
Mean token accuracy over 500 training steps for the three setups
Figure 4: Training metrics showing the loss convergence (left) and mean token accuracy (right) across 500 training steps.
Test accuracy on MedQA: Apertus 8B and 70B base and LoRA models compared with GPT-4o Mini, GPT-4o and GPT-5.1
Figure 5: MedQA MCQ accuracy metric during testing over the test split of the MedQA dataset.

Discussion

Our fine-tuning experiments demonstrate that domain-specific adaptation can substantially improve Apertus’s performance on medical question answering. The Apertus 8B model improved from a baseline accuracy of 46.7% to 56.6% after LoRA fine-tuning with optimized hyperparameters, representing a gain of approximately 10 percentage points. Similarly, the 70B model improved from 51.2% to 60.8% with LoRA fine-tuning, confirming that the benefits of domain adaptation scale with model size.

However, a significant performance gap remains between the fine-tuned Apertus models and current proprietary systems. GPT-4o achieves 87.4% accuracy on the same test split, while GPT-5.1 reaches 88.9%. Even the smaller GPT-4o Mini (73.8%) substantially outperforms our best fine-tuned model. This gap likely reflects differences in pre-training data scale, model architecture, and potentially the inclusion of medical knowledge during the pre-training phase of these proprietary models.

As we quickly observed overfitting of the model to the training dataset, performance could potentially be improved by fine-tuning on a larger and more diverse dataset. By manually inspecting model outputs, we observed that the model successfully adapts to the multiple-choice format but often selects incorrect answer choices. This suggests that the model lacks the underlying medical knowledge required to distinguish between plausible options. Therefore, expanding the fine-tuning data to include medical textbooks, clinical guidelines, or other knowledge-rich sources could help the model acquire the necessary domain expertise. Such an approach would also avoid the methodological limitation of fine-tuning on a subset of the benchmark used for evaluation.

Limitations. Our study has several limitations. First, we did not perform cross-fold validation, meaning our reported accuracies may be subject to variance depending on the specific train-test split. Second, due to computational constraints, we only performed extensive hyperparameter tuning for the 8B model with LoRA; the 70B model and full fine-tuning setups may benefit from further optimization. Third, we focused exclusively on the English subset of MedQA, leaving the multilingual capabilities of Apertus unexplored.

Future Work. Several directions could extend this work. Incorporating additional biomedical datasets, such as PubMedQA, MedMCQA, or medical textbook corpora, could provide more diverse training signal and reduce overfitting. Exploring the multilingual subsets of MedQA would leverage Apertus’s intended strength in cross-lingual performance. Finally, investigating alternative parameter-efficient fine-tuning methods such as QLoRA or adapter layers could further improve the trade-off between computational cost and model performance.

References

[1] A. Toma, P. R. Lawler, J. Ba, R. G. Krishnan, B. B. Rubin, and B. Wang, “Clinical Camel: An open expert-level medical language model with dialogue-based knowledge encoding,” arXiv:2305.12031, 2023.

[2] Project Apertus, “Apertus: Democratizing open and compliant LLMs for global language environments,” arXiv:2509.14233, 2025.

[3] E. Hu, Y. Shen, P. Wallis, Z. Allen-Zhu, Y. Li, S. Wang, L. Wang, and W. Chen, “LoRA: Low-rank adaptation of large language models,” arXiv:2106.09685, 2021.

[4] D. Jin, E. Pan, N. Oufattole, W.-H. Weng, H. Fang, and P. Szolovits, “What disease does this patient have? A large-scale open domain question answering dataset from medical exams,” Applied Sciences, vol. 11, no. 14, 6421, 2021, doi:10.3390/app11146421.

[5] vals.ai, “MedQA benchmark,” 2025, vals.ai/benchmarks/medqa.

[6] K. Ponkshe and R. Singhal, “Apertus fine-tuning recipes,” GitHub, 2025, github.com/swiss-ai/Apertus-finetuning-recipes.