We address the general task ofstructuredcommonsense reasoning:
given a natural language input, the goal is to generate agraphsuch 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 ascode generationtasks,
pre-trained LMs ofcodearebetterstructured 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 thesenatural languagetasks, we show that using our approach, acodegeneration 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 athttps://github.com/madaan/CoCoGen.