> For the complete documentation index, see [llms.txt](https://docs.aisl.science/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisl.science/learning-and-resources/training-apertus.md).

# Training Apertus

Guide for supervised fine-tuning Apertus 1.5, starting on Kaggle and scaling text-focused training workflows on CSCS Clariden.

Use the [Apertus 1.5 SFT notebook on Kaggle](https://www.kaggle.com/code/andreasmartinch/sft-apertus-v1-5-8b-hack-apertus-template) as the common notebook for Kaggle and CSCS Clariden.

The notebook supports three training methods:

* **QLoRA** — validated on Kaggle and CSCS Clariden;
* **LoRA** — validated on CSCS Clariden;
* **Full SFT** — validated on CSCS Clariden with DeepSpeed ZeRO-3.

Select the method in the notebook:

```python
TRAINING_METHOD = "qlora"
# "qlora" | "lora" | "full"
```

## Recommended workflow

1. Define or reserve a held-out evaluation set.
2. Evaluate the base model as a baseline.
3. Fine-tune on the training data.
4. Evaluate the adapted model on the same held-out examples.
5. Compare loss, task behaviour, format adherence and task-specific metrics.

Start with QLoRA on Kaggle using 2 x T4 GPUs. Once the complete workflow works, use the same notebook on CSCS Clariden when more compute is needed.

## Text-focused checkpoint

For the current teaching workflow, use [`andreasmartin/apertus-v1.5-8b-text`](https://huggingface.co/andreasmartin/apertus-v1.5-8b-text).

## CSCS Clariden

For larger experiments, use the same notebook through the [Clariden JupyterHub](https://jupyter-clariden.cscs.ch/). QLoRA, LoRA and Full SFT have been validated in the current JupyterHub workflow. The tested setup and CSCS-specific notes are documented in [Training Apertus on CSCS Clariden](https://docs.aisl.science/learning-and-resources/training-apertus/cscs-clariden).

## Credentials

On Kaggle, use Kaggle Secrets. On CSCS JupyterLab, the notebook can ask interactively for missing Hugging Face and Weights & Biases credentials.

Do not place tokens, passwords, or private keys directly in notebook source code, repositories, screenshots, or shared chats.

## Related resources

* [Apertus 1.5 SFT notebook on Kaggle](https://www.kaggle.com/code/andreasmartinch/sft-apertus-v1-5-8b-hack-apertus-template)
* [Training Apertus on CSCS Clariden](https://docs.aisl.science/learning-and-resources/training-apertus/cscs-clariden)
* [Apertus 1.5 8B text-focused checkpoint](https://huggingface.co/andreasmartin/apertus-v1.5-8b-text)
* [Official Apertus 1.5 8B model](https://huggingface.co/swiss-ai/Apertus-v1.5-8B)
* [Hack Apertus](https://hackapertus.ch/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aisl.science/learning-and-resources/training-apertus.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
