<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Development of a Chatbot Using Machine Learning Algorithms to Automate Educational Processes</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dmitry Alekseev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Polina Shagalova</string-name>
          <email>polli-shagalova@yandex.ru</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Eleonora Sokolova</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>NNSTU n.a. R. E. Alekseev</institution>
          ,
          <addr-line>Minina str., 24 Nizhny Novgorod, 603950</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The use of chatbots in educational processes is relevant, where point communication with each student on common issues is required. A chatbot with artificial intelligence has been developed to automate educational processes. The cross-platform Telegram messenger is used to interact with the user. To increase the efficiency of creating a dataset, a graphical application interface in Python has been developed. Using libraries for creating graphical interfaces based on the Qt5 platform allows you to quickly navigate the intents, requests, responses that are already in the dataset. At the stage of developing the model structure, various vectorizers with different parameters were tested. To determine the intentions of users, a machine learning model was developed and implemented. The accuracy of the classification of user requests after training the model was 97%. An additionally developed algorithm based on the Levenshtein distance increased the classification accuracy. If the user's intent is not defined, a “stub” is triggered: “I did not understand the meaning of your question. Please rephrase it.” Besides, the chatbot implements voice message recognition. As a result of the chatbot's interaction with users, statistics on requests are collected and all events occurring in the program are recorded. All information is presented graphically. After authentication, the user gets access to all statistics and can send messages on behalf of the bot, so the teacher can give a detailed answer. The architecture of the chatbot model allows it to be used on datasets of any educational process.</p>
      </abstract>
      <kwd-group>
        <kwd>process</kwd>
        <kwd>Chatbot</kwd>
        <kwd>machine learning</kwd>
        <kwd>natural language processing</kwd>
        <kwd>graphical interfaces</kwd>
        <kwd>educational</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Currently, artificial intelligence systems are developing, where one of the directions in the
development of machine programs, chatbots that have artificial intelligence and interact with many
users. The use of these technologies has great potential in the field of education, for example, in
processes where the teacher spends a lot of time consulting students on typical issues. Chatbot
development technologies are used to develop assistants for entering a higher educational institution, in
online courses, in organizing students ' time, etc. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. At the same time, chatbots perform, as a rule,
elementary functions, reducing time and routine work.
      </p>
      <p>The paper presents a chatbot with artificial intelligence, trained on the developed dataset, which
allows automating the process of passing the norm control by students-answers questions, sends the
necessary documents to fill out, can connect a teacher to send more answers-consultations, provides
statistics, and registers all events that occur. The chatbot selects the answer based on a given list of
possible answers, using ranking technology.</p>
      <p>2021 Copyright for this paper by its authors.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Creating a dataset</title>
      <p>
        For the process of passing the norm control, a dataset has been developed that represents a set of
intentions of users – intents. Each intent includes examples of questions that users can ask, and the
chatbot's answers to the questions asked (Figure 1). The implementation of the dataset includes 18
intents, the chatbot's questions, and answers were compiled on the basis of regulatory documents of the
NNSTU n.a. R.E. Alekseev [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ][
        <xref ref-type="bibr" rid="ref3">3</xref>
        ][
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] for the implementation of the WRC. Each intent includes up to
20-30 questions.
      </p>
      <p>Experience in the field of natural language processing has shown that it is inconvenient and
inefficient to navigate a dataset and fill it out in a text editor. To increase the efficiency of work, a
special application was created – a text editor. Its graphical interface allows you to quickly navigate in
intents, requests and responses, that are already in the dataset (Figure 2).</p>
      <p>
        To create the application, PyQt5 was used – a set of Python libraries for creating graphical interfaces
