SlideShare a Scribd company logo
4/4/2022
1
Como construir chatbots
inteligentes sin morir en el intento
@JordiCabot / @ingdesoftware / @xatkit– jordicabot.com / ingenieriadesoftware.es
Introduction
1
2
4/4/2022
2
About
SOM Research Lab
Software runs the world. Models run the software
3
4
4/4/2022
3
Nuestra misión
Interested in the broad area
of systems and software
engineering, especially
promoting the rigorous use
of software models and
engineering principles in
all software engineering
tasks.
Flickr/clement127
5
6
4/4/2022
4
Context
Can you help us create a chatbot to help
newcomers to write good bug reports on GitHub?
Sure! It’s just a set of questions &
answers, this will be pretty simple!
Narrator It wasn’t.
Once upon a time in 2018 (we were
young and naïve)
7
8
4/4/2022
5
We were asked to build a bot. We ended up
building a bot platform
But at least we’ve
learnt some things
along the way that
today we want to
share with you
3 times so far!
Why you all need to have
some bot building notions
9
10
4/4/2022
6
And more predictions:
- By 2024, consumer retail spend via chatbots worldwide will reach $142 billion—up from just
$2.8 billion in 2019.
Chatbot market is worth over 1 Billion USD
11
12
4/4/2022
7
Chatbots <-> Software engineers
• Software Engineers -> Chatbot
– Chatbots are a new type of software artefact that
we’ll need to consider in our dev projects
• Chatbot -> Software Engineering
– Bots are more and more playing a supportive role in
many SE tasks (e.g. in GH) so better to know how they
work and their limitations
13
14
4/4/2022
8
Hidden Technical debt in Machine Learning Systems - Google -
https://proceedings.neurips.cc/paper/2015/file/86df7dcfd896fcaf2674f757a
2463eba-Paper.pdf
15
16
4/4/2022
9
Core chatbot concepts
What is exactly a Chatbot?
• Bot are software components
• Chatbot = Bot + Chat interface
– Tb llamado asistente digital, asistente
virtual,…
• Voicebot = Chatbot + Voice Interface
Voicebot
Chatbot
Bot
17
18
4/4/2022
10
VoiceBot
• Alexa, Google Assistant ,…
• They all hide a chatbot inside
1. Speech-to-text
2. Process the text as a
chatbot
3. Text-to-speech to reply
Chatbot vs LiveChat
• LiveChat: a person is behind
• They can be combined
– Bot  Person: when the bot doesn’t know how to
answer (or the visitor is specially “interesting”)
– Person  Bot: when no support person is available
or the client is not worth
19
20
4/4/2022
11
Examples of bots
21
22
4/4/2022
12
23
24
4/4/2022
13
Types of chatbots
Types of chatbots
Button-
based (no AI)
Intent-based
Open
questions
Open
domain
25
26
4/4/2022
14
We ignore open-domain bots (e.g. LaMDA)
• They can chat about
everything but
– A complete black-box
– ``Useless’’ for a specific
business
https://mindmatters.ai/2022/03/the-ai-illusion-state-of-the-art-chatbots-arent-what-
they-seem/
Creating a chatbot
1 – Why is it so challeging?
27
28
4/4/2022
15
Software
(bot
part)
NLU
(chat
part)
Complexity of chatbots
Chat
bots
Many pieces to assemble
Input/Output
Messaging channels
External
Platforms
NLU Engine
Events!
29
30
4/4/2022
16
Chatbots are complex software systems
Conversation Logic
Text Processing
External Services
Messaging
Platforms
Deployment
Evolution
Maintenance
Tests
J Cabot, L Burgueño, R Clarisó, G Daniel, J Perianez-
Pascual, R Rodríguez-Echeverría:
Testing challenges for NLP-intensive
bots. BotSE@ICSE 2021: 31-34
Creating a chatbot
2 – The NLP component
31
32
4/4/2022
17
How NLP works in chatbots
Bots and NLP/NLU
• At the core of all AI bots there is a NLU/NLP
engine with two key missions
– Classify the user utterance (i.e. input text) in
one of the intents (set of possible
questions/requests) the bot understands
– Identify the parameters (called « entities »)
from the utterance
33
34
4/4/2022
18
NLP in a chatbot implies
Parameters (entities)
I would like to order a medium pepperoni pizza
Intent
Input text (utterance)
• Understand what the user is trying to ask the bot
• Identify and gather the data in the request that the bot needs to construct
the response
35
36
4/4/2022
19
NLU approaches
• Regular expressions
• Require an almost exact match. Only useful for very concrete cases
• Grammar-based approaches
• Useful for small domains with a very specific vocabulary and constructs
• E.g. Stanford Parser
• Neural Networks - Multiclass classifiers
1. You provide some training sentences for each intent (the "classes" ).
2. The classifier learns from these sentences
3. It assigns any new input text to one of the classes (with %confidence)
Hi
Good morning
Good afternoon
Hello
Morning!
Example: bot that greets you, informs about
the schedule and lets you buy a pizza
Greetings
I’d like to buy a
pizza
I want a pizza
Can I order a
pizza?
Buy
Are you open?
Is it open now?
What are your
opening hours?
At what time do
you start?
Schedule
If a user says, “I would like to order a pizza now” what is the closest intent?
Not that easy when intents start to overlap (e.g. offering a job vs looking
for a job: “can I offer you a job?” vs “do you have any job offer”)
37
38
4/4/2022
20
Entity recognition
• We need to understand the intent but also identify the entities
• Much easier if PizzaType is an enumeration ({ Pepperoni, Veggie, Hawaian ,…})
instead of the any string
ChooseYourPizza
I’d like a PizzaType pizza
I’m taking a PizzaType pizza
I think I’m going for a PizzaType
39
40
4/4/2022
21
Common tricks in NLU Engines
• Stemmers identify the lemma of the word (e.g. to focus on the verb, not on
the tense of the verb for matching purposes)
• Synonyms and paraphrasing are an automatic way to expand the training
sentences
• Entity augmentation also generalize training sentences
• E.g. What’s the weather in Barcelona -> What’s the weather in @city
• Augmentation is possible for a large number of data types and common concepts
(measures, countries, dates,…)
Taking a closer look at the NN
https://github.com/xatkit-bot-platform/xatkit-nlu-server
41
42
4/4/2022
22
The ML model
Even this “simple” arch easily gets over > 100.000 parameters!
Step 1 – From words to vectors of numbers
43
44
4/4/2022
23
Step 2 Embedding -> similar words have
similar vectors
King – man + woman = Queen
Training and prediction
history = model.fit(np.array(context.training_sequences), np.array(context.training_labels),
epochs=configuration.num_epochs, verbose=2)
full_prediction = context.nlp_model.predict(sequence_from_sentence_to_predict)
Tip: Predicting always via the NN is overengineering sometimes
(e.g. Yes/No answers)
45
46
4/4/2022
24
Remember: the SW part of any ML project
And we could go on and on ...
47
48
4/4/2022
25
Beyond intent classification
• Great bots go beyond providing the right answer, e.g.
they could show some empathy
• Several language models (for toxicity detection, for
sentiment analysis, language identification, emoji
support…) can be easily integrated in bots
PRO tip: Monitor your bots
• You will fail to predict:
• What users want to know
• How they express their intentions
• Careful with self-learning
• Filter out what the bot needs to add as training sentences to avoid strange
derivations
49
50
4/4/2022
26
Creating a chatbot
3 – The Software component
What bot building tool should I
use?
51
52
4/4/2022
27
>100 bot platforms
• Rasa, BotPress, Chatfuel, Inbenta, Botsify,
Flow XO, Xatkit…
• And plenty NLP engines: DialogFlow, Lex,
LUIS, Watson, NLP.js
It all depends
• What are your priorities
– Open source?
– Free?
– Programming language of the bot?
– Natural languages (e.g. Catalan)
– Availability of connectors
– On-premises option?
– Plain textual bots or fully functional ones?
– Low-code/ no-code or tech skills?
– Possibility to migrate from one NLP engine to another?
– Monitoring dashboard / reports ?
– …
53
54
4/4/2022
28
Building bots in Xatkit
https://github.com/xatkit-bot-platform
Xatkit’s philosophy: Do not reinvent the wheel
Other solutions
Plenty of great NLU engines
and libraries, let’s not waste
our time building a new one
but take the best of breed
and focus on features to
help you create better bots
Xatkit is a chatbot orchestration platform
55
56
4/4/2022
29
Another reason to avoid strong
coupling to specific NLU/NLP libraries
Xatkit architecture
(write your bot once, run it anywhere)
Chatbot
Designer
Intent Recognition NLU Providers
(platform-specific)
Platform DSL / Libraries
Intent DSL
Xatkit DSL
Chatbot
User
Instant
Messaging
Platforms
Xatkit Runtime
Execution DSL
uses
uses
Platform-independent
chatbot definition
External
Services
Deployment
Configuration
Platform
Designer
G Daniel , J Cabot , L Deruelle, M Derras :
Xatkit: A Multimodal Low-Code Chatbot
Development Framework. IEEE
Access 8: 15332-15346 (2020)
57
58
4/4/2022
30
Xatkit DSL
• Bots are created with the Xatkit DSL offering a chatbot-
specific syntax for creating:
– Intents the bot needs to match
– The behavior to execute in response to the matched intents
• Our DSL aims to combine the benefits of:
– Having a chatbot-specific DSL that facilitates the creation of chatbot
applications by providing higher-level chatbot modeling primitives
– The full power of a general programming language to create any
type of bot, not just simple textual ones
Xatkit DSL
• Should we go for an external DSL or an internal one?
– External one: independent language with its own compiler, editor,…
You control everything
– Internal ones: lives inside another language. You can reuse the host
language but are also constrained by it
• We started with an external one and had to reimplement
everything
In our scenario, Internal DSLs are the way to go (Martin Fowler)
59
60
4/4/2022
31
Our DSL is implemented as a Java Fluent API
• Create bots using your preferred Java editor
– Benefit from all existing Java tooling when developing bots (e.g. debuggers)
– Reuse any Java library for complex bot behaviors
– Intuitive Fluent Interfaces to help you create advanced conversations
– Based on state machine semantics to build any type of bot
Intent DSL example
61
62
4/4/2022
32
Execution DSL example – State
machines
Easy deployments
A Xatkit bot can be packaged as a single jar
with no external dependencies. Just execute
the jar to get the bot up and running
Via a simple configuration file you can
connect your bot with external services, e.g.
NLP Engines and communication channels
63
64
4/4/2022
33
Xatkit is available on GitHub
Advanced topics
65
66
4/4/2022
34
Beyond predefined intents
80/20 - Pareto Rule
• 80% of user utterances will match 20%
of your intents
• Recursive Pareto: 64% (80% of 80%) of
your input utterances will be reduced to
4% (20% of 20%) of your defined intents.
67
68
4/4/2022
35
Open questions -> Plan B in your default fallback
https://haystack.deepset.ai/
BODI (Bots for Open Data) we use text to SQL models to try to
answer a larger variety of questions
No-learn / No-work chatbot
building
69
70
4/4/2022
36
Low-code / no-code
• Many bot platforms try to offer low-code / no-
code interfaces to define bots (e.g. GUIs)
writing less code
• But this is not enough for many non-tech users
Keep in mind: 1 language -> ++notations
No-Learn (e.g. bots from Excel)
71
72
4/4/2022
37
No-Work
• Bots derived from your
db data
– E.g. an eCommerce bot
that answers questions
about your products,
shipping options,…
Multiexperience Development
Platforms (MXDP)
73
74
4/4/2022
38
One app -> Multiple interfaces
Related also to Multimodal AI
E.g.: DALL-E
75
76
4/4/2022
39
E Planas, G Daniel, M Brambilla, J Cabot:
Towards a model-driven approach for
multiexperience AI-based user interfaces. Softw.
Syst. Model. 20(4): 997-1009 (2021)
But this brings plenty of new challenges
• A chatbot that knows where you’re looking at
(e.g. the product in the eCommerce shop) and
takes in that info
• How do you test that the different UIs behave
in a consistent way?
77
78
4/4/2022
40
Exciting times ahead
The LOCOSS project (Low-code
development of smart software)
Traditional
SW model
Smart software model
Data
Smart
back-end
AI quality
properties
Smart
front-end
Quality dashboard
LOCOSS DSLs & Editors LOCOSS infrastructure
Explanations
Domain Knowledge,
Goals & Ethical concerns
provides
receives
Monitoring
Testing
Explainability
specifies
Code
Generation
Local
packages
Cloud
services
AI Platforms
Training component
Code Data Params
Deployment component
ML
Model
79
80
4/4/2022
41
To know more: xatkit.com /
jordicabot.com /
ingenieriadesoftware.es
jcabot@uoc.edu
@xatkit / @JordiCabot / @ingdesoftware
81

More Related Content

PPTX
The Software Challenges of Building Smart Chatbots - ICSE'21
PDF
Lessons learned from building a commercial bot development platform
PDF
Everything you need to know about chatbots
PPTX
Chatbot
PDF
IRJET - A Study on Building a Web based Chatbot from Scratch
PDF
Student information chatbot final report
PDF
PPTX
Using Chatbots in Extension Programming
The Software Challenges of Building Smart Chatbots - ICSE'21
Lessons learned from building a commercial bot development platform
Everything you need to know about chatbots
Chatbot
IRJET - A Study on Building a Web based Chatbot from Scratch
Student information chatbot final report
Using Chatbots in Extension Programming

Similar to Cómo construir un chatbot inteligente sin morir en el intento (20)

ODP
Levelling up in open source
DOCX
A Comprehensive Overview of Chatbot Development_ Tools and Best Practices.docx
PPTX
Chatbot Tutorial - Create your first bot with Xatkit
PPTX
Using Generative AI in the Classroom .pptx
PDF
Will your intranet be replaced with a (chat) bot?
PDF
FOAI MICRO PROJECT__chatbot_gtu_project.
PPTX
Chatbots Using GPT (Generative Pretrained Transformer)
PPTX
chatgpt.pptx
PPTX
Chatbots
PDF
Chatbots for Brand Representation in Comparison with Traditional Websites
PPTX
Whats a Chat bot
PPTX
chatbotppt-2-221230190622-6b7k0e717.pptx
PPTX
Chatbot Technology
PDF
Realizing AI Conversational Bot
PPTX
Final presentation on chatbot
PDF
ChatGPT.pdf
PDF
ChatGPT.pdf
PDF
IRJET- Artificial Intelligence Based Chat-Bot
PPTX
UXPA2019 Not Your Average Chatbot: Using Cognitive Intercept to Improve Infor...
PDF
Bot. You said bot? Let build bot then! - Laurent Ellerbach
Levelling up in open source
A Comprehensive Overview of Chatbot Development_ Tools and Best Practices.docx
Chatbot Tutorial - Create your first bot with Xatkit
Using Generative AI in the Classroom .pptx
Will your intranet be replaced with a (chat) bot?
FOAI MICRO PROJECT__chatbot_gtu_project.
Chatbots Using GPT (Generative Pretrained Transformer)
chatgpt.pptx
Chatbots
Chatbots for Brand Representation in Comparison with Traditional Websites
Whats a Chat bot
chatbotppt-2-221230190622-6b7k0e717.pptx
Chatbot Technology
Realizing AI Conversational Bot
Final presentation on chatbot
ChatGPT.pdf
ChatGPT.pdf
IRJET- Artificial Intelligence Based Chat-Bot
UXPA2019 Not Your Average Chatbot: Using Cognitive Intercept to Improve Infor...
Bot. You said bot? Let build bot then! - Laurent Ellerbach
Ad

