Full text
i Document Clustering as an approach to template extraction André Miguel Fernandes Rodrigues Dissertation presented as partial requirement for obtaining the Master’s degree in Information Management
i NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa DOCUMENT CLUSTERING AS AN APPROACH TO TEMPLATE EXTRACTION by André Miguel Fernandes Rodrigues Dissertation presented as partial requirement for obtaining the Master’s degree in Information Management, Specialization in Knowledge Management and Business Intelligence Advisor: Professora Doutora Mariana Sá Correia Leite de Almeida Co Advisor: Ricardo Costa Dias Rei July 2021
ii ACKNOWLEDGEMENTS I want to express my gratefulness to my advisors Mariana Almeida and Ricardo Rei, to Cleverly for the opportunity, to my friends, and to my family. This project has received funding from the European Union’s Horizon 2020 research and innovation program under grant agreement No 873904.
iii ABSTRACT A great part of customer support is done via the exchange of emails. As the number of emails exchanged daily is constantly increasing, companies need to find approaches to ensure its efficiency. One common strategy is the usage of template emails as an answer. These answers templates are usually found by a human agent through the repetitive usage of the same answer. In this work, we use a clustering approach to find these answer templates. Several clustering algorithms are researched in this work, with a focus on the k-means methodology, as well as other clustering components such as similarity measures and pre-processing steps. As we are dealing with text data, several text representation methods are also compared. Due to the peculiarity of the provided data, we are able to design methodologies to ensure the feasibility of this task and develop strategies to extract the answer templates from the clustering results. KEYWORDS Document Clustering; Similarity Measures; Text Representation; Template; Natural Language Processing
iv INDEX 1. Introduction .................................................................................................................. 1 1.1. Motivation ............................................................................................................. 1 1.2. Goal and Contributions ......................................................................................... 1 2. Background ................................................................................................................... 3 2.1. Supervised Machine Learning ............................................................................... 3 2.1.1. Perceptron ...................................................................................................... 3 2.1.2. Multi-Layer Perceptron .................................................................................. 4 2.1.3. Transfomers .................................................................................................... 5 2.2. Unsupervised Machine Learning ........................................................................... 7 2.2.1. Partitioning Algorithms .................................................................................. 8 2.2.1.1. K-means ................................................................................................................... 8 2.2.1.2. K-medoids ................................................................................................................ 9 2.2.1.3. K-means++ ............................................................................................................... 9 2.2.1.4. Spherical K-means ................................................................................................... 9 2.2.2. Hierarchical Clustering ................................................................................. 10 2.2.3. Density-Based Clustering Algorithms ........................................................... 11 2.3. Cluster Evaluation ................................................................................................ 12 2.3.1. External Cluster Evaluation .......................................................................... 12 2.3.1.1. F-measure and Rand Index .................................................................................... 12 2.3.1.2. Entropy and Purity ................................................................................................. 14 2.3.1.3. V-measure ............................................................................................................. 14 2.3.2. Internal Quality Measures ............................................................................ 15 2.4. Text Representation ............................................................................................ 17 2.4.1. Sparse Models .............................................................................................. 17 2.4.2. Dense Models ............................................................................................... 18 2.4.3. BERT .............................................................................................................. 18 2.5. Similarity Measures and Text Comparison .......................................................... 20 2.5.1. Similarity Measures ...................................................................................... 20 2.5.2. Text distances ............................................................................................... 20 3. Related Work .............................................................................................................. 22 3.1. Clustering Methodology ...................................................................................... 22 3.2. BERT-Based models ............................................................................................. 23 3.3. Document Clustering ........................................................................................... 24
v 3.3.1. Spam Filter .................................................................................................... 24 3.3.2. Template Finder ........................................................................................... 25 4. Corpus and Data Analysis ........................................................................................... 26 4.1. Cleverly Corpus .................................................................................................... 26 4.2. Created Corpora .................................................................................................. 27 4.2.1. Silver Corpus ................................................................................................. 27 4.2.2. Annotated Pairs of Templates ...................................................................... 27 4.3. Evaluation Tasks .................................................................................................. 28 4.3.1. Tasks and Experiments ................................................................................. 28 4.3.1.1. Grouping Task ........................................................................................................ 29 4.3.1.2. Relationship between Metrics .............................................................................. 30 4.3.2. Text Pre-processing and Algorithm Evaluation ............................................ 31 4.3.2.1. Text Preprocessing ................................................................................................ 31 4.3.2.2. Clustering External Evaluation............................................................................... 32 5. Results and Discussion ................................................................................................ 34 5.1. Experimental Setup ............................................................................................. 34 5.1.1. Optimal K-means .......................................................................................... 35 5.1.2. Cosine Algorithm .......................................................................................... 35 5.2. Template Extraction ............................................................................................ 36 5.2.1. Partition Analysis .......................................................................................... 37 5.2.2. Candidates Quality and Template Extraction ............................................... 37 6. Conclusion .................................................................................................................. 39 7. Limitations and Future Work ...................................................................................... 40 8. Bibliography ................................................................................................................ 41
vi LIST OF FIGURES Figure 2.1: Representation of an MLP with two hidden layers. ................................................ 4 Figure 2.2: Graphical representation of an RNN. Taken from https://tinyurl.comm/4jkguspv 5 Figure 2.3: Graphical Representation of the Transformers model architecture. Taken from (Vaswani, et al., 2017). ....................................................................................................... 6 Figure 2.4: Graphical representation of hard clustering vs soft clustering. Taken from https://tinyurl.com/19vic4av ............................................................................................. 7 Figure 2.5: Example of K-means algorithm with k=3. Taken from https://tinyurl.com/3mxykbu9 .......................................................................................... 8 Figure 2.6: Example of a Dendrogram. Taken from https://tinyurl.com/cralh7qq ................. 10 Figure 2.7: BERT input representation. Taken from (Devlin, Chang, Lee, & Toutanova, 2018) .......................................................................................................................................... 19 Figure 3.1 - SBERT architecture at inference, taken from (Reimers & Gurevych, 2019) ......... 24 Figure 4.1: Distribution of human similarity score in auxiliary corpus .................................... 28
vii LIST OF TABLES Table 2.1: Decision Meaning .................................................................................................... 13 Table 4.1: Corpus Statistics ...................................................................................................... 26 Table 4.2: Annotation criteria .................................................................................................. 27 Table 4.3: Grouping Task Evaluation ........................................................................................ 29 Table 4.4: Correlation between metrics .................................................................................. 30 Table 4.5: Differences between Stemming and Lemmatization .............................................. 32 Table 4.6: Average ARI in different pre-processing combinations .......................................... 33 Table 4.7: Average V-measure in different pre-processing combinations .............................. 33 Table 5.1: Average Silhouette Score per Number of Clusters ................................................. 35 Table 5.2: Top 5 clusters with higher average silhouette score .............................................. 38
viii LIST OF ABBREVIATIONS AND ACRONYMS AI Artificial Inteligence Seq2Seq Sequence-to-Sequence RNN Recurrent Neural Networks DBSCAN Density-based spatial clustering of applications with noise ARI Adjusted Rand Index BoW Bag-of-Words TF-IDF Term Frequency-Inverse Document Frequency CBOW Continuous Bag-of-Words BERT Bidirectional Encoder Representations from Transformers KLD Kullback-Leibler Divergence SVM Support Vector Machines KNN K nearest neighbors
7 2.2. UNSUPERVISED MACHINE LEARNING Unsupervised Machine Learning algorithms differ from Supervised ones in that the target variables are not known. Therefore, this learning consists in discovering a structure or relationship between the different inputs. Although there are several methods of Unsupervised Machine Learning, the most known algorithms are related to Clustering which is the main focus of this work. Clustering is the task of separating data into groups of similar points. (Kaufman & Rousseew, 1990) state it as “the art of finding groups in data”. These resulting groups are called clusters. One goal when clustering is to make points belonging to a cluster similar between themselves (i.e., have a high intracluster similarity) and reduce the similarity between points from other clusters (i.e., have a low intercluster similarity). Similarity is a measure of the relationship between two points. Clustering algorithms can be divided in two main categories: hard clustering and soft clustering. The difference between them is that while in hard clustering each point belongs solely to one cluster, in soft clustering a point can be part of more than one cluster. Figure 2.4: Graphical representation of hard clustering vs soft clustering. Taken from https://tinyurl.com/19vic4av In this work, we will be focusing on hard clustering. As mentioned before in Section 1.2, the clustering results depend on the representation of each point, the similarity measure and the clustering algorithm used (Jain, Murty, & Flynn, 1999). It is worthy to note that while literature offers a large portfolio of clustering algorithms, there is no universal methodology that applies perfectly to every case and dataset. Three types of clustering algorithms can be distinguished, which will be discussed and given examples in this chapter: - Partitioning Algorithms - Hierarchical Algorithms - Density-based Algorithms While each category aims to have a clustering result that satisfies the similarity constraint, they all do it differently. The partition algorithm creates a flat partition of a specified number of clusters based on
8 a similarity measure. Hierarchical algorithms aim to create a hierarchical tree of clusters (dendrogram). And density-based algorithms as the name suggests, finds clusters by using the dense region of data points and utilizes the low-density regions as boundaries between clusters. 2.2.1. Partitioning Algorithms Partition clustering algorithms aim to optimize a certain criterion function to separate (or partition) the data objects into a number of k clusters, based on a similarity measure. A common disadvantage of these types of algorithms is that, depending on the initialization, they can reach different solutions. 2.2.1.1. K-means Perhaps the most well-known clustering algorithm, K-means was first used by Macqueen (1967). Its popularity is due to its simplicity and ability to be used for any type of problems. The idea behind kmeans is that a cluster can be represented by a central point. This algorithm uses the concept of centroid which is the mean point of the elements of a cluster. The k-means algorithm begins by setting k initial random centroids. Afterwards, each point is assigned to its closer centroid, based on a similarity measure usually being the squared Euclidean distance. The centroids are then recalculated by averaging all the points in each cluster, and the iteration begins anew. This algorithm keeps running until convergence is obtained which is when no reassignment of the centroid occurs or when the maximum number of iterations has occurred. Figure 2.5: Example of K-means algorithm with k=3. Taken from https://tinyurl.com/3mxykbu9 The two main disadvantages of k-means are as follows: 1) the need to indicate the k number of clusters before the clustering (which may bring bad clustering accuracy). Outliers can also greatly disturb the computation of the centroid. 2) the fact that the initial cluster centroids may be a bad choice which in turn can get the centroid to be trapped in a local minimum. To mitigate these disadvantages, there are some methods that can be applied, which will be discussed in this work.
9 2.2.1.2. K-medoids K-medoids is a variation of k-means that instead of using the mean (centroid) uses the median (medoid). To note that in k-means the centroid rarely corresponds to an actual data element while the medoid in k-medoids must be an element of the data (for example a document in document clustering) which makes the interpretation easier. This feature of k-medoids might be great in this project as we want to extract from each cluster a real document that represents it. The k-medoids algorithm is also less sensitive to outliers and noise. 2.2.1.3. K-means++ K-means++ algorithm is a variant of k-means proposed by (Arthur & Vassilvitskii, 2007). This variation seeks to lessen its original’s disadvantage of possible bad initialization by altering its initial conditions. Let 𝑑(𝑥) represent the minimal distance from data point 𝑥 to a cluster center already chosen. The algorithm for center initialization is as follows: 1. Randomly choose one of the data points as a cluster center 𝑐1. 2. For each data point 𝑥, determine 𝑑(𝑥). 3. Choose the next cluster center 𝑐𝑖, based on the 𝑥 with highest probability 𝑑(𝑥)2 ∑𝑑(𝑥)2 𝑥𝜖𝑋 4. Repeat steps 2 and 3 until k centers have been selected. 5. Proceed with the standard k-means algorithm. The K-means++ is as such designed to enhance the cluster center initialization for k-means. 2.2.1.4. Spherical K-means In an effort to exploit the sparsity of text data (the type of data we will explore in this work) and drawing insights of its distribution in high-dimension spaces, (Dhillon & Modha, 2001) propose a variant of the well-known “Euclidean” k-means by using cosine similarity as its similarity measure. Firstly, this algorithm has the assumption that the document vectors have been normalized to have unit 𝐿2 norm (for each data point 𝑧, ‖𝑧‖=1) which in turn means they can be represented as points on a high-dimension unit sphere (hence the name spherical k-means). As such, documents with different lengths but with equivalent subjects will be regarded as similar vector-wise. The cosine similarity can be derived from the Euclidean dot product formula and is represented as such: 𝑠𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦=cos(𝜃)= 𝐴∗𝐵 ||𝐴|| ||𝐵||= ∑𝐴𝑖𝐵𝑖 𝑛𝑖=1 √∑𝐴𝑖2 𝑛𝑖=1 √∑𝐵𝑖2 𝑛𝑖=1 However, if the element (for example documents) vectors are normalized, the cosine similarity can be represented simply as the dot product between the vectors.
10 The spherical k-means algorithm follows the same pattern as regular k-means with small differences: 1. Randomly select k document vectors as the concept vectors (which in regular k-means would be named centroid) 2. For each document vector 𝑥𝑖, compute the closest concept vector in cosine similarity and assign 𝑥𝑖 to its cluster. 3. Compute the new concept vectors as the normalized mean in each cluster. 4. Repeat steps 2 and 3 until some stopping criteria is achieved. 2.2.2. Hierarchical Clustering Distinctly from partition clustering methods, hierarchical clustering seeks to build a tree of cluster usually represented by a dendrogram. These methods can be further categorized as agglomerative or divisive depending on how the clustering tree is built. While the agglomerative approach begins with each point being an individual cluster and is progressively joined with its next most similar cluster in a bottom-up fashion until all points are in one cluster, the divisive approach begins with all the points together in one cluster and iteratively splits them until single points, in a top-down flow. Figure 2.6: Example of a Dendrogram. Taken from https://tinyurl.com/cralh7qq One main advantage over previous clustering algorithms is the fact that there is no need to specify the number of clusters. In contrast, these types of algorithms can have bad outputs if wrong merges or splits are made as those steps are irreversible.
11 Agglomerative hierarchical clustering algorithms are usually as follows: 1. Take each point as a single cluster. 2. Compute the similarity between each of the cluster to find the closest (most similar) pair. 3. Merge the similar cluster to create a new cluster. 4. Repeat steps 2) and 3) until there is only one cluster. The most important step in this kind of algorithm is made between step 1 and 2 which is to choose how to calculate the similarity between two clusters. There are many ways to calculate this similarity between them such as: min, where the similarity between two clusters is the minimum distance between two points from different clusters; max, where the similarity is given by the maximum distance between two points in different clusters; or average, where the similarity is the calculated average of all the distances between all points from the first cluster with all the others from the second one. Divisive hierarchical clustering works as the opposite of Agglomerative algorithms, where it begins with one cluster and keeps on splitting until clusters are single data points. Bisecting k-means is an example of divisive hierarchical clustering. As the name entails, it is a variant of K-means. This method’s main idea is to keep applying the k-means algorithm to each partition. The algorithm is as follows: 1. All documents are placed into one Cluster. 2. Pick a cluster to split. 3. Apply K-means with k=2. (Bisecting step) 4. Repeat steps 2 and 3 until the desired number of cluster k is achieved. In step 2, there are several approaches to choose which cluster to split, it could be the one with the least overall similarity, the largest cluster, or a mixture of both criteria. According to (Steinbach, Karypis, & Kumvar, 2000) there are not significant differences in results between the criterions. They also conclude that the bisecting K-means technique is better than the standard K-means approach and is as good or better than the usual hierarchical algorithms. 2.2.3. Density-Based Clustering Algorithms Density-based clustering algorithms instead of using proximity to group objects, are based on the notion of density. The core concept is to keep merging points with a cluster as long as the density remains high. Density Based Spatial Clustering of Application with Noise or DBSCAN is the most well-known algorithm of this type. Like Hierarchical Clustering, it does not need the number of clusters as an input parameter. It has however two user defined parameters: the epsilon (ε) and the minimum number of sample M. Regarding ε, two points are considered neighbors if the distance between them is smaller than epsilon. M is the minimum number of neighbors a certain point must have to be categorized as a core point. There are three classifications for points: core, border, and outlier.
12 A core point has at least m points in its neighborhood (including itself). A border point does not have at least m points in its neighborhood but is the vicinity of a core point. Finally, an outlier or noise point is a point that does not belong to the neighborhood of a core point. The standard DBSCAN algorithm starts with no pre-selected clusters and can be seen as: 1. Pick a random point that has not been assigned to a cluster and is not assigned as an outlier. Analyze the neighborhood according to M. If the point is a core point, it is a new cluster. If it is not, assign as an outlier and pick another point. 2. Add the neighborhood points of the core point to the cluster. Check the neighborhood points for core points and add its neighborhood to the cluster. Repeat until no more new points are added to the cluster. Previously assigned outliers may be now assigned as border points. 3. Repeat step 1 and 2 until every point has been visited and they are either part of a cluster or an outlier. As the name states, this algorithm is resistant to noise and can handle outliers. However, it is does not handle high dimensional data too well, which is a problem in document clustering. 2.3. CLUSTER EVALUATION We have presented different algorithms and methods to be used in data clustering. However, as it is an unsupervised learning task, in real problems there are usually no a priori information about the dataset. This makes the validation of the clustering results a challenging phase when applying a clustering algorithm and often regarded as important as the clustering itself (Hassani & Seidl, 2017). One type of information not usually known is the number of clusters. Algorithms like K-means (section 2.2.1.1.) depend on such parameter and the search for the optimal k is a highly non-trivial task. Hence, many cluster validity methods have been introduced in literature to solve these problems and to evaluate the partitions of the data to represent its original structure. Two main types of evaluation measures can be distinguished: external evaluation and internal evaluation. Along this subchapter we will be going through each of them, give some examples and state their advantages and disadvantages. 2.3.1. External Cluster Evaluation External Validation Measures are based on previous knowledge about data. This usually means to compare the results of a clustering algorithm to a provided labeled partition of the data. Its intent is to measure how similar the cluster labels match a set of predefined classes deemed as the true clusters (commonly referred to as the gold standard). 2.3.1.1. F-measure and Rand Index Evaluation measures used to usually evaluate classification methods can be applied to pattern recognition when the ground truth is known. The most common measures are Recall, Precision and its harmonic mean, F1-measure. These evaluation measures usually use the concepts of True Positive
13 (TP), True Negative (TN), False Positive (FP) and False Negative (FN) in its calculation and are calculated over pairs of points. Given two documents, they are considered as a TP decision if they are similar and were assigned to the same cluster. If the documents are not similar and were assigned to different clusters, they are considered a TN decision. On the other hand, if two not similar documents are assigned to the same cluster, it is a FP decision. Finally, a FN decision is when two similar documents are assigned to different clusters. By knowing the ground truth, we can ascertain if two documents are similar if they belong to the same class (or label). Table 2.1 illustrates these concepts. Table 2.1: Decision Meaning Assigned Same Cluster Assigned different clusters Belong same class TP FN Belong different classes FP TN As we will be using these concepts in a clustering problem, the Precision and Recall can be written as the following: 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛(𝑖,𝑗)= 𝑇𝑃 𝑇𝑃+𝐹𝑃=𝑛𝑖𝑗 𝑛𝑖 𝑅𝑒𝑐𝑎𝑙𝑙(𝑖,𝑗)=𝑇𝑃 𝑇𝑃+𝐹𝑁= 𝑛𝑖𝑗 𝑛𝑗 Where 𝑛𝑖𝑗 is the number of elements of label 𝑖 that are in cluster 𝑗; 𝑛𝑖 is the number of elements in label 𝑖 and 𝑛𝑗 is the number of objects in cluster 𝑗. As the F-Measure is the harmonic mean of the previous concepts, it is given by the following equation: 𝐹(𝑖,𝑗)= 2 ∗ 𝑅𝑒𝑐𝑎𝑙𝑙(𝑖,𝑗)∗𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛(𝑖,𝑗) 𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛(𝑖,𝑗)+𝑅𝑒𝑐𝑎𝑙𝑙(𝑖,𝑗) Label 𝑖 has the F-measure equivalent to the maximum value at any cluster. The overall F-measure of the clustering is given by the weighted average of all the labels’ F-measure: 𝐹= ∑𝑛𝑖 𝑛max𝐹(𝑖,𝑗) 𝑖 One of the first clustering validation measures was the Rand Index, also known as accuracy. Presented by (Rand, 1971),it is calculated as the proportion of accurate assignments over all assignments. Using the previous notions, it is defined as: 𝑅𝐼= 𝑇𝑃+𝑇𝑁 𝑇𝑃+𝐹𝑃+𝐹𝑁+𝑇𝑁
14 An improvement on this index was developed named Adjusted Rand Index (ARI). One of its advantages over its predecessor is its ability to compare partitions of the data with different number of clusters. Using the previous notions, it can be defined as (Santos & Embrechts, 2009): 𝐴𝑅𝐼=(𝑛2) (𝑇𝑃+𝑇𝑁)−[(𝑇𝑃+𝐹𝑃)(𝑇𝑃+𝐹𝑁)(𝐹𝑁+𝑇𝑁)(𝐹𝑃+𝑇𝑁)] (𝑛2)2−[(𝑇𝑃+𝐹𝑃)(𝑇𝑃+𝐹𝑁)+(𝐹𝑁+𝑇𝑁)(𝐹𝑃+𝑇𝑁)] Greater values in these measures suggest higher quality of the clustering result. 2.3.1.2. Entropy and Purity Entropy measures how spread a distribution is. If all clusters have only objects of a single label, the calculated entropy will be 0. As the variety of labels per cluster increases the worse the clustering is and the higher the entropy. Using the previous notation, the probability of a member of cluster j belonging to the label I is 𝑝𝑖𝑗=𝑛𝑖𝑗 𝑛𝑗. The entropy of each cluster j is calculated as: 𝐸𝑖= ∑𝑝𝑖𝑗∗ log𝑝𝑖𝑗 𝐿𝑖=1 Where L is the number of labels. The entropy of the cluster results is given as the weighted average of each cluster by the size of each cluster. 𝐸𝑛𝑡𝑟𝑜𝑝𝑦= ∑𝑑𝑗 𝑑∗𝐸𝑗 𝑘 𝑖=1 Where k is the number of clusters, d the number of elements in the dataset used for clustering and 𝑑𝑗 the size of the cluster j. Purity measures how greatly clusters contain elements of a single label. The purity of a cluster is given by the highest probability 𝑝𝑖𝑗 in the given cluster j. Using previous terminology, it is represented as 𝑝𝑢𝑟𝑖𝑡𝑦𝑗=max𝑝𝑖𝑗. Similarly to the overall entropy, the overall purity of the clustering is given as: 𝑃𝑢𝑟𝑖𝑡𝑦= ∑𝑑𝑗 𝑑∗𝑝𝑢𝑟𝑖𝑡𝑦𝑗 𝑘 𝑖=1 2.3.1.3. V-measure Based on entropy, (Rosenberg & Hirschberg, 2007) presented V-measure which is an external cluster evaluation measure centered around the ideas of homogeneity and completeness. The homogeneity criteria’s basis is that clustering must assign only datapoints that belong to a single label belong to a single cluster. Assuming there are 𝑁 data samples, 𝐶 different classes, 𝐾 different clusters and 𝑛𝑐𝑘 represents the number of elements that belong to class 𝑐 and cluster 𝑘, the homogeneity can be defined as: ℎ=1 − 𝐻(𝐶,𝐾) 𝐻(𝐶)
15 Where: 𝐻(𝐶,𝐾)= −∑ ∑ 𝑛𝑐𝑘 𝑁log ( 𝑛𝑐𝑘 ∑𝑛𝑐𝑘 𝐶𝑐=1 ) 𝐶𝑐=1 𝐾 𝑘=1 And: 𝐻(𝐶)= −∑ ∑𝑛𝑐𝑘 𝐾 𝑘=1 𝐶log (∑𝑛𝑐𝑘 𝐾 𝑘=1 𝐶) 𝐶𝑐=1 While both previous Purity and Entropy measures represent evaluations of homogeneity of clustering results, they do not address the completeness concept. According to (Rosenberg & Hirschberg, 2007), all elements that belong to a single class must be assigned to a single cluster so that completeness is achieved. Considering previous notations, completeness can be seen as: 𝑐=1 − 𝐻(𝐾,𝐶) 𝐻(𝐾) Where: 𝐻(𝐾,𝐶)= −∑ ∑ 𝑛𝑐𝑘 𝑁log ( 𝑛𝑐𝑘 ∑𝑛𝑐𝑘 𝐾 𝑘=1 ) 𝐾 𝑘=1 𝐶𝑐=1 And: 𝐻(𝐾)= −∑ ∑𝑛𝑐𝑘 𝐶𝑐=1 𝐶log (∑𝑛𝑐𝑘 𝐶𝐶=1 𝐶) 𝐾 𝑘=1 The V-measure is the computed weighted harmonic mean of these two concepts and can be given as such: 𝑉= (1+𝛽)∗ℎ∗𝑐 (𝛽∗ℎ)+𝑐 Where β can be given different values to attribute different weights in the calculations. 2.3.2. Internal Quality Measures As opposed to external quality measures, internal quality measures aim to assess how good a clustering result is using only features and intrinsic information from the data set (Hassani & Seidl, 2017), meaning without respect to external “gold” information regarding the correct clusters. These measures try to quantify previously shown cluster properties: cluster cohesion, meaning how similar are two objects in a cluster; and cluster separation, meaning how dissimilar are clusters from one another. A commonly used measure is the Sum of Squared Error (SSE). It can be used to measure cohesion by comparing each element of a cluster to its centroid. With a similar concept, the separation of a cluster can be measured by comparing each centroid to the centroid of the dataset which we will call Between cluster sum of squares (BSS). They can be defined as follows:
16 𝑆𝑆𝐸= ∑∑(𝑥− 𝑚𝑖)2 𝑥𝜖𝐶𝑖 𝑖 𝐵𝑆𝑆= ∑|𝐶𝑖|(𝑚−𝑚𝑖)2 𝑖 Where 𝐶𝑖 represents cluster 𝑖 with |𝐶𝑖| being its size; 𝑚𝑖representing the centroid of cluster 𝑖, and 𝑚 the centroid of the whole dataset. One measure that combines both cohesion and separation ideas is the Silhouette Coefficient. It is a sample-based coefficient and is defined as: 𝑠(𝑖)= 𝑏(𝑖)−𝑎(𝑖) max (𝑎,𝑏) Where 𝑎(𝑖) is the average distance between sample 𝑖 and all other points in the same cluster, and 𝑏(𝑖) is the minimum average distance between sample 𝑖 and points belonging to another cluster. The coefficient result ranges from -1 to 1 and we can infer the following: if 𝑠(𝑖) is close to 0 the sample is between two clusters. If close to -1 then the sample should be assigned to other clusters while if close to 1, then the sample likely belongs to the correct cluster. This coefficient can be further applied by computing the average for each cluster or for all the dataset, which can give some general insights when analyzing the clustering results. Another measure that also considers both cohesion and separation properties is the Davies-Bouldin Index (DBI). Presented by (Davies & Bouldin, 1979) it aimed to “infer the appropriateness of data partitions” while “not depend(ant) on either the number of clusters analyzed nor the method of partitioning”. This index uses the concept of cluster similarity between two clusters 𝑖 and 𝑗 defined as follows: 𝑅𝑖𝑗= 𝑠𝑖+ 𝑠𝑗 𝑑𝑖𝑗 Where 𝑠𝑖 is the average distance between the cluster’s centroid and each point belonging to it - also known as the cluster diameter; and 𝑑𝑖𝑗 is the distance between the centroids of cluster 𝑖 and 𝑗. The DBI then takes the maximum cluster similarity for each cluster and averages it: 𝐷𝐵𝐼= 1𝑘 ∑max 𝑖≠𝑗 𝑅𝑖𝑗 𝑘 𝑖=1 As it takes the highest similarity of each cluster, the smaller the index, the more distinct the clusters are from each other, therefore the better the partition is.
23 Each clustering technique is then applied to the dataset and evaluated in efficiency rate and its calculated mean silhouette index. When using only the significant words, the k-medoids algorithm has the best efficiency rate while k-means has the best silhouette index. By adding the general words to the representation of the documents and evaluating the results, the hierarchical clustering has better results in both evaluation measures. The author concludes that while the k-means methods show the most significant silhouette index, it is sensitive to general words and as such, the hierarchical clustering method is deemed to be the better text clustering method as it achieves great results while not being sensitive to the addition of general words. The purpose of (Balabantaray, Sarma, & Jha, 2015) was to compare the k-medoids and k-means clustering algorithms. 100 documents equally distributed between 5 domains were pre-processed. Tokenization, stop-words removal and TF-IDF transformations were applied to the data. The k-means and k-medoids algorithm were then applied and evaluated with an efficiency rate. It was observed that the k-means algorithm yields better result than the k-medoids. 3.2. BERT-BASED MODELS After the release of BERT, various BERT-based models have emerged. One of them is Sentence-BERT (Reimers & Gurevych, 2019). Sentence-BERT or SBERT is a modification of the BERT network that uses Siamese structure and triplet networks to derive semantically meaningful sentence embeddings (meaning that semantically similar sentences are closer in vector space). This enabled BERT to be used in tasks which were not applicable for BERT such as clustering and large-scale semantic similarity comparison. In previous chapters, we stated that in document clustering, a common method is to map each sentence to a vector space. The clustering algorithm would then group close vectors as semantically similar sentences. Using regular BERT, a way to get this vector space embeddings is to input individual sentences into BERT and use the output layer as embeddings. In an effort to further increase the quality of these embeddings, SBERT was developed. The architecture of SBERT is as follows. Firstly, SBERT adds a pooling layer to the output of BERT to create a fixed size sentence embedding. Several strategies such as using the output of the [CLS] token and the mean all output vectors were experimented. Secondly, to fine-tune BERT, SBERT uses a Siamese neural network that uses the same weights while working in parallel on two different input vectors so that the produced embeddings can be compared. This network objective function depends on the available training data. In the paper, they present three different objective functions: the classification objective Function, where the two sentence embeddings are concatenated and multiplied by a trainable weight and the cross-entropy is then optimized; the regression objective function, where the cosine similarity of the two sentence embeddings is computed and the meansquared-error loss is optimized; and the triplet objective function, where given the sentence a, a sentence p and a sentence n with positive and negative intent regarding a, the triplet function tunes the network so that the distance between a and n is greater than a and p. SBERT is trained on the combination of the SNLI and the Multi-Genre NLI dataset. Together they add up to one million sentence pairs annotated with the following labels: contradiction, entailment and neutral. This SBERT version is fine-tuned with the Classification Objective Function. Throughout the paper, SBERT is evaluated in different tasks against other models specifically such as Universal Sentence Encoder and BERT itself. SBERT is able to achieve improvements over other state-
24 of-art sentence embeddings methods in tasks such as Semantic Textual Similarity (STS). In these STS tasks, the dataset provides a label between 0 and 5 on the semantic relatedness of sentence pairs. When checking the correlation between the cosine similarity of sentence representations and the gold labels of various STS the improvement is quite significant regarding other models. Apart from SBERT using BERT as the base of the model, the authors also use RoBERTa (Liu, et al., 2019) as the base transformer encoder, creating the SRoBERTa model. According to them, using RoBERTa instead of BERT did not yield a significant improvement in the experiments. Another great advantage stated by the authors is the fact that SBERT is computationally efficient, being able to compute sentence embeddings faster than other methods which will be relevant in this work. Figure 3.1 - SBERT architecture at inference, taken from (Reimers & Gurevych, 2019) 3.3. DOCUMENT CLUSTERING The following works have clustering as a major component in their methodology. They present different strategies where document clustering is relevant and served as inspiration to the present work. 3.3.1. Spam Filter Emails have become a target of spam attacks due to its popularity and necessity. As such, a need to develop more complex spam filtering methods to counter these attacks has started to grow. The following works applied different algorithms in different ways. Document clustering has been also applied to detect spam emails. That is the case of (Sasaki & Shinnou, 2005), that uses the Ling-Spam corpus with 481 spam messages out of 2893 emails. After representing the document in a vector space, the email set is divided into k groups by the spherical k-means algorithm. Then, for each created cluster, a label is assigned. If the ratio of spam email to all email in the cluster is higher than 70%, the cluster is considered spam. Centroid vectors for each cluster are calculated and used as the cluster representation. New emails are then compared to each centroid via cosine similarity. The new email gains the same label as its most relevant cluster.
25 The authors also evaluate the impact of pre-processing techniques such as lemmatization and stop words removal, as well as the representation of the documents via Term Frequency or TF-IDF is experimented. Classification methods such as Support Vector Machines (SVM) are also used for comparison. All these experiments are evaluated via the precision of spam and non-spam assignment. While SVM results are higher, the various experiments using this clustering method achieve approximately similar results as most variations of the experiment achieve near 100% precision for both spam and non-spam. The authors conclude that is it as effective method for detecting spam. 3.3.2. Template Finder In (Mota, Martins, & Coheur, 2013) the aim is to build an Answer Template Retrieval System. This system retrieves a reply from a corpus of email/reply pairs to be used by a human agent as the core to the response of a new email. As the available corpus did not have annotations, such as labeling of the email/reply pairs, the system must be able to perform another task apart from the answer retrieval. This task is the identification of similar answers to be used as templates. To perform such task, a cluster-based methodology was considered. The idea consists of identifying similar answers using a modified version of Jaccard Distance created for this problem named Edit Percentage. This measure dictates how much of a given email must be edited to be transformed into another one. The authors consider two emails to be in the same cluster if the edit Percentage is at most 10%. Given emails A and B which have an edit percentage lower than 10% to email B, the authors considered A and B to be in the same cluster even if their edit percentage is higher than 10%. Clusters with only one element were removed. From the 12k email/reply pairs, 1150 clusters were found. The authors then defined the retrieval task as a classification problem and as such tested several algorithms (Logistic Regression, k nearest neighbors (KNN), and others) with a 5-fold cross validation. Due to the good results and efficiency of KNN, further experimentation was done with such algorithm. Using the precision@10 metric (the right cluster must be in a list of 10 possibilities), the best result was 62%.
26 4. CORPUS AND DATA ANALYSIS In this chapter we will present the corpus, have an in-depth analysis, and explain all the processing stages applied to it. Due to the nature of the dataset, some auxiliary corpora are created and used in some validation tasks. 4.1. CLEVERLY CORPUS The main goal of the thesis is to study unsupervised machine learning methods to discover new email templates. For that purpose, we used a proprietary corpus of costumer support that was provided by Cleverly after being anonymized. The corpus comprises information regarding emails as well as a set of existing templates of frequent replies. The variables are as follows: Title, Text_Question and Text_Answer which represent the title of the email, the content of the sent email and the content of the response email, respectively. The Template_Number variable which indicates which template has been used in this answer and is a null value if no template was assigned. The Template_Title variable represents the title of the template and can be seen as a small summary of the text. Template_Text is the core text of the template and used as basis in the Text_Answer response. In 1.1 we mentioned that one of the strategies to enhance customer support would be the usage of templates, we also stated some companies may already be using templates and this is one of those cases. When analyzing the data, some inconsistencies and problems were found, therefore the following transformations and filtering were done: some emails were either blank or had non impactful text (emails comprised of only a link or a word or were incomplete) and so emails with less than 20 words were removed; when looking at the Template_Number variable, some emails had more than one template assigned to it. This could have different meanings, like the templates used were different versions of the same answer or the answer was built out of more than one template. As we want to find new templates, entries that had more than one template assigned to it were removed. The inconsistency where Template variable being True while having no assigned Template_Number was also addressed. This leaves us with a dataset of 54723 emails. Nº of Emails Nº of Answers without Template Nº of Answers with Template Nº of Different Templates 54723 29937 24786 721 Table 4.1: Corpus Statistics As represented in Table 4.1, around half of the dataset has an assigned template. This does not necessarily mean no templates were used on emails without an assigned template. They could just not have been documented. However, we know for certain that emails with an assigned template were written with it as its basis.
27 4.2. CREATED CORPORA There exist several methods to evaluate clustering results (section 2.3). While some methods depend on the intra and inter distance between clusters, others depend on the ground truth. In the present work, we believe that we cannot take the emails with assigned templates as a perfect ground truth. Nevertheless, we can however use a subgroup of emails to use metrics that rely on ground truth. There is also the need to evaluate the presented similarity measures in the given problem and understand if they achieve conclusions similar to the human agent. As such, we created two new corpora. 4.2.1. Silver Corpus This development corpus is comprised only by the emails that have an assigned template. This new dataset was dubbed Silver Dataset (allusion to gold standard) and consists of the 24786 emails with 721 different templates. This corpus will be used mainly to validate results. 4.2.2. Annotated Pairs of Templates Templates are created from the constant usage of similar emails. They could be found through luck and repetition or through the usage of similarity metrics to connect similar emails. To be able to evaluate the veracity of this metrics and complement this work, we created a dataset based on our notion of similarity. Due to the great number of emails in the dataset, if a human agent decided to compare every pair of emails, besides unfeasible, most of these paired emails would be extremely different from one another. By using templates, the number of possible comparisons is greatly reduced and as such a more notable range of differences is allowed. Therefore, the basis of this new corpus is the list of templates. Since we have 721 templates, there are 259560 possible pair combinations. We selected 146 random comparisons (i.e., 146 different pairs of templates) and gave them a score for how similar its texts are to each other. This score goes from 0 to 4 and its criteria is as follows: 0 Completely different Templates 1 Not very Similar Templates 2 Related Templates 3 Very related Templates but differ in a small detail 4 Equal Templates Table 4.2: Annotation criteria
28 As this corpus was created by one person, these annotations cannot be seen as the truth and/or perfect. However, they can be used to evaluate the quality of similarity measures. The score distribution can be seen in figure 4.1. Templates are mostly different from one another as they tend to respond to different subjects. This can be seen in the distribution as most of the pairs were not related at all. On the other hand, the level 4 of similarity was granted to 14% of the pairs, meaning that in the opinion of the evaluation agent, some templates are essentially the same and could be merged into one. Figure 4.1: Distribution of human similarity score in auxiliary corpus 4.3. EVALUATION TASKS In the present work, we know there at least 721 clusters, which are represented by the known templates. We have however no knowledge of how many templates are in the remaining emails. If the number of templates is directly proportional to the number of emails, and since about half of our dataset has a template, we could be looking at doubling our number of known templates. On the other hand, this number could be small, and most of the unlabeled emails belong to an already known template. This issue is especially relevant to algorithms like k-means where we need to input the number of clusters to find. To further increase our familiarity with the presented measures and algorithms we perform different experiments on the data to gain insights for the problem at hand. As such, we will create tasks with the goal of finding the most appropriate combination of metrics and methods to use in our final approach. 4.3.1. Tasks and Experiments Throughout chapters 2 and 3 we presented different ways of representing and comparing text. We chose four of them to compare and analyze. The first one is TF-IDF due to its simplicity and popularity in other works. In section 2.4, contextualized word embeddings were presented, and great importance was given to the BERT model. In section 3.2, a faster, more efficient model than BERT in some similarity tasks was presented. According to (Reimers & Gurevych, 2019), this SBERT model can create sentence 0 20 40 60 80 100 120 0 1 2 3 4 Distribution of human similarity score
29 embeddings which are comparable with cosine similarity. Most works covered in section 3 use cosine similarity as the similarity measure. We decided to use cosine similarity for comparing both TF-IDF and SBERT text representations. Finally, we chose two other text comparison techniques, Edit distance and Jaccard distance to evaluate its effectiveness in the given problem. For the sake of clarity, when referring to TF-IDF and SBERT metrics, we are referring to the usage of cosine similarity jointly with the TF-IDF and SBERT representations. 4.3.1.1. Grouping Task The Silver corpus was created from the provided Email Corpus as an effort to have a representation closer to reality. While not a perfect representation, it is as close as possible to the ground truth. To better understand if this corpus can be used as an accurate representation of reality, we created the following algorithm on the basis that a given email has greater similarity to emails belonging to the same template than to emails belonging to different templates. The algorithm is as follows: - Step 1: Choose a group of emails represented by a unique template which has not been analyzed yet. - Step 2: Pick a random element e in that group that has not been chosen. - Step 3: Pick another random element a in that group, and a random element b outside the group. - Step 4: Use the similarity measure to compare the element chosen in step 2 with the elements chosen in step 3. - Step 5: According to the chosen measure, if e and a and more similar (higher value) than e and b, add 1 to the count of correct grouping. - Step 6: Repeat steps 3-5 until all elements of the chosen group have been considered. - Step 7: Repeat steps 1-6 until all groups have been analyzed. - Step 8: Compute the score of correct grouping by dividing the count of correct grouping by the number of possible groupings. With this algorithm, we can evaluate how well the four chosen metrics and representations accurately compare text in the given problem. By obtaining a high result in this experiment, we can assume the Silver data is correctly built and the metrics used can be used when clustering. To further analyze the viability of this Silver Data, we computed the Average Similarity between all groups as well as lowest and highest similarity in the given metric. This may provide further understanding of which metric to use. Metric Grouping Task Average Sim TFIDF 0.9952 0.228 SBERT 0.995 0.651 Edit Distance 0.98 0.264 Jaccard Distance 1 0.652 Table 4.3: Grouping Task Evaluation
30 Table 4.3 represents the above-mentioned experiments. The grouping task presents fantastic results to all different metrics, with the Jaccard Distance stating that the grouping is perfect. Although the other results do not have an objectively better metric, the TF-IDF and Edit Distance metrics may be used more intuitively by humans as they have bigger interval of similarity. We conclude that the Silver Data has great viability and will be used in experiments to test the effectiveness of other components of the Clustering process. 4.3.1.2. Relationship between Metrics We have ascertained that the Silver data is a good representation of the ground truth, and the metrics can be used to compare emails. In the next experiment we want to test if the similarity seen by the metrics is close to that of a human agent. Meaning that the relationship and comparison of text with the given metrics should have similar results to those of a human agent. The corpus created in section 4.2.2 should help analyze such relationships as it provides an intuitive approach of comparing the metrics with our previously labeled similarity score. We measured the Spearman correlation between the values given by the human agent and each of the measures in the given pairing. Correlation TFIDF SBERT Edit Distance Jaccard TFIDF SBERT 0.49 Edit Distance 0.156 0.202 Jaccard 0.159 0.216 0.441 Human Score 0.822 0.812 0.801 0.783 Table 4.4: Correlation between metrics In Table 4.4 we present such results. To note while the metrics have low correlation between themselves, they all have high correlation with the human score metric. When considering the two previous tasks regarding metrics, we concluded they do not have a significant difference between one another. From this point on we decided to use only TF-IDF and SBERT metrics for future experiments. The reason being Jaccard distance has the lowest correlation to the human similarity score while Edit distance takes much longer than the other metrics to compute. The remaining methods can be used to evaluate if contextual word embeddings like SBERT are better in cases like the present one when compared to more simple text representation methods such as TFIDF.
31 4.3.2. Text Pre-processing and Algorithm Evaluation In the previous sections, different approaches were conducted to find differences in the chosen metrics. Due to related work presented in chapter 3 and to previous experiments, we have established that there are only minor differences in the presented similarity measures. In this subsection, we aim to select the optimal method for each of the other components. We have tested the viability of the Silver Dataset as the real representation of the template grouping and determined it was a good representation. This has two consequences: firstly, it enables the use of External Quality Measures (section 2.3.1.) for clustering results since we have a representation of the original data structure (or ground truth); secondly, a rare case of clustering problem where the exact number of clusters is known is presented. In consequence, we can test different combinations of text representation, similarity measures and document pre-processing techniques in an objectively easy to evaluate environment. While this will not directly achieve the objective of finding new templates in the data, we are under the assumption that if we find a clustering methodology capable of having high evaluation in this sub dataset, the same methodology will translate comparable results when clustering with all the data. Some Clustering Algorithms may use the number of clusters as an optional parameter; however, the k-means family of clustering algorithms need only the number of clusters to be executed. With one of its main issues solved, we can make use of this unique case to figure out the optimal type of k-means algorithm to be used in the final approach where the only issue would be finding the optimal number of clusters. Since we are having this approach to decrease the number of parameters to optimize, we are focusing on k-means related algorithms and some hierarchical algorithms. Thus, clustering methods that use other parameters will not be used in this evaluation as the number of clusters in the result of these methods may greatly differ from the number of actual clusters present in the dataset and thus would behave poorly with ground truth related evaluations. 4.3.2.1. Text Preprocessing Briefly mentioned in section 3.1., text preprocessing is a common module used in most NLP tasks. The act of splitting the text into words is called tokenization and is applied to all experiments. Several preprocessing techniques can be applied to the text documents. These transformations may reduce the high dimensionality of the feature space, as they reduce the number of words in the vocabulary. As they remove noisy features, they are expected to improve the clustering result, efficiency, and performance. Words present in nearly all text documents do not add relevancy to the document. Examples of these words are prepositions, pronouns, and articles such as you, your, as and is. This group of words is commonly referred as stopwords. They do not contribute to the semantic value of text as their appearance in one document does not help differentiate from the others. Commonly stored in a list, the removal of stopwords is considered a preprocessing step. Words that share a common lemma (canonical form of a set of words) can be represented with the same term. This process of taking into consideration the morphological structure of words and
32 transform them back to their lemma is called lemmatization. This is achieved by having a detailed dictionary where the algorithm can connect a word to its lemma. Stemming algorithms on the other hand remove parts of a given word by considering prefixes and suffixes usually found in inflected words. This new term is not necessarily a real word. Pre-processing method Original Word Stemming Lemmatization is is Be Change Chang Change changing chang Change densely dens Densely populated popul populated Table 4.5: Differences between Stemming and Lemmatization Lemmatization has the capability of producing real words which may be an advantage but takes longer than stemming to compute. Taking advantage of the situation regarding clustering evaluation, we will experiment different combinations of these techniques and perform a comparison of its impact on the results. 4.3.2.2. Clustering External Evaluation After presenting different methodologies, we will be now evaluating its effect with the External Quality Measures mentioned in 2.3.1. The experiments will go as such: - Apply different combinations of preprocessing techniques to the corpus. - Represent the documents with TFIDF and SBERT, the two remaining representations of text. - Run the k-means, k-medoid and agglomerative clustering algorithms with number of clusters set to the same as the number of templates in the Silver Data (721). - Use ARI and the V-measure (section 2.3.1.) to evaluate the clustering results. In this experiment, we also had an iteration where apart from tokenization, no preprocess was applied. Due to the preprocessing, the dimensionality of the representations suffered minor modifications. While the SBERT representation has the same dimensionality, 512, since it is a fixed vector; the dimensionality of the TF-IDF representations were reduced by a small margin.
39 6. CONCLUSION The goal of this project was to develop a methodology capable of extracting unknown templates from a group of customer support response emails. To do so, we propose a solution based on clustering techniques. As the focus of this work, we extensively researched and analyzed these techniques. Three main components could be gathered: the clustering algorithm, the document representation, and the similarity measure. In the data provided to us, some emails already had an assigned template. Due to this uniqueness of the data, a smaller dataset with known ground truth was extracted. This enabled the use of external cluster validation measures. In addition, an annotated dataset was created. This contribution further enabled the evaluation of clustering components. Particularly, high correlation was observation between most similarity measures and the evaluation of the human agent. To represent the documents into readable data by the algorithms, some techniques were considered. TF-IDF representations had better performance when compared with contextualized word embeddings, such as SBERT. Likewise, we compared different similarity measures, with cosine similarity achieving better results. Several clustering algorithms were evaluated during this research. In initial experiments, better results were achieved by hierarchical clustering algorithms and medoid based algorithms. These types of algorithms are better suited for document clustering. While evaluating different clustering algorithms, we also tested the impact of different text preprocessing techniques such as stopwords removal and stemming. Overall, the impact was non-significant. These insights were then applied to the full dataset. While we focused on the partition with better silhouette score, further analysis led to believe that almost every clustering partition could be used to give insights to the problem at hand. While we did find some unknown templates, as they had very high scores, we have no feasible way of evaluating every single cluster. As most template candidates were comprised of various types of emails, we conclude that further clustering could be done, either with by initializing k-means with a higher number of clusters or applying hierarchical clustering with a specific cutoff.
40 7. LIMITATIONS AND FUTURE WORK One of the limitations of this project is inherent to its approach. As mentioned by (Hassani & Seidl, 2017), clustering evaluation is often as much or more difficult than the clustering itself. While in this case we had the advantage of having some emails with assigned templates and used this particularity to verify the if clustering algorithm was able to detect some of the known templates, an optimal solution to evaluate the clustering results of the full data is still difficult without the need for human intervention. Another limitation is that we were unable to apply some of the algorithms to the full dataset. When applied to the silver dataset, they achieved slightly better results than algorithms applied to the full dataset. As such it would be useful to explore methods of applying such algorithms to a higher quantity of dataset, perhaps in an implementation by batches. Future approaches could include the exploration of other known clustering algorithms such as fuzzy clustering, or perhaps the creation of custom algorithms based on the insights given by this work. It would also be interesting to measure the impact of other data pre-processing techniques. While SBERT embeddings have fixed dimensionality, representations based on bag-of-words have dimensionality that depend on the number of words in the given vocabulary. Using only specific words, such as the most used or the least used, could be interesting. Furthermore, processes of data dimensionality reduction such as Principal Component Analysis and Latent Dirichlet Allocation could be applied. Most response emails can be divided in three main parts: the greeting, which is the beginning of the message, where we usually find the name to whom the given email is addressed to and a small opening introduction (such as Hello or Thank you for reaching out); the body, where the main content of the mail is; and the signoff, which contains a closing statement. Content wise, the greetings and the signoff offer no value to the email. While representations like TF-IDF somewhat counter this by assigning smaller weights to terms that appear in many different documents (which would be the case for words belonging to these two parts of the email), their removal from the document could further enhance the document representation phase of the work. On an ending note, while we had issues fully evaluating new templates, we confirmed that some known templates were also correctly identified. As such it would also be interesting to apply this methodology to different datasets.
41 8. BIBLIOGRAPHY Ariff, N. M., Bakar, M. A., & Rahman, M. I. (2018). Comparative study of document clustering algorithms. International Journal of Engineering and Technology (UAE), 7(4), 246-251. Arthur, D., & Vassilvitskii, S. (2007). k-means++: the advantages of careful seeding. Society for Industrial and Applied Mathematics, 1027-1035. Bahdanau, D., Cho, K., & Bengio, Y. (2015). Neural machine translation by jointly learning to align and translate. Retrieved from https://arxiv.org/abs/1409.0473 Balabantaray, R. C., Sarma, C., & Jha, M. (2015). Document clustering using k-means and k-medoids. Retrieved from https://arxiv.org/abs/1502.07938 Cho, K., Van Merriënboer, B., Bahdanau, D., & Bengio, Y. (2014). On the properties of neural machine translation: Encoder-decoder approaches. Retrieved from https://arxiv.org/abs/1409.1259 Chorowski, J., Bahdanau, D., Serdyuk, D., Cho, K., & Bengio, Y. (2015). Attention-based models for speech recognition. Retrieved from https://arxiv.org/abs/1506.07503 Davies, D. L., & Bouldin, D. W. (1979). A cluster separation measure. IEEE transactions on pattern analysis and machine intelligence, (2), 224-227. Devlin, J., Chang, M. W., Lee, K., & Toutanova, K. (2018). Bert: Pre-training of deep bidirectional transformers for language understanding. Retrieved from https://arxiv.org/abs/1810.04805 Dhillon, I. S., & Modha, D. S. (2001). Decompositions for Large Sparse Text Data Using Clustering. Machine Learning, 143-175. doi:10.1023/A:1007612920971 Hassani, M., & Seidl, T. (2017). Using internal evaluation measures to validate the quality of diverse stream clustering algorithms. Vietnam Journal of Computer Science, 4(3), 171-183. Huang, A. (2008). Similarity measures for text document clustering. Proceedings of the sixth new zealand computer science research student conference (NZCSRSC2008), 4, pp. 9-56. Jain, A. K., Murty, M. N., & Flynn, P. J. (1999). Data clustering: a review. ACM computing surveys (CSUR), 31(3), 264-323. doi:10.1145/331499.331504 Kaufman, L., & Rousseew, P. J. (1990). Finding Groups in Data: An Introduction to Cluster Analysis. John Wiley & Sons. doi:10.1002/9780470316801 Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., . . . Stoyanov, V. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach. Retrieved from https://arxiv.org/abs/1907.11692 Luong, T., Pham, H., & Manning, C. D. (2015). Effective approaches to attention-based neural machine translation. Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, (pp. 1412-1421). doi:10.18653/v1/D15-1166
42 Martin, L., Muller, B., Suárez, P. J., Dupont, Y., Romary, L., de la Clergerie, É. V., . . . Sagot, B. (2019). CamemBERT: a Tasty French Language Model. Retrieved from https://arxiv.org/abs/1911.03894 Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word representations in vector space. Retrieved from https://arxiv.org/abs/1301.3781 Mitchell, T. M. (1997). Machine Learning. Mota, P., Martins, B., & Coheur, L. (2013). Designing an answer template retrieval system. Technical Report 35, INESC-ID. Peters, M. E., Neumann, M., Iyyer, M., Gardner, M., Clark, C., Lee, K., & Zettlemoyer, L. (2018). Deep contextualized word representations. Retrieved from https://arxiv.org/abs/1802.05365 Rand, W. M. (1971). Objective criteria for the evaluation of clustering methods. Journal of the American Statistical association, 66(336), 846-850. Reimers, N., & Gurevych, I. (2019). Sentence-bert: Sentence embeddings using siamese bertnetworks. Retrieved from https://arxiv.org/abs/1908.10084 Rosenberg, A., & Hirschberg, J. (2007). V-measure: A conditional entropy-based external cluster evaluation measure. Proceedings of the 2007 joint conference on empirical methods in natural language processing and computational natural language learning (EMNLP-CoNLL), (pp. 410-420). Rosenblatt, F. (1958). The perceptron: a probalistic model for information storage and organization in the brain. Psychological Review, 65(6), 386-408. Santos, J. M., & Embrechts, M. (2009). On the use of the adjusted rand index as a metric for evaluating supervised classification. International conference on artificial neural networks, 175-184. doi:10.1007/978-3-642-04277-5_18 Sasaki, M., & Shinnou, H. (2005). Spam detection using text clustering. 2005 International Conference on Cyberworlds (CW'05), (pp. 4-pp). Shalev-Shwartz, S., & Ben-David, S. (2014). Understanding machine learning: From theory to algorithms. Cambridge: Cambridge University Press. doi:10.1017/CBO9781107298019 Steinbach, M., Karypis, G., & Kumvar, V. (2000). A comparison of document clustering techniques. Sutskever, I., Vinyals, O., & Le, Q. V. (2014). Sequence to sequence learning with neural networks. Advances in neural information processing systems, 3104-3112. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., . . . Polosukhin, I. (2017). Attention Is All You Need. Advances in neural information processing systems, (pp. 5998- 6008).
43 Wu, Y., Schuster, M., Chen, Z., L, Q. V., M. N., Macherey, W., . . . Dean, J. (2016). Google’s neural machine translation system: Bridging the gap between. Retrieved from https://arxiv.org/abs/1609.08144v2 Zhu, Y., Kiros, R., Salakhutdinov, R., Urtasun, R., Torralba, A., & Filder, S. (2015). Aligning books and movies: Towards story-like visual explanations by watching movies and reading books. Proceedings of the IEEE international conference on computer vision, (pp. 19-27).
44