Learning to Disentangle Latent Reasoning Rules with Language VAEs: A Systematic Study
Yingji Zhang, Marco Valentino, Danilo S. Carvalho, André Freitas · 2025
Read Learning to Disentangle Latent Reasoning Rules with Language VAEs: A Systematic Study by Yingji Zhang, Marco Valentino, Danilo S. Carvalho, André Freitas (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-19418.txt.
Introduction
Yingji Zhang and co-authors study whether language models can store reasoning rules as separate, tidy parts of their inner space, in this 2025 paper. Big models often memorize answers instead of applying rules. The team built a pipeline on variational autoencoders for text, with three rule-based tasks.
With clear teaching signals, rules split into distinct clusters in the model's feature space. Feeding rule hints into the query side helped the decoder fetch stored values more reliably. On math tasks, more samples stopped helping past a point. Feed-forward layers held rule separation better than attention layers. The authors frame the work as a step toward clearer model reasoning.
Catalog record
| CREATOR | Yingji Zhang, Marco Valentino, Danilo S. Carvalho, André Freitas |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 36 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2506-19418
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Learning to Disentangle Latent Reasoning Rules with Language VAEs: A Systematic Study Yingji Zhang, Marco Valentino, Danilo S. Carvalho, André Freitas Abstract Incorporating explicit reasoning rules within the latent space of language models (LMs) offers a promising pathway to enhance generalisation, interpretability, and controllability. While current Transformer-based language models have shown strong performance on Natural Language Inference (NLI) tasks, they often rely on memorisation rather than rule-based inference. This work investigates how reasoning rules can be explicitly embedded and memorised within the LMs through Language Variational Autoencoders (VAEs). We propose a complete pipeline for learning reasoning rules within Transformer-based language VAEs. This pipeline encompasses three rule-based reasoning tasks, a supporting theoretical framework, and a practical end-to-end architecture. The experiment illustrates the following findings: Disentangled reasoning: Under explicit signal supervision, reasoning rules—viewed as functional mappings—can be disentangled within the encoder’s parametric space. This separation results in distinct clustering of rules in the output feature space. Prior knowledge injection: injecting reasoning information into the Query enables the model to more effectively retrieve the stored value Value from memory based on Key. This approach offers a simple method for integrating prior knowledge into decoder-only language models. Performance bottleneck: In mathematical reasoning tasks using Qwen2.5 (0.5B), increasing sample count doesn’t improve performance beyond a point. Moreover, ffn layers are better than attention layers at preserving the separation of reasoning rules in the model’s parameters. 1 Introduction Figure 1: Overview, where (\pi,x,c) represents the (rule, input premise(s), conclusion) . To systematically evaluate rule-based learning within a VAE framework, first, we examine three rule-based NLI tasks. Second, we formalise the hypothesis that reasoning rules can be functionally and separately encoded within the encoder’s parametric space, enabling rule learning in the latent space, grounded in the theoretical framework of neural tangent kernels. Third, we introduce an end-to-end VAE architecture, with three different latent injection setups, designed to capture coarse-grained reasoning patterns in its latent space while remaining sensitive to the lexical semantics of the input. Encoding reasoning patterns or explicit rules within latent representations holds significant promise for enhancing the generalisation, interpretability, and controllability of neural models, which is particularly salient in the neuro-symbolic AI domain Bonnet and Macfarlane 2024 ; Yu et al. 2025 . Over recent years, Transformer-based language models (LMs) have achieved notable success across a variety of Natural Language Inference (NLI) tasks Yang et al. 2024 ; Qwen et al. 2025 . Nonetheless, a growing body of research has demonstrated that these models often rely on memorisation rather than rule-based inference mechanisms, thereby constraining their capacity for generalisation and interpretability Yan et al. 2025 . Therefore, this study focuses on the question: How can reasoning rules (i.e., memorised input-output patterns 1 1 1 Please notice that exploring the composition and generalisation over rules in the NLI task is not the target of this work. The motivation of this work is to explicit encode the memorised reasoning input-output patterns in the latent space. ) be explicitly encoded within the latent space of language models? Variational Autoencoder (VAE) Kingma and Welling 2013 provides a compelling framework for this direction. The integration of prior distribution serves as an inductive bias, enabling the model to leverage existing knowledge and providing a principled way to incorporate domain expertise Papamarkou et al. 2024 . In this work, we focus on lightweight LMs (<1B parameters) as VAE decoders, allowing accessible evaluation of training dynamics, memory capacity, and model updates of the Transformer architecture Zhong et al. 2025 ; Morris et al. 2025 . More importantly, because our primary motivation is to study latent rule encoding and separation, we fully re-train the decoder. As a result, the geometry and separation of the latent space are not constrained by the model’s size or architectures, enabling a more lightweight and controlled analysis of representation learning. Accordingly, we propose a complete pipeline for learning NLI reasoning rules within Transformer-based language VAEs Li et al. 2020 ; Zhang et al. 2024c : First, we focus on three distinct rule-based reasoning tasks, each characterised by unique syntax, inference patterns and levels of granularity: Mathematical Reason Meadows et al. 2023 , Syllogistic Reason Valentino et al. 2025 , and Explanatory Reason Zhang et al. 2024b . Second, following the Neural Tangent Kernel (NTK) theory Jacot et al. 2018 , we claim that by supervising the inference rule information, the inference rule can be encoded in the parametric space (i.e., weight matrix) of encoder, which subsequently leads to the rule separation in the latent sentence space. This formalisation allows us to explicit encode the reasoning rule in the latent space. Third, we propose an end-to-end VAE architecture where the latent space can encode both coarse-grained reasoning rules and fine-grained reasoning patterns that arise from semantic differences in the inputs, and evaluate three ways to inject the latent space into the LM decoder by intervening the attention network. We conduct extensive experiments to assess the effectiveness of rule encoding and reasoning generation capabilities. The experiment illustrates the following results and findings: Disentangled Reasoning: Under explicit signal supervision, reasoning rules—viewed as functional mappings—can be disentangled within the encoder’s parametric space. This separation results in distinct clustering of rules in the output feature space, suggesting the potential for employing rule-based NTK theory to better understand the training dynamics and internal geometry of gradient-based neural NLI model. Prior Knowledge Injection: Different injection setups result in varying levels of reasoning performance. The optimal configuration is achieved by injecting the latent space into the query matrix of the attention network. Intuitively, injecting reasoning information into the Query enables the model to more effectively retrieve the stored value Value from memory based on Key. This approach offers a simple method for integrating prior knowledge into decoder-only language models. Performance Bottleneck: A case study on the mathematical reasoning task reveals a performance bottleneck in decoder-only LM, Qwen2.5 (0.5B), where increasing the number of samples per operation fails to yield performance improvements beyond a certain threshold. Additionally, we observe that ffn network is more effective than attention in maintaining the separation of reasoning rules within the learned parametric space. To the best of our knowledge, this is the first study to explore the explicit encoding of NLI rules within the latent space of language VAEs. 2 Related Work In this section, we review the related work around two topics: rule-based representation learning and language VAEs , to highlight the current research limitation and elucidate the motivation underlying our work. Rule-based Representation Learning. Encoder-only models have been employed for tasks such as mathematical operations, where the encoder learns structured transformations, as demonstrated by Valentino et al. 2024 . In addition, VAE-based approaches have shown promise in tasks requiring structured reasoning, such as visual program synthesis, where the goal is to generate programs that fulfill a specified task Sun et al. 2018 ; Bonnet and Macfarlane 2024 ; van Krieken et al. 2025 . Similarly, grammar-based approaches using VAEs have been applied to infer ordinary differential equation (ODE) formulas from data Yu et al. 2025 . Moreover, Decoder-only models, particularly large language models (LLMs), leverage in-context learning by using demonstrations to infer and apply underlying reasoning patterns Liu et al. 2023b ; Bhattamishra et al. 2024 . Despite these