PyClause - Simple and Efficient Rule Handling for Knowledge Graphs

Patrick Betz, Luis Galárraga, Simon Ott, Christian Meilicke, Fabian M. Suchanek, Heiner StuckenschmidtIJCAI 2024

Introduction

Knowledge Graphs (KGs) are structured databases of facts, such as livesIn(Eleanor_Roosevelt, New_York), which serve as the backbone for many modern AI applications. To extract insights from these graphs, researchers often employ "rule mining" to discover logical patterns. For instance, a rule might state: If an individual resides in a city within a specific country, they are likely a citizen of that country.

While tools like AMIE and AnyBURL are highly effective at mining these rules, a significant "application gap" exists. Applying these rules to predict missing links, calculate precision on new datasets, or generate explanations typically requires complex, custom implementations. Existing logic-based systems, such as ProbLog, frequently fail to scale to the millions of facts present in real-world KGs. PyClause addresses this gap by providing a standardized, high-performance toolkit for rule handling.

System Architecture and Methods

PyClause utilizes a two-tier architecture to balance ease of use with computational efficiency:

  1. clause (Python Package): This high-level API manages configuration via YAML files, handles data loading, and provides convenience wrappers for popular rule learners.
  2. c_clause (C++ Core): The underlying engine performs the heavy lifting. Tasks like "grounding" rules—finding specific entities that satisfy a rule's conditions—and data storage are implemented in C++ to ensure maximum performance.
PyClause architecture overview and example usage script.

The library supports four primary operations:

  • PREDICT: Identifies missing subjects or objects in a triple and scores potential candidates.
  • EXPLAIN: Provides the specific rules and "body groundings" (supporting facts) that justify a prediction.
  • SCORE: Calculates metrics such as support, confidence, and precision for rules against a KG.
  • MATERIALIZE: Computes the "deductive closure," inferring every possible new fact by applying rules to the existing graph.

Experimental Evaluation

The authors evaluated PyClause using standard Knowledge Graph Completion (KGC) benchmarks:

  • FB15k-237: A Freebase subset with ~272k triples and over 5 million rules.
  • WN18RR: A WordNet subset with ~86k triples and ~97k rules.
  • Hetionet: A large biomedical KG with over 2 million facts, used for a drug repurposing case study.

Key Results

PyClause demonstrates substantial performance improvements over existing symbolic tools. By offloading rule grounding to the C++ core, it processes tasks in seconds that might otherwise take hours.

Performance comparison between PyClause and AnyBURL across different tasks and datasets.

Specific highlights include:

  • Ranking Speed: On FB15k-237, PyClause completed ranking in 47.3 seconds, roughly 3x faster than AnyBURL (155 seconds).
  • Rule Retrieval: PyClause retrieved predicting rules for FB15k-237 in 147 seconds, whereas AnyBURL required 3.4 hours.
  • Scalability: Compared to ProbLog on the WN18RR dataset, PyClause finished in minutes, while ProbLog failed to terminate after two hours.
  • Practical Application: In a drug repurposing test on Hetionet, PyClause predicted that Isoetarine could treat Asthma (likelihood 0.449), explaining the prediction via its similarity to Salbutamol.

Limitations and Future Work

Currently, PyClause focuses on Horn rules (simple "if-then" logic) and is restricted to binary predicates without negation. Future development aims to integrate PyClause more deeply into neuro-symbolic machine learning pipelines, allowing symbolic rules to function as features or constraints within neural network architectures.

Summary updated

BibTeX
@inproceedings{betz2024pyclause,
  author = {Patrick Betz and Luis Galárraga and Simon Ott and Christian Meilicke and Fabian M. Suchanek and Heiner Stuckenschmidt},
  title = {{PyClause - Simple and Efficient Rule Handling for Knowledge Graphs}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
}
Figure