Language Models of Code are Few-Shot Commonsense Learners

31474

Authors

nan

Abstract

AbstractWe 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 (T5) and other strong LMs such as GPT-3 in the few-shot setting.

Keywords

nan

Full Content

Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 1384 - 1403 December 7-11, 2022 ©2022 Association for Computational Linguistics Language Models of Code are Few-Shot Commonsense Learners Aman Madaan♠, Shuyan Zhou♠, Uri Alon♠, Yiming Yang♠, Graham Neubig♠ † ♠ Language Technologies Institute, Carnegie Mellon University, USA † Inspired Cognition, USA {amadaan,shuyanzh,ualon,yiming,gneubig}@cs.cmu.edu Abstract We address the general task of structured com- monsense 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 feasi- ble, these serialized graphs strongly deviate from the natural language corpora that LMs were pre-trained on, hindering LMs from gen- erating them correctly. In this paper, we show that when we instead frame structured common- sense 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. Our code and data are available at https: //github.com/madaan/CoCoGen . 1 Introduction The growing capabilities of large pre-trained lan- guage models (LLMs) for generating text have en- abled their successful application in a variety of tasks, including summarization, translation, and question-answering (Wang et al., 2019; Raffel et al., 2019; Brown et al., 2020; Chowdhery et al., 2022). Nevertheless, while employing LLMs for natu- ral language (NL) tasks is straightforward, a ma- jor remaining challenge is how to leverage LLMs for structured commonsense reasoning, including tasks such as generating event graphs (Tandon et al., 2019), reasoning graphs (Madaan et al., 2021a), scripts (Sakaguchi et al., 2021), and argument ex- planation graphs (Saha et al., 2021). Unlike tradi- tional commonsense reasoning tasks such as read- ing comprehension or question answering, struc- tured commonsense aims to generate structured output given a natural language input. This family of tasks relies on the natural language knowledge learned by the LLM, but it also requires complex structured prediction and generation. To leverage LLMs, existing structured common- sense generation models modify the output format of a problem. Specifically, the structure to be gen- erated (e.g., a graph or a table) is converted, or “serialized”, into text. Such conversions include “flattening” the graph into a list of node pairs (Fig- ure 1d), or into a specification language such as DOT (Figure 1c; Gansner et al., 2006). While converting the structured output into text has shown promising results (Rajagopal et al., 2021; Madaan and Yang, 2021), LLMs struggle to generate these “unnatural” outputs: LMs are primarily pre-trained on free-form text, and these serialized structured outputs strongly diverge from the majority …

Content truncated to 500 words

Labeled Text

AbstractWe 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 (T5) and other strong LMs such as GPT-3 in the few-shot setting.

Publication Details

Paper ID:
31474
Year:
2022
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan