A Guide to Chatbot Architecture
Humans are always fascinated with self-operating devices and today, it is software called “Chatbots” which are becoming more human-like and are automated. The combination of immediate response and constant connectivity makes them an enticing way to extend or replace the web applications trend. But how do these automated programs work? Let’s have a look.
How can Chatbots process human languages?
At first, a Chatbot can look like a normal app. There is an application layer, a database and APIs to call external services. In a case of the chatbot, the UI is replaced with a chat interface. While Chatbots are easy to use for users, it adds complexity for the app to handle.
There is a general worry that the bot can’t understand the intent of the customer. The bots are first trained with the actual data. Most companies that already have a chatbot must be having logs of conversations. Developers use that logs to analyze what customers are trying to ask and what does that mean. With a combination of Machine Learning models and tools built, developers match questions that customer asks and answers with the best suitable answer. For example: If a customer is asking “Where is my payment receipt?” and “I have not received a payment receipt”, mean the same thing. Developers strength is in training the models so that the chatbot is able to connect both of those questions to correct intent and as an output produces the correct answer. If there is no extensive data available, different APIs data can be used to train the chatbot.
How is the Chatbot trained?
Training a chatbot happens at much faster and larger scale than you teach a human. Humans Customer Service Representatives are given manuals and have them read it and understand. While the Customer Support Chatbot is fed with thousands of conversation logs and from those logs, the chatbot is able to understand what type of question requires what type of answers.
How does the chatbot learn after it is live?
Once the chatbot is ready and is live interacting with customers, smart feedback loops can be implemented. During the conversation when customers ask a question, the chatbot can smartly give them a couple of answers by providing different options like “Did you mean a,b or c”. That way customers themselves matches the questions with actual possible intents and that information can be used to retrain the machine learning model, hence improving the chatbot’s accuracy.
Despite this, there are limitations in place assuring that the model should not change based on new replies where users are not driving the bot in right direction. A chatbot will also not just rephrase what the people say in the chat but it is indeed taught to answer things that the bot’s owner wants it to answer.
How Chatbots actually work?
The chatbots work by adopting 3 classification methods:
Pattern Matchers:
Bots use pattern matching to classify the text and produce a suitable response for the customers. A standard structure of these patterns is “Artificial Intelligence Markup Language” (AIML).
A simple pattern matching example:
The machine then gives an output:
Human: Do you know who Abraham Lincoln is?
Robot: Abraham Lincoln was the US President during American civil war.
The chatbot knows the answer only because his or her name is in the associated pattern. Similarly, chatbots respond to anything relating it to the associated patterns. But it can not go beyond the associated pattern. To take it to an advanced level algorithms can help.
Algorithms
For each kind of question, a unique pattern must be available in the database to provide a suitable response. With lots of combination on patterns, it creates a hierarchical structure. We use algorithms to reduce the classifiers and generate the more manageable structure. Computer scientists call it a “Reductionist” approach - in order to give a simplified solution, it reduces the problem.
Multinational Naive Bayes is the classic algorithm for text classification and NLP. For an instance, let’s assume a set of sentences are given which are belonging to a particular class. With new input sentence, each word is counted for its occurrence and is accounted for its commonality and each class is assigned a score. The highest scored class is the most likely to be associated with the input sentence.
For example Sample Training set
class: greeting
“How you doing?”
“good morning”
“hi there”
Few sample Input sentence classification:
input: “Hello good morning”
term: “hello” (no matches)
Term: “good” (class: greeting)
term: “morning” (class: greeting)
classification: greeting (score=2)
With the help of the equation, word matches are found by giving some sample sentences for each class. A classification score identifies the class with the highest term matches but it also has some limitations. The score signifies which intent is most likely for the sentence but does not guarantee it is the perfect match. The ighest score only provides the relativity base.
Artificial Neural Networks
Neural Networks are a way of calculating the output from the input using weighted connections which are calculated from repeated iterations while training the data. Each step through the training data amends the weights resulting in the output with accuracy.
As discussed earlier here also, each sentence is broken down into different words and each word then is used as input for the neural networks. The weighted connections are then calculated by different iterations through the training data thousands of times. Each time improving the weights to making it accurate. The trained data of the neural network is a comparable algorithm requiring less code and coding time - in other words there is less code and more dependency on the comparable algorithm. When there is a comparably small sample, where the training sentences have 200 different words and 20 classes, then that would be a matrix of 200×20. But this matrix size increases by n times more gradually and can cause a huge number of errors. In these kinds of situations, processing speed should be considerably high.
There are multiple variations in neural networks, algorithms as well as patterns matching code. Complexity may also increase in some of the variations. But the fundamental remains the same, and the important work is that of classification.
NLU (Natural Language Understanding)
It has 3 specific concepts like:
Entities: Entity basically represents a concept in your Chatbot. It might be a payment system in your Ecommerce Chatbot.
Intents: It is basically the action chatbot should perform when the user say something. For instance, intent can trigger the same thing if user types “I want to order a red pair of shoes”, “Do you have red shoes? I want to order them” or “Show me some red pair of shoes”, all of these user’s texts trigger a single command giving users options for a Red pair of shoes.
Context: When an NLU algorithm analyzes a sentence, it does not have the history of the user conversation. It means that if it receives the answer to a question it has just asked, it will not remember the question. For differentiating the phases during the chat conversation, it’s state should be stored. It can either be flags like “Ordering Pizza” or parameters like “Restaurant: ‘Dominos’”. With context, you can easily relate intents with no need to know what the previous question was.
NLP (Natural Language Processing)
A Natural Language processing (NLP) chatbot takes some combination of steps to convert the customer’s text or speech into structured data that is used to select the related answer. Some of the Natural Language Processing steps are:
Sentiment Analysis: Tries to learn if the user is having a good experience or if after some point the chat should be forwarded to the human.
Tokenization: The NLP divides a string of words into pieces or tokens that are linguistically symbolic or are differently useful for the application.
Named Entity Recognition: The chatbot program model looks for categories of words, like the name of the product, the user’s name or address, whichever data is required.
Normalization: The Chatbot program model processes the text in an effort to find common spelling mistakes or typographical errors that the user might be trying intent to convey. This gives a more human like effect to the chatbot for the users.
Dependency Parsing: The Chatbot looks for the objects and subjects - verbs, nouns and common phrases in the user’s text to find dependent and related phrases that users might be trying to convey.
Like most of the Applications, the Chatbot is also connected to the Database. The knowledge base or the database of information is used to feed the chatbot with the information needed to give a suitable response to the user. Data of user’s activities and whether or not your chatbot was able to match their questions, is captured in the data store. NLP translates human language into information with a combination of patterns and text that can be mapped in the real time to find applicable responses.
There are NLP services and applications programming interfaces that are used to build the chatbots and make it possible for all type of businesses, small. Medium and large scale. The main point here is that Smart Bots have the potential to help increase your customer base by improving the customer support services and as a result boosts the sales as well as profits. They are an opportunity for many small and mid-sized companies to reach a huge customer base.
Author - Mitul Makadia (Twitter - @mitulmakadia / LinkedIn - https://www.linkedin.com/in/mitulmakadia/)
Author Bio - Mitul Makadia is Founder of Maruti Techlabs and a true technophile. With his industry experience, he has rapidly developed Maruti Techlabs in specialized services like Chatbot Development, Artificial Intelligence, Natural Language Processing and Machine Learning. Makadia has considerable expertise in Chatbot Development and NLP.
Requirements for functional equivalence to conscious processing? by DaltonG (General AI Discussion) |
Will LLMs ever learn what is ... is? by HS (Future of AI) |
Who's the AI? by frankinstien (Future of AI) |
Project Acuitas by WriterOfMinds (General Project Discussion) |
Ai improving AI by infurl (AI Programming) |
Atronach's Eye by WriterOfMinds (Home Made Robots) |
Running local AI models by spydaz (AI Programming) |
Hi IM BAA---AAACK!! by MagnusWootton (Home Made Robots) |
LLaMA2 Meta's chatbot released by spydaz (AI News ) |
ollama and llama3 by spydaz (AI News ) |
AI controlled F-16, for real! by frankinstien (AI News ) |
Open AI GPT-4o - audio, vision, text combined reasoning by MikeB (AI News ) |
OpenAI Speech-to-Speech Reasoning Demo by MikeB (AI News ) |
Say good-bye to GPUs... by MikeB (AI News ) |
Google Bard report by ivan.moony (AI News ) |
Elon Musk's xAI Grok Chatbot by MikeB (AI News ) |
Most Online Today: 453. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)