Language Models of Code are Few-Shot Commonsense Learners
On the map: LLM reasoning → Reasoning benchmarks and evaluation
Abstract (arXiv)
We address the general task of structured commonsense reasoning: given a natural language input, the goal is to generate a graph such as an event -- or a reasoning-graph. To employ large language models (LMs) for this task, existing approaches ``serialize'' the output graph as a flat list of nodes and edges. Although feasible, these serialized graphs strongly deviate from the natural language corpora that LMs were pre-trained on, hindering LMs from generating them correctly. In this paper, we show that when we instead frame structured commonsense reasoning tasks as code generation tasks, pre-trained LMs of code are better structured commonsense reasoners than LMs of natural language, even when the downstream task does not involve source code at all. We demonstrate our approach across three diverse structured commonsense reasoning tasks. In all these natural language tasks, we show that using our approach, a code generation LM (CODEX) outperforms natural-LMs that are fine-tuned on the target task (e.g., T5) and other strong LMs such as GPT-3 in the few-shot setting.
Key facts. Cited by 160 papers in the map (data through 7 Oct 2026). Placed in Reasoning benchmarks and evaluation, one of 17 directions in LLM reasoning. Builds on 26 of its 39 references that are in the map. First posted on arXiv 13 Oct 2022.
Builds on
26 of 39 references.
References · 26
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2021Training Verifiers to Solve Math Word Problemscited by 9,743
- 2019Sentence-BERT: Sentence Embeddings using Siamese BERT-Networkscited by 9,049
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2019BERTScore: Evaluating Text Generation with BERTcited by 5,462
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2019SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systemscited by 1,718
- 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
14 more
- 2022ProgPrompt: Generating Situated Robot Task Plans using Large Language Modelscited by 598
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2018VirtualHome: Simulating Household Activities via Programscited by 411
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
- 2022Autoformalization with Large Language Modelscited by 252
- 2022Synchromesh: Reliable code generation from pre-trained language modelscited by 156
- 2019WIQA: A dataset for "What if..." reasoning over procedural textcited by 71
- 2018Tracking State Changes in Procedural Text: A Challenge Dataset and Models for Process Paragraph Comprehensioncited by 62
- 2021ExplaGraphs: An Explanation Graph Generation Task for Structured Commonsense Reasoningcited by 58
- 2021Think about it! Improving defeasible reasoning by first modeling the question scenariocited by 20
- 2020Neural Language Modeling for Contextualized Temporal Graph Generationcited by 13
- 2021Could you give me a hint? Generating inference graphs for defeasible reasoningcited by 10
- 2022Coalescing Global and Local Information for Procedural Text Understandingcited by 10
- 2021CURIE: An Iterative Querying Approach for Reasoning About Situationscited by 3
Built on by
Citing papers per year: 2022: 9; 2023: 59; 2024: 47; 2025: 33; 2026: 12.
160 papers.
Sort:
By area:
- 2023A Survey of Large Language Modelscited by 2,537
- 2023WebArena: A Realistic Web Environment for Building Autonomous Agentscited by 1,908
- 2022PAL: Program-aided Language Modelscited by 635
- 2022Towards Reasoning in Large Language Models: A Surveycited by 593
- 2023ViperGPT: Visual Inference via Python Execution for Reasoningcited by 591
- 2023MAmmoTH: Building Math Generalist Models through Hybrid Instruction Tuningcited by 483
- 2023Augmented Language Models: a Surveycited by 398
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2024Retrieval-Augmented Generation for AI-Generated Content: A Surveycited by 352
- 2022Large Language Models are Better Reasoners with Self-Verificationcited by 304
- 2023MEDITRON-70B: Scaling Medical Pretraining for Large Language Modelscited by 272
- 2022Reasoning with Language Model Prompting: A Surveycited by 251
38 more
- 2023Can Language Models Solve Graph Problems in Natural Language?cited by 249
- 2023A Comprehensive Survey of AI-Generated Content (AIGC): A History of Generative AI from GAN to ChatGPTcited by 221
- 2023TidyBot: Personalized Robot Assistance with Large Language Modelscited by 219
- 2023A Pretrainer's Guide to Training Data: Measuring the Effects of Data Age, Domain Coverage, Quality, & Toxicitycited by 180
- 2025WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learningcited by 162
- 2023SMART-LLM: Smart Multi-Agent Robot Task Planning using Large Language Modelscited by 151
- 2024Fine-Tuning Enhances Existing Mechanisms: A Case Study on Entity Trackingcited by 140
- 2023Domain Specialization as the Key to Make Large Language Models Disruptive: A Comprehensive Surveycited by 134
- 2023Skill-it! A Data-Driven Skills Framework for Understanding and Training Language Modelscited by 120
- 2024GTBench: Uncovering the Strategic Reasoning Limitations of LLMs via Game-Theoretic Evaluationscited by 118
- 2024Reducing hallucination in structured outputs via Retrieval-Augmented Generationcited by 92
- 2023Retrieving Multimodal Information for Augmented Generation: A Surveycited by 84
- 2024If LLM Is the Wizard, Then Code Is the Wand: A Survey on How Code Empowers Large Language Models to Serve as Intelligent Agentscited by 77
- 2022Complementary Explanations for Effective In-Context Learningcited by 71
- 2022Code4Struct: Code Generation for Few-Shot Event Structure Predictioncited by 70
- 2023CodeIE: Large Code Generation Models are Better Few-Shot Information Extractorscited by 67
- 2024CodeChameleon: Personalized Encryption Framework for Jailbreaking Large Language Modelscited by 65
- 2023MR-GSM8K: A Meta-Reasoning Benchmark for Large Language Model Evaluationcited by 57
- 2023How Do In-Context Examples Affect Compositional Generalization?cited by 51
- 2024To Code, or Not To Code? Exploring Impact of Code in Pre-trainingcited by 47
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2024Can LLM Graph Reasoning Generalize beyond Pattern Memorization?cited by 46
- 2023LaMPilot: An Open Benchmark Dataset for Autonomous Driving with Language Model Programscited by 45
- 2024LLaMoCo: Instruction Tuning of Large Language Models for Optimization Code Generationcited by 45
- 2023Entity Tracking in Language Modelscited by 44
- 2024Synatra: Turning Indirect Knowledge into Direct Demonstrations for Digital Agents at Scalecited by 43
- 2023Statler: State-Maintaining Language Models for Embodied Reasoningcited by 40
- 2024IndoCulture: Exploring Geographically-Influenced Cultural Commonsense Reasoning Across Eleven Indonesian Provincescited by 38
- 2024KARMA: Augmenting Embodied AI Agents with Long-and-short Term Memory Systemscited by 38
- 2024Graph-enhanced Large Language Models in Asynchronous Plan Reasoningcited by 37
- 2024Unveiling the Impact of Coding Data Instruction Fine-Tuning on Large Language Models Reasoningcited by 31
- 2024Code Pretraining Improves Entity Tracking Abilities of Language Modelscited by 31
- 2023CodeKGC: Code Language Model for Generative Knowledge Graph Constructioncited by 28
- 2024The RealHumanEval: Evaluating Large Language Models' Abilities to Support Programmerscited by 28
- 2024Unlocking Reasoning Potential in Large Langauge Models by Scaling Code-form Planningcited by 24
- 2024Steering Large Language Models between Code Execution and Textual Reasoningcited by 24
- 2023Causal Reasoning of Entities and Events in Procedural Textscited by 23
- 2023In-context Learning Generalizes, But Not Always Robustly: The Case of Syntaxcited by 22
50 most cited of 160 All 160 (JSON)
- 2026Keyword Harnesses Fail Open: A Cheap Diagnostic Ladder for Tool-Use Claims in Small Language Models1 Oct 2026
- 2026REARL: A Closed-loop Autonomous Driving Simulation Enhancement Framework with Real Traffic Data and Large Language Models17 Sep 2026
- 2026A Closed-Loop Multi-Agent Framework for Robust Multi-Robot Manipulation8 Jul 2026
- 2026PreAct: Computer-Using Agents that Get Faster on Repeated Tasks16 Jun 2026
- 2026User as Code: Executable Memory for Personalized Agents15 Jun 2026
- 2026Entity tracking emerges in sub-billion parameter language models and exceeds human performance in naturalistic narratives4 Jun 2026
- 2026From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verification24 Apr 2026
- 2026A Taxonomy of Programming Languages for Code Generation31 Mar 2026
- 2026TRUE: A Trustworthy Unified Explanation Framework for Large Language Model Reasoning21 Feb 2026
- 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generation15 Feb 2026
- 2026ChartAttack: Testing the Vulnerability of LLMs to Malicious Prompting in Chart Generation19 Jan 2026
- 2026KALE: Enhancing Knowledge Manipulation in Large Language Models via Knowledge-aware Learning12 Jan 2026
38 more
- 2025Representation Interventions Enable Lifelong Knowledge Memory Control in LLMs25 Nov 2025
- 2025Multi-agent Self-triage System with Medical Flowcharts16 Nov 2025
- 2025left|,circlearrowright,boxedBUS,right|: A Large and Diverse Multimodal Benchmark for evaluating the ability of Vision-Language Models to understand Rebus Puzzles3 Nov 2025
- 2025Large Language Models Meet Text-Attributed Graphs: A Survey of Integration Frameworks and Applications24 Oct 2025
- 2025Constraints-of-Thought: A Framework for Constrained Reasoning in Language-Model-Guided Search10 Oct 2025
- 2025TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture30 Sep 2025
- 2025Legal Requirements Translation from Law3 Jul 2025
- 2025Don't throw the baby out with the bathwater: How and why deep learning for ARC17 Jun 2025
- 2025Code Execution as Grounded Supervision for LLM Reasoning12 Jun 2025
- 2025Transforming Expert Knowledge into Scalable Ontology via Large Language Models10 Jun 2025
- 2025Can Theoretical Physics Research Benefit from Language Agents?6 Jun 2025
- 2025Read it in Two Steps: Translating Extremely Low-Resource Languages with Code-Augmented Grammar Books2 Jun 2025
- 2025Generalizable LLM Learning of Graph Synthetic Data with Post-training Alignment1 Jun 2025
- 2025Whispers of Many Shores: Cultural Alignment through Collaborative Cultural Expertise30 May 2025
- 2025R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning27 May 2025
- 2025Program of Equations Thoughts to Solve Algebra Word Problems26 May 2025
- 2025WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learning22 May 2025
- 2025Large Language Models for Computer-Aided Design: A Survey13 May 2025
- 2025a1: Steep Test-time Scaling Law via Environment Augmented Generation20 Apr 2025
- 2025MobileCity: An Efficient Framework for Large-Scale Urban Behavior Simulation18 Apr 2025
- 2025Rethinking Multilingual Continual Pretraining: Data Mixing for Adapting LLMs Across Languages and Resources5 Apr 2025
- 2025Synthetic Function Demonstrations Improve Generation in Low-Resource Programming Languages24 Mar 2025
- 2025Language Models, Graph Searching, and Supervision Adulteration: When More Supervision is Less and How to Make More More13 Mar 2025
- 2025Neuroplasticity and Corruption in Model Mechanisms: A Case Study Of Indirect Object Identification27 Feb 2025
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs26 Feb 2025
- 2025FactFlow: Automatic Fact Sheet Generation and Customization from Tabular Dataset via AI Chain Design & Implementation25 Feb 2025
- 2025Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generation18 Feb 2025
- 2025GraphThought: Graph Combinatorial Optimization with Thought Generation17 Feb 2025
- 2025MIH-TCCT: Mitigating Inconsistent Hallucinations in LLMs via Event-Driven Text-Code Cyclic Training13 Feb 2025
- 2025CodeSteer: Symbolic-Augmented Language Models via Code/Text Guidance4 Feb 2025
- 2025Large Language Models as Common-Sense Heuristics31 Jan 2025
- 2025DarkMind: Latent Chain-of-Thought Backdoor in Customized LLMs24 Jan 2025
- 2025Semantic Exploration with Adaptive Gating for Efficient Problem Solving with Language Models10 Jan 2025
- 2024On the Limit of Language Models as Planning Formalizers13 Dec 2024
- 2024What Really is Commonsense Knowledge?6 Nov 2024
- 2024Can Language Models Enable In-Context Database?4 Nov 2024
- 2024Cross-Lingual Auto Evaluation for Assessing Multilingual LLMs17 Oct 2024
- 2024FLARE: Faithful Logic-Aided Reasoning and Exploration14 Oct 2024
50 newest of 160 All 160 (JSON)
- 2022PAL: Program-aided Language Modelscited by 635
- 2022Towards Reasoning in Large Language Models: A Surveycited by 593
- 2023ViperGPT: Visual Inference via Python Execution for Reasoningcited by 591
- 2023Augmented Language Models: a Surveycited by 398
- 2022Large Language Models are Better Reasoners with Self-Verificationcited by 304
- 2022Reasoning with Language Model Prompting: A Surveycited by 251
- 2023Can Language Models Solve Graph Problems in Natural Language?cited by 249
- 2024GTBench: Uncovering the Strategic Reasoning Limitations of LLMs via Game-Theoretic Evaluationscited by 118
- 2023MR-GSM8K: A Meta-Reasoning Benchmark for Large Language Model Evaluationcited by 57
- 2023How Do In-Context Examples Affect Compositional Generalization?cited by 51
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2024Can LLM Graph Reasoning Generalize beyond Pattern Memorization?cited by 46
12 most cited of 50 All 50 (JSON)
- 2026A Closed-Loop Multi-Agent Framework for Robust Multi-Robot Manipulation8 Jul 2026
- 2026TRUE: A Trustworthy Unified Explanation Framework for Large Language Model Reasoning21 Feb 2026
- 2026LogitsCoder: Towards Efficient Chain-of-Thought Path Search via Logits Preference Decoding for Code Generation15 Feb 2026
- 2025left|,circlearrowright,boxedBUS,right|: A Large and Diverse Multimodal Benchmark for evaluating the ability of Vision-Language Models to understand Rebus Puzzles3 Nov 2025
- 2025Constraints-of-Thought: A Framework for Constrained Reasoning in Language-Model-Guided Search10 Oct 2025
- 2025TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture30 Sep 2025
- 2025Code Execution as Grounded Supervision for LLM Reasoning12 Jun 2025
- 2025Generalizable LLM Learning of Graph Synthetic Data with Post-training Alignment1 Jun 2025
- 2025R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning27 May 2025
- 2025Program of Equations Thoughts to Solve Algebra Word Problems26 May 2025
- 2025a1: Steep Test-time Scaling Law via Environment Augmented Generation20 Apr 2025
- 2025Rethinking Multilingual Continual Pretraining: Data Mixing for Adapting LLMs Across Languages and Resources5 Apr 2025
12 newest of 50 All 50 (JSON)
- 2023WebArena: A Realistic Web Environment for Building Autonomous Agentscited by 1,908
- 2025WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learningcited by 162
- 2023SMART-LLM: Smart Multi-Agent Robot Task Planning using Large Language Modelscited by 151
- 2024If LLM Is the Wizard, Then Code Is the Wand: A Survey on How Code Empowers Large Language Models to Serve as Intelligent Agentscited by 77
- 2024Synatra: Turning Indirect Knowledge into Direct Demonstrations for Digital Agents at Scalecited by 43
- 2024KARMA: Augmenting Embodied AI Agents with Long-and-short Term Memory Systemscited by 38
- 2024Bootstrapping Cognitive Agents with a Large Language Modelcited by 9
- 2025Can Theoretical Physics Research Benefit from Language Agents?cited by 9
- 2023AVIS: Autonomous Visual Information Seeking with Large Language Model Agentcited by 8
- 2025MobileCity: An Efficient Framework for Large-Scale Urban Behavior Simulationcited by 5
- 2026PreAct: Computer-Using Agents that Get Faster on Repeated Taskscited by 4
- 2025Multi-agent Self-triage System with Medical Flowchartscited by 2
12 most cited of 13 All 13 (JSON)
- 2026Keyword Harnesses Fail Open: A Cheap Diagnostic Ladder for Tool-Use Claims in Small Language Models1 Oct 2026
- 2026PreAct: Computer-Using Agents that Get Faster on Repeated Tasks16 Jun 2026
- 2025Multi-agent Self-triage System with Medical Flowcharts16 Nov 2025
- 2025Can Theoretical Physics Research Benefit from Language Agents?6 Jun 2025
- 2025WebAgent-R1: Training Web Agents via End-to-End Multi-Turn Reinforcement Learning22 May 2025
- 2025MobileCity: An Efficient Framework for Large-Scale Urban Behavior Simulation18 Apr 2025
- 2024Synatra: Turning Indirect Knowledge into Direct Demonstrations for Digital Agents at Scale24 Sep 2024
- 2024KARMA: Augmenting Embodied AI Agents with Long-and-short Term Memory Systems23 Sep 2024
- 2024Bootstrapping Cognitive Agents with a Large Language Model25 Feb 2024
- 2024If LLM Is the Wizard, Then Code Is the Wand: A Survey on How Code Empowers Large Language Models to Serve as Intelligent Agents1 Jan 2024
- 2023SMART-LLM: Smart Multi-Agent Robot Task Planning using Large Language Models18 Sep 2023
- 2023WebArena: A Realistic Web Environment for Building Autonomous Agents25 Jul 2023
12 newest of 13 All 13 (JSON)
- 2023LaMPilot: An Open Benchmark Dataset for Autonomous Driving with Language Model Programscited by 45
- 2024Enhancing Autonomous Vehicle Training with Language Model Integration and Critical Scenario Generationcited by 19
- 2026REARL: A Closed-loop Autonomous Driving Simulation Enhancement Framework with Real Traffic Data and Large Language Modelscited by 0
- 2026REARL: A Closed-loop Autonomous Driving Simulation Enhancement Framework with Real Traffic Data and Large Language Models17 Sep 2026
- 2024Enhancing Autonomous Vehicle Training with Language Model Integration and Critical Scenario Generation12 Apr 2024
- 2023LaMPilot: An Open Benchmark Dataset for Autonomous Driving with Language Model Programs7 Dec 2023
- 2023A Survey of Large Language Modelscited by 2,537
- 2023MAmmoTH: Building Math Generalist Models through Hybrid Instruction Tuningcited by 483
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2023MEDITRON-70B: Scaling Medical Pretraining for Large Language Modelscited by 272
- 2023A Comprehensive Survey of AI-Generated Content (AIGC): A History of Generative AI from GAN to ChatGPTcited by 221
- 2023TidyBot: Personalized Robot Assistance with Large Language Modelscited by 219
- 2023A Pretrainer's Guide to Training Data: Measuring the Effects of Data Age, Domain Coverage, Quality, & Toxicitycited by 180
- 2024Fine-Tuning Enhances Existing Mechanisms: A Case Study on Entity Trackingcited by 140
- 2023Domain Specialization as the Key to Make Large Language Models Disruptive: A Comprehensive Surveycited by 134
- 2023Skill-it! A Data-Driven Skills Framework for Understanding and Training Language Modelscited by 120
- 2023Retrieving Multimodal Information for Augmented Generation: A Surveycited by 84
- 2022Complementary Explanations for Effective In-Context Learningcited by 71
12 most cited of 89 All 89 (JSON)
- 2026User as Code: Executable Memory for Personalized Agents15 Jun 2026
- 2026Entity tracking emerges in sub-billion parameter language models and exceeds human performance in naturalistic narratives4 Jun 2026
- 2026From Natural Language to Verified Code: Toward AI Assisted Problem-to-Code Generation with Dafny-Based Formal Verification24 Apr 2026
- 2026A Taxonomy of Programming Languages for Code Generation31 Mar 2026
- 2026ChartAttack: Testing the Vulnerability of LLMs to Malicious Prompting in Chart Generation19 Jan 2026
- 2026KALE: Enhancing Knowledge Manipulation in Large Language Models via Knowledge-aware Learning12 Jan 2026
- 2025Representation Interventions Enable Lifelong Knowledge Memory Control in LLMs25 Nov 2025
- 2025Large Language Models Meet Text-Attributed Graphs: A Survey of Integration Frameworks and Applications24 Oct 2025
- 2025Legal Requirements Translation from Law3 Jul 2025
- 2025Don't throw the baby out with the bathwater: How and why deep learning for ARC17 Jun 2025
- 2025Transforming Expert Knowledge into Scalable Ontology via Large Language Models10 Jun 2025
- 2025Read it in Two Steps: Translating Extremely Low-Resource Languages with Code-Augmented Grammar Books2 Jun 2025
12 newest of 89 All 89 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2025Com2: A Causal-Guided Benchmark for Exploring Complex Commonsense Reasoning in Large Language Models
- 2024MIDGARD: Self-Consistency Using Minimum Description Length for Structured Commonsense Reasoning
- 2024ACCORD: Closing the Commonsense Measurability Gap
- 2022Revisiting Generative Commonsense Reasoning: A Pre-Ordering Approach
- 2024Eliciting Better Multilingual Structured Reasoning from LLMs through Code
- 2022Commonsense Knowledge Reasoning and Generation with Pre-trained Language Models: A Survey
- 2024Can LLMs perform structured graph reasoning?
- 2024The Mystery of Compositional Generalization in Graph-based Generative Commonsense Reasoning