Workflow Quick Start

A step-by-step guide on how to extract sentiment from restaurant reviews

Workflows are at the core of 90%of AirOps use cases. In this guide, we will make an example Sentiment Analysis app that extracts sentiment, keywords, and a sentiment score from a restaurant review.

Let's dive in...

1. Define Workflow inputs

  1. Click on a Blank Workflow to start a draft of your Workflow

  2. Click Add field to group in the Start step

  3. Click on Long Text to create a multi-line text box

  4. Label the field "Restaurant Review"

  5. Optionally: configure the Variable Name, which will be used to reference the input. Notice the variable name will be "restaurant_review" by default.

  6. Optionally: write a Hint to provide further detail or instructions for the user such as "Enter a single restaurant review to analyze"

  7. Make the field Required by clicking on the toggle

  8. Click Save field

2. Configure the Large Language Model step

Next, we need to use an LLM step to analyze the sentiment of the restaurant review. We are going to add the following info to the LLM Step :

  1. System Prompt - The role/objective we want the model to fulfil

  2. Example User / Assistant Pairs - Static examples of the model performing the task required to train it

  3. A real request - The actual request we want the model to perform with the runtime data

i. Set up the LLM step

  1. Click Add Step > LLM > Configure

  2. Choose GPT Turbo 3.5 as the model (always experiement with different models to find the best one)

  3. Set the Temperature to 0.1 (temperature determines the amount of variability and creativity in the response - the higher the temperature, the more varied the response)

ii. Define the System Prompt

The System prompt specifies the persona and/or task of the AI, it is optional. Set it to the following :

System: You are a restaurant review analyzer. Extract positive keywords, negative keywords, and a sentiment score on a scale from -1.0 to 1.0, in 0.1 increments, from the restaurant review. Output in JSON only

Experiment further : You can specify whether you want to Stream Results (as they are generated by the model) or request consistent results from the model. For more information on these settings, please see our document on the LLM Step.

iii. Provide an Example of the Correct Response with a User-Assistant Pair:

User / Assistant pairs are example input / output pairs that help demonstrate to the model how to behave with real examples.

The LLM will attempt to follow conventions and behaviors demonstrated in the User / Assistant pairs that you pass in. It's a very powerful way to "train" the model how to behave and with larger models, 5, 10 or even 50 examples can be passed in.

This technique is also known as K-Shot prompting. "K" represents the number of examples you are providing.

User: I ordered chirashi for lunch. Good presentation. Need to work on the freshness of the items. Service was good. Would not return for raw items.

Assistant: { "positive_keywords": [ "good presentation", "service was good"] "negative_keywords": [ "need to work on the freshness of the items", "would not return for raw items" ] "sentiment_score": 0.2 }

Use a real example: The best way to generate high-quality outputs is by providing a high-quality example to the model. Use the most realistic example when possible, whether from the internet or from your own data.

iv. After your examples, add your real input in a final User message

Now that we've provided an example to the model, we need to provide the restaurant review to the model by referencing the variable name with Liquid syntax:

  1. Get the variable name from your input in the Start Step (restaurant_review)

  2. Add a user message after the User/Assistant pair you provided from Step 2

  3. Click on the pill of your input variable in the user message - this will apply Liquid syntax to your variable!

User: {{restaurant_review}}

3. Name, Test, and Publish

  1. Add a name and emoji for your application to help distinguish it

  2. Test and validate that it works as expected:

    • Click Test All

    • Copy and paste a restaurant review to analyze

    • Click Execute

  3. Click Publish App after testing

  4. Click Run App to see and run your final app

Last updated