{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/mlps-learn-in-context","title":"MLPs Learn In-Context on Regression and Classification Tasks","arxiv_id":"2405.15618","date":"2024-05-24","proceeding":null,"authors":["William L. Tong","Cengiz Pehlevan"],"abstract":"In-context learning (ICL), the remarkable ability to solve a task from only input exemplars, is often assumed to be a unique hallmark of Transformer models. By examining commonly employed synthetic ICL tasks, we demonstrate that multi-layer perceptrons (MLPs) can also learn in-context. Moreover, MLPs, and the closely related MLP-Mixer models, learn in-context comparably with Transformers under the same compute budget in this setting. We further show that MLPs outperform Transformers on a series of classical tasks from psychology designed to test relational reasoning, which are closely related to in-context classification. These results underscore a need for studying in-context learning beyond attention-based architectures, while also challenging prior arguments against MLPs' ability to solve relational tasks. Altogether, our results highlight the unexpected competence of MLPs in a synthetic setting, and support the growing interest in all-MLP alternatives to Transformer architectures. It remains unclear how MLPs perform against Transformers at scale on real-world tasks, and where a performance gap may originate. We encourage further exploration of these architectures in more complex settings to better understand the potential comparative advantage of attention-based schemes.","url_abs":"https://arxiv.org/abs/2405.15618v3","url_pdf":"https://arxiv.org/pdf/2405.15618v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"mlps-learn-in-context","repo_url":"https://github.com/wtong98/mlp-icl","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"jax","reach":null},{"paper_slug":"mlps-learn-in-context","repo_url":"https://github.com/wtong98/equality-reasoning","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"inductive-bias","task_name":"Inductive Bias"},{"task_slug":"relational-reasoning","task_name":"Relational Reasoning"},{"task_slug":"regression-1","task_name":"regression"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"average-pooling","method_name":"Average Pooling"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"global-average-pooling","method_name":"Global Average Pooling"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"mlp-mixer","method_name":"MLP-Mixer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2405.15618","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.15618"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/wtong98/mlp-icl","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/wtong98/equality-reasoning","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":2,"unverified":14},"by_repo_kind":{"official":{"samples":2,"ran":2,"repositories":1},"listed":{"samples":14,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"f61ae07d4631d9b1","entry":"extract_plot_vals","repo":"wtong98/mlp-icl","repo_kind":"official","path":"experiment/12_1_varlen.py","file_url":"https://github.com/wtong98/mlp-icl/blob/HEAD/experiment/12_1_varlen.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f61ae07d4631d9b1"}},{"code_sha256_prefix":"d4db75712f9f1fac","entry":"parse_act_fn","repo":"wtong98/mlp-icl","repo_kind":"official","path":"model/mlp.py","file_url":"https://github.com/wtong98/mlp-icl/blob/HEAD/model/mlp.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d4db75712f9f1fac"}},{"code_sha256_prefix":"319a98623566a232","entry":"batch_choice","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"task/same_different.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/task/same_different.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"319a98623566a232"}},{"code_sha256_prefix":"5fa631733bb450dd","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/15_sd_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/15_sd_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5fa631733bb450dd"}},{"code_sha256_prefix":"b5f3a19b7ce47734","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/16_vision_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/16_vision_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b5f3a19b7ce47734"}},{"code_sha256_prefix":"b5e9a9e2ffa64603","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/16_vision_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/16_vision_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b5e9a9e2ffa64603"}},{"code_sha256_prefix":"ffb78190c259516d","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/16_vision_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/16_vision_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ffb78190c259516d"}},{"code_sha256_prefix":"90313b609b4c6424","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/17_misc_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/17_misc_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"90313b609b4c6424"}},{"code_sha256_prefix":"16f5d571b9bf0cb4","entry":"extract_plot_vals","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/17_misc_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/17_misc_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"16f5d571b9bf0cb4"}},{"code_sha256_prefix":"7b4ee056d6210466","entry":"gen_patches","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"task/same_different.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/task/same_different.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7b4ee056d6210466"}},{"code_sha256_prefix":"da15b3a0a1c5d885","entry":"is_match","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/18_rich_val_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/18_rich_val_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"da15b3a0a1c5d885"}},{"code_sha256_prefix":"1f826f6239ea4963","entry":"parse_act_fn","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"model/mlp.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/model/mlp.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1f826f6239ea4963"}},{"code_sha256_prefix":"1740a9257cba0423","entry":"pred_rich_acc","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"experiment/15_sd_clean.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/experiment/15_sd_clean.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1740a9257cba0423"}},{"code_sha256_prefix":"56b5496fff97f2a9","entry":"split_cases","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"common.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"56b5496fff97f2a9"}},{"code_sha256_prefix":"7664f6068e128909","entry":"summon_dir","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"common.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7664f6068e128909"}},{"code_sha256_prefix":"15eb159df9aef8e0","entry":"t","repo":"wtong98/equality-reasoning","repo_kind":"listed","path":"common.py","file_url":"https://github.com/wtong98/equality-reasoning/blob/HEAD/common.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"15eb159df9aef8e0"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}