A Pseudo-Semantic Loss for Autoregressive Models with Logical Constraints

Abstract

Neuro-symbolic AI bridges the gap between purely symbolic and neural approaches to learning. This often requires maximizing the likelihood of a symbolic constraint w.r.t the neural network's output distribution. Such output distributions are typically assumed to be fully-factorized. This limits the applicability of neuro-symbolic learning to the more expressive auto-regressive distributions, e.g., transformers. Under such distributions, computing the likelihood of even simple constraints is #P-hard. Instead of attempting to enforce the constraint on the entire likelihood distribution, we propose to do so on a random, local approximation thereof. More precisely, we approximate the likelihood of the constraint with the pseudolikelihood of the constraint centered around a model sample. Our approach is factorizable, allowing us to reuse solutions to sub-problems---a main tenet for the efficient computation of neuro-symbolic losses. It also provides a local, high fidelity approximation of the likelihood: it exhibits low entropy and KL-divergence around the model sample. We tested our approach on Sudoku and shortest-path prediction cast as auto-regressive generation, and observe that we greatly improve upon the base model's ability to predict logically-consistent outputs. We also tested our approach on the task of detoxifying large language models. We observe that using a simple constraint disallowing a list of toxic words, we are able to steer the model's outputs away from toxic generations, achieving SoTA compared to previous approaches.

Cite

Text

Ahmed et al. "A Pseudo-Semantic Loss for Autoregressive Models with Logical Constraints." Neural Information Processing Systems, 2023.

Markdown

[Ahmed et al. "A Pseudo-Semantic Loss for Autoregressive Models with Logical Constraints." Neural Information Processing Systems, 2023.](https://mlanthology.org/neurips/2023/ahmed2023neurips-pseudosemantic/)

BibTeX

@inproceedings{ahmed2023neurips-pseudosemantic,
  title     = {{A Pseudo-Semantic Loss for Autoregressive Models with Logical Constraints}},
  author    = {Ahmed, Kareem and Chang, Kai-Wei and Van den Broeck, Guy},
  booktitle = {Neural Information Processing Systems},
  year      = {2023},
  url       = {https://mlanthology.org/neurips/2023/ahmed2023neurips-pseudosemantic/}
}