NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ConstraintChecker: A Plugin for Large Language Models to Reason on Commonsense Knowledge Bases

Quyet V. Do, Tianqing Fang, Shizhe Diao, Zhaowei Wang, Yangqiu Song

Abstract

Large Language Models (LLMs) demonstrate impressive general-purpose reasoning but often falter when tasked with the strict symbolic constraints required for Commonsense Knowledge Base (CSKB) reasoning. We introduce ConstraintChecker, a modular "plug-and-play" component designed to enforce relational rules—such as ensuring a "feeling" relation describes a mental state rather than an action. By validating predictions through independent symbolic filters, ConstraintChecker achieves consistent accuracy and F1 score improvements across major benchmarks like CKBPv2 and SD-ATOMIC20.

Introduction

Commonsense Knowledge Bases (CSKBs), such as ATOMIC and ConceptNet, organize human knowledge into triples: (head event, relation, tail event). A core challenge in this domain is determining the "plausibility" of a given triple. While LLMs excel at generating fluent text, they often rely on semantic proximity rather than the specific logical requirements of a relation. For instance, an LLM might incorrectly validate the triple (PersonX prepares for a competition, xReact, PersonX wins) because "preparing" and "winning" are semantically related. However, the xReact relation specifically requires the tail to be a mental state (a feeling). Since "winning" is an event or outcome, the triple is logically invalid.

Methodology: The ConstraintChecker Framework

ConstraintChecker operates as a symbolic filter that post-processes LLM predictions. It consists of two primary modules that work in tandem to verify if a triple adheres to predefined relational constraints.

The ConstraintChecker architecture: Module 1 identifies constraints based on the relation, and Module 2 uses an LLM to verify them. The final answer is a logical AND of the main task and the checker.

Module 1: Rule-based Constraint Identification

This module uses a set of preset rules to determine which constraints apply to a specific relation (e.g., xAttr, xIntent). The authors categorize these into three types:

  • Typing Constraints: Ensures the tail event belongs to the correct category, such as Activity, Mental State, or Persona.
  • Temporal Constraints: Validates the chronological order of events (e.g., does the head event necessarily precede the tail?).
  • Ambiguity Constraints: Checks if the events are semantically informative and grammatically sound.

Module 2: Zero-shot Verification

Once constraints are identified, Module 2 generates targeted, zero-shot questions for the LLM. For example, to check a typing constraint, it might ask: "Does the clause 'PersonX win' express a mental state of the subject? Answer Yes or No."

Plug-and-Play Aggregation

The final plausibility score is determined by a logical AND operation. A triple is only considered plausible if both the primary reasoning task (e.g., a Chain-of-Thought prompt) and the ConstraintChecker return a "Yes." This design specifically targets False Positive errors, where the model is misled by surface-level word associations.

Experimental Evaluation

The framework was evaluated on two key benchmarks:

  1. CKBPv2: A human-curated benchmark for Commonsense Knowledge Base Population.
  2. SD-ATOMIC20: A synthetic discriminative version of the ATOMIC20 dataset, designed to test a model's ability to distinguish between valid commonsense and perturbed, incorrect triples.

Results and Discussion

ConstraintChecker consistently improved performance across various LLMs (including ChatGPT and GPT-3.5) and prompting strategies (Zero-shot, Few-shot, and Chain-of-Thought).

Performance comparison of various prompting methods with and without ConstraintChecker on CKBPv2 and SD-ATOMIC20 benchmarks.

On the CKBPv2 benchmark, the plugin provided an average F1 improvement of approximately 1%. On the more challenging SD-ATOMIC20 dataset, improvements were even more significant, with F1 increases reaching up to 2.32% for ChatGPT in zero-shot settings.

Ablation studies revealed that Typing constraints were the most effective, addressing a significant blind spot in how LLMs categorize event-based knowledge. Furthermore, the modular approach proved superior to "single-prompt" methods, where including rules in the main prompt often led to "interference" and degraded performance.

Conclusion

ConstraintChecker demonstrates that modular, symbolic verification can effectively mitigate the tendency of LLMs to hallucinate plausibility based on semantic similarity. By separating the generative reasoning task from the constraint-checking step, the framework provides a cost-effective and interpretable way to enhance the reliability of commonsense reasoning. Future work will explore automatic constraint induction to reduce the need for manual rule engineering and extend the framework to more general question-answering tasks.

Summary updated

BibTeX
@inproceedings{do2024constraintchecker,
  author = {Quyet V. Do and Tianqing Fang and Shizhe Diao and Zhaowei Wang and Yangqiu Song},
  title = {{ConstraintChecker: A Plugin for Large Language Models to Reason on Commonsense Knowledge Bases}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=ijtzTIiptz},
}
Figure