Teaching LLMs How to Learn with Contextual Fine-Tuning

Younwoo Choi *
Muhammad Adil Asif *
Ziwen Han
John Willes
Rahul G. Krishnan
University of Toronto
Vector Institute

ICLR 2025

*Equal contribution, Work conducted while at the Vector Institute

Diagram of the transformer deep learning architecture.

Abstract

Prompting Large Language Models (LLMs), or providing context on the expected model of operation, is an effective way to steer the outputs of such models to satisfy human desiderata after they have been trained. But in rapidly evolving domains, there is often need to fine-tune LLMs to improve either the kind of knowledge in their memory or their abilities to perform open ended reasoning in new domains. When human’s learn new concepts, we often do so by linking the new material that we are studying to concepts we have already learned before. To that end, we ask, “can prompting help us teach LLMs how to learn”. In this work, we study a novel generalization of instruction tuning, called contextual fine-tuning, to fine-tune LLMs. Our method leverages instructional prompts designed to mimic human cognitive strategies in learning and problem-solving to guide the learning process during training, aiming to improve the model’s interpretation and understanding of domain-specific knowledge. We empirically demonstrate that this simple yet effective modification improves the ability of LLMs to be fine-tuned rapidly on new datasets both within the medical and financial domains.

Overview

Contextual Fine-Tuning (CFT) is a novel approach that blends in-context learning with gradient-based learning to improve how Large Language Models (LLMs) learn domain-specific knowledge. Unlike traditional continued pre-training or instruction fine-tuning, CFT uses contextual prompts to guide the model’s learning process.

OpenMedText

To test domain adaptation in a challenging setting, we curated a biomedical dataset of 121,489 biomedical journal articles (MDPI) and 29 open-source medical textbooks. We release OpenMedText as a resource for domain adaptation research.

Experiments

We evaluate on both medical and financial tasks to show the effectiveness of CFT.

Medical tasks include subsets of MMLU including Anatomy, Clinical Knowledge, College Biology, College Medicine, Medical Genetics, Professional Medicine, and the MedQA professional exam dataset.

Financial tasks include FiQA sentiment analysis, MultiFin headline classification, and Causal20.

Setup

Results (Medical Domain)

7B Model Results

Model (7B)AnatomyClinical KnowledgeCollege BiologyCollege MedicineMedical GeneticsProfessional MedicineMedQAAverage
Chat44.0746.7948.6139.0249.0048.9038.9645.05
Chat (CPT)45.1947.1749.3143.9350.5046.3239.2845.96
Chat (CFT)48.1548.8752.0844.2254.0046.6940.6547.81
AdaptLLM44.4547.3648.2739.6045.0038.6137.1242.92

13B Model Results

Model (13B)AnatomyClinical KnowledgeCollege BiologyCollege MedicineMedical GeneticsProfessional MedicineMedQAAverage
Chat51.8556.6054.1746.8263.5056.9945.3353.61
Chat (CPT)50.3760.0055.9050.5862.0057.3543.9554.31
Chat (CFT)53.3363.2157.9956.3562.5057.7244.8556.56

Results (Financial Domain)

7B Model Results

Model (7B)FiQA (F1)Causal20 (F1)MultiFin (F1)Average
Chat56.4090.4038.7461.48
Chat (CPT)62.5390.1638.2363.64
Chat (CFT)67.6990.1746.0167.96

13B Model Results

Model (13B)FiQA (F1)Causal20 (F1)MultiFin (F1)Average
Chat61.1884.7745.8163.92
Chat (CPT)66.9690.0645.3367.45
Chat (CFT)70.5589.8750.9470.45

BibTeX citation

    @inproceedings{
choi2025teaching,
title={Teaching {LLM}s How To Learn with Contextual Fine-Tuning},
author={Younwoo Choi and Muhammad Adil Asif and Ziwen Han and John Willes and Rahul G. Krishnan},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://arxiv.org/abs/2503.09032}
}