# DisBot: A Portuguese Disater Support Dynamic Knowledge Chatbot
## 4 DisBot Framework
### Natural Language Understanding  
The NLU component of DisBot aims to understand/identify two types of essential information: intents and entities. The first can be interpreted as understanding what the user wants, that is, what is the intention of his/her message, and can be as simple as classifying a \"Ola amigoi!/Hey Friend!\" as a greeting. The second one, however, aims to help the chatbot detail the user's intention, using custom entities, as some intents are dependent on additional information to be handled. A simple example would be \"Como posso falar com os bombeiros?/How can I speak with the fire brigade?\", which, for example, purposes can be interpreted as an ask_for_contact intent. Without identifying \"bombeiros/fire brigade\" as a type of organization the chatbot would never have been able to answer that question correctly, as it would have no means to understand whose contact the user needed.  
Our NLU component has been trained using more than 400 Portuguese hand-made annotated phrases that we have created, divided into 25 distinct intents. These phrases also include more than 100 distinct entity references for four distinct custom entities: time, location, organization, and disaster type. Our intents are divided into generic intents, chitchat intents, and request intents. Table 6 presents all of these intents, with some examples.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Featurizer** & **Type** & **Function** \\ \hline \multirow{3}{*}{Spacy Featurizer} & \multirow{3}{*}{Dense} & Entity extraction \\  & & Intent classification \\  & & Response classification \\ \cline{1-1}   Lexical Syntactic Featurizer & \multirow{3}{*}{Sparse} & Entity extraction \\ \cline{1-1}   scikit-learn Count Vectorizer (words) & & Intent classification \\ \cline{1-1}   scikit-learn Count Vectorizer (character n-grams) & & Response selection \\ \hline \hline \end{tabular}
\end{table}
Table 5: Used featurizers and related functions.  
These intents aim to provide citizens and first responders with a tool to be able to obtain critical, but generic, knowledge in disaster situations. The chitchat intents are necessary for giving the chatbot a tool to deal with user intents that are outside of its main scope, yielding a more fluid and natural conversation with its users, while also allowing for user engagement outside of disaster scenarios.  
Both intents and entities are being classified using the state-of-the-art architecture Dual Intent Entity Transformer (DIET) [28]. The DIET classifier was introduced in 2020 as a multi-task transformer architecture that handles both intent classification and entity recognition together. It provides the ability to use various pre-trained embeddings, achieving competitive results with other large-scale models that are very resource and time dependent. The DIET architecture is based on a Transformer [29]--a deep learning model that is designed to handle sequential data without the need to process it in order--shared for both tasks. A sequence of entity labels is predicted by a Conditional Random Field (CRF) [30] tagging layer, on top of the transformer output sequence corresponding to the input sequence of tokens. The intent labels the transformer outputs are then embedded into a single semantic vector space. Finally, a dot-product loss is then used to maximize the similarity with the target label and minimize similarities with negative samples.