ontolearn.scripts.litserve_neural_reasoner
Attributes
Classes
NeuralReasonerAPI is a LitAPI implementation that handles requests to a neural reasoner |
Module Contents
- class ontolearn.scripts.litserve_neural_reasoner.NeuralReasonerAPI(path_neural_embedding, gamma=0.9)
Bases:
litserve.LitAPI
NeuralReasonerAPI is a LitAPI implementation that handles requests to a neural reasoner using OWL expressions. It utilizes a neural embedding model for reasoning over ontology data.
- path_neural_embedding
Path to the neural embedding.
- Type:
str
- gamma
Minimum confidence threshold for the reasoning model, defaults to 0.9.
- Type:
float
- path_neural_embedding
- gamma
- setup(device)
Sets up the neural reasoner instance.
- decode_request(request)
Decodes an incoming request to extract the DL expression and namespace.
- Parameters:
request (dict) – A dictionary containing the request data, with ‘expression’ and ‘namespace’ keys.
- Returns:
A tuple with the DL expression (str) and namespace (str).
- Return type:
tuple
- predict(data)
Predicts individuals of the given OWL expression using the neural reasoner.
- Parameters:
data (tuple) – A tuple containing the DL expression (str) and namespace (str).
- Returns:
A set of individuals satisfying the given OWL expression.
- Return type:
set
- encode_response(output)
Encodes the output from the reasoner back into a DL expression format for response.
- Parameters:
output (set) – A set of OWL expressions representing the individuals.
- Returns:
A dictionary with ‘retrieval_result’ key containing a list of DL expressions as strings.
- Return type:
dict
- ontolearn.scripts.litserve_neural_reasoner.parser