Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a compositional neural instance retriever to handle incompleteness in the data #123

Open
Jean-KOUAGOU opened this issue Dec 4, 2024 · 17 comments
Assignees
Labels
enhancement New feature or request

Comments

@Jean-KOUAGOU
Copy link

  • A compositional neural instance retriver can parse and encode a class expression into a continuous vector, which is then used together with the embedding of an individual to produce a probability "that the individual is an instance of the class expression"

  • We plan to implement three compositional neural instance retrievers based on: 1) a transformer architecture, 2) an rnn architecture, 3) the NAND operator and direct interpretations of DL concetpts as sets

  • An initial implementation with a transformer architecture is available at https://github.com/dice-group/CoNeuralReasoner

  • Integration should start in the coming weeks

@Demirrr
Copy link
Member

Demirrr commented Dec 4, 2024

@LckyLke and @Jean-KOUAGOU

We have two different neural OWL reasoner that can retrieve instances by using embeddings/neural networks
@LckyLke and @Jean-KOUAGOU. Given that @LckyLke 's approach already implemented/experimented etc., please create a feature branch @LckyLke and integrate your model into owlapy that is already integerated in ontolearn (later on we will depricate it in ontolearn)

Todos for @LckyLke :

  • Create a python package named owl_neural_reasoners
  • Create an abstract.py that specifies the interface of our neural reasoners
  • Create a script that only contains your approach
  • Create an example for the retrival task into examples folder ( this basically => https://github.com/dice-group/Ontolearn/blob/develop/examples/retrieval_eval.py)
  • Write a regression test for the retreival performances on family dataset

Once these steps are done, @Jean-KOUAGOU can start their integration of compostional neural instance retriever

Please thumps up of you like the plan

@Demirrr Demirrr added the enhancement New feature or request label Dec 4, 2024
@LckyLke
Copy link
Collaborator

LckyLke commented Dec 4, 2024

We have to see if the interface, i.e. the abstract neural reasoner, needs adjustment depending on which methods the neural reasoners should really have to implement.

Also now we have dicee (for KGE) and ontolearn (for example script) as dependecies

Feature branch: here

@Demirrr
Copy link
Member

Demirrr commented Dec 4, 2024

I have been thinking about following our design

from owlapy.owl_ontology_manager import SyncOntologyManager, OntologyManager
from owlapy.owl_reasoner import StructuralReasoner, SyncReasoner
cwr_reasoner=StructuralReasoner(ontology=OntologyManager().load_ontology(path="KGs/Family/father.owl"))
owr_reasoner=SyncReasoner(ontology=SyncOntologyManager().load_ontology(path="KGs/Family/father.owl"),reasoner="HermiT")
neural_reasoner_A=NeuralReasonerA(ontology=NeuralReasonerOntologyManager(), ...)
neural_reasoner_B=NeuralReasonerB(ontology=NeuralReasonerOntologyManager(), ...)

@Demirrr
Copy link
Member

Demirrr commented Dec 4, 2024

Why do you think that we need ontolearn here ?

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 4, 2024

Why do you think that we need ontolearn here ?

Yes, I guess I should refactor and use Structural reasoner directly for the reference results

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

Now we dont use ontolearn anymore :)

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

I have been thinking about following our design

from owlapy.owl_ontology_manager import SyncOntologyManager, OntologyManager
from owlapy.owl_reasoner import StructuralReasoner, SyncReasoner
cwr_reasoner=StructuralReasoner(ontology=OntologyManager().load_ontology(path="KGs/Family/father.owl"))
owr_reasoner=SyncReasoner(ontology=SyncOntologyManager().load_ontology(path="KGs/Family/father.owl"),reasoner="HermiT")
neural_reasoner_A=NeuralReasonerA(ontology=NeuralReasonerOntologyManager(), ...)
neural_reasoner_B=NeuralReasonerB(ontology=NeuralReasonerOntologyManager(), ...)

but why should we what some form of ontology parameter? Usually we don't want to load an ontology in to memory for a KGE based model, do we?

@Demirrr
Copy link
Member

Demirrr commented Dec 5, 2024

You are right that we do not want to load an ontology into memory for KGE base models if the path of a pretrained model is given.

The purpose of NeuralReasonerOntologyManager() is to encapsulate the preprocessing steps, read and write computations within an ontology manager class. By doing so, we can abide by the interface of using reasoners (e.g. StructuralReasoner and SyncReasoner)

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

I will think of a sensible implementation for this class as well than 👍🏼

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

@LckyLke and @Jean-KOUAGOU

We have two different neural OWL reasoner that can retrieve instances by using embeddings/neural networks @LckyLke and @Jean-KOUAGOU. Given that @LckyLke 's approach already implemented/experimented etc., please create a feature branch @LckyLke and integrate your model into owlapy that is already integerated in ontolearn (later on we will depricate it in ontolearn)

Todos for @LckyLke :

* [x]  Create a python package named owl_neural_reasoners

* [x]  Create an abstract.py that specifies the interface of our neural reasoners

* [x]  Create a script that only contains your approach

* [x]  Create an example for the retrival task into examples folder ( this basically => https://github.com/dice-group/Ontolearn/blob/develop/examples/retrieval_eval.py)

* [x]  Write a regression test for the retreival performances on family dataset

Once these steps are done, @Jean-KOUAGOU can start their integration of compostional neural instance retriever

Please thumps up of you like the plan

for the regression test to work with the github action we should provide a pretrained model for Family somewhere to fetch during testing.

@Demirrr
Copy link
Member

Demirrr commented Dec 5, 2024

Why don't we train the model from scratch and evaluate it as we have been doing in the dice-embeddings ( see for example https://github.com/dice-group/dice-embeddings/blob/develop/tests/test_regression_conex.py)

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

What hardware are we running this action on? I thought this might take too long but if there is gpu available this would work ofc 👍🏻

@Demirrr
Copy link
Member

Demirrr commented Dec 5, 2024

It doesn't take much time even without gpu provided that the number of epochs, embedding dims are set accordingly 😀

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 5, 2024

Ok I will test how long it takes :)

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 6, 2024

You are right that we do not want to load an ontology into memory for KGE base models if the path of a pretrained model is given.

The purpose of NeuralReasonerOntologyManager() is to encapsulate the preprocessing steps, read and write computations within an ontology manager class. By doing so, we can abide by the interface of using reasoners (e.g. StructuralReasoner and SyncReasoner)

Should preprocessing involve training a model if a kb path is provided?

@Demirrr
Copy link
Member

Demirrr commented Dec 6, 2024

I would say no because the training process might differ between approaches.

@LckyLke
Copy link
Collaborator

LckyLke commented Dec 12, 2024

Cause of Issue #124 I removed the neural ontology manager for the time being

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants