Fine-tuning vs. In-context Learning in Large Language Models: A Formal Language Learning Perspective

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Ghosh, Bishwamittra, Das, Soumi, Speicher, Till, Wu, Qinyuan, Khan, Mohammad Aflah, Garg, Deepak, Gummadi, Krishna P., Terzi, Evimaria
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916022241460224
author Ghosh, Bishwamittra
Das, Soumi
Speicher, Till
Wu, Qinyuan
Khan, Mohammad Aflah
Garg, Deepak
Gummadi, Krishna P.
Terzi, Evimaria
author_facet Ghosh, Bishwamittra
Das, Soumi
Speicher, Till
Wu, Qinyuan
Khan, Mohammad Aflah
Garg, Deepak
Gummadi, Krishna P.
Terzi, Evimaria
contents Large language models (LLMs) operate in two fundamental learning modes - fine-tuning (FT) and in-context learning (ICL) - raising key questions about which mode yields greater language proficiency and whether they differ in their inductive biases. Prior studies comparing FT and ICL have yielded mixed and inconclusive results due to inconsistent experimental setups. To enable a rigorous comparison, we propose a formal language learning task - offering precise language boundaries, controlled string sampling, and no data contamination - and introduce a discriminative test for language proficiency, where an LLM succeeds if it assigns higher generation probability to in-language strings than to out-of-language strings. Empirically, we find that: (a) FT has greater language proficiency than ICL on in-distribution generalization, but both perform equally well on out-of-distribution generalization. (b) Their inductive biases, measured by the correlation in string generation probabilities, are similar when both modes partially learn the language but diverge at higher proficiency levels. (c) Unlike FT, ICL performance differs substantially across models of varying sizes and families and is sensitive to the token vocabulary of the language. Thus, our work demonstrates the promise of formal languages as a controlled testbed for evaluating LLMs, behaviors that are difficult to isolate in natural language datasets. Our source code is available at https://github.com/bishwamittra/formallm.
format Preprint
id arxiv_https___arxiv_org_abs_2604_23267
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Fine-tuning vs. In-context Learning in Large Language Models: A Formal Language Learning Perspective
Ghosh, Bishwamittra
Das, Soumi
Speicher, Till
Wu, Qinyuan
Khan, Mohammad Aflah
Garg, Deepak
Gummadi, Krishna P.
Terzi, Evimaria
Computation and Language
Machine Learning
Large language models (LLMs) operate in two fundamental learning modes - fine-tuning (FT) and in-context learning (ICL) - raising key questions about which mode yields greater language proficiency and whether they differ in their inductive biases. Prior studies comparing FT and ICL have yielded mixed and inconclusive results due to inconsistent experimental setups. To enable a rigorous comparison, we propose a formal language learning task - offering precise language boundaries, controlled string sampling, and no data contamination - and introduce a discriminative test for language proficiency, where an LLM succeeds if it assigns higher generation probability to in-language strings than to out-of-language strings. Empirically, we find that: (a) FT has greater language proficiency than ICL on in-distribution generalization, but both perform equally well on out-of-distribution generalization. (b) Their inductive biases, measured by the correlation in string generation probabilities, are similar when both modes partially learn the language but diverge at higher proficiency levels. (c) Unlike FT, ICL performance differs substantially across models of varying sizes and families and is sensitive to the token vocabulary of the language. Thus, our work demonstrates the promise of formal languages as a controlled testbed for evaluating LLMs, behaviors that are difficult to isolate in natural language datasets. Our source code is available at https://github.com/bishwamittra/formallm.
title Fine-tuning vs. In-context Learning in Large Language Models: A Formal Language Learning Perspective
topic Computation and Language
Machine Learning
url https://arxiv.org/abs/2604.23267