PSyKI - psykei/psyki-python Wiki

Theory

The design of PSyKI is inspired by a common SKI workflow that has been derived analyzing SKI algorithms from the literature. There are 4 macro stages during SKI:

  • the first one is straight forward and it consists in parsing the symbolic knowledge into some data structure like an AST (abstract syntax tree);
  • then there is the need to pass from crispy logic rules (they can be either true or false, there is no in-between) to a continuous interpretation (usually into [0, 1] range) to later inject them into a sub-symbolic predictor, we call this step fuzzification;
  • the injection stage is algorithm-specific, however the vast majority of literature works fall back into three macro families (constraining, structuring, embedding). The output of this step is a predictor capable of exploiting the prior knowledge;
  • finally training is virtually always required.

SKI workflow

Overall design

Following the previous workflow, we designed PSyKI in such a way to offer support (an abstraction) to each stage of the workflow. The main entity of PSyKI is the Injector. An Injector is a SKI algorithm for a specific predictor. The user can inject prior symbolic knowledge encoded in a set of Formula(e) and obtain a new predictor that is able to exploit the knowledge during the training (and after it). An Injector requires a Fuzzifier to map crispy logic formulae into a continuous interpretation.

PSyKE class diagram

A Formula is a visitable data structure that encodes one logic rule written in a specific logic formalism. Right now there is support for Datalog formulae (with negation but without function symbols, aka no recursion). A Fuzzifier transforms a Formula into a sub-symbolic object (e.g., ad-hoc layers of neural networks, continuous functions, etc.).