Specification of Real-time Inference Request and Response
Specification of Request Payload Contents
A payload should be a JSON object. In the highest level, the JSON object contains four fields:
version, gml_task, graph, and targets.
{
"version" : string,
"gml_task" : string,
"graph" : object,
"targets" : [ ... ]
}
version– (String, required) The version of payload to be used. The current version isgs-realtime-v0.1.gml_task– (String, required) The graph machine learning task this payload is for. The current version supports two options:node_classificationnode_regression
graph– (JSON objects, required) The contents of a payload, with “nodes”, and “edges” keys. See below for details.targets– (Array of JSON objects, required) The contents of target nodes or edges for prediciton.
Contents of objects in the graph field
A graph object contains two objects: nodes, and edges.
{
"nodes" : [ ... ],
"edges" : [ ... ]
}
nodes– (array of JSON objects) Each object specifies anodeobject.edges– (array of JSON objects) Each object specifies anedgeobject.
Contents of a node object listed in a nodes array
A node object listed in a nodes array can contain the following required fields.
{
"node_type" : string,
"node_id" : string,
"features" : {
feature name: feature value,
feature name: feature value,
...
}
}
node_type– A string specifying the node type name in a graph. It should be same as thenode_typedefined in GConstruct JSON specification or thetypevalues ofnodesdefined in GSProcessing JSON specification.node_id– A string specifying a unique node identifier. The identifiers are used to build a sub-graph according to the contents of the edges object.features– A dictionary, with feature names as keys, and feature values as its values. Features names must match thefeature_nameentries defined in GConstruct JSON specification, or thenamevalues offeaturesfields defined in GSProcessing JSON specification.
Contents of an edge object listed in an edges array
An edge object listed in an edges array must contain the following required fields.
{
"edge_type" : [(source node type), (edge type), (destination node type)],
"src_node_id" : string,
"dest_node_id" : string,
"features" : {
feature name: feature value,
feature name: feature value,
...
}
}
edge_type– An array specifying the edge type name in the format of three strings, which indicate the source node type, the edge type, and the destination edge type. It should be same as therelationfields defined in GConstruct JSON specification or thetypevalues ofsourcerelation, anddestfileds defined in GSProcessing JSON specification.src_node_id– A string specifying the source node identifier.dest_node_id– A string specifying the destination node identifier.features– A dictionary, with feature names as keys, and feature values as its values. feature names should be same as thesefeature_namedefined in GConstruct JSON specification, or thesenamevalues offeaturesfields defined in GSProcessing JSON specification.
Contents of text features
- If the deployed model utilizes text features for model training, in the payload users can submit raw text directly as shown below. Features names must match the
feature_nameentries defined in :ref:`GConstruct JSON specification <gconstruction-json>`, or the
namevalues offeaturesfields defined in GSProcessing JSON specification.
{
"features" : {
feature name: <feature-text-value>,
...
}
}
Contents of a target object listed in a targets array
Depending on the value of gml_task, a target object in a targets array could be a node object
or an edge object as defined above. As a target object, the features field is not required.
Note
A target object, a
nodeor anedge, should have the samenodeoredgeobject in thenodesoredgesarray. For example, in the below payload example, theauthornodea39is a target node, and it also is one of the nodes in thenodeslist.{ "version": "gs-realtime-v0.1", "gml_task": "node_classification", "graph": { "nodes": [ { "node_type": "author", "node_id": "a4444", "features": { ...... }, }, { "node_type": "author", "node_id": "a39", "features": { ...... }, }, ...... ], "edges": [ ......] }, "targets": [ { "node_type": "author", "node_id": "a39" } ] }
Specification of Response Body Contents
A response body is a JSON object.
Response Body Syntax:
{
"status_code" : "int",
"request_uid" : "string",
"message" : "string",
"error" : "string",
"data" : {
results: [
{
"node_type" : "string",
"node_id" : "string",
"predictions" : [ ...... ]
},
or
{
"edge_type" : ["string", "string", "string"],
"src_node_id" : "string",
"dest_node_id" : "string",
"predictions" : [ ...... ]
}
]
}
}
Response Body Structure:
- (dict) –
status_code(int) –- An integer indicates the outcome status, including:
200: request processed successfully.400: the request payload has JSON format errors.401: the request payload missed certain fileds, required by Payload specification.402: the request payload missed values on certain fileds, e.g., missing a node identifier innode_idfield.403:node_typeof nodes in thetargetfield does not exist in thegraphfield.404: values of thenode_idfileds of nodes in thetargetfield do not exist in thegraphfield.411: errors occurred when converting the request payload into DGL graph format for inference.421: the task ingml_taskdoes not match the task that the deployed model is for.500: internal server errors.
request_uid(string) –A string serves as a unique identifier for the request payload. This identifier is logged on the endpoint side and returned to invokers, facilitating error debugging.
message(string) –A string provides additional information when the
status_codeis 200.
error(string) –A string provides detailed explanations when the
status_codeis NOT 200.
data(dict) –When the
status_codeis 200, includes a populateddatafield. Otherwise, thedatafield is empty.results(list) –A list that includes the inference values for all nodes or edges specified in the payload’s
targetsfield.- (dict) –
- For node prediction tasks (node classification and node regression):
node_type(string) –Specifies a node type name in a graph.
node_id(string) –Specifies a node identifier.
- For edge prediciton tasks (edge classification and edge regression):
edge_type(list ) –An array specifying the edge type name in the format of three strings, which indicate the source node type, the edge type, and the destination edge type.
src_node_id(string) –Specifies the source node identifier.
dest_node_id(string) –Specifies the destination node identifier.
prediction(list) –A list containing the inference results for all target nodes or edges. For classification tasks, the value of
predictionis a list of logits that can be used with classification methods such as argmax. For regression tasks, the value ofpredictionis a list with a single element, which represents the regression result.