Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Scallop: A Language for Neurosymbolic Programming

Scallop lets neural networks and logic programs train together end to end

  • Problem Neural models and logic programs can't be trained as one system by default. Logic programs have no usable gradients, because their discrete operations aren't differentiable and their loss landscape isn't continuous.
  • Method Scallop is a neurosymbolic language built on Datalog. It attaches a tag to each tuple and carries those tags through relational queries, which gives the gradients needed for training.
  • Results Scallop reached a 99.4% test success rate on PacMan-Maze after only 50 training episodes.

Table 3: PacMan-Maze performance

Table 3 . PacMan-Maze performance.

Original paper · CC BY 4.0 · Ziyang Li, Jiani Huang, Mayur Naik · Scallop: A Language for Neurosymbolic Programming · Original paper figure · Extracted the figure area from page 18 of the original PDF.

Why neural models and logic programs don't train together

A neural model and a logic program can't be trained as one system by default, because the two parts learn in different ways. Deep learning fits its parameters with gradient-based methods over a deep neural network, using a set of input-output training data. A logic program such as P is interpretable, but it operates only on limited, structured input r.

A neural model such as M_θ can read rich input x, such as an image, but it is not interpretable. Applications such as question answering and code completion need both properties, so developers want to combine the two paradigms. In the handwritten formula example, a CNN turns the image into a sequence of symbols, and a classical parser evaluates the formula.

Many neurosymbolic systems exist, but the authors found no language with compiler support that makes the approach widely accessible. They set five criteria for a practical language, covering the data representation, the reasoning language, the differentiable engine, per-application tuning, and integration with existing training pipelines.

The third criterion is the hardest, because the engine must learn under algorithmic supervision, where labels exist only for inputs and outputs and not for the intermediate symbols r. Under this supervision, the learner has no direct signal for r, so it must pass the error back through the logic program.

Neural networks learn from gradients of differentiable activation functions, which lets the gradient flow through each layer. A logic program has no such gradients by default, because its operations on discrete symbols aren't differentiable. The loss landscape of a logic program isn't continuous, so the gradient calculations need a special treatment.

So the open question is how to differentiate the high-level logic program P, so that its gradient can be combined with the gradient of the neural model. Scallop addresses this by building on provenance semirings, which tag tuples and propagate those tags through relational queries.

The key idea: tags carried through the rules

Scallop attaches a tag to each tuple and lets the relational operators carry those tags from inputs to outputs. Each decision answers one of the problems raised earlier: how to represent the data, how to state the rules, and how to compute the gradients.

Relations can encode arbitrary graphs, such as scene graphs or abstract syntax trees, so symbolic data fits naturally. A relational database can combine several modalities in one store. The reasoning language extends Datalog, so programs stay rule-based and easier to write, debug, and verify. Datalog implementations can reuse optimizations from relational database systems, which speeds up inference and learning.

Tags also need an algebra, and the authors take it from provenance semirings, which define how tags combine.

Tags are combined by binary disjunction, binary conjunction, and unary negation, which resemble logical or, and, and not. The main change the authors make is adapting this framework to an extended fragment of relational algebra that includes recursion, negation, and aggregation. Different provenance structures give different heuristics for the gradient calculations, so training can be tuned to each application.

How a Scallop program runs end to end

A Scallop program starts with the tagging step, where each input tuple receives a tag from the input tag space. Untagged input facts don't need any tag at all, because Scallop simply assigns them the tag 1. The SclRam program then operates on these tagged facts, propagating tags through its rules. Scallop lets the user name a set of output relations, and the recover function is applied only to tags under those relations.

This restriction avoids redundant computations on relations the application never reads.

The surface program compiles down to SclRam, a lower-level representation with its own operational semantics. Recursion in SclRam follows least fixed point iteration, as in Datalog, and runs one stratum at a time. Iterating per stratum keeps stratified negation and aggregation well defined. Each step evaluates all rules in the stratum and returns the updated database.

When a tuple is derived from two derivations, the old and new tags are joined with disjunction.

Scallop's surface syntax reads like Horn clauses, with commas separating conjunctive body atoms. Disjunction is written as multiple rules that share the same head predicate. The compiler rejects a rule such as not something_is_true(), because its negation isn't stratified.

Provenance tags are propagated through disjunction, conjunction, and negation, which resemble logical or, and, and not. Tags 0 and 1 represent unconditionally false and true, so untagged inputs behave like certain facts. For differentiable provenances, the input tag space is [0, 1], and each output tag is a dual-number carrying a probability and its derivative.

Three differentiable provenances: dmmp, damp and dtkp