More from Facultad de Informática UCM (20)

PDF
¿Por qué debemos seguir trabajando en álgebra lineal?
PDF
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
PDF
DRAC: Designing RISC-V-based Accelerators for next generation Computers
PDF
uElectronics ongoing activities at ESA
PDF
Tendencias en el diseño de procesadores con arquitectura Arm
PDF
Formalizing Mathematics in Lean
PDF
Introduction to Quantum Computing and Quantum Service Oriented Computing
PPTX
Computer Design Concepts for Machine Learning
PDF
Inteligencia Artificial en la atención sanitaria del futuro
PDF
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
PDF
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
PPTX
Fault-tolerance Quantum computation and Quantum Error Correction
PDF
Automatic generation of hardware memory architectures for HPC
PDF
Type and proof structures for concurrency
PDF
Hardware/software security contracts: Principled foundations for building sec...
PDF
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
PDF
Do you trust your artificial intelligence system?
PDF
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
PDF
Challenges and Opportunities for AI and Data analytics in Offshore wind
PDF
Evolution and Trends in Edge AI Systems and Architectures for the Internet of...
¿Por qué debemos seguir trabajando en álgebra lineal?
TECNOPOLÍTICA Y ACTIVISMO DE DATOS: EL MAPEO COMO FORMA DE RESILIENCIA ANTE L...
DRAC: Designing RISC-V-based Accelerators for next generation Computers
uElectronics ongoing activities at ESA
Tendencias en el diseño de procesadores con arquitectura Arm
Formalizing Mathematics in Lean
Introduction to Quantum Computing and Quantum Service Oriented Computing
Computer Design Concepts for Machine Learning
Inteligencia Artificial en la atención sanitaria del futuro
Design Automation Approaches for Real-Time Edge Computing for Science Applic...
Estrategias de navegación para robótica móvil de campo: caso de estudio proye...
Fault-tolerance Quantum computation and Quantum Error Correction
Automatic generation of hardware memory architectures for HPC
Type and proof structures for concurrency
Hardware/software security contracts: Principled foundations for building sec...
Jose carlossancho slidesLa seguridad en el desarrollo de software implementad...
Do you trust your artificial intelligence system?
Redes neuronales y reinforcement learning. Aplicación en energía eólica.
Challenges and Opportunities for AI and Data analytics in Offshore wind
Evolution and Trends in Edge AI Systems and Architectures for the Internet of...
Ad

