Skip to main content
QUICK REVIEW

[论文解读] Language Models of Code are Few-Shot Commonsense Learners

Aman Madaan, Shuyan Zhou|arXiv (Cornell University)|Oct 13, 2022
Topic Modeling被引用 5
一句话总结

本文提出 CoCoGen,一种将结构化常识推理任务(如剧本生成和推理图构建)转化为代码生成问题的方法,利用代码大语言模型(Code-LLMs)进行处理。通过将结构化输出转换为可执行的 Python 代码,CoCoGen 使 Codex 等 Code-LLM 在三个不同任务的 few-shot 设置下,优于自然语言 LMs(如 T5、GPT-3),在无需任务特定微调的情况下,展现出更高的结构准确性和推理质量。

ABSTRACT

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.

研究动机与目标

  • 为解决使用大语言模型生成结构化常识输出(如事件图、推理图)的挑战。
  • 识别现有方法将结构化输出序列化为扁平化、不自然的文本格式,此类格式不适合自然语言模型的问题。
  • 探索预训练于编程语法与结构的代码生成模型是否能更有效地处理结构化推理任务。
  • 证明将常识推理问题转化为代码生成任务,可提升模型在 few-shot 设置下的性能。

提出的方法

  • 将结构化常识输出(如事件图或推理图)转化为可执行的 Python 代码表示,以保留其层次结构与关系结构。
  • 使用预训练的 Code-LLMs(如 Codex)直接从自然语言提示生成这些代码表示。
  • 使用 Python 的面向对象语法,将节点表示为类实例,边表示为父子关系。
  • 在 few-shot 设置下进行模型训练或提示,无需任务特定微调,充分利用其在代码语料上的预训练优势。
  • 将生成的代码解析为有效的结构化输出(如图结构),用于下游评估。
  • 使用标准评估指标(如 F1、精确匹配和结构准确率)对比自然语言 LMs 的性能。

实验结果

研究问题

  • RQ1当在相同任务上微调时,Code-LLM 是否比自然语言 LMs 更准确地生成结构化常识输出?
  • RQ2将结构化输出表示为可执行代码,是否能提升模型在 few-shot 推理设置下的性能?
  • RQ3与序列化文本格式(如 DOT 或边列表)相比,使用代码表示生成的输出在结构保真度上表现如何?
  • RQ4单一 Code-LLM 是否能在无需任务特定微调的情况下,泛化到多种结构化常识推理任务?

主要发现

  • 在所有三项结构化常识推理任务——剧本生成、事件图构建和推理图生成中,Codex 在 few-shot 设置下均优于微调后的 T5 和 GPT-3 模型。
  • 性能提升在结构准确率方面尤为显著,Codex 生成的语法和拓扑错误明显少于自然语言 LMs。
  • CoCoGen 的 F1 和精确匹配得分高于基线模型,表明代码表示比序列化文本格式更能有效保持图结构。
  • 该方法在多种任务中表现出强鲁棒性,表明 Code-LLM 即使在输入为纯自然语言时,也能泛化于结构化推理任务。
  • 结果表明,Code-LLM 在编程语法与语义上的预训练,使其具备更强的结构化推理能力,适用于结构化生成任务。
  • 作者观察到,自然语言 LMs 在生成序列化格式时难以维持图的拓扑结构,而 Code-LLM 通过代码的正确结构有效保留了关系。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。