Disentangling Reasoning Capabilities from Language Models with Compositional Reasoning Transformers (2023)

Abstract: This paper presents ReasonFormer, a unified reasoning framework for mirroring the modular and compositional reasoning process of humans in complex decision-making. Inspired by dual-process theory in cognitive science, the representation module (automatic thinking) and reasoning modules (controlled thinking) are decoupled to capture different levels of cognition. Upon the top of the representation module, the pre-trained reasoning modules are modular and professional in specific and fundamental reasoning skills (e.g., logic, simple QA, etc). To mimic the controlled compositional thinking process, different reasoning modules are dynamically activated and composed in both parallel and cascaded manners to control what reasoning skills are activated and how deep the reasoning process will be reached to solve the current problems. The unified reasoning framework solves multiple tasks with a single model, and is trained and inferred in an end-to-end manner. Evaluated on 11 datasets requiring different reasoning skills and complexity, ReasonFormer demonstrates substantial performance boosts, revealing the compositional reasoning ability. Few-shot experiments exhibit better generalization ability by learning to compose pre-trained skills for new tasks with limited data, and decoupling the representation module and the reasoning modules. Further analysis shows the modularity of reasoning modules as different tasks activate distinct reasoning skills at different reasoning depths.

## introduction prevailing language models (lms) @xcite demonstrate impressive performance in natural language processing tasks, question: what cause car accident? and have ushered in a new trend in ai research. despite the emerging fervor, the homogeneous lms relying on a single call of the model are less modular and are hard to explicitly model the complex reasoning process @xcite like humans. in the dual-process theory @xcite in cognitive psychology, there are two cognitive systems interacted to form a whole reasoning process. system 1 (automatic thinking) generates intuitive patterns of ideas, and system 2 (controlled thinking) constructs reasoning in an orderly logical series of compositional reasoning processes. besides, in the process of system 2, different functional brain areas could be modular and interact with each other. system 2 can decide how to compose different reasoning skills and when to stop thinking. as the example shown in fig. 1 , when finding the cause of a car accident, humans intuitively comprehend the question (system 1), and then conduct compositional reasoning (system 2: recalling @xmath0. we would like to incorporate this mechanism into ai models in decision-making, and make the following assumptions: (1) the representation module (system 1) and reasoning module (system 2) can be decoupled and (2) the "complicated" reasoning process can be disentangled into multi-step executions of compositional "fundamental" reasoning modules, whose compositionality can be learnt with limited data. also, the "fundamental" nature of basic reasoning skills allows them to have rich training instances for reliable skill pre-training. under these motivations, this paper proposes the modular and compositional reasoning framework -reasonformer, to mirror human's compositional reasoning process, with the following characteristics: (1) the representation module and reasoning modules are decoupled; (2) reasoning modules are modular and professional in fundamental reasoning skills; (3) reasoning modules are compositional in parallel and cascaded manner, to dynamically decide the activated reasoning skills and the reasoning complexity; (4) the general-purpose reasoning framework is end-to-end and unified in solving multiple tasks with one model. specifically, the representation module learns contextual representations of problems. upon the top of the it, there are cascaded reasoning modules to perform compositional multi-step reasoning. the reasoning modules are pre-trained to expert in specific reasoning skills (e.g., logic, qa, fact, etc.). these pre-trained reasoning skills are considered relatively fundamental and have rich resources. two additional blocks complete the whole framework: the reasoning router and the reasoning adapter. the reasoning router decides which reasoning skills are activated in each reasoning step, and when to stop the reasoning process. the adapter adapts the reused reasoning modules to different steps of the reasoning process. we comprehensively evaluate the framework on 11 datasets emphasizing different reasoning skills and complexity, and highlight the following findings: (1) substantial performance boosts demonstrate models' harvest of compositional reasoning ability, and both the reasoning-centric pre-training and reasoning adapter bring compounding performance gains. (2) results of few-shot experiments show that specialized modules enables better generalization by learning to compose pre-trained skills for low-resource tasks, and decoupling of representation module and reasoning modules. (3) further analysis reveals the distinct reasoning skills required for different tasks at different reasoning depths, shoring up the modularity of reasoning modules. ## reasoning skills formulation the compositional reasoning process of lms' relies on the pre-training of several fundamental reasoning skills and their compositionality. hence, the selection of skills is critical. ## reasonformer framework as shown in fig. 2 , the general-purpose reasoning framework is built based on encoder-decoder architecture to process multiple tasks (i.e., all pretraining tasks and downstream tasks) with a unified model, where all tasks are tackled as unified text-totext generation tasks. we first reformat all the tasks into the same format using hard prompts @xcite . for example, the question-answering task input can be prompted with the template: the question is {question}. please give the answer:", and the expected output is the answer text. given the prompted task inputs, the modular and compositional framework consists of two components in its encoder: the representation module (system 1) and the reasoning modules (system 2). the representation module ( § 3.1) captures the intuitive understanding of problems by calculating initial contextual representations. upon the top of the representation module, there are several pretrained reasoning modules ( § 3.2) with different reasoning skills, waiting for interaction to form a compositional reasoning process. for reasoning process organization, there are reasoning routers ( § 3.2.2) to decide the (parallel) activated skills and when to stop the (cascaded) reasoning process. ## related works multi-step reasoning. multi-step reasoning is a characteristic of human thinking. multi-hop reasoning @xcite asks the system to logically switch attention to different contexts @xcite or make a multistep deduction for a new conclusion @xcite . recently, chain-ofthought prompting @xcite provides the model with manual prompts about the intermediate reasoning steps. @xcite use lms to iteratively select evidence and generate inferences. however, they always require discrete manual-written reasoning traces. @xcite is a position paper raising interest in mod-eling these cascaded inference processes of lms with a probabilistic program. lm modularity. since human brains have various functional areas, it is inspiring to explore the modularity of lms. mixture-of-experts (moe) @xcite use experts in ffn layers for sparse learning. however, their major motivation is to increase the model capacity while keeping efficiency, without emphasis on the speciality of expert. recent works begin to explore domain-specific experts @xcite and modality-specific experts @xcite . skillnet proposes skill-specific experts @xcite . however, the activated skills need to be manually specified, and do not explicitly model the cascaded reasoning process and disentangling of perception and cognition. considering these directions in the whole picture, this paper targets to explore the modeling of modular and the compositional multi-step reasoning process of ai models in an end-to-end manner. ## conclusion this paper stimulates the compositional reasoning process of humans in decision-making, and makes the following hypotheses: (1) the intuitive perception system (system 1) and cognitive reasoning system (system 2) can be decoupled and (2) the complex decision-making can be disentangled into multi-step execution of fundamental reasoning skills. correspondingly, we propose reason-former, a compositional general-purpose reasoning framework. reasonformer decouples the representation module and reasoning modules, which are pre-trained to expert in fundamental reasoning skills. the reasoning modules are dynamically composed in parallel and cascaded manner to form a whole reasoning process. reasonformer is end-to-end and unified in solving multiple tasks with one model. extensive experiments on 11 tasks reveal the compositional reasoning ability of reason-former and disentangling of representation and reasoning modules.