SlideShare a Scribd company logo
KorraAI Framework
A framework for building probabilistic virtual agents
ANTON ANDREEV, CNRS, GIPSA-LAB, GRENOBLE
JULY 2022
About me
• 7 years in private sector
• 2 years NLP + Semantic Annotation
• 10 years CNRS - Ingénieur d'études
• Brain Computer Interface (BCI), Brain Invaders, P300 speller for
patients, Artificial Nose, Virtual Reality
• C/C++, C#, Matlab, Unity, Python, Julia
• Data scientist
• 2.5 years development of KorraAI framework
Humans
• Search for repeating patterns
• to predict future events
• repeating events can be uninteresting (e.g. computer games)
• Have periodic needs
• hunger, thirst, communication, sleep, rest …
• Do perform certain activities periodically
• watch movies, play computer games, do sport …
• Can work with uncertain information
• difficult to model with current hardware computer architectures
ECA Challenges
ECA (Embodied Conversational Agent) = Virtual Agent = Bot
• Users have too high expectations
• Natural language is not a precise language (Lojban is)
• Reasoning and how to take decisions
• Humans are faster learners (just from a few examples)
• Synchronization with facial expressions and gestures
• Real time processing
*ECA (Embodied Conversational Agent)
General ECA vs Specialized ECA
Specialized ECA
• Works over specific domain
• Limits the ambiguity in user’s responses
• Allows for pre-defined suggested answers and questions
• Requires less NLP efforts
• Is more practically oriented
KANOPEE is an specialized ECA into the domains of
sleep disorders and smoking addiction
KorraAI original design goals
• Web-site: https://github.com/toncho11/KorraAI
• Platform for experimentation and research
• Example: use of Probabilistic Programming (PP) in ECAs
• NLP + Semantic Annotation + Ontologies + RDF database
• Favors the use of probabilistic models – distributions and Bayesian networks
• Provide natural experience
• No fixed events
• For both specialized and general ECA
• Focuses on the ECA to user communication
• Easy to install and be used as a commercial product
KorraAI main features (1)
• At every start it generates a new
communication pipeline called Interaction
Queue
• Pro-active
•Can start communications by itself
•Does not block
• Manages user's responses with level of
confidence
•Used directly in Bayesian networks
•Used in probabilistic sampling
KorraAI main features (2)
• Handles changes in behavior over time
• Built-in support for Probabilistic
Programming and Bayesian networks
• Extensible – each ECA is a plugin
• Can be used on mobile phone and VR
• Real-time, support facial expressions
Application targets
• Everyday companion
• Sales agent
• Teacher
• Customer service
• Coach
KorraAI Technical Details
• Unity component Morph3D / MCS (free)
• Uses Windows voice synthesis or Amazon Polly (paid)
• Unity component for the lip-sync (paid)
• Unity component for music playback (paid)
KorraAI’s Plugin Architecture
• Separation between ECA
model and execution engine
• ECA models are hosted in
the KorraAI.dll
• Same 3D model, total
different behavior
ECAs in KorraAI
In reality building an ECA should start from an existing model
• Ana
• simple – used to show how to encode your first ECA
• Joi
• everyday companion
• April – commercial
•every day companion and sales agent
KorraAI Architecture
How to encode a personality?
The distribution over the activities and needs of a person (or an ECA): sleep, hunger, play video
games, shopping, etc. is called the "Main Distribution"
In real world In KorraAI
The target domain Categories and Interactions
How often do we do certain things? Distributions (e.x. “Main Distribution”)
Behavior can change over time or
interaction with others
Model Update Trigger class
Reasoning Probabilistic reasoning
Evaluate state and react Model Evaluate Trigger class with
probabilistic model
Tutorial on new ECA model in KorraAI
• Interactions Categories (required)
• Interactions (required)
• Main Distribution (required)
• Timing distributions
• Distributions within each category
• Triggers
• Probabilistic variables and Bayesian networks
Distributions
KorraAI is a non-deterministic program. It has probabilistic sampler.
• "Main Distribution"
• generates the "Interactions Queue" (at stat-up or on Trigger request)
• using probabilistic variables for each category
• Internal category distribution
• Time distributions (no fixed time intervals)
• Speech pauses – Normal (m=3.7s,v=0.25)
• When to smile – Normal (m=12s,v=3)
Distributions are
pushed everywhere
it can
Speech generation (1)
An example of how several distributions are used to generate speech
Speech generation (2)
Example movie suggestion text generation using a distribution
string text = KorraModelHelper.GetChance(new string[] {
"How about this " + type + " " + movieName + "? I recommend it.", //1
"I have a new " + type + " suggestion for you. It is called : " + movieName + ". You
should try it.", //2
(KorraModelHelper.GetChance(3) ? "Do you feel bored? " : "") + "I recommend you to
watch the " + type + " " + movieName + ".", //3
"Time for something interesting to watch. Try this one: " + movieName + ".", //4
"You are going to like this " + type + ": " + movieName + ". I highly recommend it." //5
});
Pre-generated Interaction Queue
Advantages:
• Easier to verify the resulting "Main Distribution“
• Easier to inspect
Example:
|1. Hi|2. What is your name?|3. My name is Joi.|4. Listen to this song: Robin
Schulz - Sugar. Please note that pressing Escape at any time will stop playback.|5. Time
for another outfit.|6. How about this TV series Shameless? I recommend it.|7. Time for
some sport. You should go to the gym. Sport is good for both physical and metal
health.|8. <prosody pitch="+0%">I was thinking. God must love stupid people. <break
time="600ms"/>He created SO many of them!</prosody>|9. ###place holder for
InAGoodMood|10. How old are you?|
Two models: ECA and User
We keep two models that are interconnected. Humans also build a
model for their interlocutors.
Example:
• We model the user's likeliness to watch a movie
• And use this model in the ECA's movie suggestions model
Naturalization
We need to follow some human norms during conversation
Speech
• Some interactions are manually added – initial greeting
• Certain interactions are coupled together
• Addressing by name: "Peter, …" follows a distribution
Non-verbal:
• Reaction time pause is smaller than starting new interaction
• Time ECA’s eyes stay focused on user is limited
• Voice annotation with SSML
• Facial expressions available: smile, surprise, blink with one eye, …
Handling of Empty Categories
Problem: when a category is depleted, a normalization will be applied and this
will increase the probabilities of the other categories
• Actually good – we compensate with what we have
• Bad because now we can not maintain the desired “Main Distribution”
Strategies:
• Set explicitly how a distribution changes
• If category A is depleted – use this new distribution
• If category A and B are depleted – use this new distribution
•Normalization only over certain categories, the others stay fixed (better)
Probabilistic Programming (1)
Problem with Probabilistic models:
• Tools for creating them – complete mess (Math, English, Diagrams,
Pictures) or some bizarre programming language e.g. Bugs
Advantages of PP:
• inference and modelling are completely separate – we can define models
without caring how we are going to do inference
• probabilistic inference is built-in in the PPL
• models can be specified in a declarative manner
• models compose freely, allowing us to construct complex models from
simpler ones
• popular host language with extensions KorraAI uses PP
Probabilistic Programming (2)
Probabilistic Programming Languages (PPL):
• WebPPL - http://webppl.org
• Figaro – https://github.com/p2t2/figaro
• Microsoft Infer.NET https://github.com/dotnet/infer
In KorraAI:
• Inference is exact
• Probabilistic C# library using LINQ extensions
https://github.com/joashc/csharp-probability-monad
• Allows for encoding of Bayesian networks
• Best alternative is Infer.NET
Example Probabilistic C# (1)
Model the “JokeTellingRate” used by the ECA
The initial model of the user:
• InAGoodMood = BernoulliF(Prob(0.6));
• LikesJoke = BernoulliF(Prob(0.7));
Where LikesJoke can be adjusted by a natural question "Do you like
jokes?“. Using predefined answers and probabilities:
• Absolutely– 0.9
• Mostly – 0.6
• Rather not –0.3
We are building a model of the user that
is used in the ECA’s “Main Distribution”
and thus affecting the ECA behavior
Example Probabilistic C# (2)
private static Func<bool, bool, Prob>
TellJokeProb = (likesJoke, inGoodMood) =>
{
if (likesJoke && inGoodMood) return Prob(0.4)
if (likesJoke && !inGoodMood) return Prob(0.9);
return Prob(0.2);
};
public static FiniteDist<bool> TellJokeRate =
from like in LikesJoke
from mood in InAGoodMood
from joke in BernoulliF(TellJokeProb(like, mood))
select joke;
CPD (Conditional probability
distribution)
Implementation of
the JokeTellingRate
InAGoodMood = BernoulliF(Prob(0.6));
LikesJoke = BernoulliF(Prob(0.7));
Model Update Trigger (MUT)
• Can track elapsed time (since ECA start) or 24h time
• Can tracks the user's responses
• Decides whether to re-sample the “Main Distribution”
Example MUTs:
• A MUT can track the user's response to "Did you watch a movie
yesterday?“, update the probabilistic variable responsible for the
Movie Suggestions category and force a probabilistic re-sampling and
thus modify the ECA’s behavior by suggesting more (less) movies
• After 15 minutes we can increase the number of jokes and again
request a re-sampling
Model Evaluate Trigger (MET)
• Again can track the user's responses
• Usually stores a probabilistic model such as BN
• Decides whether to inject a new interaction
Example MET
• Encode a surprise – a Bayesian model evaluates the plausibility
(or POE) of the user's response and if a contradiction is detected ,
it supplies a reaction – an interaction that goes first in the
Interaction Queue
Execution statistics
Problem: construct the Main Distribution for N interactions works, but it
won’t work for a fixed interval of time (1 hour for example). Interactions
take time. We can try to evaluate how much real time the Interaction
Queue will take to execute (FIT) and adjust the Main Distribution
FIT=∑((Ai+Pi) * Ci) for all categories i= 1..N
• Ai - average time per category (question + user's response)
• Pi – average time between interactions
• Ci – interactions per category
An ECA must run for some time in order to collect these real time
statistics
Sales agent ECA
• Set Categories: “Getting to know the user”, “Small talk”, “Introducing the
domain of the product”
• Set initial “Main Distribution” where “Getting to know the user”, “Small
talk” are with higher probabilities than “Introducing the domain of the
product”
• Set Triggers
• MUT – modify the “Main Distribution” to include more of the category “Introducing the
domain of the product” after 10-15 minutes
• MET – evaluate the user’s confidence in the ECA using a probabilistic model to decide
when to ask the user to buy a product (insert buy interaction in the Interaction Queue)
• Infer hidden states
• Instead of asking directly “Do you earn well?” we can infer the user’s purchasing power
based on other questions using a probabilistic model based on published statistics
Resources
Links on Probabilistic Programming:
◦ https://www.youtube.com/watch?v=fclvsoaUI-U
◦ https://www.cs.cornell.edu/courses/cs4110/2016fa/lectures/lecture33.html
◦ https://www.youtube.com/watch?v=9SEIYh5BCjc&ab_channel=MITCBMM
Questions?

More Related Content

PPTX
Jay Yagnik at AI Frontiers : A History Lesson on AI
PPTX
AI Workshops at Computers In Libraries 2024
PDF
AI - Artificial Intelligence - Implications for Libraries
PPTX
Building Your Own AI Instance (TBLC AI )
PDF
NCompass Live: AI: The Modern Day Pandora's Box
PDF
Ai = your data | Rasa Summit 2021
PDF
Chatbots in 2017 -- Ithaca Talk Dec 6
PDF
Human-in-the-loop: a design pattern for managing teams that leverage ML
Jay Yagnik at AI Frontiers : A History Lesson on AI
AI Workshops at Computers In Libraries 2024
AI - Artificial Intelligence - Implications for Libraries
Building Your Own AI Instance (TBLC AI )
NCompass Live: AI: The Modern Day Pandora's Box
Ai = your data | Rasa Summit 2021
Chatbots in 2017 -- Ithaca Talk Dec 6
Human-in-the-loop: a design pattern for managing teams that leverage ML

Similar to KorraAI - a probabilistic virtual agent framework (20)

PDF
A Guide to AI for Smarter Nonprofits - Dr. Cori Faklaris, UNC Charlotte
PDF
Human-in-a-loop: a design pattern for managing teams which leverage ML
PPTX
Generative AI in CSharp with Semantic Kernel.pptx
PDF
AC Atlassian Coimbatore Session Slides( 22/06/2024)
PDF
Generative Models and ChatGPT
PPTX
Past, Present and Future of Generative AI
PDF
PPTX
Generative AI, WiDS 2023.pptx
PDF
ChatGPT and AI for web developers - Maximiliano Firtman
PPTX
Role of Dialog and Explicit A.I. for Building Trust in Human-Robot Interaction
PDF
Probabilistic Programming: Why, What, How, When?
PDF
Nlp presentation
PDF
Lec 1-2 ssdsdffffsssssfsdfsdfstGenAI.pdf
PPTX
Artificial Intelligence (AI) – Powering Data and Conversations.pptx
PPTX
AI tools in Scholarly Research and Publishing
PPTX
Smart Health Chatbot health care for patients.pptx
PDF
Wondershare PDFelement Pro Crack FREE Download
PDF
2025-03-20 - How to use AI to your advantage - AI-Driven Development.pdf
PDF
Wondershare Filmora 14.3.2 Crack + License Key Free Download
PDF
AOMEI Backupper Crack 2025 FREE Download
A Guide to AI for Smarter Nonprofits - Dr. Cori Faklaris, UNC Charlotte
Human-in-a-loop: a design pattern for managing teams which leverage ML
Generative AI in CSharp with Semantic Kernel.pptx
AC Atlassian Coimbatore Session Slides( 22/06/2024)
Generative Models and ChatGPT
Past, Present and Future of Generative AI
Generative AI, WiDS 2023.pptx
ChatGPT and AI for web developers - Maximiliano Firtman
Role of Dialog and Explicit A.I. for Building Trust in Human-Robot Interaction
Probabilistic Programming: Why, What, How, When?
Nlp presentation
Lec 1-2 ssdsdffffsssssfsdfsdfstGenAI.pdf
Artificial Intelligence (AI) – Powering Data and Conversations.pptx
AI tools in Scholarly Research and Publishing
Smart Health Chatbot health care for patients.pptx
Wondershare PDFelement Pro Crack FREE Download
2025-03-20 - How to use AI to your advantage - AI-Driven Development.pdf
Wondershare Filmora 14.3.2 Crack + License Key Free Download
AOMEI Backupper Crack 2025 FREE Download
Ad

Recently uploaded (20)

PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Current and future trends in Computer Vision.pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPT
Occupational Health and Safety Management System
PPT
introduction to datamining and warehousing
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
Soil Improvement Techniques Note - Rabbi
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
PPT on Performance Review to get promotions
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Current and future trends in Computer Vision.pptx
III.4.1.2_The_Space_Environment.p pdffdf
Occupational Health and Safety Management System
introduction to datamining and warehousing
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
Soil Improvement Techniques Note - Rabbi
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPT on Performance Review to get promotions
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Integrating Fractal Dimension and Time Series Analysis for Optimized Hyperspe...
86236642-Electric-Loco-Shed.pdf jfkduklg
Fundamentals of Mechanical Engineering.pptx
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Ad

KorraAI - a probabilistic virtual agent framework

  • 1. KorraAI Framework A framework for building probabilistic virtual agents ANTON ANDREEV, CNRS, GIPSA-LAB, GRENOBLE JULY 2022
  • 2. About me • 7 years in private sector • 2 years NLP + Semantic Annotation • 10 years CNRS - Ingénieur d'études • Brain Computer Interface (BCI), Brain Invaders, P300 speller for patients, Artificial Nose, Virtual Reality • C/C++, C#, Matlab, Unity, Python, Julia • Data scientist • 2.5 years development of KorraAI framework
  • 3. Humans • Search for repeating patterns • to predict future events • repeating events can be uninteresting (e.g. computer games) • Have periodic needs • hunger, thirst, communication, sleep, rest … • Do perform certain activities periodically • watch movies, play computer games, do sport … • Can work with uncertain information • difficult to model with current hardware computer architectures
  • 4. ECA Challenges ECA (Embodied Conversational Agent) = Virtual Agent = Bot • Users have too high expectations • Natural language is not a precise language (Lojban is) • Reasoning and how to take decisions • Humans are faster learners (just from a few examples) • Synchronization with facial expressions and gestures • Real time processing *ECA (Embodied Conversational Agent)
  • 5. General ECA vs Specialized ECA Specialized ECA • Works over specific domain • Limits the ambiguity in user’s responses • Allows for pre-defined suggested answers and questions • Requires less NLP efforts • Is more practically oriented KANOPEE is an specialized ECA into the domains of sleep disorders and smoking addiction
  • 6. KorraAI original design goals • Web-site: https://github.com/toncho11/KorraAI • Platform for experimentation and research • Example: use of Probabilistic Programming (PP) in ECAs • NLP + Semantic Annotation + Ontologies + RDF database • Favors the use of probabilistic models – distributions and Bayesian networks • Provide natural experience • No fixed events • For both specialized and general ECA • Focuses on the ECA to user communication • Easy to install and be used as a commercial product
  • 7. KorraAI main features (1) • At every start it generates a new communication pipeline called Interaction Queue • Pro-active •Can start communications by itself •Does not block • Manages user's responses with level of confidence •Used directly in Bayesian networks •Used in probabilistic sampling
  • 8. KorraAI main features (2) • Handles changes in behavior over time • Built-in support for Probabilistic Programming and Bayesian networks • Extensible – each ECA is a plugin • Can be used on mobile phone and VR • Real-time, support facial expressions
  • 9. Application targets • Everyday companion • Sales agent • Teacher • Customer service • Coach
  • 10. KorraAI Technical Details • Unity component Morph3D / MCS (free) • Uses Windows voice synthesis or Amazon Polly (paid) • Unity component for the lip-sync (paid) • Unity component for music playback (paid)
  • 11. KorraAI’s Plugin Architecture • Separation between ECA model and execution engine • ECA models are hosted in the KorraAI.dll • Same 3D model, total different behavior
  • 12. ECAs in KorraAI In reality building an ECA should start from an existing model • Ana • simple – used to show how to encode your first ECA • Joi • everyday companion • April – commercial •every day companion and sales agent
  • 14. How to encode a personality? The distribution over the activities and needs of a person (or an ECA): sleep, hunger, play video games, shopping, etc. is called the "Main Distribution" In real world In KorraAI The target domain Categories and Interactions How often do we do certain things? Distributions (e.x. “Main Distribution”) Behavior can change over time or interaction with others Model Update Trigger class Reasoning Probabilistic reasoning Evaluate state and react Model Evaluate Trigger class with probabilistic model
  • 15. Tutorial on new ECA model in KorraAI • Interactions Categories (required) • Interactions (required) • Main Distribution (required) • Timing distributions • Distributions within each category • Triggers • Probabilistic variables and Bayesian networks
  • 16. Distributions KorraAI is a non-deterministic program. It has probabilistic sampler. • "Main Distribution" • generates the "Interactions Queue" (at stat-up or on Trigger request) • using probabilistic variables for each category • Internal category distribution • Time distributions (no fixed time intervals) • Speech pauses – Normal (m=3.7s,v=0.25) • When to smile – Normal (m=12s,v=3) Distributions are pushed everywhere it can
  • 17. Speech generation (1) An example of how several distributions are used to generate speech
  • 18. Speech generation (2) Example movie suggestion text generation using a distribution string text = KorraModelHelper.GetChance(new string[] { "How about this " + type + " " + movieName + "? I recommend it.", //1 "I have a new " + type + " suggestion for you. It is called : " + movieName + ". You should try it.", //2 (KorraModelHelper.GetChance(3) ? "Do you feel bored? " : "") + "I recommend you to watch the " + type + " " + movieName + ".", //3 "Time for something interesting to watch. Try this one: " + movieName + ".", //4 "You are going to like this " + type + ": " + movieName + ". I highly recommend it." //5 });
  • 19. Pre-generated Interaction Queue Advantages: • Easier to verify the resulting "Main Distribution“ • Easier to inspect Example: |1. Hi|2. What is your name?|3. My name is Joi.|4. Listen to this song: Robin Schulz - Sugar. Please note that pressing Escape at any time will stop playback.|5. Time for another outfit.|6. How about this TV series Shameless? I recommend it.|7. Time for some sport. You should go to the gym. Sport is good for both physical and metal health.|8. <prosody pitch="+0%">I was thinking. God must love stupid people. <break time="600ms"/>He created SO many of them!</prosody>|9. ###place holder for InAGoodMood|10. How old are you?|
  • 20. Two models: ECA and User We keep two models that are interconnected. Humans also build a model for their interlocutors. Example: • We model the user's likeliness to watch a movie • And use this model in the ECA's movie suggestions model
  • 21. Naturalization We need to follow some human norms during conversation Speech • Some interactions are manually added – initial greeting • Certain interactions are coupled together • Addressing by name: "Peter, …" follows a distribution Non-verbal: • Reaction time pause is smaller than starting new interaction • Time ECA’s eyes stay focused on user is limited • Voice annotation with SSML • Facial expressions available: smile, surprise, blink with one eye, …
  • 22. Handling of Empty Categories Problem: when a category is depleted, a normalization will be applied and this will increase the probabilities of the other categories • Actually good – we compensate with what we have • Bad because now we can not maintain the desired “Main Distribution” Strategies: • Set explicitly how a distribution changes • If category A is depleted – use this new distribution • If category A and B are depleted – use this new distribution •Normalization only over certain categories, the others stay fixed (better)
  • 23. Probabilistic Programming (1) Problem with Probabilistic models: • Tools for creating them – complete mess (Math, English, Diagrams, Pictures) or some bizarre programming language e.g. Bugs Advantages of PP: • inference and modelling are completely separate – we can define models without caring how we are going to do inference • probabilistic inference is built-in in the PPL • models can be specified in a declarative manner • models compose freely, allowing us to construct complex models from simpler ones • popular host language with extensions KorraAI uses PP
  • 24. Probabilistic Programming (2) Probabilistic Programming Languages (PPL): • WebPPL - http://webppl.org • Figaro – https://github.com/p2t2/figaro • Microsoft Infer.NET https://github.com/dotnet/infer In KorraAI: • Inference is exact • Probabilistic C# library using LINQ extensions https://github.com/joashc/csharp-probability-monad • Allows for encoding of Bayesian networks • Best alternative is Infer.NET
  • 25. Example Probabilistic C# (1) Model the “JokeTellingRate” used by the ECA The initial model of the user: • InAGoodMood = BernoulliF(Prob(0.6)); • LikesJoke = BernoulliF(Prob(0.7)); Where LikesJoke can be adjusted by a natural question "Do you like jokes?“. Using predefined answers and probabilities: • Absolutely– 0.9 • Mostly – 0.6 • Rather not –0.3 We are building a model of the user that is used in the ECA’s “Main Distribution” and thus affecting the ECA behavior
  • 26. Example Probabilistic C# (2) private static Func<bool, bool, Prob> TellJokeProb = (likesJoke, inGoodMood) => { if (likesJoke && inGoodMood) return Prob(0.4) if (likesJoke && !inGoodMood) return Prob(0.9); return Prob(0.2); }; public static FiniteDist<bool> TellJokeRate = from like in LikesJoke from mood in InAGoodMood from joke in BernoulliF(TellJokeProb(like, mood)) select joke; CPD (Conditional probability distribution) Implementation of the JokeTellingRate InAGoodMood = BernoulliF(Prob(0.6)); LikesJoke = BernoulliF(Prob(0.7));
  • 27. Model Update Trigger (MUT) • Can track elapsed time (since ECA start) or 24h time • Can tracks the user's responses • Decides whether to re-sample the “Main Distribution” Example MUTs: • A MUT can track the user's response to "Did you watch a movie yesterday?“, update the probabilistic variable responsible for the Movie Suggestions category and force a probabilistic re-sampling and thus modify the ECA’s behavior by suggesting more (less) movies • After 15 minutes we can increase the number of jokes and again request a re-sampling
  • 28. Model Evaluate Trigger (MET) • Again can track the user's responses • Usually stores a probabilistic model such as BN • Decides whether to inject a new interaction Example MET • Encode a surprise – a Bayesian model evaluates the plausibility (or POE) of the user's response and if a contradiction is detected , it supplies a reaction – an interaction that goes first in the Interaction Queue
  • 29. Execution statistics Problem: construct the Main Distribution for N interactions works, but it won’t work for a fixed interval of time (1 hour for example). Interactions take time. We can try to evaluate how much real time the Interaction Queue will take to execute (FIT) and adjust the Main Distribution FIT=∑((Ai+Pi) * Ci) for all categories i= 1..N • Ai - average time per category (question + user's response) • Pi – average time between interactions • Ci – interactions per category An ECA must run for some time in order to collect these real time statistics
  • 30. Sales agent ECA • Set Categories: “Getting to know the user”, “Small talk”, “Introducing the domain of the product” • Set initial “Main Distribution” where “Getting to know the user”, “Small talk” are with higher probabilities than “Introducing the domain of the product” • Set Triggers • MUT – modify the “Main Distribution” to include more of the category “Introducing the domain of the product” after 10-15 minutes • MET – evaluate the user’s confidence in the ECA using a probabilistic model to decide when to ask the user to buy a product (insert buy interaction in the Interaction Queue) • Infer hidden states • Instead of asking directly “Do you earn well?” we can infer the user’s purchasing power based on other questions using a probabilistic model based on published statistics
  • 31. Resources Links on Probabilistic Programming: ◦ https://www.youtube.com/watch?v=fclvsoaUI-U ◦ https://www.cs.cornell.edu/courses/cs4110/2016fa/lectures/lecture33.html ◦ https://www.youtube.com/watch?v=9SEIYh5BCjc&ab_channel=MITCBMM

Editor's Notes

  • #2: Last updated July 2022.
  • #4: For example humans can get bored when prediction matches result in a computer game. Communication with other people can be considered as both “Need” or “Periodical Activity”. The Von Neumann architecture is one that works with exact data and it is the one used in every computer today. It is not designed (from hardware point of view) to store and handle uncertain information. But it can still be done using programming. There are many probabilistic frameworks available.
  • #5: One needs very good NLP and Semantic Analysis to make a good ECA. High expectations because movies make AI so human like in both reasoning and how it looks. NLP with performance of 80% is doable, but then it is a long way between 80 and 82%. Lojban is a carefully constructed spoken language. Its syntactic structure and validity of a sentence is unambiguous. Lojban's grammar is based on simple rules, and its linguistic features are inspired by predicate logic.
  • #7: Not hard to install and execute – no need to install second party runtimes such as  Java, extra compilers, etc.
  • #9: Also: currently only on one programming language C# (which helps development a lot) Probabilistic Programming and Bayesian Networks are used for modelling
  • #10: It can employ different strategies and behaviors over time.
  • #12: KorraAI.dll is the plugin and can host several ECAs.  We exchange models as source code or compiled in KorraAI.dll.
  • #13: April is the combination of an everyday companion and sales agent. April is closed source.
  • #14: On the left we see the “engine” of KorraAI and on the right components 7, 8, 9, 10, 11 and 12 represent the “model” provided by an ECA designer. The engine executes a loop that is defined by components 1,2,3,4. The “Main Distribution” controls the overall behavior and it is stored in component 11. The engine assures that the interactions are loaded from 10, then it uses the Main Distribution to produce the Interactions Queue 3.
  • #16: The KorraAI engine consults the ECA model and executes accordingly. One needs to provide at least “Interactions Categories”, “Intertactions and Timing Distributions - “Interaction Categories” can be “The ECA introduces her/his self”, “The ECA asks the user introduction questions”, “Jokes”, “Suggest movies to watch”, “Motivate the user to do sport”. - An “interaction” is for example “Ask the user hers/his name” from the interaction category “The ECA asks the user introduction questions”. An interaction can also be non-verbal. - Triggers are described later in the presentation. They track user’s responses and elapsed time and depending on the type of trigger they can contain a probabilistic model and they can either update the “Main Distribution” (and thus change the ECA behavior) or add a new interaction in the “Interaction Queue”. - KorraAI promote the use of probabilistic variables and probabilistic models.
  • #17: Non-deterministic program – the output is not the same every time it the program is executed with the same input. - “Main Distribution” sets which categories should be used to define the principal behavior of the ECA. It also sets how much each Interaction Category should be used. For example Category 1 can be with 0.7 probability, and Category 2 can be with 0.3 probability and thus we will have much more interactions from Category 1. - Each category can also have a distribution. Be default it is the uniform. The idea is that certain interactions in a category should be used before others (depending on elapsed time for example). For example some type of mildly offensive jokes should be reserved for later in the communication. The So we reduce the chance of using these in the beginning, but it is still possible to have a mildly offensive joke in the beginning. - Time should not be fixed. Fixed time intervals will allow the user to get accustomed to the ECA and know what to expect (at which moment). Timing distributions are for example: “Distribution on pause between two interactions”, “When to smile”, “Pause before reacting to the user’s response”, “How much time before the ECA gives up on waiting for user’s response”. Often the normal distribution is used centering around some value in seconds e.g. mean = 20 seconds and variance = 1.5
  • #18: Here three distributions are used to select which phrases the ECA will utter. 1) First a category is selected using a probabilistic sampler. For example “Suggest a Movie”. 2) Then we sample over all the interactions inside the category. We select a movie where some movies could be with higher likeliness to be selected – this can be based on the genre of the movie for example. 3) The interaction itself contains code that generates phrases in real time 3) is explained on the next slide
  • #19: The name of the movie is stored in the “movieName” variable. This an actual code from KorraAI when a interaction from the category “Suggest a Movie” has been sampled (selected). The following methods can be used: - KorraModelHelper.GetChance – uniformly select an item from an array - KorraModelHelper.GetChance(3) – return true with probability 33% - KorraModelHelper.GetChance(4) – return true with probability 25% The phrase is built dynamically by selecting a principal phrase with KorraModelHelper.GetChance() and then we have 33% chance to add "Do you feel bored? " if principal phrase 3 is selected. Example movie suggestion. The name of the movie is stored in the “movieName” variable. string text = KorraModelHelper.GetChance(new string[] { "How about this " + type + " " + movieName + "? I recommend it.", //1 "I have a new " + type + " suggestion for you. It is called : " + movieName + ". You should try it.", //2 (KorraModelHelper.GetChance(3) ? "Do you feel bored? " : "") + "I recommend you to watch the " + type + " " + movieName + ".", //3 "Time for something interesting to watch. Try this one: " + movieName + ".", //4 "You are going to like this " + type + ": " + movieName + ". I highly recommend it." //5 });
  • #20: There are two possibilities: To use a pre-generated Interaction Queue. This is easier to test and it can be inspected at any time. One can verify if the generated interactions really follow the “Main Distribution” from which they were generated. This is the method used in KorraAI. We can not generate the exact text for all interactions in advance, that is why we have placeholders such as “###place holder for InAGoodMood”. The exact text for the mood interaction is generated just before execution based on the current mood of the ECA. Each interaction is supplied (probabilistically sampled) just before it is needed. This method also has advantages: we do not need to track when to regenerate (re-sample) the “Main Distribution” which is needed when communicating with the user or over time. Also we do not need to use placeholders for certain interactions.
  • #21: Both are probabilistic models.
  • #22: There is a SpeechAdapdation modeule in KorraAI that handles some of the naturalization tasks. Speech: - At the beginning of the session a “Hello” interaction is inserted which uses a uniform distribution over “Hi”, Hello”, “Hello there”, “Hey” and if this is not the first interaction then it adds the word “again”. If the name of the user is available, the name can also be included in the greeting. - When the ECA asks the user his name then it is better that the ECA also introduce her name in this very moment. In general these are two independent interactions in the Interaction Queue and they can be sampled not one after another. - Sometimes we address people by name. But this should not be all the time or it may become annoying (for some people). That is why there is a distribution that sets that calling by name should be only in 33% of the cases and only for specific interaction categories. Non-verbal: - “Reaction time pauses” follows a different distribution (that produces a shorter time interval) than “New interaction pause”. - When the ECA starts a new speech interaction the ECA’s stays focused on the user using a time interval produced by a Normal distribution (mean = 7 seconds, variance = 1.2). - Voice annotation: pauses, pitch, speed, intensity. SSML - Speech Synthesis Markup Language
  • #23: Normalization: the sum of probabilities of all categories is 1. After some of the categories are depleted then for example the music suggestions will increase from 10 per hour to 18 for example. This can be unwanted behavior. The user might not like too many music suggestions. So we are not following the desired behavior. The best solution is to keep the proportions for some categories and let the others compensate after normalization. This must be set in advance by the ECA designer.
  • #24: PP = Probabilistic Programming BUGS is a software package for performing Bayesian inference Using Gibbs Sampling
  • #25: All 3: Javascript, Scala and C# have elements from functional languages. C#'s LINQ is declarative functional programming. WebPPL uses Javascript as host language - Figaro uses Scala as host language - Infer.NET is with host language C# Exact inference is possible for small probabilistic models otherwise it might take a lot of time. Figaro and Infer.NET are very similar – the probabilistic part is provided as a library instead of language extensions. Book for Figaro: "Practical Probabilistic Programming“: https://www.manning.com/books/practical-probabilistic-programming
  • #26: We set the initial preferences of the user in the form of the probabilistic variables InAGoodMood and LikesJoke. They can be updated by using a question that maps the predefined answers to probabilities. Here we able to incorporate an answer with a variable level of confidence into the “Main Distribution” concerning the “Tell Joke” category and thus modify the ECA behavior.
  • #27: The syntax here is similar to LINQ in C# and SQL in general. This syntax is actually rather intuitive. We define a case when the user is for example not in a good mood and likes jokes in general to be with probability 0.9. This is because we want to cheer her/him up. Another case is 0.4 and all the others are with probability 0.2. Next we define a sampling method that intuitively does the following: it takes samples from LikesJoke and InAGoodMood and applies probabilistic reasoning using the function that we defined previously TellJokeProb. After that TellJokeRate  is used in the "Main Distribution“ for the category “Tell Jokes”.
  • #28: 24h time means: is it morning, time to eat, time to sleep, time to rest, etc. Another example of time MUT is to update the “Main Distribution”, so that Movie Suggestions are increased in the evening (after 19h), because we know that the user is occupied, so during the day we should not temp him/her with many movie suggestions.
  • #29: POE – probability of observed evidence A contradiction is calculated and then we need to set a threshold – at which value the evidence for contradiction is sufficient, so that we can trigger a response in the form of surprise.
  • #30: Forecasted  Interactions Time (FIT) When constructing the “Main Distribution” we provide how much each category should be presented. This works when we sample, for example, a 100 interactions. But in order to be able to correctly model the Main Distribution, it is necessary to know how much time each interaction takes, so that the Main Distribution can be respected for a specific time interval – for example 1 hour. Pi is controlled by a distribution, so we already know its mean value. Ci also known.
  • #31: The hidden states can be used in probabilistic models. For example a good education is a factor that usually means that the user will have a higher purchasing power.