🧠 Neurosymbolic AI (NeSy)
Definitions
- Neuro: Neural models that learn patterns from data using continuous vector representations.
- Symbolic: Systems that represent and reason with explicit symbols such as rules, logic, or structured knowledge (e.g., logical formulas, KGs, ontologies).
- Neurosymbolic (NeSy): A system that connects neural learning with symbolic reasoning under a shared framework, combining symbolic structure with a learned neural component.
- NeSy AI Research: A field studying how to combine neural models and symbolic logic to achieve both data-driven learning and structured reasoning.
Subfields of NeSy
- Knowledge Representation: Combining Neuro and Symbolic approaches.
- Learning and Inference: Focusing on differentiible reasoning and multisource knowledge.
- Explainability and Trustworthiness: Developing interpretable models and reasoning processes for trust.
- Logic and Reasoning: Integrating logic with Neural Networks (NNs).
- Meta-Cognition: Monitoring and evaluating reasoning processes through NN + symbolic methods.
💬 What is LLM + NeSy?
Traditional LLM Limitations
Traditional LLMs face several issues that NeSy aims to address:
- Hallucination.
- Lacking systematic compositional generalization.
- “Lost in the Middle” phenomenon.
- Unguaranteed systematically well-formed output.
- Unfaithful Chain-of-Thought (CoT).
Adding Reasoning with NeSy
NeSy enhances LLMs by integrating reasoning through:
- Probabilistic Logic and Neural Predicates (e.g., DeepProbLog).
- End-to-end Differentiable Proving (e.g., NTP).
- Semantic loss functions.
- Logic-Constrained Decoding.
- Structured Planning / Symbolic Search Modules (e.g., Tree-of-Thoughts).
🛠️ Tight and Loose NeSy Implementations
The presentation distinguishes between two main implementation types.
| Feature | Tight NeSy Implementation | Loose NeSy Implementation |
|---|---|---|
| Architecture | Embedded in a single architecture. | Separate modules communicating through I/O. |
| Optimization | Jointly optimized. | Trained independently. |
| Symbolic Role | Encoded in layers or loss terms. | Applied mostly at inference. |
| Gradients | Update both neural and symbolic parts. | No gradients regarding symbolic aspects. |
| Examples | Neural Theorem Prover, DeepProbLog, Semantic Loss, LogicMP. | FunSearch, ChemCrow, Tree of Thoughts, Grammar-Constrained Decoding. |
Current Progress:
- Most LLM integration currently uses Loose approaches.
- Major publications directly discussing Tight NeSy + LLM are scarce.
- There are emerging attempts to integrate Tight NeSy with Autoregressive Models.
📉 Tight NeSy Example 1: A Semantic Loss Function
Paper: A Semantic Loss Function for Deep Learning with Symbolic Knowledge (ICML, 2018).
Core Idea
- Goal: Augment neural networks to make predictions subject to constraints and use symbolic knowledge to improve learning.
- Method: Derived from first principles, Semantic Loss (SL) bridges neural output vectors and logical constraints. It captures how close the network is to satisfying constraints.
- Logical Meaning: The loss depends only on the semantics (the set of worlds satisfying the constraint), not the syntax.
Definition
The semantic loss $L^{s}(\alpha,p)$ between a propositional logic sentence $\alpha$ and a probability vector $p$ is defined as:
\[L^{s}(\alpha,p) \propto -\log \sum_{x\models \alpha} \prod_{i:x\models X_{i}} p_{i} \prod_{i:x\models \neg X_{i}} (1-p_{i})\]It is the negative log-likelihood of generating a state that satisfies the constraint $\alpha$.
Properties
- Monotonicity: Adding stricter logical requirements cannot decrease the loss.
- Non-negativity: Loss is 0 for a tautology (always true sentence).
- Classical Behavior: Reduces to standard cross-entropy for simple labeled literals.
- Differentiable: Allows for gradient-based learning.
Results (Grid Shortest Path)
In a grid shortest path problem with complex constraints (valid path, specific degrees), adding Semantic Loss to a 5-layer MLP dramatically improved performance:
- Constraint Accuracy: 6.99% → 69.89% (MLP + Semantic Loss).
📉 Tight NeSy Example 2: Pseudo-Semantic Loss
Paper: A Pseudo-Semantic Loss for Autoregressive Models with Logical Constraints (NeurIPS, 2023).
The Gap
- Standard Semantic Loss assumes a fully factorized output distribution.
- Autoregressive (AR) models (like Transformers) are not fully factorized, and computing constraint likelihood for them is #P-hard.
Core Idea: Pseudo-Semantic Loss (PseudoSL)
- Enforces constraints on a local, factorized pseudolikelihood approximation centered around a model sample.
- Allows efficient reuse of sub-problem solutions.
Results
- Sudoku: RNN + PseudoSL improved exact accuracy from 22.40% → 28.20%.
- Warcraft Shortest Path: CNN-LSTM + PseudoSL improved consistent accuracy from 76.60% → 79.00%.
- GPT-2 Detoxification: Max Toxicity reduced to 0.29 (baseline 0.44) while maintaining text quality.
📝 Summary & Future Directions
- Classification: NeSy is categorized into “tight” (learned symbolic features) and “loose” approaches.
- State of LLMs: Most LLM integration is “loose”.
- Challenges: Tight approaches for autoregressive models exist (PseudoSL) but face scalability issues.
- Future Work: Research is needed to make semantic loss computation more efficient and applicable to harder constraints 799, 800.