word2owl

Mapping Natural Language to OWL and Back

word2owl is a system able to create, store and understand OWL 2 sentences.

It has 2 modes:

  • ⁠Insertion mode: an agent converts natural language sentences into OWL declarations and axioms, which are added to a knowledge graph;
  • ⁠Query mode: another agent uses the generated knowledge graph to answer – in natural language – the user’s natural language queries.

Once the user run the system he can immediately begin typing sentences and the agent will generate their OWL 2 translation, in a turn based dialogue fashion.

By typing “/query”, the user can switch to the query mode, in which he can ask the query mode agent about information stored in the knowledge. By typing “/test_insert”, the user can switch to the insert mode from text file, so that output is easily reproducible.

The system is capable of handling the following OWL 2 constructs:

  • Axioms: Declaration, SubClassOf, EquivalentClasses, DisjointClasses, ClassAssertion, ObjectPropertyAssertion, DataPropertyAssertion.
  • Class expressions: ObjectIntersectionOf, ObjectUnionOf, ObjectComplementOf, ObjectSomeValuesFrom, ObjectAllValuesFrom, ObjectMinCardinality, ObjectMaxCardinality, ObjectExactCardinality, DataMinCardinality, DataMaxCardinality, DataExactCardinality.

There are 4 different prompt strategies that the insertion mode’s agent can use: few-shot, few-shot Chain-of-Thought, prompt chaining few-shot, prompt chaining few-shot Chain-of-Thought.

The log of each session - containing the various stages of each inference and the inputs that the LLM receives - is available.

The initial state of the knowledge graph can be modified by altering the base ontology.

The agent is not perfect: it can give answers which are not entirely correct or construct syntactically incorrect axioms, especially for complex queries. This is a limitation of the model used, which is relatively small (8B). Better results could be obtained using larger, and more expensive, models.