Recently uploaded (20)

PPTX
Welding lecture in detail for understanding
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
composite construction of structures.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
additive manufacturing of ss316l using mig welding
PDF
PPT on Performance Review to get promotions
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Welding lecture in detail for understanding
Internet of Things (IOT) - A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Construction Project Organization Group 2.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
Foundation to blockchain - A guide to Blockchain Tech
Structs to JSON How Go Powers REST APIs.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
composite construction of structures.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
additive manufacturing of ss316l using mig welding
PPT on Performance Review to get promotions
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Strings in CPP - Strings in C++ are sequences of characters used to store and...
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Cómo construir un chatbot inteligente sin morir en el intento

  • 1. 4/4/2022 1 Como construir chatbots inteligentes sin morir en el intento @JordiCabot / @ingdesoftware / @xatkit– jordicabot.com / ingenieriadesoftware.es Introduction 1 2
  • 2. 4/4/2022 2 About SOM Research Lab Software runs the world. Models run the software 3 4
  • 3. 4/4/2022 3 Nuestra misión Interested in the broad area of systems and software engineering, especially promoting the rigorous use of software models and engineering principles in all software engineering tasks. Flickr/clement127 5 6
  • 4. 4/4/2022 4 Context Can you help us create a chatbot to help newcomers to write good bug reports on GitHub? Sure! It’s just a set of questions & answers, this will be pretty simple! Narrator It wasn’t. Once upon a time in 2018 (we were young and naïve) 7 8
  • 5. 4/4/2022 5 We were asked to build a bot. We ended up building a bot platform But at least we’ve learnt some things along the way that today we want to share with you 3 times so far! Why you all need to have some bot building notions 9 10
  • 6. 4/4/2022 6 And more predictions: - By 2024, consumer retail spend via chatbots worldwide will reach $142 billion—up from just $2.8 billion in 2019. Chatbot market is worth over 1 Billion USD 11 12
  • 7. 4/4/2022 7 Chatbots <-> Software engineers • Software Engineers -> Chatbot – Chatbots are a new type of software artefact that we’ll need to consider in our dev projects • Chatbot -> Software Engineering – Bots are more and more playing a supportive role in many SE tasks (e.g. in GH) so better to know how they work and their limitations 13 14
  • 8. 4/4/2022 8 Hidden Technical debt in Machine Learning Systems - Google - https://proceedings.neurips.cc/paper/2015/file/86df7dcfd896fcaf2674f757a 2463eba-Paper.pdf 15 16
  • 9. 4/4/2022 9 Core chatbot concepts What is exactly a Chatbot? • Bot are software components • Chatbot = Bot + Chat interface – Tb llamado asistente digital, asistente virtual,… • Voicebot = Chatbot + Voice Interface Voicebot Chatbot Bot 17 18
  • 10. 4/4/2022 10 VoiceBot • Alexa, Google Assistant ,… • They all hide a chatbot inside 1. Speech-to-text 2. Process the text as a chatbot 3. Text-to-speech to reply Chatbot vs LiveChat • LiveChat: a person is behind • They can be combined – Bot  Person: when the bot doesn’t know how to answer (or the visitor is specially “interesting”) – Person  Bot: when no support person is available or the client is not worth 19 20
  • 13. 4/4/2022 13 Types of chatbots Types of chatbots Button- based (no AI) Intent-based Open questions Open domain 25 26
  • 14. 4/4/2022 14 We ignore open-domain bots (e.g. LaMDA) • They can chat about everything but – A complete black-box – ``Useless’’ for a specific business https://mindmatters.ai/2022/03/the-ai-illusion-state-of-the-art-chatbots-arent-what- they-seem/ Creating a chatbot 1 – Why is it so challeging? 27 28
  • 15. 4/4/2022 15 Software (bot part) NLU (chat part) Complexity of chatbots Chat bots Many pieces to assemble Input/Output Messaging channels External Platforms NLU Engine Events! 29 30
  • 16. 4/4/2022 16 Chatbots are complex software systems Conversation Logic Text Processing External Services Messaging Platforms Deployment Evolution Maintenance Tests J Cabot, L Burgueño, R Clarisó, G Daniel, J Perianez- Pascual, R Rodríguez-Echeverría: Testing challenges for NLP-intensive bots. BotSE@ICSE 2021: 31-34 Creating a chatbot 2 – The NLP component 31 32
  • 17. 4/4/2022 17 How NLP works in chatbots Bots and NLP/NLU • At the core of all AI bots there is a NLU/NLP engine with two key missions – Classify the user utterance (i.e. input text) in one of the intents (set of possible questions/requests) the bot understands – Identify the parameters (called « entities ») from the utterance 33 34
  • 18. 4/4/2022 18 NLP in a chatbot implies Parameters (entities) I would like to order a medium pepperoni pizza Intent Input text (utterance) • Understand what the user is trying to ask the bot • Identify and gather the data in the request that the bot needs to construct the response 35 36
  • 19. 4/4/2022 19 NLU approaches • Regular expressions • Require an almost exact match. Only useful for very concrete cases • Grammar-based approaches • Useful for small domains with a very specific vocabulary and constructs • E.g. Stanford Parser • Neural Networks - Multiclass classifiers 1. You provide some training sentences for each intent (the "classes" ). 2. The classifier learns from these sentences 3. It assigns any new input text to one of the classes (with %confidence) Hi Good morning Good afternoon Hello Morning! Example: bot that greets you, informs about the schedule and lets you buy a pizza Greetings I’d like to buy a pizza I want a pizza Can I order a pizza? Buy Are you open? Is it open now? What are your opening hours? At what time do you start? Schedule If a user says, “I would like to order a pizza now” what is the closest intent? Not that easy when intents start to overlap (e.g. offering a job vs looking for a job: “can I offer you a job?” vs “do you have any job offer”) 37 38
  • 20. 4/4/2022 20 Entity recognition • We need to understand the intent but also identify the entities • Much easier if PizzaType is an enumeration ({ Pepperoni, Veggie, Hawaian ,…}) instead of the any string ChooseYourPizza I’d like a PizzaType pizza I’m taking a PizzaType pizza I think I’m going for a PizzaType 39 40
  • 21. 4/4/2022 21 Common tricks in NLU Engines • Stemmers identify the lemma of the word (e.g. to focus on the verb, not on the tense of the verb for matching purposes) • Synonyms and paraphrasing are an automatic way to expand the training sentences • Entity augmentation also generalize training sentences • E.g. What’s the weather in Barcelona -> What’s the weather in @city • Augmentation is possible for a large number of data types and common concepts (measures, countries, dates,…) Taking a closer look at the NN https://github.com/xatkit-bot-platform/xatkit-nlu-server 41 42
  • 22. 4/4/2022 22 The ML model Even this “simple” arch easily gets over > 100.000 parameters! Step 1 – From words to vectors of numbers 43 44
  • 23. 4/4/2022 23 Step 2 Embedding -> similar words have similar vectors King – man + woman = Queen Training and prediction history = model.fit(np.array(context.training_sequences), np.array(context.training_labels), epochs=configuration.num_epochs, verbose=2) full_prediction = context.nlp_model.predict(sequence_from_sentence_to_predict) Tip: Predicting always via the NN is overengineering sometimes (e.g. Yes/No answers) 45 46
  • 24. 4/4/2022 24 Remember: the SW part of any ML project And we could go on and on ... 47 48
  • 25. 4/4/2022 25 Beyond intent classification • Great bots go beyond providing the right answer, e.g. they could show some empathy • Several language models (for toxicity detection, for sentiment analysis, language identification, emoji support…) can be easily integrated in bots PRO tip: Monitor your bots • You will fail to predict: • What users want to know • How they express their intentions • Careful with self-learning • Filter out what the bot needs to add as training sentences to avoid strange derivations 49 50
  • 26. 4/4/2022 26 Creating a chatbot 3 – The Software component What bot building tool should I use? 51 52
  • 27. 4/4/2022 27 >100 bot platforms • Rasa, BotPress, Chatfuel, Inbenta, Botsify, Flow XO, Xatkit… • And plenty NLP engines: DialogFlow, Lex, LUIS, Watson, NLP.js It all depends • What are your priorities – Open source? – Free? – Programming language of the bot? – Natural languages (e.g. Catalan) – Availability of connectors – On-premises option? – Plain textual bots or fully functional ones? – Low-code/ no-code or tech skills? – Possibility to migrate from one NLP engine to another? – Monitoring dashboard / reports ? – … 53 54
  • 28. 4/4/2022 28 Building bots in Xatkit https://github.com/xatkit-bot-platform Xatkit’s philosophy: Do not reinvent the wheel Other solutions Plenty of great NLU engines and libraries, let’s not waste our time building a new one but take the best of breed and focus on features to help you create better bots Xatkit is a chatbot orchestration platform 55 56
  • 29. 4/4/2022 29 Another reason to avoid strong coupling to specific NLU/NLP libraries Xatkit architecture (write your bot once, run it anywhere) Chatbot Designer Intent Recognition NLU Providers (platform-specific) Platform DSL / Libraries Intent DSL Xatkit DSL Chatbot User Instant Messaging Platforms Xatkit Runtime Execution DSL uses uses Platform-independent chatbot definition External Services Deployment Configuration Platform Designer G Daniel , J Cabot , L Deruelle, M Derras : Xatkit: A Multimodal Low-Code Chatbot Development Framework. IEEE Access 8: 15332-15346 (2020) 57 58
  • 30. 4/4/2022 30 Xatkit DSL • Bots are created with the Xatkit DSL offering a chatbot- specific syntax for creating: – Intents the bot needs to match – The behavior to execute in response to the matched intents • Our DSL aims to combine the benefits of: – Having a chatbot-specific DSL that facilitates the creation of chatbot applications by providing higher-level chatbot modeling primitives – The full power of a general programming language to create any type of bot, not just simple textual ones Xatkit DSL • Should we go for an external DSL or an internal one? – External one: independent language with its own compiler, editor,… You control everything – Internal ones: lives inside another language. You can reuse the host language but are also constrained by it • We started with an external one and had to reimplement everything In our scenario, Internal DSLs are the way to go (Martin Fowler) 59 60
  • 31. 4/4/2022 31 Our DSL is implemented as a Java Fluent API • Create bots using your preferred Java editor – Benefit from all existing Java tooling when developing bots (e.g. debuggers) – Reuse any Java library for complex bot behaviors – Intuitive Fluent Interfaces to help you create advanced conversations – Based on state machine semantics to build any type of bot Intent DSL example 61 62
  • 32. 4/4/2022 32 Execution DSL example – State machines Easy deployments A Xatkit bot can be packaged as a single jar with no external dependencies. Just execute the jar to get the bot up and running Via a simple configuration file you can connect your bot with external services, e.g. NLP Engines and communication channels 63 64
  • 33. 4/4/2022 33 Xatkit is available on GitHub Advanced topics 65 66
  • 34. 4/4/2022 34 Beyond predefined intents 80/20 - Pareto Rule • 80% of user utterances will match 20% of your intents • Recursive Pareto: 64% (80% of 80%) of your input utterances will be reduced to 4% (20% of 20%) of your defined intents. 67 68
  • 35. 4/4/2022 35 Open questions -> Plan B in your default fallback https://haystack.deepset.ai/ BODI (Bots for Open Data) we use text to SQL models to try to answer a larger variety of questions No-learn / No-work chatbot building 69 70
  • 36. 4/4/2022 36 Low-code / no-code • Many bot platforms try to offer low-code / no- code interfaces to define bots (e.g. GUIs) writing less code • But this is not enough for many non-tech users Keep in mind: 1 language -> ++notations No-Learn (e.g. bots from Excel) 71 72
  • 37. 4/4/2022 37 No-Work • Bots derived from your db data – E.g. an eCommerce bot that answers questions about your products, shipping options,… Multiexperience Development Platforms (MXDP) 73 74
  • 38. 4/4/2022 38 One app -> Multiple interfaces Related also to Multimodal AI E.g.: DALL-E 75 76
  • 39. 4/4/2022 39 E Planas, G Daniel, M Brambilla, J Cabot: Towards a model-driven approach for multiexperience AI-based user interfaces. Softw. Syst. Model. 20(4): 997-1009 (2021) But this brings plenty of new challenges • A chatbot that knows where you’re looking at (e.g. the product in the eCommerce shop) and takes in that info • How do you test that the different UIs behave in a consistent way? 77 78
  • 40. 4/4/2022 40 Exciting times ahead The LOCOSS project (Low-code development of smart software) Traditional SW model Smart software model Data Smart back-end AI quality properties Smart front-end Quality dashboard LOCOSS DSLs & Editors LOCOSS infrastructure Explanations Domain Knowledge, Goals & Ethical concerns provides receives Monitoring Testing Explainability specifies Code Generation Local packages Cloud services AI Platforms Training component Code Data Params Deployment component ML Model 79 80
  • 41. 4/4/2022 41 To know more: xatkit.com / jordicabot.com / ingenieriadesoftware.es jcabot@uoc.edu @xatkit / @JordiCabot / @ingdesoftware 81