1. CET313 Artificial Intelligence
Answer:
Introduction
To a large extent, Artificial Intelligence (ΑΙ) fuses daily life with the development and
analysis of intelligent software and hardware, often identified as intelligent agents. The
resulting intelligent agents are postulated to carry out various tasks including but not
limited to labor work and sophisticated operations such as learning and data analysis. An
example of one of the most popular intelligent agents is the chatbot which is a denotation of
intelligent Human-Computer Interaction (HCI) (Bansal & Khan, 2018). Primarily, chatbots
can emulate among other processes, human conversation as well as entertain users making
them applicable in fields like education, information retrieval, business, finance, healthcare,
and e-commerce (Abu & Atwell, 2010). According to Adamopoulou & Moussiades (2020), a
chatbot is a computer program that generates responses like a smart entity when engaged
through text or over voice and understands one or more human languages through the use
of Natural Language Processing (NLP).
The popularity of chatbots has been driven by the need to engage users over live chat
interfaces which essentially facilitates the provision of real-time customer services across
various fields. In practice, users utilize the underlying chat services to gain and access
information such as product details or obtain assistance such as solving technical issues in
products etcetera (Adam, et al., 2021). Besides, since knowledge in the use of a given
chatbot can be transferred to the application of other chatbots, as well as there being
limited data requirements, the development of chatbots allows for faster scaling and
widespread usage (Klopfenstein, et al., 2017). (Klopfenstein, et al., 2017) argues that,
communication reliability, quick and straightforward development iterations, absence of
version fragmentation, as well limited design requirements for the agent interface are
among the main advantages for developers.
Chatbot Prototype
Mission Statement
In this study, we seek to develop a knowledge base chatbot prototype that depending on
user requirements provides general information on various aspects of foreign exchange
2. markets. As such, the target audience of the proposed prototype is players in the finance
industry. The chatbot will provide general information on issues such as what foreign
exchange entails, the history of the foreign exchange market, the market’s structure, parties
involved, importance, etcetera.
Overview Of Tutorial Improvement
Some of the areas that we have improved on the original tutorial include, adding a scoring
method i.e., cosine similarity for evaluating the quality of responses to be given to users,
adding user interaction interfaces such as collecting user information such as username,
developing a relatively advanced database with questions and expected answers, optimized
the chatbot to respond to both keywords and phrases that are input by users. For instance,
if a user passes a phrase like what about forex the expected response will be the same as
that given to a user who passes the keyword forex.
Moreover, by defining an option of the similarity metric to be used which primarily would
be either cosine, cityblock, euclidean, l1, l2, and Manhattan it enables the developers to
twerk the chatbot configurations to improve the quality of the responses.
Literature Review
History Of Chatbots
Chatbots have over time, symbolized a shift in how individuals interact with data and
services online (Brandtzaeg & Følstad, 2017). Following the proposal of Alan Turing in 1950
that “Machines can think”, the concept of a chatbot was first popularized (Adamopoulou &
Moussiades, 2020). Sixteen years later, Eliza, the first publicly known chatbot which used a
pattern matching approach (Brandtzaeg & Følstad, 2017) and template-based response
method, was developed to function as a psychotherapist providing the user utterances in
the form of a question. While Eliza was not comprehensive, it paved way for the
development of other chatbots such as Parry in 1972 (Sean, 2020) by Kenneth Colby and
Alice in 1995 (Wallace, 2009). The Alice chatbot which won the Turing awards in 2000,
2001, and 2004 was dependent on a simple pattern-matching algorithm integrated with an
underlying intelligence built on the Artificial Intelligence Markup Language (AIML) (Gracas,
et al., 2013).
Research interest in chatbots as shown in figure 1 below, based on a Scopus search
by (Adamopoulou & Moussiades, 2020), increased significantly in the years following 2016.
Figure 1: Number of documents that explore chatbots between 2000 and 2019, source:
https://www.ncbi.nlm.nih.gov
In 2001, the development of the SmarterChild chatbot was a pivotal moment for the
evolution of chatbot technology after it was made available on several platforms such as
3. America Online (AOL) and Microsoft (MSN) to facilitate the retrieval of information,
marking an important developmental point in machine learning (ML) and human-computer
interaction since information could now be accessed based on discussions by chatbots as
opposed to human agents (Molnár & Zoltán, 2018).
McTear (2021) argues that the emergence of chatbots is due to the need of addressing
various features of conversational computer systems in industrial applications with the
recent research interest being a direct response to the “…uptake of so-called virtual
assistants by big tech companies” (Dale, 2016), in particular, the adoption of Siri as a
constituent of the Apple Operating System in 2011, Amazon's proposal of Alexa as from
2014 as well as the conversational turn of both Facebook, Microsoft, and Google since
2016 (Dale, 2016).
Usage Of Chatbots
(Brandtzaeg & Følstad, 2017) conduct a study on why people use chatbots. According to
Brandtzaeg & Følstad (2017), chatbots are used in several ways including in customer
service, social and emotional support, information, and entertainment, besides connecting
users to other individuals or machines. This applicability of chatbots has prompted the
adaption of chatbots across different fields and applications, ranging from education to
finance, enveloping healthcare and entertainment (Caldarini, et al., 2022).
The upward trend observed in 2016 (see figure 1) was brought about by the evolution of
artificial intelligence which changed the way individuals communicate with manufacturers.
Moreover, the development of chatbots for social media allowed users to carry out some
daily tasks using their social media messengers. By the end of 2016, there were
approximately 34,000 bots in usage across fields such as “…Marketing, Supporting Systems,
Health Care, Entertainment, Education, and Cultural Heritage” (Adamopoulou &
Moussiades, 2020).
Application Of Chatbots
Chatbots should be implemented anthropomorphically (that is, adopt a human-like form)
and generate a sense of social presence (Zhang, et al., 2012). This is achieved through
adopting features of human-human communication. In their study (Adam, et al., 2021)
argue that most chatbot designs are generally focused on anthropomorphic design cues and
how they will impact human behavior while taking into consideration the perceptions and
adoption of the agents.
Pattern Matching
During implementation, rule-based agents match the user input to a specified rule pattern
and return a predefined response from a list of responses by using Pattern Matching
4. algorithms (Marietto, et al., 2013). Both Eliza and Alice were implemented using pattern
matching. The snip below shows an example of a pattern-matching algorithm.
Parsing
Parsing is used to examine the input provided by users by using natural language
processing or computer language. The technique transforms the input into a list of lexicons
i.e., lexical parsing to establish the grammatical distribution of the text before generating
appropriate responses (Devakunchari, et al., 2019).
Other approaches for building chatbots include ChatScript, SQL, and Relational Database for
building knowledge chatbots, Language tricks which uses sentences and other language
structures to expand the knowledge of chatbots, and which uses NLP to produce responses
by establishing relationships between various documents (Devakunchari, et al., 2019).
Prototype Development Reflection
Our goal was to develop a foreign exchange market knowledge base chatbot whose purpose
is to interact with users and provide responses to the user in question based on their
queries related to concepts of foreign exchange. To achieve this, we used a natural language
approach that combines some features from parsing and latent semantic analysis. The
whole process was interesting given the necessity of selecting an appropriate source of
information, processing the information, adding the information into two documents for
relationship matching, and developing the interaction component of the chatbot.
Source Of Information
I realized that there isn’t a ready-to-use source of information which posed a challenge of
how to collect the data. Most of the information sources that I came across focused on a
specific aspect of the foreign exchange market such as the characteristics, functioning, risks,
etcetera. Second, having found a relatively comprehensive source of information, the second
challenge was to structure the database such that it will not cause issues during data
processing which prompted me to store the data in a text format.
Processing Information
During prototype implementation, I noted that developing the chatbot requires about three
components i.e., the introduction where the chatbot interacts with a user for the first time,
collects information such as their name, offers greetings and basic directions, accepts user
input, and generating responses to the user input depending on the most relevant response
from among all the possible responses. Therefore, this necessitated generating and defining
all possible keywords and phrases that are related to the foreign exchange market which
was a challenge since I had to read through the original information to establish all the
5. relevant text manually before adding it to the databases for processing and automation.
Besides, I realized that it is important to have a valid and relatively well-performing
document comparison metric. In this case, I experimented with the Cosine, Euclidean, and
Manhattan distance metrics.
Different text processing approaches tended to lead to varying responses. I assumed this is
because approaches such as vectorization, lemmatization, stemming, etcetera lead to
different outputs which are processed differently when generating responses.
Interaction Component
Lastly, I noted that user-friendliness is an important factor, and to make the chatbot
convenient for user interaction, an exit criterion needed to be defined. For instance, we
allowed the user to terminate the chat session by typing inputs such as Bye or Quit.
Evaluation
In this section, we discuss an evaluation of the final chatbot prototype including the
decision-making process, test plans, testing results, and alterations suggested by
test/evaluation results.
Decision-Making Process
Instances that required decision-making included database selection, question and answer
definition as well as response generation.
Database Selection
Wikipedia is one of the largest knowledge databases on the internet which, unlike scholarly
articles, tends to provide a general overview of a given concept.
Table 1: Overview of the table of components for foreign exchange
Table 1 above provides an overview of the topics explored in the Wikipedia page of Foreign
Exchange Market which can be accessed through the Foreign exchange market link. This
aligns with the original objective in which we sought to provide a user with general
information regarding the foreign exchange market. However, during the process of testing,
we noted that the definition of risk provided in the Wikipedia page had a document
similarity with the speculation component. We therefore decided to collect information
regarding the market’s risk from
https://corporatefinanceinstitute.com/resources/knowledge/finance/foreign-exchange-
risk/ which improved the performance of the prototype.
6. As noted earlier, database section was split into two i.e., the possible questions and
response databases.
Questions
There are many possible questions that a user could supply to the chatbot and since
different individuals tend to require different information, it is not feasible to generate all
possible questions. As such, we used the titles provided in the database to generate a list of
possible questions. Using these questions, the similarity between a new question and those
in the database was computed using a pairwise similarity metric and linked to the response
that has the best similarity. An example of the information source for the question What is
the market size? is given in the snip below.
Responses
The response to the questions that were generated corresponded to the content below each
of the titles from which the questions were generated. For instance, the response to the
What is the market size? Was selected to be as shown in the snip below.
Further Decision Making
Other decisions such as the username with which to refer to the user and when to terminate
the interaction depended on the user input. For instance, if a user, defined their name as
John Doe, the program will explicitly refer to them as John Doe until the program is
terminated and a new username is supplied. This was achieved through the use of
conditional statements such as if-else statements. An example of a user-supplied name is
shown in the following snip.
Test Plans
The performance of the chatbot was evaluated on how well it generated responses. Up to
three document similarity metrics were used and the resulting responses were explored.
This involved using the same 5 questions per metric and evaluating the quality of the
responses. The number of times that the chatbot generated the correct responses were
computed and used to determine the overall accuracy of the chatbot per metric. During our
evaluation, we noted that the cosine similarity metric had 8 correct responses out of 10
compared to that of the Euclidean and Manhattan metrics each of which generated 6 correct
responses.
Prior to generating responses, the optimal response was that which had the closest
similarity with responses to questions that are similar to those supplied by the user. To
determine the most relevant response, a threshold of a cosine similarity of less than 30 was
7. selected. In this case, if a response to a question had a similarity score greater than 30, it
was considered not relevant and a message was displayed. Otherwise, the response with the
maximum cosine similarity was selected and returned to the user.
Evaluation Results
To evaluate the effectiveness of the chatbot. We considered the use of both a keyword and
phrase relating to what the foreign exchange market (i.e., Forex market) is. The original
question in the question database is: What is forex while the keyword is forex. The
following snip provides an overview of the responses generated by the chatbot with
different variants of the question. From the snip below, the chatbot generates 6 correct
responses out of 7 questions. We however note that for the incorrect response, there is no
inclusion of the keyword Forex which might have led to the retrieval of the provided
information.
Conclusion
Most organizations that are technology-oriented are increasingly adopting the use of AI
technology to improve the quality of services offered to their clients. With an ever-growing
competition, it is only necessary that the respective organizations integrate new methods
like intelligent agents such as the chatbot to automate various processes including but not
limited to collecting customer orders, providing customer support, information, and
entertainment. The objective of the current study was to implement an information-
retrieval chatbot whose role was to provide users with various aspects of the foreign
exchange market. To this end, we used a natural language processing approach to
preprocess the data and genearte patterns that could allow Latent Semantic Analysis for the
comparison of information to generate responses.
Since based on past chatbot projects, we noted that sample response data can be stored in
json files. We noted that collecting data and processing it as json is bit tedious compared to
collecting data and storing in different two seprate text files. This allows for faster scaling of
the databases compared to the sytax based data storage requirement by json.
How has academic theory or practical advice from the sources you have used informed and
improved your chatbot?
There are different approaches towards generating meaning from text in semantic analysis.
Following practical advice, we learnt that while lemmatization improves the quality of data,
vectorization I useful in converting input data from its raw format (that is, text) into vectors
of real numbers that machine learning algorithms support. In our case, using vectorization
helped the cosine similarity model compute the similarity between potential responses to a
question based on the content of the new user query.
8. Were there any aspects of developing your chatbot that involved you working in new ways
or ways that you had not anticipated?
The chatbot required that we have two separate databases i.e., questions and expected
responses. We had not anticipated that the chatbot could generate insights and
corresponding responses from two different databases. Besides, we tried to experiment
with different similarity metrics and data processing techniques for the chatbot.
While using the count and Term Frequency — Inverse Document Frequency (tfidf)
vectorizers, we noted that the model generally returned more relevant responses when we
used the count vectorizer which was unexpected since we had assumed the tfidf vectorizer
generates better insights from the text data.
An Honest Appraisal of Your Performance and The Produced Chatbot
The chatbot performs relatively well when supplied with input that has almost similar
composition as the questions used to build the chatbot. However, since the approach is
based on supervised learning, the chatbot when supplied with completely new input with a
different composition, it sometimes generates irrelevant output. In such cases, we would
ordinarily expect that it will terminate but the bot terminates on few occasions when the
similarity score is very low. The chatbot does not preprocess data to remove noise such as
punctuations and numbers which might influence the performance of the chatbot especially
if it is adapted for machine learning.
References
Abu, S. B. & Atwell, E., 2010. Chatbots: are they really useful?. J. Lang. Technol. Comput.
Linguist., Volume 22, pp. 29-49.
Adam, M., Wessel, M. & Benlian, A., 2021. AI-based chatbots in customer service and their
effects on user compliance. Electron Markets, 31(2021), pp. 427-445.
Adamopoulou, E. & Moussiades, L., 2020. An Overview of Chatbot Technology. Neos
Marmaras, Greece, AIAI, pp. 373-383.
Bansal, H. & Khan, R., 2018. A review paper on human computer interaction. Int. J. Adv. Res.
Comput. Sci. Softw. Eng., 8(2018), p. 53.
Brandtzaeg, P. B. & Følstad, A., 2017. Why people use chatbots. In: e. a. Kompatsiaris I, ed.
Internet Science. Cham: Springer.
Caldarini, G., Jaf, S. & McGarry, K., 2022. A Literature Survey of Recent Advances in Chatbots.
Information, 13(41).
9. Dale, R., 2016. The return of the chatbots. Nat Lang Eng, 22(5), pp. 811-817.
Devakunchari, R., Agarwal, R. & Agarwa, E., 2019. A Survey of Chatbot Design Techniques.
International Journal of Engineering and Advanced Technology (IJEAT), 8(2S2), pp. 35-39.
Gracas, B. M. M. d. et al., 2013. Artificial Intelligence Markup Language: A Brief Tutorial.
International Journal of Computer Science & Engineering Survey, 4(3), p. 1–20.
Klopfenstein, L., Delpriori, S., Malatini, S. & Bogliolo, A., 2017. The rise of bots: a survey of
conversational interfaces, patterns, and paradigms. s.l., Association for Computing
Machinery, pp. 555-565.
Marietto, M. et al., 2013. Artificial intelligence markup language: A brief tutorial.
International Journal of Computer Science and Engineering Survey, 04(2013).
McTear, M., 2021. Conversational AI: Dialogue Systems, Conversational Agents, and
Chatbots. Williston: Morgan & Claypool.
Molnár, G. & Zoltán, S., 2018. The role of chatbots in formal education. s.l., IEEE.
Sean, B., 2020. Chatbot History: The Parry Chatbot, s.l.: Yakbots.
Wallace, R., 2009. The anatomy of A.L.I.C.E. In: R. Epstein, G. Roberts & G. Beber, eds. Parsing
the Turing Test: Philosophical and Methodological Issues in the Quest for the Thinking
Computer. Cham: Springer, pp. 181-210.
Zhang, H. et al., 2012. Mood and social presence on consumer purchase behaviour in C2C E-
commerce in Chinese culture.. Electronic Markets, 22(3), pp. 143-154.