LogicMP: A Neuro-symbolic Approach for Encoding First-order Logic Constraints
Weidi Xu, Jingwei Wang, Lele Xie, Jianshan He, Hongting Zhou, Taifeng Wang, Xiaopei Wan, Jingdong Chen, Chao Qu, Wei Chu
TL;DR
LogicMP introduces a differentiable neuro-symbolic layer that encodes first-order logic constraints via mean-field inference on Markov Logic Networks, enabling plug-and-play integration with any neural encoder. By reformulating MF updates as parallel tensor operations through clause-level simplifications and parallel Einstein summation, LogicMP reduces the traditional MF complexity and achieves scalable inference on groundings up to the order of 10^5–10^6, e.g., 262K variables within 0.03 seconds. Empirically, LogicMP delivers accuracy and efficiency gains across document image understanding, relational graph reasoning, and sequence labeling tasks, outperforming advanced neuro-symbolic baselines and enabling training on larger grounding sets. The approach demonstrates the practical value of combining MLN-based FOLCs with neural representations, enabling structured predictions that honor logical constraints in diverse real-world data domains.
Abstract
Integrating first-order logic constraints (FOLCs) with neural networks is a crucial but challenging problem since it involves modeling intricate correlations to satisfy the constraints. This paper proposes a novel neural layer, LogicMP, whose layers perform mean-field variational inference over an MLN. It can be plugged into any off-the-shelf neural network to encode FOLCs while retaining modularity and efficiency. By exploiting the structure and symmetries in MLNs, we theoretically demonstrate that our well-designed, efficient mean-field iterations effectively mitigate the difficulty of MLN inference, reducing the inference from sequential calculation to a series of parallel tensor operations. Empirical results in three kinds of tasks over graphs, images, and text show that LogicMP outperforms advanced competitors in both performance and efficiency.
