Skip to main content

Reasoning

The Reasoning Step system enables characters to use logical reasoning and decision-making within the virtual world by considering specific Attributes. These Attributes can be configured to guide the behavior of an AI character based on outcomes of their thought process.

Reasoning

This guide covers the various ways in which the Reasoning Step can be used and how to configure it for your character.

Using the Reasoning Step Output

The output of the Reasoning Step can be used in two ways:

  • Reasoning output is automatically factored in when influencing character dialogue generation.
  • Reasoning output can be directly accessed to further power client-side changes.

Reasoning Step Uses


The Reasoning Step can be used in a variety of applications. Given below are the most common use-cases in which this step may be used to enhance an AI-driven character’s behavior.

Friendly Companion

Major NPCs and AI companions can be evolved beyond using pre-defined emotions, enabling custom emotions such as “nostalgia” or “envy” to be added to their repertoire. This allows for the creation of a companion that can respond in a more personalized and relatable manner, allowing for a deeper connection with the user.

Helpful Sidekick

A sidekick, advisor, or squadmate NPC can be equipped with the ability to determine if the player sounds frustrated or requires help. When these circumstances are detected, the character can offer assistance and trigger relevant actions to help the player overcome challenges, providing a more seamless and supportive gameplay experience.

Onboarding Character

When introducing new players to a game or application, an onboarding character can gain the ability to recommend relevant interesting activities or tasks based on the progression of the user. By understanding the player's progress, the character can suggest engaging and relevant experiences, making the onboarding process more enjoyable and personalized.

Educational Guide

In an educational setting, an AI character can act as a guide for learners, accessing the learner's knowledge and progress as the work through the subject matter. Based on this progress assessment, the character can recommend specific learning materials, exercises, and additional resources tailored to the learner's needs, fostering a more effective and personalized educational experience.

Personalized Virtual Assistant

Virtual assistant characters can gain the ability to not only understand the user’s requests, but also consider their preferences and goals. AI assistants can evaluate the user’s previous interactions, preferences, and contextual information in order to provide recommendations and suggestions that align with their overall interests and aspirations, making it a truly personalized and helpful assistant.

Storytelling and Interactive Narratives

In an interactive storytelling experience, AI characters can adapt the narrative based on the user's choices and actions. The characters can reason about the user's behavior, preferences, and motivations, dynamically adjusting the story and the character's responses to create a more responsive, engaging, and immersive storytelling experience.

Accessing Reasoning Step Tools


To access the Reasoning Step tools for your character, open the Advanced tab and select Reasoning from the menu options along the top.

Tab

Alternately, you can scroll down to the bottom of the Advanced tab to find the tools manually.

Once at the Reasoning tool interface, switch the Enable Reasoning toggle to On.

Enable

The Reasoning tool interface then opens.

Click on the Edit button to open the Reasoning YAML interface to get started making changes.

Edit

The Reasoning YAML editor is an accessible, human-friendly data serialization framework that structures information in a format both humans and machines can understand.

This interface includes Data Structure drop-down references to assist with the various configurations.

YAML

Reasoning YAML Configurations


To configure the Reasoning Step for your AI character, you can make all the necessary changes using the YAML Editor in Inworld Studio.

Provided below is a detailed description of the YAML structure and the fields you can use to customize the reasoning behavior of your character.

Reasoning Object

A Reasoning Object is a container for the Reasoning Configuration and contains a variety of configurations that determine the operation of the reasoning process.

Enabled

Boolean. The enabled field is a boolean that indicates whether reasoning is enabled for the current step. When set to true, reasoning is performed during the execution of the reasoning step. When set to false, reasoning will be skipped.

Attributes

Repeated Attribute. The attributes field is a list of attributes to be predicted during the execution of the reasoning step. Each attribute is defined using the Attribute object. Refer to the Attribute object for more details.

Lookback Window

Integer. The lookback_window field determines the number of previous dialog turns that are considered when making predictions for reasoning attributes. This specifies how far back in the conversation the AI character looks to gather information and make informed decisions.

For example, if the lookback_window is set to 3, the character would consider the three most recent dialog turns (most recent player phrase, preceding character phrase, preceding player phrase) to reason and make predictions.

Reasoning Attributes

Reasoning Attributes define the settings for an attribute used in reasoning. These objects include fields: id, name, type, description, and enum_values.

An overview of the fields and their usage within the Attribute message is given below.

ID

String, Required. The id field is a required alphanumeric string without spaces. It serves as the unique identifier for the attribute and is used to reference and access the attribute within the system.

Example:

  • id: state_of_mind

Name

String, Required. The name field is a required string that represents the name of the attribute. It can include spaces and provides a human-readable label for the attribute.

Type

AttributeType, Required. The type field is a required attribute that defines the data type of the attribute. The AttributeType enum defines the possible types for an attribute. It includes the following values:

  • UNSPECIFIED (0): Represents an unspecified or not defined type.
  • STRING (1): Represents a string type.
  • BOOLEAN (2): Represents a boolean type.
  • NUMBER (3): Represents a number type.
  • ENUM (4): Represents an enum type.

Description

String, Required. The description field is a required string that provides a description of the type of reasoning required for the attribute. It explains the purpose or context of the attribute within the reasoning process.

EnumValues

Repeated String, Optional. The enumValues field is an optional field that is only used when the attribute type is ENUM. It represents the set of values that define the possible options for the attribute. Each value is represented as a string.

Emotion Attribute

Inworld's suite of tools includes an out-of-the-box Emotion System.

In cases where more fine-grained emotions are needed, this system allows you to specify emotion values in the Reasoning Emotion field.

Note: If values are specified here, the out-of-the-box emotion system is disabled, causing Reasoning to instead supply emotions inferred during conversations.

Reasoning Step Example


Shown below is an example of a Reasoning Step configuration YAML object using all the fields.

attributes:
- id: next_quest
name: Next quest
type: STRING
description: This attribute represents the next quest that {player} has shown an interest in.
enumValues:
- Shadow Hunt
- Crystal Echoes
- Silent Whisper
- id: state_of_mind
name: State of mind
type: STRING
description: This attribute represents the internal thought of {character} given the current conversation.
- id: impatience_measure
name: Impatience measure (1-10)
type: NUMBER
description: This attribute represents the degree in which {character} is getting impatient, on the order of 1 to 10, with 10 being the most impatient.
lookbackWindow: 3

This example enables reasoning and defines three attributes to be predicted:

  • “impatience_measure”
  • “state_of_mind”
  • "next_quest”

It then sets the Lookback Window to “3”, indicating the system should consider the last three dialog turns when predicting the attribute values during the Reasoning Step.

Reasoning Results in Client App


Using Reasoning Results in your Client App with the Inworld SDKs is a streamlined process.

The SDK provides an event called inworld.reasoning.update that delivers the results of the Reasoning Step to your app.

When the Reasoning Step is completed, your app receives a TriggerEvent with the name “inworld.reasoning.update.” This event contains a parameter named "reasoning" which holds the inferred attributes and their corresponding values.

Shown below is an example of how the TriggerEvent might look:

{
"trigger": {
"name": "inworld.reasoning.update",
"parameters": [
{
"name": "reasoning",
"value": "{\"ready_for_quest\": false}"
}
]
}
}

In this example, the "reasoning" parameter indicates the attribute "ready_for_quest" has been inferred, and its value is set to "false".

To make use of these reasoning results in your app, you can extract the attribute values from the TriggerEvent's "reasoning" parameter and incorporate them into your app's logic.

Depending on the context, you can either (1) personalize the user experience, (2) make informed decisions, or (3) trigger specific actions based on the reasoning outcomes.