Natural Language Processing 
with the Amazon Echo: Novus

Table of Contents:

What is the Echo?

High-level overview of project

Why Neo4j?

Summary of process
Slide
This is a text cell.

The Skill

the Lambda handler

the Intent Schema

the Utterances

How it Works

More on Wolfram

Future applications and directions

What is the Echo?

The Amazon Echo is a voice powered device that allows users to automate a variety of tasks from sending emails, ordering food, turning lights on and off, and perform complex computations. It is powered by the Alexa Voice Service

The Alexa Skills Kit (ASK) is a collection of self-service APIs, tools and assorted documentation that make it easier to add new skills to your device in order to perform the tasks that you want

High-level overview:

Why Neo4j?

Neo4j is a graph database management system; graph databases are the future

Graph databases are comprised of nodes which represent entities, and edges which represent relationships between entities

hence, relationships are 1st class citizens of a graph DB

The power of graph databases come from three key features:

Performance

Flexibility

Agility

Performance:

As a company’s dataset grows, performance tends to decrease with other kinds of databases. This has to do with the way aggregate or relational databases manage connected data: anything more than a shallow traversal of immediate relationships will be slow because of the number of index lookups involved. In contrast, graph DB have index-free adjacency; because of the fundamentally path-oriented nature of the data model, any path-based operation is going to be fast because it is aligned with the way in which the data is laid out. This also lends itself to localization of queries because each query will traverse the graph in an optimized way. Thus, performance as a database grows will remain constant.

Flexibility:

Graphs are naturally additive i.e., we can add new kinds of relationships, new nodes, new labels, and new subgraphs — new pieces of information — to an existing structure without disturbing existing queries and application functionality. This flexibility extends to the way in which we first think about relationships, via a whiteboard approach, before they are implemented in the structure. Hence, structure and schema emerge in tandem with our growing understanding of the problem space (as opposed to being enforced from the get-go) even before digitalization.

Agility:

Graph DB are perfect for the fast-paced environment of BL; it allows us to evolve our data model in step with the rest of our technology stack. The schema-free nature of graph DB — coupled with the readily testable nature of a graph DB’s API and query language — lets us evolve an application in a controlled manner.

The Process:

User gives an input that follows a specific utterance pattern

Utterances trigger the launch or intent request specified in the AWS Lambda server

Lambda triggers the EC2 server, which in turn runs the associated scripts for data querying and computation

The results of the computation are stored in the server as a new JSON file

This new file is then converted to a webpage and Alexa is alerted that this occurs

Alexa gives the appropriate speech output back to the user

The Skill

The skill itself is governed by three parts:

The Lambda handler

The intent schema

The associated utterances

Lambda Handler:

The Lambda handler is the base of the skill: It handles the general functionality and relates them to defined intents. An intent represents an action that fulfills a user’s spoken request; it is a specific part of your overall service that your skill provides. The Lambda handler also handles the helper functions that build the responses Alexa outputs.

Intent Schema:

The intent schema is a defined set of valid intents in a JSON format:

{
  "intents": [
    {
      "intent": "firstIntent",
      "slots": [
        {
          "name": "Name1",
          "type": "LIST_OF_VALUES"
        },
        {
          "name": "Name2",
          "type": "AMAZON.BUILT_IN_TYPE"
        }
      ]
    },
    {
      "intent": "secondIntent"
    }
  ]
}

Each intent has two properties: the intent property gives the name of the intent, and the slots property lists the applicable values that can be used to invoke the intent in speech.

Utterances:

The utterances are what the user speaks to invoke the skill. There can be many utterances per intent request. They are sentences that can contain the variable slot values:

MyIntent   launch my intent for {slotValue}
MyIntent   find my intent for {slotValue}

How It Works

Once the skill is invoked via Alexa Voice Service, the associated functions that handle the skill’s capabilities are utilized. These functions include GET requests that are sent to retrieve information from the EC2 server via a web-based API developed through the Flask framework. Depending on the intent, certain pieces of information or computation will happen server-side:

The first intent validates a user’s credentials for added security. The intent schema hosts a list of possible usernames and passwords, and the GET request attempts to match these listed values to the web API on the EC2 instance. If there is not a match, then the user cannot retrieve any information until they are validated.

The second intent takes the user’s stored validated credentials from the previous intent, and sends a GET request to the web API on the EC2 instance that computes the latest possible report of the data; this request triggers a python subprocess script that runs Wolfram Language code for the desired computation and then exports it as a JSON file and stores it elsewhere in the EC2 server. It’s this resulting JSON file that then turned into an interactive report using the d3 library.

The Wolfram Language script does multiple things:

It imports the raw data from the locally hosted Neo4j database

It converts the data into a suitable format

It then performs the necessary statistical calculations on the data

It finally exports the results to a separate JSON file that is stored elsewhere on the EC2 server

More on Wolfram...

Future Applications

Medical industry

patient home use

surgeon use

Space technologies

aboard ships in zero-gravity environments

Future Code:

More accurate statistics

Using the FindDistribution function will provide us with a more accurate statistical interpretation of the given data, because it looks for the best n distributions for a given dataset. As opposed to using DistributionFitTest which tests against a family of normal distributions

Less rudimentary security layer

Visual understanding of Alexa’s “thought process”

a way for folks to see how Alexa is processing all of this information that you have given her

Implementing use of Wolfram Cloud

This was our Plan A, but we did not have enough time to deal to sufficiently troubleshoot the Cloud