Compositional Structured Explanation Generation with Dynamic Modularized Reasoning (2024)

Abstract: In this work, we propose a new task, compositional structured explanation generation (CSEG), to facilitate research on compositional generalization in reasoning. Despite the success of language models in solving reasoning tasks, their compositional generalization capabilities are under-researched. Our new CSEG task tests a model’s ability to generalize from generating entailment trees with a limited number of inference steps – to more steps, focusing on the length and shapes of entailment trees. CSEG is challenging in requiring both reasoning and compositional generalization abilities, and by being framed as a generation task. Besides the CSEG task, we propose a new dynamic modularized reasoning model, MORSE, that factorizes the inference process into modules, where each module represents a functional unit. We adopt modularized self-attention to dynamically select and route inputs to dedicated heads, which specializes them to specific functions. Using CSEG, we compare MORSE to models from prior work. Our analyses show that the task is challenging, but that the dynamic reasoning modules of MORSE are effective, showing competitive compositional generalization abilities in a generation setting.

## introduction large-scale language models @xcite @xcite have shown remarkable performance on reasoning tasks, such as reading comprehension @xcite , natural language inference @xcite , story generation @xcite , etc. however, @xcite ; @xcite ; @xcite argued that these models lack human-like reasoning capabilities. humans excel in compositional generalization @xcite , a capacity to combine an inventory of known constituents to predict larger sent1: puddles of water will receive sunlight sent2: temperature is a measure of heat energy sent3: if something receives sunlight, it will increase in temperature hypothesis: the puddles of water will increase in heat energy hypothesis: the puddles of water will increase in heat energy int1: the puddles of water will increase in temperature sent2: temperature is a measure of heat energy sent3: if something receives sunlight, it will increase in temperature sent1: puddles of water will receive sunlight rt: if-then rt: substitution entailment tree candidate sentences & a hypothesis compounds, during reasoning. for example, humans who understand calculation constituents, e.g., subtraction sub(x,y) and mixed additionsubtraction operations sub(x, add(y, z)), can solve larger compounds, e.g., sub(w, sub(x, add(y, z))). various studies @xcite @xcite have explored compositional generalization abilities in reasoning tasks. but, these works focus on compositionality units manifesting on the word level and involving specific linguistic phenomena, and neglect inferential processes holding between sentences. but sentence-level composition can enhance the capacity of models to execute complex contextual reasoning. to fill this gap, we propose a new task, compositional structured explanation generation, cseg. cseg is a new setting built on seg @xcite , a task for models to generate a multi-step entailment tree -given a hypothesis and candidate sentences. the tree indicates how the hypothesis follows from the text. fig. 1 shows an example. each step (e.g., sent1 & @xmath0, belonging to one of six reasoning types, such as if-then (it) and substitution (subs) (see @xcite for examples). we consider each reasoning type as a constituent unit. to test compositional generalization in reasoning, our new task cseg requires models to generalize from entailment trees with a limited number of reasoning steps to trees involving more steps. for example, a model is expected to generate a larger compound (entailment tree) with more reasoning steps, e.g., c 3 : subs(subs(it(p 1 , p 2 ) → h 1 , p 3 ) → h 2 , p 4 ) → h 3 , by combining known constituents c 1 : subs(it(p 1 , p 2 ) → h 1 , p 3 ) → h 2 and c 2 : subs(p 1 , p 2 ) → h, where c 1 replaces p 1 in c 2 ). here, compositionality units, i.e., reasoning types, operate on the sentence level and involve reasoning components. our new cseg task requires: i) reasoning capabilities, to infer new conclusions from existing information; and ii) compositional generalization capability, to generalize to unseen compounds using previously learned constituents. recent efforts @xcite @xcite aimed to improve reasoning abilities, while ignoring the compositional generalization capacity. existing symbolic-based approaches @xcite @xcite used multiple modules that each perform unique types of reasoning, endowing models with strong compositionality. but they rely on pre-defined reasoning rules and need training data for each pre-defined module. inspired by this, we propose a dynamically modularized reasoning model morse. our model simulates the symbolic process by specializing transformer self-attention heads to what we call dynamic modules. we design a modularized self-attention mechanism that dynamically selects and routes inputs to dedicated modularized heads, specializing them to specific functions. the dynamics embodied in morse through its self-assembling modules makes it applicable to multiple datasets without pre-defined knowledge and extend to novel inference types. our main contributions are: compositional generalization has been researched for decades @xcite @xcite , including two significant properties: productivity and systematicity @xcite . among these, productivity is similar to length generalization, in that both evaluate generalization to deeper reasoning chains. but for evaluating productivity, primitive units needed for solving deeper samples must have been learned during training. in contrast to the related length-generalization work of @xcite , our cseg task aims to evaluate productivity in a structured compositional generalization reasoning task. we therefore guarantee that primitive units (rule types) needed for solving deeper samples have been learned in training. importantly, we frame cseg as a generation task, which unlike classification settings as in @xcite , makes it harder for models to exploit shortcuts. recently, there has been renewed interest in exploring compositional generalization in reasoning tasks. @xcite ; hudson and manning (2019); @xcite ; @xcite proposed challenging compositional tasks in visual qa. @xcite designed compositional questions for qa and found even the strongest model struggled with these challenging questions. other works probed the compositional abilities of models in natural language inference @xcite @xcite @xcite , focusing on specific linguistic phenomena, such as quantifiers, negation, or predicate replacements. i.e., they investigate compositionality in phenomena manifesting at the word level, in contrast to inferential processes holding between sentences. to fill this gap, we examine compositional generalization in a multi-step entailment tree generation task, where different inference rules need to be composed. concurrent work @xcite also concentrates on sentence-level compositionality in reasoning, but is limited in using a synthetic dataset. in comparison, we employ both natural language and synthetic data, and introduce a new model, with potential for further improvement, that can serve as a strong baseline for the task. neural-symbolic and neural methods prior works show that symbolic approaches @xcite @xcite that adopt pre-defined inference rules to establish derivations through iterative reasoning, endow models with strong compositionality. but being dependent on pre-defined rules, the models are limited to well-defined tasks. recently, yi et al. (2018); yin et al. (2018); li et al. (2020) ; @xcite used neural networks to map raw signals to symbolic representations and subsequently performed symbolic reasoning to make predictions. as symbolic reasoning is brittle, novel works based on neural modular networks (nmn) @xcite combine individual neural modules endowed with specialized reasoning capabilities. e.g., @xcite ; @xcite designed various modules in an nmn to perform unique types of reasoning in end-to-end manner. similarly, @xcite proposed a text module network for complex reasoning tasks, where each module is an existing qa system. however, all these approaches require prior knowledge and rely on brittle symbolic transfer, to subsequently deploy pre-defined modules for each sub-task, and well-designed modules require substantial extra training data. finally, symbolic reasoning methods are typically driven by weak supervision, given the lack of intermediate labels. this can result in error accumulation and time-consuming learning. to address these challenges, we propose a model with dynamic modules that make specific module functions more independent from prior knowledge, to endow models with greater flexibility when handling new tasks. our work may seem related to mixture-of-expert (moe) models @xcite @xcite that aim to decompose tasks by composing separate networks, each of which is trained to handle a subset of a complete leaves sent i are sentences from the candidate set s, and hypot is the tree's root, given by the hypothesis h. int j are inferred intermediate conclusions that provide the basis for further reasoning steps. compositional generalization testing to examine compositional reasoning capabilities, we partition our benchmark datasets along two generalization properties: productivity and systematicity. productivity-length evaluates systems on longer proof lengths than they have been trained on, where both train and test sequences are composed of identical primitives. hence, we rearrange the data by proof length, i.e., number of intermediate nodes in each tree (including hypothesis node). we partition the data into: i) primitive entailment trees of length one or two; ii) compositional entailment trees of length three. foot_1 fig. 2 shows examples. systematicity-shape examines the capability of (re)combining known constituents to a larger compound. hence, we rearrange the dataset by tree shapes. to select appropriate data, we proceed as follows: we i) limit the inference steps of each tree to four -given that larger steps present an unsolved challenge for existing neural models @xcite ); ii) extract the tree shapes from candidate data; iii) find there exist only six different shapes, depicted as shape-* in fig. 2 (details in appendix a.2); iv) select, among six possible shapes, simple structures (shape-a*) as primitives, and more complex (compositional) ones (shape-b*) as compositions for generalization testing. we guarantee that compositional shapes are built from primitive shapes: @xmath1, @xmath2, @xmath3. in figure 2 , we use dashed squares to single out one primitive shape for each compositional shape. ## morse: dynamic modularized reasoning model we introduce our dynamic modularized reasoning model morse that generates compositional structured explanations. morse contains: i) an encoder consisting of original and modularized transformer blocks to perform reasoning; ii) a decoder using original transformer blocks to generate the entailment tree structure. see the overview in fig. 3 . ## conclusion we present a new setup for explanation generation to facilitate compositional generalization in reasoning research. inspired by highly compositional symbolic systems, we propose a novel modularized reasoning model morse that factorizes reasoning processes into a combination of dynamically specializing modules. our results establish morse as a strong baseline for the task, using two benchmarks. a future direction is to learn how to initialize more modules on demand.