Relational Programming with Foundational Models

Ziyang Li, Jiani Huang, Jason Liu, Felix Zhu, Eric Zhao, William Dodds, Neelay Velingker, Rajeev Alur, Mayur Naik

Abstract

Foundation models (FMs) have demonstrated remarkable capabilities in natural language understanding and perception, yet they frequently struggle with rigorous logical reasoning, factual consistency, and integration with structured data. This paper introduces VIEIRA, a declarative framework that unifies FMs with symbolic logic by treating them as relational plugins. By offloading complex reasoning to a probabilistic logic engine while utilizing FMs for perception, VIEIRA achieves state-of-the-art performance on diverse reasoning tasks with remarkably concise code. Our evaluation across nine benchmarks shows that VIEIRA provides a robust, scalable, and modular "glue language" for the next generation of AI systems.

Introduction

Despite their power, foundation models like GPT-4 and CLIP suffer from three primary flaws: they "hallucinate" non-factual information, struggle with mathematical or logical chains, and are difficult to integrate with structured environments like SQL databases. Current development practices often rely on ad-hoc Python scripts or fragile prompting chains (e.g., Chain-of-Thought) to connect these models. These methods lack formal structure, making them difficult to debug or scale across different modalities.

VIEIRA addresses this by proposing a unified framework built on the principles of probabilistic relational programming. It treats neural models as reliable components within a structured, declarative program, effectively bridging the gap between neural perception and symbolic reasoning.

Methodology: Models as Relational Plugins

The core innovation of VIEIRA is its Relational Abstraction. The framework treats foundation models as stateless functions that transform relations—essentially tables of data. For instance, a CLIP model can be viewed as a function that takes an image and returns a table of labels with associated probabilities.

VIEIRA treats foundation models as relational plugins, transforming data tables through neural perception (e.g., fact retrieval or image classification).

Core Components

  • Datalog-based Logic: VIEIRA uses a declarative language based on Datalog. Developers define what the relationships are rather than how to solve the problem step-by-step. The system utilizes the SCALLOP compiler for execution.
  • Foreign Interface: This allows developers to wrap any foundation model as a Foreign Predicate (FP) or Foreign Attribute (FA) using simple Python snippets, ensuring the framework is extensible to future models.
  • Neuro-Symbolic Labor Split: VIEIRA divides tasks into perception and logic. The FM handles perception (e.g., identifying objects in an image), while the symbolic engine handles logic (e.g., counting or comparing those objects).
  • Probabilistic Soft Logic: To account for neural uncertainty, VIEIRA propagates probabilities through the logic chain, allowing for uncertainty estimation and the ranking of final results.

Experimental Evaluation

The authors evaluated VIEIRA across nine diverse benchmark tasks spanning text, vision, and math, including Date Reasoning (DR), Kinship Reasoning (KR), and Visual Question Answering (VQA).

Key Results

VIEIRA demonstrated superior performance in zero-shot and few-shot settings compared to strong neural baselines:

  • Logical Precision: On the "Tracking Shuffled Objects" task, VIEIRA achieved 100% accuracy, significantly outperforming GPT-4 with Chain-of-Thought (~84%).
  • Visual Reasoning: In the GQA benchmark, VIEIRA reached 57.9% Recall@1, a massive improvement over the neural-only ViLT model (4.9%).
  • Generalizability: As reasoning complexity increased (e.g., longer kinship chains), VIEIRA's performance remained stable, whereas standard GPT-4 performance degraded.
  • Efficiency: Most VIEIRA programs are under 100 lines of code, achieving results comparable to fine-tuned models without requiring task-specific training.

Discussion and Future Work

VIEIRA's "aha moment" lies in treating a language model not as a chatbot, but as a noisy, on-demand database. This allows standard database operations—joins, filters, and aggregates—to be applied to unstructured neural outputs. By narrowing the FM's role to "semantic parsing" or "perception," the system avoids the logic errors common in pure neural execution.

However, the framework currently depends on the quality of the human-designed Domain Specific Language (DSL). Future work will explore weakly-supervised training, using the logic program's output to fine-tune the underlying foundation models, and addressing potential computational bottlenecks in large-scale relational joins.

Summary updated

BibTeX
@inproceedings{li2024relational,
  author = {Ziyang Li and Jiani Huang and Jason Liu and Felix Zhu and Eric Zhao and William Dodds and Neelay Velingker and Rajeev Alur and Mayur Naik},
  title = {{Relational Programming with Foundational Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i9.28934},
}
Figure