用树结构正则化让Transformer模型学会语法,提升泛化能力
Sneaking Syntax into Transformer Language Models with Tree Regularization
- 通过可微的正则化损失,将句法解析结果转化为隐藏状态的正交约束
- 在WikiText-103上训练时,对分布外数据困惑度降低10%,句法泛化提升9.5点
- 无需改架构,适合预训练语言模型的持续优化和对抗性任务微调
尽管人类语言理解基于层次化的树状结构,但像Transformer这样的神经模型缺乏直接的句法归纳偏置。引入句法归纳偏置可提升模型鲁棒性和数据效率,但现有方法常限制模型表达能力或增加推理复杂度。本文提出TreeReg,一种结构化正则化器,通过将银级句法解析的括号决策转化为可微的正交性约束,软性注入句法偏置。TreeReg与标准语言模型目标无缝集成,无需架构改动。在WikiText-103等自然语言语料上预训练的模型,在分布外数据上困惑度降低最高达10%,句法泛化能力提升最高达9.5点,所需训练数据不足常规模型的一半即可超越其表现。该方法同样适用于大模型:对Sheared Llama进行持续预训练后,句法泛化性能提升;在MultiNLI上微调时,使对抗性自然语言推断基准性能下降减少41.2点。代码已开源。
原文摘要 · Abstract (English)
While compositional accounts of human language understanding are based on a hierarchical tree-like process, neural models like transformers lack a direct inductive bias for such tree structures. Introducing syntactic inductive biases could unlock more robust and data-efficient learning in transformer language models (LMs), but existing methods for incorporating such structure greatly restrict models, either limiting their expressivity or increasing inference complexity. This work instead aims to softly inject syntactic inductive biases into given transformer circuits, through a structured regularizer. We introduce TreeReg, an auxiliary loss function that converts bracketing decisions from silver parses into a set of differentiable orthogonality constraints on vector hidden states. TreeReg integrates seamlessly with the standard LM objective, requiring no architectural changes. LMs pre-trained with TreeReg on natural language corpora such as WikiText-103 achieve up to 10% lower perplexities on out-of-distribution data and up to 9.5 point improvements in syntactic generalization, requiring less than half the training data to outperform standard LMs. TreeReg still provides gains for pre-trained LLMs: Continued pre-training of Sheared Llama with TreeReg results in improved syntactic generalization, and fine-tuning on MultiNLI with TreeReg mitigates degradation of performance on adversarial NLI benchmarks by 41.2 points. We release all code to guide future research.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。