Introduction
While Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language understanding and generation, they remain prone to hallucinations and factual errors. A more subtle but equally critical flaw is logical inconsistency. A model may correctly identify a statement as true but fail to recognize that its negation is false, or it may struggle to maintain consistency across complex logical combinations of facts. In high-stakes domains such as law, medicine, and finance, this lack of logical reliability is a significant barrier to adoption. This research introduces a framework to measure and mitigate logical inconsistency in LLMs by leveraging Knowledge Graphs (KGs) and efficient fine-tuning techniques.
Problem Definition: Logical Inconsistency
Previous research has largely focused on "paraphrase consistency"—ensuring a model provides the same answer to semantically identical questions. This study shifts the focus to logical consistency, evaluating whether a model respects the fundamental rules of propositional logic. Specifically, the framework tests the model's handling of primitive logical operators:
-
Negation ($\neg$): If $p$ is true, $ eg p$ must be false.
-
Conjunction ($\wedge$): If $p$ and $q$ are true, $p \wedge q$ must be true.
- Disjunction ($\vee$): If $p$ is true, $p \vee q$ must be true regardless of $q$.
Methodology
Knowledge Graph Contextualization
To isolate logical reasoning from the model's internal (and potentially flawed) knowledge, the researchers employ a Retrieval-Augmented Generation (RAG) approach. The model is provided with a specific "context" derived from a Knowledge Graph. This context consists of a set of triplets (subject-relation-object) that serve as the ground truth for the verification task.
Algorithmic Implementation
The process involves retrieving a $\lambda$-hop subgraph around the subject of a fact to build a relevant context. This ensures the model has the necessary information to evaluate the target fact without relying on external hallucinations.
Supervised Fine-Tuning (SFT)
To improve consistency, the authors utilize QLoRA (Quantized Low-Rank Adaptation) to fine-tune models like Llama-2 and Gemma. QLoRA is a parameter-efficient method that updates the model's internal weights to prioritize logical rules. This approach was found to be three times more efficient than full fine-tuning, making it accessible for researchers with limited computational resources.
Datasets
The study introduces three new "Logical Fact-Checking" (LFC) datasets derived from real-world Knowledge Graphs:
- FreebaseLFC: Based on Freebase, covering facts about people, places, and institutions.
- NELLLFC: Based on the "Never-Ending Language Learner" dataset.
- WikiLFC: Derived from the large-scale WikiKG90Mv2.
These datasets transform structured KG triplets into natural language "Fact-Context" pairs. Additionally, the framework was tested on the FEVER dataset to evaluate performance in purely natural text environments.
Key Insights and Results
The Generalization Effect
A major finding of the research is the "Generalization Aha! Moment." Fine-tuning a model on simple, primitive facts (e.g., $p$ and $ eg p$) allows it to generalize to complex logical structures (e.g., $(p \vee q) \wedge r$) and even abstract rules like De Morgan’s Laws. This suggests that LLMs can learn the underlying structure of logic rather than just memorizing patterns.
Prompting vs. Fine-Tuning
The study reveals that standard prompting techniques, including zero-shot instruction prompting, are often insufficient. In some cases, prompting actually decreased consistency in base models. True logical reliability requires updating the model's internal weights through supervised fine-tuning, which outperformed zero-shot prompting by up to 46% in consistency scores.
Performance Gains
- Consistency Boost: Fine-tuned models achieved a 14% average improvement in logical consistency across all tested datasets.
- Model Scaling: While larger models (e.g., Llama-2-70B, GPT-4o) are inherently more consistent, they still struggle with complex rules like the Law of Syllogism without targeted tuning.
Conclusion and Future Work
This research demonstrates that logical consistency is a distinct and improvable metric in LLM performance. While a consistent model is not necessarily accurate (it could be consistently wrong), a logically sound model is far easier to debug and verify.
Future work will address current limitations, such as moving beyond binary "Yes/No" responses to handle "Unknown" or "Partially True" labels. Additionally, researchers aim to extend the framework to more complex natural language scenarios where logical relations are implied rather than explicitly stated in structured triplets.
Summary updated