# TR-GPT-CF: A Topic Refinement Method Using GPT and Coherence Filtering
## 2 Materials and Methods  
To overcome the shortcomings of conventional topic models in generating coherent and interpretable topics, we present an innovative topic refinement framework, which, to the best of our knowledge, has not been previously presented in the literature. While this work was inspired by [38], our approach differs significantly. The referenced study relies solely on large language models (LLMs) for topic refinement, whereas our proposed method integrates multiple techniques, as outlined below. A high-level overview of our framework is illustrated in Figure 1. Preprocessing, topic extraction, and topic refinement compose the three primary phases. Our proposed method, TR-GPT-CF, focuses on topic refinement, which consists of two main stages, misaligned word detection and misaligned word replacement. Misaligned word detection aims to identify words that are not semantically related to the other word in the topic. Misaligned word replacement aims to generate alternative words that are selected based on their coherence. This framework is model agnostic, allowing it to utilize any topic modeling method and dataset. Because of its flexibility, it can be used for a variety of purposes, including academic research and industry-specific analysis. Being independent of a particular model allows it to adjust to different data requirements and characteristics, increasing its usefulness and scalability across domains. In this research, we utilize various datasets as shown in Table 1. We employ multiple datasets to evaluate the effectiveness of our refinement method across different contexts. We sourced certain datasets from standard scikit-learn libraries, specifically AGNews, Yahoo Answers, and 20 Newsgroup. Specifically, this experiment utilizes the 'train' data from the AGNews and 20 Newsgroup datasets and only 20,000 training samples from the Yahoo Answers dataset. The remaining three datasets--TagMyNews from [39], SMS Spam from [40], and [PERSON]'s Research Article from [41]--were obtained from their respective sources. These datasets provide a diverse range of topics and formats, enabling comprehensive analysis across different domains. By leveraging their distinct characteristics, we aim to derive meaningful insights and enhance our understanding of the underlying patterns within the data. In this work, we applied numerous preprocessing standards, including the elimination of stop words and lemmatization, to ensure that our model focused on the most relevant words, thereby enhancing the quality of the topics generated. Further preprocessing techniques such as normalization and tokenization were utilized to refine the dataset before analysis. Given the vast amount of unstructured data on the internet, particularly from social media--where user-generated content [42] and short text predominate--we refined our preprocessing with several specific actions. Since our framework is designed to handle both long and short text, some preprocessing steps followed the method proposed by [43] and implemented by [44]. Building on the aforementioned foundational steps, we further optimized the dataset using the following actions:  
* Removing high-frequency words: Identify and remove the most frequent words in the corpus, based on TF-IDF scores. This procedure prevents the model from focusing on very common words (e.g., \"the\" and \"and\"). * Eliminating repetitive patterns: Eliminate redundant sequences such as \"hahahahaha\" or \"hihihihi\" that contribute unnecessary noise to the corpus. This procedure uses regular expressions to replace any character repeated three or more times with a single occurrence. * Removing non-alphabet character: employ regular expression to eliminate non-alphaetic characters. * Eliminating very short documents: exclude documents that are excessively brief or potentially solely consist of nonsensical content, which might not be meaningful for topic modeling.