IBM / LNN

A `Neural = Symbolic` framework for sound and complete weighted real-value logic
https://IBM.github.io/LNN/
Apache License 2.0
226 stars 438 forks source link

Add support for filtering invalid groundings out #87

Open HRezaei opened 1 year ago

HRezaei commented 1 year ago

As you already know, doing outer join on constants produces many groundings which might be semantically invalid or impossible. This increases the size of the grounding table unnecessarily which in turn impacts performance drastically. To reduce search space, a proper solution might be to allow non-primitive types to be used in place of constants and then, to do type checking. Maybe you have plans for fixing this in a better way. However, here is a small change that makes this possible at least for some applications, in the meantime.

This PR allows developers to define their own neurons or formula (possibly inherited from LNN classes) and add a filter_valid_groundings method which takes the data frame of all potential groundings and returns another data frame in place. Thus they have the opportunity to filter out incompatible groundings.