# TR-GPT-CF: A Topic Refinement Method Using GPT and Coherence Filtering
## 2 Materials and Methods
### Misaligned Word Detection  
Prior research indicates that words unrelated to others within a topic are recognized as intruders [33; 54]. In [33] intruder identification was conducted by presenting users with a collection of words. The users were instructed to identify the word that was unrelated to other words in the topics. For instance, \"banana\" is rapidly identified as the intruder in a collection of [lion, tiger, elephant, banana, giraffe, zebra] as the other words such as (lion, tiger, elephant, giraffe, zebra) all represent animals. Conversely, in a set like {bike, professor, kangaroo, swift, green, Brazil}, which lacks this thematic unity, identifying the outlier becomes more challenging. Reference [55] presents a method for detecting intruder words through the utilization of semantic similarity measures in an expanded corpus. More external data are added to the initial corpus to include a larger vocabulary, word embeddings are created to capture semantic meanings, and documents are grouped together to uncover hidden topics. Each cluster's centroid in the embedding space signifies its corresponding topic, and the low cosine similarity of intruder words to the topic centroid indicates semantic divergence. Although the previous paper referred to the irrelevant word as an 'intruder', in this work, we prefer to use the term'misaligned word'. This new terminology emphasizes the broader applicability and unique methodology of our technique, which extend beyond the constraints of previously established frameworks. In contrast to the methodologies proposed in previous studies, our TR-GPT-CF mechanism utilizes the _bert-base-unased_ model of BERT embeddings [56], which are contextualized to capture the specific meaning of a word based on its surrounding words. Recent advancements in BERT [57; 58] have further improved their effectiveness in various applications. BERT embeddings provide greater flexibility and depth in representing text, especially for tasks like intruder word detection in complex or ambiguous contexts. Unlike static embedding, which struggles with polysemy--for example, 'bank' as a financial institution versus 'bank' as the side of a river--the BERT contextualized approach allows for dynamic representations that adapt to different contexts. Our work employs the Hugging Face transformer library [59] to apply the _bert-base-uncased_ version of the BERT model, which features 12 layers and 768 hidden units [56]. This model is pre-trained on a large corpus of English text where all input words are converted to lowercase, making it case sensitive. In this work, misaligned word detection is designed to analyze the semantic and statistical properties of words within a given topic in order to identify misaligned words. It starts by generating embeddings \(M\) for all words in the topic \(T\) using the _bert-base-uncased_ model of BERT embeddings and calculates a centroid embedding \(M(t_{i})\), which represents the semantic center of the topic. Cosine similarity \(s\) is then computed between each word's embedding \(w_{i}\) and the centroid \(c\) to measure how closely each word aligns with the overall topic. Instead of relying solely on cosine similarity to detect outliers as suggested in [55], we utilize the Z-score to standardize the similarity values. Using only cosine similarity presents challenges in defining a universal threshold to classify a word as a misaligned word. The similarity score range can vary widely across different topics and datasets. For example, in some topics, all words may naturally exhibit low similarity scores due to the nature of the embeddings, complicating the identification of true misaligned words. Additionally, misaligned words often appear as'relative' outliers--that is, their similarity to the centroid is significantly lower than that of other words within the topic. However, cosine similarity alone fails to account for the distribution of similarity scores within a topic.