Skip to content

Commit

Permalink
kif files for diffent levels of ai-dsl ontology prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
NuNetIO committed May 21, 2021
1 parent ff30f44 commit d6e4ea8
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 58 deletions.
28 changes: 28 additions & 0 deletions ontology/FakeNewsScore.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(instance fakeNewsScore SNetAIService)
(documentation fakeNewsWarning EnglishLanguage "Calls dependent services, calculates summary result from their outputs
and calculates the overall probability that the provided content contains fake news")

(hasDependency fakeNewsScore uclnlp)
(hasInput fakeNewsScore uclnlpOutput)
; there should be a way to infer this from the previous axiom

(hasDependency fakeNewsScore fnsBinaryClassifier)
(hasInput fakeNewsScore fnsBinaryClassifierOutput)
; there should be a way to infer this from the previous axiom

(hasOutput fakeNewsScore fakeNewsScoreOutput)
(instance fakeNewsScoreOutputType DataType)

(=>
(and
(subclass ?fakeNewsScoreOutput JSONDef)
(hasField ?fakeNewsScoreOutput url URL)
(...)
; all fields of actual data structure as approximately indicated here https://gitlab.com/nunet/fake-news-detection/fake_news_score/-/issues/22
; actual data structure is determined by the code
(...)
)
(instance ?fnsBinaryClassifierOutput fnsBinaryClassifierOutputType)
)

; ideally we should include here the definition of RealizedFunction, as described in Idris part of the AI-DSL
47 changes: 47 additions & 0 deletions ontology/NuNet.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(subclass NuNetEnabledSNetAIService SNetAIService)
(documentation NuNetEnabledSNetAIService EnglishLanguage "SNetAIService which can be deployed on NuNetEnabledComputers and orchestrated via NuNet platfrom")

(=>
(and
(hasMetadata ?SNetAIServiceMetadata ?SNetAIService)
(hasField ?SNetAIServiceMetadata RequiredComputingResources)
; includes many other prerequisites and special protobuf definitions
)
(instance ?SNetAIService NuNetEnabledSNetAIService)
)

(subclass NuNetEnabledComputer Computer)
(documentation NuNetEnabledComputer EnglishLanguage "A Computer which was onboarded to NuNet platfrom and complies to its requirements.")

(=>
(and
(hasRun ?NuNetEnabledComputer NuNetOnboardingScript)
(hasMetadata ?NuNetEnabledComputer ?ComputerMetadata)
(hasField AvailableComputingResources ?ComputerMetadata)
(or
(runsOS ?NuNetEnabledComputer Linux)
(runsOs ?NuNetEnabledComputer Raspbian)
)
(or
(hasHardware ?NuNetEnabledComputer PC)
(hasHardware ?NuNetEnabledComputer RaspberyPi)
)
)
(instance ?NuNetEnabledComputer NuNetEnabledComputer)
)

; here we check if a NuNetEnabledSNetAIService can be deployed on a NuNetEnabledComputer
; at any particular instance in time
; since AvailableComputingResources depend on state of the computer at that time
; (therefore it can be calculated only at runtime)

(=>
(and
(hasMetadata ?NuNetEnabledComputer ?ComputerMetadata)
(hasField ?AvailableComputingResources ?ComputerMetadata)
(hasMetadata ?NuNetEnabledSNetAIService ?SNetAIServiceMetadata)
(hasField ?RequiredComputingResources ?SNetAIServiceMetadata)
(lessThanOrEqualTo ?RequiredComputingResources ?AvailableComputingResources)
)
(canDeploy ?NuNetEnabledSNetAIService ?NuNetEnabledComputer)
)
9 changes: 9 additions & 0 deletions ontology/NuNetEnabledComputer.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(instance machineOne NuNetEnabledComputer)
(documentation machineOne EnglishLanguage "Free text explanation of the computer and its capabilities (if the owner wishes to expose)")

(hasMetadata machineOne ComputerMetadata)
; there should be a way to actually check that the metadata file is contained on the machine (or it returns it if needed)
(hasField AvailableComputingResources ComputerMetadata)
; there should be a way to check actual resources and reise them here
(runsOS machineOne Linux)
(hasHardware machineOne PC)
41 changes: 41 additions & 0 deletions ontology/SingularityNet.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(subclass SNetAIService ComputerProgram)
(subclass SNetAIService SoftwareContainer)
(documentation SNetAIService EnglishLanguage
"Software package exposed via SNetPlatfrom and conforming to the special packaging rules")

(subclass SNetAIServiceIO Descriptor)

(instance hasInput BinaryPredicate)
(domain hasInput 1 SNetAIService)
(domain hasInput 2 SNetAIServiceIO)

(instance hasOutput BinaryPredicate)
(domain hasOutput 1 SNetAIService)
(domain hasOutput 2 SNetAIServiceIO)

; we can also use TernaryPredicate here in order to make it more open for change
; currently I am not sure if it will make things more or less complicated

(=>
(or
(subclass ?SNetAIServiceInputIO JSONDef)
(subclass ?SNetAIServiceInputIO ProtoBufDef)
(subclass ?SNetAIServiceInputIO IdrisTypeDef)
)
(instance ?SNetAIServiceInputIO SNetAIServiceInputIO)
)

(instance hasMetadata BinaryPredicate)
(domain hasMetadata 1 SNetAIService)
(domain hasMetadata 2 SNetAIServiceMetadata)

; We can then define axioms defining valid json and protobuf on SNet platfrom
; Further, we want to define all primitive data types allowed by service ontologies
; however it is not clear how do to it in kif or SUMO
; so this is listed only as indication but is not correct
; this is subject of the future work

(subclass JSONDef DataType)
(subclass URL DataType)
(subclass Text DataType)
(subclass Boolean DataType)
22 changes: 22 additions & 0 deletions ontology/fnsBinaryClassifier.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(instance fnsBinaryClassifier SNetAIService)
(documentation fnsBinaryClassifier EnglishLanguage "A pre-trained binary classification model for fake news detection")

(hasInput fnsBinaryClassifier fnsBinaryClassifierInput)
(hasOutput fnsBinaryClassifier fnsBinaryClassifierOutput)

(instance fnsBinaryClassifierInputType DataType)
(instance fnsBinaryClassifierOutputType DataType)

(=>
(and
(hasField ?fnsBinaryClassifierInput mainText Text)
)
(instance ?fnsBinaryClassifierInput fnsBinaryClassifierInputType)
)

(=>
(and
(hasField ?fnsBinaryClassifierOutput fakeOrNot Boolean)
)
(instance ?fnsBinaryClassifierOutput fnsBinaryClassifierOutputType)
)
58 changes: 0 additions & 58 deletions ontology/sumo_install.sh

This file was deleted.

38 changes: 38 additions & 0 deletions ontology/uclnlp.kif
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(instance uclnlp SNetAIService)
(documentation uclnlp EnglishLanguage "Forked and adapted component of stance detection algorithm by UCL Machine Reading group.")

(hasInput uclnlp uclnlpInput)
(hasInput uclnlp uclnlpOutput)

(instance uclnlpInputType DataType)
(instance uclnlpOutputType DataType)

(=>
(and
(hasField ?uclnlpInput titleText AlphaNumericString)
(hasField ?uclnlpInput mainText AlphaNumericString)
)
(instance ?uclnlpInput uclnlpInputType)
)

(=>
(and
(hasField ?uclnlpOutput agree RealNumber)
(hasField ?uclnlpOutput disagree RealNumber)
(hasField ?uclnlpOutput discuss RealNumber)
(hasField ?uclnlpOutput unrelated RealNumber)
)
(instance ?uclnlpOutput uclnlpOutputType)
)

; THIS COMMENT APPLIES TO ALL SERVICE DEFINITIONS
;
; here we enter the territory of type definitions and type checking
; which is the subject of formal type-checking part of AI-DSL
; therefore it is left unfinished here
; however, what we could do here is:
; (1) define correct serviceInput and serviceOutput types (unique for each service)
; (2) if possible, provide proof that if a service data of correct type on input, then it will output correctly typed data
; (3) if that will not be possible (which is the default option when actual service AI are not written in Idris):
; (3.1) check if input data is of correct type at runtime and refuse to start service if it is not;
; (3.2) check if output data is of correct type before sending it to the caller and raise error if it is not so;

0 comments on commit d6e4ea8

Please sign in to comment.