based on the Qt5 platform [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The created dataset was used for training the model and the operation of
an algorithm based on the Levenshtein distance.
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Developing a machine learning model</title>
      <p>To determine the intentions of users, a machine learning model has been developed that classifies
user messages. Here, the class is the intent from the dataset. The stages of the classification algorithm
are shown in Figure 3.</p>
    </sec>
    <sec id="sec-4">
      <title>3.1 Text Preprocessing</title>
      <p>Text preprocessing is a mandatory step in solving the problem of natural language processing, which
allows increasing the accuracy of the classification of user intentions. It includes reducing words to
lowercase, lemmatization, removing noise (non-letter characters), correcting grammatical errors in user
queries.</p>
      <p>
        In order for the machine learning model to perceive the same words written using different registers
as the same user's intention, all words are reduced to lower case in the developed model. For
lemmatization, the pymorphy2 library was chosen, the use of which showed the best results for a small
amount of data at the input. As a result of lemmatization, word forms are reduced to a normal
(dictionary) form [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] for their subsequent analysis. Noise removal consists in removing non-letter
      </p>
    </sec>
    <sec id="sec-5">
      <title>3.2 Vectorization</title>
      <p>characters – numbers, punctuation marks, extra spaces, special characters, or, for example, html tags.
Removing noise and reducing words to lowercase are implemented using the string library. To correct
grammatical errors in user requests, the pyaspeller library is used, whose tools, in case of an incorrect
word (grammatical error), replace it with the closest correct form of the word.</p>
      <p>
        Vectorization is the process of converting text into a numeric vector. To create a chatbot, an analysis
of existing algorithms for creating vector representations of texts was performed, the following
vectorization algorithms were selected and investigated [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]: CountVectorizer, TfidfVectorizer,
HashingVectorizer. As a result of the research, the optimal values of the vectorizer parameters are
found, presented in Table 1.
      </p>
      <p>Parameters of vectorizers
the threshold for the frequency of ignoring terms
when building a dictionary is 0.85 (if the threshold is
exceeded, the terms are ignored)
- the threshold for the frequency of ignoring terms
when building a dictionary is 0.85;
- linear scaling</p>
      <sec id="sec-5-1">
        <title>HashingVectorizer to be extracted not</title>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>3.3 Classification</title>
    </sec>
    <sec id="sec-7">
      <title>3.4 The results obtained</title>
      <p>Based on the data obtained, it is concluded that the best options for the vectorizer and classifier will
be the CountVectorizer and the support vector method (Figure 4). The accuracy of the classification of
user requests by the model was 97%.</p>
      <sec id="sec-7-1">
        <title>Initial value 2</title>
      </sec>
      <sec id="sec-7-2">
        <title>Final value 10 Step 1</title>
        <p>2 10 1
- entropy (the more homogeneous the set,
the less entropy)
- error of the 1st kind (the frequency of a
randomly selected example of a training
sample will be classified incorrectly, gini)
they are selected automatically
methods are investigated: Lasso regression,</p>
      </sec>
      <sec id="sec-7-3">
        <title>Ridge regression, Elastic-net</title>
        <p>- balanced (inversely proportional to the
frequencies of classes in the input data),
- they are selected automatically
100
2,0</p>
        <p>Parameters
number of
"neighbors"
maximum tree depth
a function for
dividing data into
subclasses
a priori probabilities
of classes
regularization
method
class weights
maximum number of
training iterations
regularization
parameter
(selection of
significant features)
class weights
maximum number of
training iterations
- balanced (inversely proportional to the
frequencies of classes in the input data),
- they are selected automatically
100</p>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>4. An algorithm based on the Levenshtein distance</title>
      <p>
        To improve the accuracy of intent recognition and reduce the number of situations when the chatbot
will not be able to determine the user's intention and answer his question (in this case, a "stub" is
triggered), a modified Levenshtein algorithm was developed and applied [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], based on the calculation
of the "editorial distance" metric – the difference between two sequences of characters. The value of
the Levenshtein metric is determined by the minimum number of operations of replacing, inserting,
deleting one character when converting one string (word) to another. This algorithm is included in the
processing of intents if the machine learning model cannot classify the user's intention. In this case, the
user's message is compared with messages from the dataset and the Levenshtein distance is calculated.
The ratio distances of the Levenshtein to the length of the message from the dataset is taken as a
configurable parameter of the modified algorithm:
 
