Agents and LRNN in 2P-Kt

abstract

In the last few years neural network have proven to be a quite efficient tool to solve complex problems, unfortunately they lack the interpretability and expressive power of first-order logic; Lifted Relational Neural Networks (LRNN) have been proposed to tackle this problem.

In particular, the latent relational structure of a given problem is described by a set of first-order logic rules that are then used to create a number of neural networks, one for each example.

Given that the problem setting is shared by all the examples, the corresponding neural networks share their weights and these can be efficiently learned using stochastic gradient descent.

2P-Kt is a Kotlin-based and multi-platform multi-paradigm logic programming framework based on tuProlog.

It aims at becoming an open ecosystem for Symbolic Artificial Intelligence, and it does so by providing a set of inter-dependent modules supporting knowledge representation and automatic reasoning through logic programming.

outcomes

Online Report

Summary

This project goal is to add to 2P-Kt a module that provides an implementation of LRNN, this will be obtained by leveraging on the official implementation of LRNN, NeuraLogic, available in github.The expected deliverable is a module that uses existing modules of 2P-Kt to provide the description of a problem and then relies on NeuraLogic to construct the NNs, associated to the examples written with 2P-Kt, and to learn their weights through stochastic gradient descent.In order to reach this goal the project could be divided into the following steps:
  1. Create classes/sub-types from interfaces of Fact and Rule to deal with weighted clauses
  2. Provide a way to save template, examples and queries in '.txt' files, using string formatter 2. Provide a way to create additional test queries and to use the learned weights to perform inference 2. Check template to avoid cycles
  3. Create a Solver that calls NeuraLogic with path to the files created in (2)
  4. Check queries in order to avoid using those not matched in the ground network (NeuraLogic stops with error)

NeuraLogic

As of 04/2020, commit: ac33e94

Value Hierarchy

Value

Abstact class provided in package cz.cvut.fel.ida.algebra.values, implements Iterable, Comparable and Serializable.value_umlclass.png

ScalarValue

scalarvalue_umlclass.png

VectorValue

vectorvalue_umlclass.png

MatrixValue

matrixvalue_umlclass.png

One, Zero

ScalarValue constants used to make operations faster.

TensorValue

This class is a work in progress.

Weight

Provided in package cz.cvut.fel.ida.algebra.weights. It should be created via a factory.weight_umlclass.png

Term Hierarchy

Term

Provided in package cz.cvut.fel.ida.logic, implements Serializableterm_stateDiagram.png

Variable

Implements Term.variable_umlclass.png

Constant

Implements Term.constant_umlclass.png

Weighted Fact

Weighted Rule

Template Hierarchy

Template

Implements Model and Exportable.template_umlclass.png

Neuralizer

Implements exportable.neuralizer_umlclass.png

NeuralProcessingSample

Extends NeuralSample (Defined in "Neural/src/main/java/cz/cvut/fel/ida/neural/networks/computation/training/NeuralSample.java")neuralprocessingsample_umlclass.png

Query Hierarchy

Query

Abstract class, provided in package cz.cvut.fel.ida.learning, implements Exportable.query_umlclass.png

QueryNeuron

Provided in package cz.cvut.fel.ida.neural.networks.structure.components.neurons, extends Query, NeuralModel>.queryneuron_umlclass.png

Model Hierarchy

Interface Model

Provided in package cz.cvut.fel.ida.learning.model_int_umlclass.png

NeuralModel

It is provided in package cz.cvut.fel.ida.neural.networks.computation.training and implements Model.neuralmodel_umlclass.png

NeuralSample

It is provided in package cz.cvut.fel.ida.neural.networks.computation.training and extends LearningSample .neuralsample_umlclass.png

End2endTrainigBuilder

Provided in package cz.cvut.fel.ida.pipelines.building; Extends extends AbstractPipelineBuilder, Progress>>.

LRNN Module 2P-Kt

This module provides an interface between 2P-kt and NeuraLogic, in particular the classes FactProb and RuleProb can be used to go from 2P-kt's facts and rules to a format accepted by NeuraLogic, by associating them with weights and providing a way to create files in the format required by NeuraLogic's Pipelines.The class Sources is used to work with NeuraLogic's Sources and Settings, in order to change the parameters and the files to be used by the Pipeline. Activation is an enumeration class from which the user can choose the activation function to be used during training.More information are available in the README.md of the repository.

LRNN Solver

Leverages on the CLI and Pipelines modules of NeuraLogic to provided learning and inference functions to users. An example of usage is provided in it.unibo.tuprolog.lrnn.Example.ktlrnnSolver_umlClass.png

Sources

Provided in package it.unibo.tuprolog.lrnn.sources.sources_umlClass.png

FactProb

Provided in package it.unibo.tuprolog.lrnn.clauses.factprob_umlClass.png

RuleProb

Provided in package it.unibo.tuprolog.lrnn.clauses.ruleprob_umlClass.png

Activation

Enum class provided in package it.unibo.tuprolog.lrnn.clauses.activation_umlClass.png

Repo