How to Add An NLP Web Service Solution to RIDE

Overview

The RIDE standalone application features a collection of example scenes that display key capabilities of the API. 

This tutorial shows how developers can add additional NLP web services to RIDE.

Page Contents

ExampleNLP_OpenAI_GPT-3

Overview

This tutorial shows how developers can add additional NLP web services to RIDE.

Background:

  • RIDE communicates with cloud NLP services through their REST APIs
  • RIDE provides a series of C# interfaces that can be implemented and extended
  • RIDE provides a common REST web services framework 
  • See the ExampleNLP scene and associated script for existing NLP solutions

Requirements

  • Existing NLP AI web service (e.g., AWS Lex) account
  • Web service requirements (e.g., authentication method)
  • Web service interaction details (e.g., endpoint URI)

Set Up External NLP Service

Implement RIDE C# Interfaces 

  • RIDE offers interfaces for web requests and responses, with specialized interfaces for NLP, which in turn get implemented for specific solutions:
    • IRideSystem
      • INLPSystem
        • INLPQnASystem (question answering interface)
          • AWSLexSystem
          • AzureQnAMakerSystem
          • GoogleDialogFlowSystem
          • INLPEntitiesSystem (entity analysis interface)
            • AzureTAEntitiesSystem
          • INLPSentimentSystem (sentiment analysis interface)
            • AzureTASentimentSystem
  • In terms of interaction, an NLP solution typically provides a single response given a single  request. In RIDE, the INLPQnASystem is most commonly used for these basic inputs and outputs, even when these not necessarily map to actual questions and answers. If your NLP solution provides more complex interactions, you may want to create an alternative NLP system that implements INLPSystem.
  • The INLPQnASystem structure is as follows:
    • ServiceRequest
      • NLPRequest
        • NLPQnAQuestion
    • SystemResponse 
      • NLPResponse
        • NLPQnAAnswer
  • Note that in the currently implemented NLP systems an NLPRequest and NLPQnAQuestion, as well as, NLPResponse and NLPQnAAnswer, are functionality similar. As such, they may not always be as consistently used as they should.
  • Create a new C# file within the Ride.NLP namespace to contain the Request/Question and Response/Answer structures in the format the NLP solution uses. 
    • Typically this will be JSON that is (de-)serialized. You can manually create the structs, or copy example JSON and in MS Visual Studio select Paste Special > Paste JSON as Classes. 
    • Example: OpenAIGPT3.cs
  • Create a new C# file within the Ride.NLP namespace to contain the new NLP system.
    • Inherit from RideSystemMonoBehaviour and implement INLPQnASystem
    • Implement the AskQuestion and Request functions, using the earlier defined structures
    • Example: OpenAIGPT3System.cs
    • Note that authorization in particular determines how to send the web request. Look at the Azure, AWS and Google NLP solutions to see how each case is handle.

Create Test App

  • Create a new scene and script to test your new NLP solution
  • Initialize your RIDE NLP system, call the new AskQuestion function and provide an OnComplete function that handles the response
  • Example: ExampleNLP scene, any of the OpenAI related code in the associated C# script

Related Example Information

Refer to the NLP Service Comparison page under the Examples documentation for more about NLP web services currently in RIDE.

Achievement Unlocked!

What other cloud solutions might you implement within RIDE to benefit your research and simulations?