LYRICS: A General Interface Layer to Integrate Logic Inference and Deep Learning

Giuseppe Marra, Francesco Giannini, Michelangelo Diligenti, Marco Gori

Introduction

Deep learning excels at processing "low-level" sensorial data, such as pixels or audio, but often struggles with "high-level" reasoning. Conversely, symbolic logic is adept at representing complex rules but fails to handle the noise and ambiguity inherent in real-world data. A major bottleneck in modern AI is deep learning's heavy reliance on massive amounts of supervised data, which is often slow and expensive to collect. Furthermore, standard neural networks are "black boxes" that offer no guarantees that their outputs will follow basic logical consistencies—for instance, a model might classify a "dog" as a "non-mammal."

LYRICS addresses these challenges by providing a general-purpose interface layer that allows researchers to integrate First-Order Logic (FOL) directly into TensorFlow computational graphs. By converting logical formulas into differentiable constraints, it enables deep learning models to learn from both raw data and structured human knowledge, significantly improving performance in data-scarce scenarios.

Methodology

The core of LYRICS is its ability to translate First-Order Logic (FOL) into TensorFlow (TF) computational graphs. This process involves several key steps:

  1. Declarative Language: Users define the problem using high-level constructs like Domain (sets of objects), Predicate (properties of objects), and Function.
  2. Fuzzy Logic Translation: To make logic compatible with a neural network's gradient-based optimization, LYRICS employs t-norm fuzzy logic. This maps Boolean values (True/False) to the continuous interval [0, 1]. Logical operators like AND ($\wedge$), OR ($\vee$), and IMPLIES ($\Rightarrow$) are converted into mathematical operations such as multiplication or addition.
T-norm fuzzy logic operators used to map Boolean logic to differentiable mathematical operations.
  1. Constraint Optimization: Logical formulas are transformed into real-valued constraints added to the standard loss function. During training, the system minimizes classification error while simultaneously maximizing the "truth degree" of the provided logical rules.
  2. Agnostic Integration: Built on TensorFlow, LYRICS allows any neural architecture (e.g., CNNs, LSTMs) to be bound to a logical predicate.
Overview of the LYRICS pipeline: translating First-Order Logic into a TensorFlow computational graph.

Experimental Evaluation

The authors evaluated LYRICS across several distinct tasks to demonstrate its versatility:

  • Synthetic Geometry: A semi-supervised learning task involving points in concentric circles to test manifold regularization.
  • CoNLL 2000: A standard Natural Language Processing (NLP) benchmark for "chunking" (identifying parts of sentences).
  • CiteSeer: A citation network dataset consisting of 3,312 scientific papers and 4,732 citation links, used for document classification.

Key Results

  • CiteSeer Accuracy: LYRICS showed a massive boost when training data was limited. With only 10% of the training data, a standard Neural Network achieved 60.08% accuracy, while LYRICS reached 67.39%. Even with 90% of the data, LYRICS outperformed the baseline (78.03% vs 72.59%).
  • NLP Chunking: On the CoNLL 2000 dataset, LYRICS improved the F1-score across the board. For rare tags specifically, the F1-score jumped from 56.24 to 57.65 in low-data regimes.
  • State-of-the-Art Comparison: On CiteSeer, LYRICS outperformed established collective classification methods like the Iterative Classification Algorithm (ICA) and Gibbs Sampling (GS).

Discussion and Key Insights

LYRICS demonstrates that logic can serve as a powerful regularizer. Instead of just learning from labels, the model uses logic as a form of "prior knowledge injection," preventing the model from making "illogical" guesses. This provides a significant "Rare Tag" Advantage: logic helps most where data is thinnest, such as labels that appear infrequently but are governed by clear grammatical rules.

Furthermore, the framework enables Collective Classification through transductive reasoning. For example, in citation networks, LYRICS can enforce "homophily" rules (e.g., cited papers likely share categories) during the inference phase on the test set. Finally, LYRICS can be used for Model Checking, allowing researchers to audit a pre-trained model's "truth degree" against various logical hypotheses.

Limitations and Future Work

While flexible, LYRICS currently requires human experts to manually define FOL rules. Future work aims to include mechanisms to automatically learn the importance or "weights" of different rules. Additionally, the authors suggest moving toward Rule Induction, using the framework's differentiability to learn new logical rules directly from data rather than just verifying them.

Summary updated

BibTeX
@inproceedings{marra2019lyrics,
  author = {Giuseppe Marra and Francesco Giannini and Michelangelo Diligenti and Marco Gori},
  title = {{LYRICS: A General Interface Layer to Integrate Logic Inference and Deep Learning}},
  booktitle = {ECML/PKDD},
  year = {2019},
  doi = {10.1007/978-3-030-46147-8\_17},
}
Figure