Java Inference SDK

After you deploy a Qwak-based model, your JVM-based client applications can use this module to get inferences from the model hosted as a real-time endpoint.

Inference Example

The following example invokes the model test_model. The model accepts one feature vector which contains three fields and produces one output field named "score".

RealtimeClient client = RealtimeClient.builder()
                .environment("env_name")
                .apiKey(API_KEY)
                .build();

PredictionResponse response = client.predict(PredictionRequest.builder()
                .modelId("test_model")
                .featureVector(FeatureVector.builder()
                        .feature("feature_a", "feature_value")
                        .feature("feature_b", 1)
                        .feature("feature_c", 0.5)
                        .build())
                .build());

Optional<PredictionResult> singlePrediction = response.getSinglePrediction();
double score = singlePrediction.get().getValueAsDouble("score");

Installation

The Java Inference SDK is hosted on Qwak's internal maven repository.

Maven Configuration

To set up a Maven-based application that uses the Java Inference SDK, add the following sections to the projects pom.xml:

<project>

...

 <repositories>
   <repository>
     <id>qwak-mvn</id>
     <name>Qwak Maven Repository</name>
     <url>https://qwak.jfrog.io/artifactory/qwak-mvn</url>
   </repository>
 </repositories>

...

 <dependencies>
   <dependency>
     <groupId>com.qwak.ai</groupId>
     <artifactId>qwak-inference-sdk</artifactId>
     <version>1.0.11</version>
   </dependency>
 </dependecies>

</project>

Gradle Configuration

To set up a Gradle-based application that uses the Java Inference SDK, add the following sections to the projects build.gradle:

repositories {
  maven {
    url "https://qwak.jfrog.io/artifactory/qwak-mvn"
  }
}

...

dependencies {
    ...
    implementation 'com.qwak.ai:qwak-inference-sdk:1.0-SNAPSHOT'
}

Model metadata

To retrieve the model metadata, use the ModelMetadataClient:

import com.qwak.ai.metadata.client.output.ModelMetadata;

...
  
ModelMetadataClient client = ModelMetadataClient.builder()
  .apiKey("YOUR QWAK API KEY")
  .build();
ModelMetadata metadata = client.getModelMetadata("MODEL NAME");

The ModelMetadata class has the following methods:

public Map<String, Object> getModel() # returns information about the model
public List<Map<String, Object>> getDeploymentDetails() # if the model is deployed, it returns data about deployment configuration
public Map<String, Map<String, Object>> getAudienceRoutesByEnvironment() # audience configuration per environment
public List<Map<String, Object>> getBuilds() # data about the DEPLOYED builds