What Can Transformers Learn In-Context? A Case Study of Simple Function Classes. Garg, S., Tsipras, D., Liang, P., & Valiant, G. August, 2023. arXiv:2208.01066 [cs]
Paper doi abstract bibtex In-context learning refers to the ability of a model to condition on a prompt sequence consisting of in-context examples (input-output pairs corresponding to some task) along with a new query input, and generate the corresponding output. Crucially, in-context learning happens only at inference time without any parameter updates to the model. While large language models such as GPT-3 exhibit some ability to perform in-context learning, it is unclear what the relationship is between tasks on which this succeeds and what is present in the training data. To make progress towards understanding in-context learning, we consider the well-defined problem of training a model to in-context learn a function class (e.g., linear functions): that is, given data derived from some functions in the class, can we train a model to in-context learn "most" functions from this class? We show empirically that standard Transformers can be trained from scratch to perform in-context learning of linear functions – that is, the trained model is able to learn unseen linear functions from in-context examples with performance comparable to the optimal least squares estimator. In fact, in-context learning is possible even under two forms of distribution shift: (i) between the training data of the model and inference-time prompts, and (ii) between the in-context examples and the query input during inference. We also show that we can train Transformers to in-context learn more complex function classes – namely sparse linear functions, two-layer neural networks, and decision trees – with performance that matches or exceeds task-specific learning algorithms. Our code and models are available at https://github.com/dtsip/in-context-learning .
@misc{garg_what_2023,
title = {What {Can} {Transformers} {Learn} {In}-{Context}? {A} {Case} {Study} of {Simple} {Function} {Classes}},
shorttitle = {What {Can} {Transformers} {Learn} {In}-{Context}?},
url = {http://arxiv.org/abs/2208.01066},
doi = {10.48550/arXiv.2208.01066},
abstract = {In-context learning refers to the ability of a model to condition on a prompt sequence consisting of in-context examples (input-output pairs corresponding to some task) along with a new query input, and generate the corresponding output. Crucially, in-context learning happens only at inference time without any parameter updates to the model. While large language models such as GPT-3 exhibit some ability to perform in-context learning, it is unclear what the relationship is between tasks on which this succeeds and what is present in the training data. To make progress towards understanding in-context learning, we consider the well-defined problem of training a model to in-context learn a function class (e.g., linear functions): that is, given data derived from some functions in the class, can we train a model to in-context learn "most" functions from this class? We show empirically that standard Transformers can be trained from scratch to perform in-context learning of linear functions -- that is, the trained model is able to learn unseen linear functions from in-context examples with performance comparable to the optimal least squares estimator. In fact, in-context learning is possible even under two forms of distribution shift: (i) between the training data of the model and inference-time prompts, and (ii) between the in-context examples and the query input during inference. We also show that we can train Transformers to in-context learn more complex function classes -- namely sparse linear functions, two-layer neural networks, and decision trees -- with performance that matches or exceeds task-specific learning algorithms. Our code and models are available at https://github.com/dtsip/in-context-learning .},
urldate = {2024-12-30},
publisher = {arXiv},
author = {Garg, Shivam and Tsipras, Dimitris and Liang, Percy and Valiant, Gregory},
month = aug,
year = {2023},
note = {arXiv:2208.01066 [cs]},
keywords = {Computer Science - Computation and Language, Computer Science - Machine Learning},
}
Downloads: 0
{"_id":"X24bGoZiT4HLrjtsJ","bibbaseid":"garg-tsipras-liang-valiant-whatcantransformerslearnincontextacasestudyofsimplefunctionclasses-2023","author_short":["Garg, S.","Tsipras, D.","Liang, P.","Valiant, G."],"bibdata":{"bibtype":"misc","type":"misc","title":"What Can Transformers Learn In-Context? A Case Study of Simple Function Classes","shorttitle":"What Can Transformers Learn In-Context?","url":"http://arxiv.org/abs/2208.01066","doi":"10.48550/arXiv.2208.01066","abstract":"In-context learning refers to the ability of a model to condition on a prompt sequence consisting of in-context examples (input-output pairs corresponding to some task) along with a new query input, and generate the corresponding output. Crucially, in-context learning happens only at inference time without any parameter updates to the model. While large language models such as GPT-3 exhibit some ability to perform in-context learning, it is unclear what the relationship is between tasks on which this succeeds and what is present in the training data. To make progress towards understanding in-context learning, we consider the well-defined problem of training a model to in-context learn a function class (e.g., linear functions): that is, given data derived from some functions in the class, can we train a model to in-context learn \"most\" functions from this class? We show empirically that standard Transformers can be trained from scratch to perform in-context learning of linear functions – that is, the trained model is able to learn unseen linear functions from in-context examples with performance comparable to the optimal least squares estimator. In fact, in-context learning is possible even under two forms of distribution shift: (i) between the training data of the model and inference-time prompts, and (ii) between the in-context examples and the query input during inference. We also show that we can train Transformers to in-context learn more complex function classes – namely sparse linear functions, two-layer neural networks, and decision trees – with performance that matches or exceeds task-specific learning algorithms. Our code and models are available at https://github.com/dtsip/in-context-learning .","urldate":"2024-12-30","publisher":"arXiv","author":[{"propositions":[],"lastnames":["Garg"],"firstnames":["Shivam"],"suffixes":[]},{"propositions":[],"lastnames":["Tsipras"],"firstnames":["Dimitris"],"suffixes":[]},{"propositions":[],"lastnames":["Liang"],"firstnames":["Percy"],"suffixes":[]},{"propositions":[],"lastnames":["Valiant"],"firstnames":["Gregory"],"suffixes":[]}],"month":"August","year":"2023","note":"arXiv:2208.01066 [cs]","keywords":"Computer Science - Computation and Language, Computer Science - Machine Learning","bibtex":"@misc{garg_what_2023,\n\ttitle = {What {Can} {Transformers} {Learn} {In}-{Context}? {A} {Case} {Study} of {Simple} {Function} {Classes}},\n\tshorttitle = {What {Can} {Transformers} {Learn} {In}-{Context}?},\n\turl = {http://arxiv.org/abs/2208.01066},\n\tdoi = {10.48550/arXiv.2208.01066},\n\tabstract = {In-context learning refers to the ability of a model to condition on a prompt sequence consisting of in-context examples (input-output pairs corresponding to some task) along with a new query input, and generate the corresponding output. Crucially, in-context learning happens only at inference time without any parameter updates to the model. While large language models such as GPT-3 exhibit some ability to perform in-context learning, it is unclear what the relationship is between tasks on which this succeeds and what is present in the training data. To make progress towards understanding in-context learning, we consider the well-defined problem of training a model to in-context learn a function class (e.g., linear functions): that is, given data derived from some functions in the class, can we train a model to in-context learn \"most\" functions from this class? We show empirically that standard Transformers can be trained from scratch to perform in-context learning of linear functions -- that is, the trained model is able to learn unseen linear functions from in-context examples with performance comparable to the optimal least squares estimator. In fact, in-context learning is possible even under two forms of distribution shift: (i) between the training data of the model and inference-time prompts, and (ii) between the in-context examples and the query input during inference. We also show that we can train Transformers to in-context learn more complex function classes -- namely sparse linear functions, two-layer neural networks, and decision trees -- with performance that matches or exceeds task-specific learning algorithms. Our code and models are available at https://github.com/dtsip/in-context-learning .},\n\turldate = {2024-12-30},\n\tpublisher = {arXiv},\n\tauthor = {Garg, Shivam and Tsipras, Dimitris and Liang, Percy and Valiant, Gregory},\n\tmonth = aug,\n\tyear = {2023},\n\tnote = {arXiv:2208.01066 [cs]},\n\tkeywords = {Computer Science - Computation and Language, Computer Science - Machine Learning},\n}\n\n\n\n\n\n\n\n","author_short":["Garg, S.","Tsipras, D.","Liang, P.","Valiant, G."],"key":"garg_what_2023","id":"garg_what_2023","bibbaseid":"garg-tsipras-liang-valiant-whatcantransformerslearnincontextacasestudyofsimplefunctionclasses-2023","role":"author","urls":{"Paper":"http://arxiv.org/abs/2208.01066"},"keyword":["Computer Science - Computation and Language","Computer Science - Machine Learning"],"metadata":{"authorlinks":{}}},"bibtype":"misc","biburl":"https://bibbase.org/zotero/abhishek-p","dataSources":["h7kKWXpJh2iaX92T5"],"keywords":["computer science - computation and language","computer science - machine learning"],"search_terms":["transformers","learn","context","case","study","simple","function","classes","garg","tsipras","liang","valiant"],"title":"What Can Transformers Learn In-Context? A Case Study of Simple Function Classes","year":2023}