Do Large Language Models Understand Logic or Just Mimick Context?

Junbing Yan, Chengyu Wang, Jun Huang, Wei ZhangarXiv 2024 · DOI

Abstract

This paper, authored by researchers at Alibaba Group and East China Normal University, investigates a fundamental question in artificial intelligence: Do Large Language Models (LLMs) possess genuine reasoning capabilities, or are they sophisticated pattern matchers? By utilizing counterfactual prompting—stress-testing models with modified logic and nonsensical premises—the study reveals that even state-of-the-art models struggle to move beyond the probabilistic associations learned during pre-training. The findings suggest that while scaling increases a model's resilience to noise, it does not necessarily bridge the gap to true logical understanding.

Introduction

LLMs have demonstrated impressive proficiency in symbolic inference and logical reasoning, often attributed to in-context learning (ICL) and Chain-of-Thought (CoT) prompting. However, a critical ambiguity remains: have these models internalized the underlying rules of logic, or are they merely predicting the most statistically likely sequence of tokens based on surface-level patterns? If a model truly understands logic, it should be able to operate under a novel set of rules provided within a prompt (e.g., a scenario where "AND" and "OR" have swapped meanings). This research employs counterfactual methods to probe the limits of LLM reasoning.

Methodology and Datasets

The researchers utilized the LogicalCOT dataset to evaluate model behavior across three distinct task types: translating natural language to formal logic (Folio), determining premise entailment (Entailment Bank), and machine reading comprehension (MRC).

Overview of the LogicalCOT dataset tasks, including Logical Reasoning, Language to Logic, and Reading Comprehension examples.

To dissect model performance, the study employed three dimensions of counterfactual prompting:

  1. Text Replacement: Premises were replaced with in-domain samples or unrelated "noise" (e.g., random Wikipedia text) to test if models could still identify the underlying logic.
  2. Reasoning Chain Modification: The intermediate steps of the Chain-of-Thought were altered to assess the model's reliance on the actual path to a conclusion.
  3. Logical Concept Swapping: In an "acid test" of logical structure, the researchers provided definitions that swapped the meanings of AND and OR to see if models could reach counter-intuitive but logically consistent conclusions.

Key Insights: The Logic Ceiling

The experiments revealed several critical limitations in current LLM architectures:

  • The "AND/OR" Failure: When instructed that the definitions of AND and OR were swapped, models almost universally failed to adjust. Even the largest 200B parameter models maintained a modification rate below 5%, remaining "locked" into the standard definitions learned during pre-training.
  • Syntactic over Semantic Processing: Models appear to prioritize "markers" (such as words in brackets) to maintain the appearance of a reasoning chain rather than processing the semantic nuances of logical connectives.
  • Examples vs. Instructions: Interestingly, "Example-based Guidance" (showing a sample of the swapped logic) was significantly more effective than "Prompt-based Guidance" (merely stating the new rules). This boosted the modification rate to 40-50% for large models, highlighting the extent to which LLMs rely on imitation over instruction.

Experimental Results

The study evaluated two major model families: LLaMA2 (7B to 70B) and Qwen (7B to 200B). A clear "resilience gap" emerged during testing. While smaller models (7B/13B) experienced sharp performance declines when context was replaced with unrelated text, larger models (70B+) remained remarkably stable.

Accuracy of Qwen models across various sizes and counterfactual replacement scenarios, illustrating the resilience of larger models to context noise.

This stability suggests that scaling increases a model's ability to distinguish signal from noise, but it does not necessarily imply a deeper grasp of logical operations. The researchers conclude that LLMs are becoming more effective at converging on expected answers based on probabilistic associations rather than genuine rule-based reasoning.

Conclusion

The authors suggest that the fundamental mechanism of current LLMs—next-token prediction—may be inherently limited. This objective prioritizes local statistical patterns over global logical consistency. Future advancements may require alternative pre-training strategies or architectural shifts capable of handling longer-span dependencies and global information integration. Until then, LLMs may remain highly effective "stochastic parrots," capable of mimicking the form of logic without fully grasping its substance.

Summary updated

BibTeX
@misc{yan2024do,
  author = {Junbing Yan and Chengyu Wang and Jun Huang and Wei Zhang},
  title = {{Do Large Language Models Understand Logic or Just Mimick Context?}},
  year = {2024},
  eprint = {2402.12091},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.12091},
}
Figure