This library provides an API for the Probabilistic Soft Logic (PSL) framework to allow programmatically defining PSL problems as well as using several other functionalities:
Each PSL problem's RuleAtomGraph (the graph connecting a ground rule with the associated ground atoms) is extracted after the inference is complete.
- The method
putsPressureOnGrounding
indicates whether a given ground rule is active with respect to the value of a given ground atom in the MAP state. distanceToSatisfaction
returns a grounding's distance to satisfaction.getCounterfactual
provides information on whether a given ground rule would be violated if the score of a given atom were modified slightly.
The subpackages talk
,
talk.pred
,
and talk.rule
allow the definition of PSL problems with human-understandable inference explanations.
If you define a custom rule class, it needs to extend one of the following classes:
TalkingLogicalRule
: weighted logical rulesTalkingLogicalConstraint
: logical constraintsTalkingArithmeticRule
: weighted arithmetic rulesTalkingArithmeticConstraint
: arithmetic constraints
Overriding a rule's generateExplanation
code allows creating custom templates for explaining the rule's logic in the context of a selected associated ground atom.
Otherwise, the rule is verbalized using according to a default paradigm.
To create predicates that can easily be rendered as noun phrases or sentences, extend the TalkingPredicate class.
Extend the PslProblem class to declare the predicates and rules that should be used for an inference. Extend the IdeaGenerator to write code for generating ground atoms.
The PartitionManager allows for several PSL inferences to be run at once if they use disjoint sets of (target) atoms. (We are also working on a queuing mechanism for problems with overlapping atom sets.)
The eval
package allows evaluating inference results against a gold standard.
Please refer to the repository's wiki for a walkthrough of a simple sample project.
The psl-ragviewer library contains code for inspecting the inference results created with the code in this repository in a GUI.