Content-free Logical Modification of Large Language Model by Disentangling and Modifying Logic Representation

Xin Wu, Yuqi Bu, Yifei Chen, Yi CaiAAAI 2025 · DOI

Abstract

Large Language Models (LLMs) often generate logically fallacious content despite their linguistic fluency, a phenomenon largely attributed to the entanglement of logical reasoning with specific content representations. We present the Logic Control Framework (LCF), a novel approach that disentangles an LLM's internal representations into independent content and logic spaces. By identifying and steering logic representations toward a "valid" region in the latent space during inference, LCF significantly enhances logical consistency without compromising linguistic quality or content relevance. Experimental results across multiple models, including Llama2 and Llama3, demonstrate substantial improvements in logical validity and fallacy identification.

Introduction

The propensity for Large Language Models (LLMs) to produce "logical hallucinations"—eloquent but fallacious reasoning—remains a critical bottleneck for their deployment in high-stakes domains. A primary cause is content entanglement: the model's reasoning process is deeply intertwined with the specific subject matter. Consequently, a model may reason correctly in one context but fail in another with an identical logical structure.

Conceptual overview of LCF: (a) Llama2's fallacious conclusion, (b) failure of original space modification, and (c) LCF's successful disentangled modification.

Existing mitigation strategies, such as fine-tuning or prompt engineering, often face a "logic-content trade-off," where improvements in reasoning come at the cost of linguistic fluency or topical relevance. This research introduces the Logic Control Framework (LCF), which mimics the human cognitive ability to separate abstract logical structures from specific content, enabling "content-free" logical corrections.

Methods

The LCF is a modular neural architecture integrated into the standard Transformer pipeline, typically following the attention and MLP layers.

Disentanglement and Contrastive Learning

The framework employs two Multi-Layer Perceptron (MLP) projectors to map hidden states into a Content Space and a Logic Space. To ensure the utility of the Logic Space, the authors utilize contrastive learning on the Logical Fallacy Understanding Dataset (LFUD). The logic projector is trained to cluster "logically valid" samples while distancing them from "logically invalid" (fallacious) counterparts.

Logical Steering and Fusion

During inference, LCF identifies a "valid direction"—a vector pointing from the invalid region toward the valid region in the logic space. The logic representation is then nudged along this vector. Finally, a cross-attention-based decoder recombines the modified logic representation with the original, untouched content representation.

Architecture of the Logic Control Framework (LCF) integrated within Transformer layers, showing the projection, modification, and decoding process.

Results

The implementation of LCF yielded significant improvements across several open-source models:

  • Logical Validity: For Llama2, the proportion of logically valid conclusions increased from 58.84% to 96.56%. Llama3 exhibited a similar improvement, rising from 51.47% to 93.13%.
  • Fallacy Identification: Accuracy in selecting correct conclusions from multiple choices improved by up to 26.96% in Llama3.
  • Content Preservation: Perplexity scores remained stable throughout the modification process, confirming that the "content" and linguistic quality were preserved despite the logical steering.
  • Layer Sensitivity: Analysis revealed that the "reasoning" primarily occurs in the middle layers (e.g., layers 10–20 of a 32-layer model), making these the optimal locations for LCF intervention.

Discussion and Conclusion

The Logic Control Framework demonstrates that logical validity is a steerable property within an LLM's latent space. By treating logic as a geometric direction independent of content, LCF provides a path toward more rational AI without sacrificing the nuances of natural language.

Future work will focus on scaling LCF to multi-step reasoning tasks and reducing the manual effort required for generating "valid" training pairs. Additionally, the computational overhead of multi-layer LCF integration remains an area for optimization. This disentanglement approach may eventually extend to other stylistic or factual dimensions of language generation.

Summary updated

BibTeX
@inproceedings{wu2025content,
  author = {Xin Wu and Yuqi Bu and Yifei Chen and Yi Cai},
  title = {{Content-free Logical Modification of Large Language Model by Disentangling and Modifying Logic Representation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i24.34740},
}
Figure