ℎ(
      </p>
      <p>(
  


)
 
)
&lt;0,2,
(1)
where distance is the Levenshtein distance; length is a function that calculates the number of characters
in a string.</p>
      <p>The threshold value is empirically determined to be 0.2. If the ratio value is less than the threshold,
then the user's intention coincides with the intention to which the example from the dataset is attributed.</p>
    </sec>
    <sec id="sec-9">
      <title>5. Creating a Telegram сhatbot</title>
      <p>
        To interact with users, the free cross-platform messenger Telegram was used [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], which allows
users to exchange text, voice messages, as well as media files of various formats. The
Pythontelegrambot library, created for the development of bots for Telegram, provides the ability to add
various functionalities for bots, for example, sending messages, files, processing commands (a line
starting with a slash character "/", including up to 32 characters of the Latin alphabet, numbers, and
underscores), etc. [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
      </p>
      <p>The developed machine learning model and an algorithm based on the Levenshtein distance were
integrated into a chatbot in Telegram. To start working with a chatbot, you need to type the name of the
bot — Normobot in the Telegram search. When you enter the start command, a welcome message
appears with an explanation of the chatbot's operation (Figure 5).</p>
      <p>At the request of the user, the bot can send the necessary regulatory documents. So, in Figure 6,
under the message from the bot with an explanation of what the norm control is, there are two buttons,
"Regulation on the verification procedure", "Regulation by type of activity". When the button is
clicked, the corresponding document will be sent to the user.</p>
      <p>For the convenience of the user when communicating with the chatbot, voice message recognition
has been added. The algorithm voices for processing messages includes, obtaining the id of a file with
a voice message; downloading this files with the OGG extension; converting it to a file with the WAV
extension; reading a file with a message, and converting it into a text form; transmitting a text message
to a machine learning model. Converting a file from the OGG extension to the WAV extension is
implemented using the pydub library. The audio recording is converted to text using the Speech
Recognition library.</p>
      <p>Figure 7 shows an example of a voice request. During the recording of the message, the question
was asked, "what to do after passing the norm control?".</p>
      <p>There are two buttons under the input line, "Checklist" and "Main errors". When you click on the
"Checklist" button, the user will receive a list of documents necessary for passing the norm control
procedure. After clicking the "Basic errors" button, the user will receive information about the mistakes
that students make most often when preparing documents for standard control.</p>
      <p>To work with the chatbot the administrator mode is implemented. After entering the password, the
user gets additional features, such as viewing the program logs, viewing statistics on requests to the
chatbot and sending messages on behalf of the chatbot (Figure 8). The added convenient function of
sending messages on behalf of the chatbot allows the teacher to give an extended answer to the
questions asked.</p>
      <p>The Logging library is used for logging, i.e. writing data about the program's operation to a file on
the disk, which is called a log or log. The logging data is displayed in the console and saved in a file
(Figure 9).</p>
      <p>Information about user requests is saved in a file with the CSV extension. This functionality was
implemented using the built-in CSV library. A screenshot of the file with user requests is shown in
Figure 10. The password required to enter the administrator mode is located in a separate file. This
allows you to change the password without reassembling the project.</p>
    </sec>
    <sec id="sec-10">
      <title>6. Conclusion</title>
      <p>As a result of the research, a chatbot with artificial intelligence has been developed to automate the
process of standard control of the WRC, which is able to send documents to the student for standard
control, give advice on the design of an explanatory note and other regulatory documents, check the
correctness of the design of documents, and enable teachers to give advice to students on behalf of the
bot. An extension of this project is the development of an algorithm for automatically filling out the
documents necessary for passing the standard control and automating the process of checking the WRC
for anti-plagiarism, as well as using it in other educational processes on the corresponding datasets.</p>
    </sec>
    <sec id="sec-11">
      <title>7. References</title>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>O. A.</given-names>
            <surname>Yudin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. A.</given-names>
            <surname>Yudin</surname>
          </string-name>
          ,
          <article-title>Writing a chatbot assistant for entering a higher educational institution. Modern science: Actual problems of theory and practice</article-title>
          ,
          <source>Series: natural and technical sciences 6</source>
          (
          <issue>2</issue>
          ) (
          <year>2019</year>
          )
          <fpage>117</fpage>
          -
          <lpage>122</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <source>[2] National standard GOST R 7.0</source>
          .
          <fpage>100</fpage>
          -
          <lpage>2018</lpage>
          .
          <article-title>Bibliographic record</article-title>
          . Bibliographic description.
          <article-title>General requirements and rules of compilation</article-title>
          . Moscow: Standartinform,
          <year>2018</year>
          . 128 p. URL: http://www.skunb.ru/data/upload/documents/files/ibo/GOST_new.pdfD0%
          <article-title>A2_%D0%A0_7_0_1 00_</article-title>
          <year>2018</year>
          _1204.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>NNSTU</surname>
            <given-names>LDPE</given-names>
          </string-name>
          <year>11</year>
          .2/
          <fpage>34</fpage>
          -
          <lpage>18</lpage>
          .
          <article-title>Position by type of activity. About the final qualifying work on educational programs of higher education of NNSTU-Nizhny Novgorod: NNSTU named after</article-title>
          R.E. Alekseev,
          <year>2018</year>
          , 38 p. URL: https://www.nntu.ru/frontend/web/ngtu/files/org_structura/ upravleniya/umu/docs/norm_docs_ngt u/pologenie_vipysk_rab_opop.pdf?
          <fpage>23</fpage>
          -
          <lpage>04</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>NNSTU-</surname>
          </string-name>
          LDPE-
          <volume>11</volume>
          .
          <fpage>3</fpage>
          -04-
          <lpage>17</lpage>
          .
          <article-title>Regulations on the procedure for checking final qualifying works for the amount of borrowing and their placement in the electronic library system of NNSTU-Nizhny Novgorod: NNSTU named after</article-title>
          R. E. Alekseev,
          <year>2017</year>
          , 12 p. URL: https://www.nntu.ru/frontend/web/ngtu/files/org_structura/upravleniya/umu/docs/norm_docs_ngt u/polog_o_poryadke_proverki_vkr.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <issue>PyQt5</issue>
          , Python Package Index,
          <year>2021</year>
          . URL: https://pypi.org/project/PyQt5.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>I.</given-names>
            <surname>Akhmetov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Krassovitsky</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Ualiyeva</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Mussabayev</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gelbukh</surname>
          </string-name>
          ,
          <article-title>Lemmatization of russian language by tree regression models</article-title>
          ,
          <source>Research in Computing Science</source>
          <volume>149</volume>
          (
          <issue>3</issue>
          ) (
          <year>2020</year>
          )
          <fpage>147</fpage>
          -
          <lpage>153</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <article-title>[7] 4 methods of text vectorization</article-title>
          ,
          <source>Python School</source>
          ,
          <year>2020</year>
          . URL: https://pythonschool.ru/nlpvectorization-methods/
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <article-title>[8] Overview of classification methods in machine Learning using Scikit-Learn,</article-title>
          <string-name>
            <surname>Tproger</surname>
          </string-name>
          ,
          <year>2019</year>
          . URL: https://tproger.ru/translations/scikit-learn-in-python/
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <article-title>[9] Metrics in machine learning tasks</article-title>
          ,
          <source>Habr</source>
          ,
          <year>2017</year>
          . URL: https://habr.com/ru/company/ods/ blog/328372/
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>J.</given-names>
            <surname>McConnell</surname>
          </string-name>
          .
          <article-title>Analysis of algorithms. Active learning approach: a textbook-</article-title>
          <source>Moscow: Technosphere</source>
          ,
          <year>2018</year>
          , 416 p.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <article-title>6 indisputable advantages of Telegram bots over mobile applications, sites and groups in social networks</article-title>
          ,
          <source>Hab</source>
          ,
          <year>2015</year>
          . URL: https://habr.com/ru/post/296388/
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <article-title>Library in Python python-telegram-bot</article-title>
          ,
          <source>DOCS Python3</source>
          ,
          <year>2021</year>
          . URL: https://docspython.ru/packages/biblioteka-python
          <article-title>-telegram-bot-python/.</article-title>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>