Google Semantic Reactor

From
Jump to: navigation, search

Youtube search... ...Google search

A tool for experimenting with natural language understanding (NLU) models via a Google Sheets add-on that allows the user to sort lines of text in a sheet using a variety of machine-learning models. Beyond ranking lists, Semantic Reactor can help write dialog for a chatbot, such as a customer service chatbot, using semantic similarity. Specifically, it can quickly add new question/answer pairs and test different phrasings, enabling developers to see how the model reacts to them. Semantic Reactor can also search through text using input-response, meaning it can examine a list of potential responses and rank each according to which the model thinks is the most likely. In input-response mode, the model predicts the most conversational response to an input, and in semantic similarity mode, it returns the answer that’s semantically closest to the input.

pasted-image-0-2.png

Why use the Semantic Reactor?

There are a lot of interesting things you can do with the Semantic Reactor, but let’s look at the following two:

  • Writing dialogue for a bot that exists within a well-defined environment and has a clear purpose (like a customer service bot) using semantic similarity.
  • Searching within large collections of text, like from a message board. For that, we will use input-response.

Writing Dialogue for a Bot Using Semantic Similarity

For the sake of an example, let’s say you are writing dialogue for a bot that answers questions about a product, in this case, cookies.

If you’ve been running a cookie hotline for a while, you probably can list the most common cookie questions. With that data, you can create your cookie bot. Start by opening a Google Sheet and writing the common questions and answers (questions in the A column, answers in the B).

Here is the start of what that Sheet might look like. Make a copy of the Sheet, which will allow you to use the Semantic Reactor Add-on. Use the tool to experiment with new QA pairs and how each model reacts to them.

Here are a few queries to try, using the semantic similarity rank method:

Query: What are cookie ingredients? Returns: What are cookies made of?

Query: Are cookies biscuits? Returns: Are cookies also called biscuits?

Query: What should I serve with cookies? Returns: What drinks go well with cookies?

Searching Through Text Using Input-Response

Sometimes you can’t anticipate what users are going to ask, and sometimes you might be dealing with a lot of potential responses, maybe thousands. In cases like that, you should use the input-response ranking method. That means the model will examine the list of potential responses and then rank each one according to what it thinks is the most likely response.

Here is a Sheet containing a list of simple conversational responses. Using the input-response ranking method, try a few generic conversational openers like “Hello” or “How’s it going?”

Note that in input-response mode, the model is predicting the most likely conversational response to an input and not the most semantically similar response.

Note that “Hello,” in input-response mode, returns “Nice to meet you.” In semantic similarity mode, “Hello” returns what the model thinks is semantically closest to “Hello,” which is “What’s up?”

Mystery of the Three Bots

To dispel some of the intimidation of using natural language understanding (NLU), and to demonstrate how it can be easily used with pre-trained, generic models, Google has released a tool for creating dialog-based games, the Semantic Reactor, and open-sourced example code, The Mystery of the Three Bots that allows you to experiment with machine-learned language models...

This simple dialog-based game is an example of using a machine-learning model inside of a web application. The model it uses is called Universal Sentence Encoder lite and is available at Tensorflow Hub. To learn more, go to the Google Cloud AI Workshop Page.

Mystery of the Three Bots is a simple dialog-based game utilizing machine learning to enable you to communicate with three characters. The goal is to determine which of several guests stole the precious MacGuffin Diamond. You interrogate three robot servants who were present during the crime:

  • Butler
  • Maid
  • Chef

The game is built as an Angular app in TypeScript. The machine learning model uses a Javascript implementation of the Universal Sentence Encoder lite, which it preloads using JSON files that were generated from comma-separated values (CSV) files (butler.csv, maid.csv, chef.csv) for each of the characters (see generate_models.js).

The game works by matching a representation of the player's input to precomputed representations of candidate strings and calculates a similarity score. For example, if the player types "Where'd the diamond go?", the game might determine that it has a similarity of 0.86 to "Where is the diamond?", and if that's a greater score than the other candidates, the game will use that as the question to the bot and return the corresponding response.

How it Works

The Mystery of the Three Bots was created using machine learning and natural language understanding. A deep-learning model, trained on billions of lines of conversation, enables players to talk to the robots through a technique called "semantic matching," sometimes called "fuzzy matching."

The robots you interview in the game are actually made up of just 200 or so pre-written conversation pairs. As the goal of the player is fixed (solve the mystery) the game writers anticipated the kinds of questions a player would ask. For example: “What did Miss Red do during dinner?” and “What container is in the Living Room?”

However, players will often use different words to ask those same questions. For example:

  • “Did Ms. Red act weird at dinner?” and
  • “Any place to hide something in the Living Room?”

This is where the natural language understanding (NLU) tech comes in.

To create the illusion of open conversation, the model handles player queries by semantically matching them to a pre-written query. Essentially, the model says: "The player said this, and that’s pretty close in meaning to this anticipated query, so I’ll return that one."

Semantic matching is used in many digital personal assistants, customer service platforms and other applications. The Mystery of the Three Bots is a small example of how it might be used within a game.