Scallop attaches a dual number to every tag in the differentiable setting, pairing a probability with its derivative with respect to the input probabilities. Each input probability starts with a derivative vector that is the standard basis vector for that input. Scallop provides 8 configurable built-in DPs, and the authors describe three of them in this section.

The three differ in runtime efficiency, reasoning granularity, and performance.

diff-max-min-prob (dmmp) attaches the basis vector as the derivative when it reads an input tag. The saturation check compares only the probability part, so the derivative doesn't block termination. Each of its operations can be implemented with time complexity O(1), which makes it extremely runtime-efficient.

diff-add-mult-prob (damp) uses the same internal tag space, tagging function and recover function as dmmp. Its disjunction and conjunction are plain addition and multiplication of dual numbers. After disjunction, damp clamps the real part and keeps the derivative unchanged. Its saturation function always returns true, which avoids non-termination but makes damp less suitable for complex recursive programs.

Each operation costs O(n), which is slower than dmmp but still very efficient in practice.

diff-top-k-proofs (dtkp) extends the top-k proofs semiring from Huang et al. to support negation and aggregation. Each dtkp tag is a DNF boolean formula, and each conjunctive clause is a proof with at most k proofs kept. When merging proofs, conflicting literals remove the whole proof, and negation converts a CNF back to DNF through cnf2dnf.

Weighted model counting turns each output formula into an output dual number, and WMC is #P-complete. WMC is the main contributor to runtime, so the tunable k lets the user balance runtime against reasoning granularity. The paper's empirical evaluation finds dtkp often the best performer, and k = 3 is usually a good choice.

PacMan-Maze: fewer episodes for a higher success rate

PacMan-Maze is a reinforcement learning task on a simplified 5 by 5 maze, where the agent sees only a raw image that changes at each step.

The baseline is a CNN Deep Q-Network that approximates the Q function and predicts the Q-value of each action from the whole game image. Scallop splits the task instead: the neural component perceives the pixels of individual cells and classifies the entity in each one. The Scallop agent needed only 50 training episodes to reach a 99.4% test success rate.

Success rate counts how many of 1000 game sessions the PacMan reaches the goal within a time budget.

The authors attribute this gain to the logic rules taking over the reasoning, which makes the network's job smaller and more modular. Datalog implementations can use relational database optimizations, which reduces the burden on the neural model. The gradient heuristic is set on line 8 of the Python code, with diff-top-k-proofs and k set to 1.

The authors use the sample of 50 episodes to contrast data needs, so the comparison concerns episodes rather than compute per episode. The paper reports these two results for PacMan-Maze only, so the data-efficiency claim rests on this one task.

Eight benchmarks and the best provenance per task

The authors evaluate Scallop on eight neurosymbolic applications, spanning image, video, natural language, planning and knowledge graph querying. In the overall benchmark accuracy comparison, dtkp gave the best Scallop variant on six tasks, damp on two and dmmp on one. Because the best provenance is picked per task, these counts don't describe one fixed setting for every application.

The comparison covers baselines such as NGS-m-BS, NS-VQA, NSCL, NMNs and LXMERT, which are the state-of-the-art neural or neurosymbolic models for each task.

The MNIST-R suite uses DeepProbLog (DPL) and the authors' prior work (Prior) as baselines, while the HWF task uses NGS-m-BS, NGS-RL and NGS-MAPO. The authors suggest dtkp with k set to 3 as a default, since it is often the best performer. They describe choosing a provenance as similar to hyperparameter tuning, so it stays a per-application decision.

The prior work, which supported only positive Datalog, couldn't express five of the eight tasks. Those five tasks need negation or aggregation, and HWF also needs floating-point support that the prior work lacks. So the expressiveness claim rests on this comparison, while the per-task accuracy values appear only in the overall figure.

Runtime and data efficiency

Table 4 reports average training time per epoch for each Scallop variant and for the baselines. On sum2 the dmmp variant averaged 34 seconds per epoch, compared to 21,430 seconds for DPL. Cost rises with k, since dtkp-10 took 185 seconds on sum2, compared to 72 seconds for dtkp-3. The diff-top-k-proofs provenance carries the most work, because its weighted model counting is the main contributor to runtime.

Table 4: Runtime efficiency comparison on selected benchmark
tasks. Numbers shown are average training time (sec.) per epoch.
Our variants attaining the best a…

Table 4 . Runtime efficiency comparison on selected benchmark tasks. Numbers shown are average training time (sec.) per epoch. Our variants attaining the best accuracy are indicated in bold.

Original paper · CC BY 4.0

On HWF the authors trained dtkp-5 on 100%, 50% and 25% of the training data. At full data Scallop scored 97.85, compared to 98.5 for NGS-m-BS, so it is slightly behind there. At 25% of the data Scallop scored 92.95, compared to 93.3 for NGS-m-BS, a gap that is also small. The authors use this table to show that Scallop's accuracy degrades gently as labelled data shrinks.

Table 5: Testing accuracy of various methods on
HWF when trained with only a portion of the data.
Numbers are in percentage (%)

Table 5 . Testing accuracy of various methods on HWF when trained with only a portion of the data. Numbers are in percentage (%).

Original paper · CC BY 4.0

Data efficiency is clearest on PacMan-Maze, where Scallop needs far fewer episodes than DQN. Scallop reached a 99.4% test success rate in 50 training episodes, while the end-to-end DQN approach needed 50K episodes to reach 84.9%. On HWF, Scallop stays close to NGS-m-BS without beating it. The authors report the PacMan-Maze gain as a data-efficiency result, not as a general claim across all tasks.

Where errors come from

The authors inspected the interface relations to find where Scallop goes wrong. Compared to purely neural models, Scallop's solutions make it easier for programmers to debug errors. Their manual checks showed that most errors come from inaccurate predictions by the neural components. For CLUTRR, the RoBERTa model correctly extracted only 84.69% of kinship relations.

Two causes are possible: the neural component may not be powerful enough, or the solution may not give adequate supervision to train it.

Better neural architectures or more data address the first cause. Tuning the selected provenance can mitigate the second cause. Incorporating integrity constraints into training or inference can also mitigate the second cause. These integrity constraints are the kind discussed in Section 3.2. In PacMan-Maze, a constraint saying the arena should hold at most one goal helps improve robustness.

The paper doesn't report how many of the errors come from each of the two causes. Because the interface relations are visible, a programmer can check whether the neural output or the logic is responsible. The paper's error analysis stays at the level of these two causes and the mitigations listed.

Limitations of termination, provenance cost and missing features

Termination isn't guaranteed in SclRam in general, because features such as value creation can keep producing new facts. The authors can only prove termination on a per-provenance basis, so a single guarantee doesn't cover every provenance. For example, if a program terminates under untagged semantics, it terminates under tagged semantics with max-min-prob provenance.

Under max-min-prob, the database saturates on the 7th iteration in their PacMan example, which is slower than untagged Datalog's 4 iterations.

The damp saturation check always returns true to avoid non-termination, and this decision makes damp less suitable for complex recursive programs. Because damp's disjunction and conjunction are plain addition and multiplication on dual-numbers, its operations take O(n) time, slower than dmmp.

The tunable k lets a user balance runtime against reasoning granularity, but the authors don't offer a rule that fixes it for every application. Advanced statistical sampling and generative modeling aren't supported yet, and the authors leave them for future work. Provenance selection stays a hyperparameter-style search, so a user has to tune it for each application.

Paper info

Authors
Ziyang Li, Jiani Huang, Mayur Naik
Venue
arXiv · Preprint
First published
2023-4-10
Added
2026-11-6
Updated
2023-4-10
Version
v1
arXiv
2304.04812
Category
cs.PL · cs.AI · cs.LG
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Abstract

We present Scallop, a language which combines the benefits of deep learning and logical reasoning. Scallop enables users to write a wide range of neurosymbolic applications and train them in a data- and compute-efficient manner. It achieves these goals through three key features: 1) a flexible symbolic representation that is based on the relational data model; 2) a declarative logic programming language that is based on Datalog and supports recursion, aggregation, and negation; and 3) a framework for automatic and efficient differentiable reasoning that is based on the theory of provenance semirings. We evaluate Scallop on a suite of eight neurosymbolic applications from the literature. Our evaluation demonstrates that Scallop is capable of expressing algorithmic reasoning in diverse and challenging AI tasks, provides a succinct interface for machine learning programmers to integrate logical domain knowledge, and yields solutions that are comparable or superior to state-of-the-art models in terms of accuracy. Furthermore, Scallop's solutions outperform these models in aspects such as runtime and data efficiency, interpretability, and generalizability.

Quote from the paper

Ziyang Li, Jiani Huang, Mayur Naik (2023). Scallop: A Language for Neurosymbolic Programming. arXiv:2304.04812v1. https://arxiv.org/abs/2304.04812v1

BibTeX
@misc{li2023scallop,
  title = {{Scallop: A Language for Neurosymbolic Programming}},
  author = {Ziyang Li and Jiani Huang and Mayur Naik},
  year = {2023},
  eprint = {2304.04812},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.04812v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up