KG-HTC: Integrating Knowledge Graphs into LLMs for Effective Zero-shot Hierarchical Text Classification
Qianbo Zang, Christophe Zgrzendek, Igor Tchappi, Afshin Khadangi, Johannes Sedlmeir · 2025
Read KG-HTC: Integrating Knowledge Graphs into LLMs for Effective Zero-shot Hierarchical Text Classification by Qianbo Zang, Christophe Zgrzendek, Igor Tchappi, Afshin Khadangi, Johannes Sedlmeir (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2505-05583.txt.
Introduction
Qianbo Zang, Johannes Sedlmeir, and co-authors add knowledge graphs to large language models to sort texts into tiered labels with no marked training data, in a 2025 paper. Tiered sorts face huge label sets and rare deep labels. Hand marked data to train past tools is often scarce.
Their method pulls small linked graphs that match each text and feeds them to the model as context. That helps the model grasp label sense at each tier. Tests on three public sets beat three past zero shot tools by a wide edge. Gains were largest at the deep tiers where past tools fail most.
Catalog record
| CREATOR | Qianbo Zang, Christophe Zgrzendek, Igor Tchappi, Afshin Khadangi, Johannes Sedlmeir |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 37 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2505-05583
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
KG-HTC: Integrating Knowledge Graphs into LLMs for Effective Zero-shot Hierarchical Text Classification Qianbo Zang, Christophe Zgrzendek, Igor Tchappi, Afshin Khadangi, Johannes Sedlmeir Abstract Hierarchical Text Classification (HTC) involves assigning documents to labels organized within a taxonomy. Most previous research on HTC has focused on supervised methods. However, in real-world scenarios, employing supervised HTC can be challenging due to a lack of annotated data. Moreover, HTC often faces issues with large label spaces and long-tail distributions. In this work, we present K nowledge G raphs for zero-shot H ierarchical T ext C lassification (KG-HTC), which aims to address these challenges of HTC in applications by integrating knowledge graphs with Large Language Models (LLMs) to provide structured semantic context during classification. Our method retrieves relevant subgraphs from knowledge graphs related to the input text using a Retrieval-Augmented Generation (RAG) approach. Our KG-HTC can enhance LLMs to understand label semantics at various hierarchy levels. We evaluate KG-HTC on three open-source HTC datasets: WoS, DBpedia, and Amazon. Our experimental results show that KG-HTC significantly outperforms three baselines in the strict zero-shot setting, particularly achieving substantial improvements at deeper levels of the hierarchy. This evaluation demonstrates the effectiveness of incorporating structured knowledge into LLMs to address HTC’s challenges in large label spaces and long-tailed label distributions. Our code is available at https://github.com/QianboZang/KG-HTC . † † paperid: 1335 1 Introduction Text classification is a fundamental task in natural language processing that focuses on assigning one or more predefined categories to a given piece of text. A specific and increasingly important extension of text classification is htc ( htc ), where the labels are not simply flat but are organized within a multi-level taxonomy. htc aims to categorize textual data into multi-level label systems with parent-child relationships, where labels at different levels are organized as a hierarchical taxonomy. Figure 1 features an example from the Amazon Product Review dataset. In this figure, the root of the hierarchy is the name of the dataset, and a review needs to be classified to labels at multiple levels. The example input text can be sequentially classified as health personal care, household supplier, and dishwashing. htc has been successfully applied in different domains, including e-commerce product categorization ( Chatterjee et al., 2021 ; Patel et al., 2022 ) , hierarchical topic modeling of e-participation platforms ( Simonofski et al., 2021 ) , and fine-grained literature management ( Chen et al., 2021 ; Kowsari et al., 2017 ) . Figure 1: An example of htc from the Amazon Product Review dataset. However, in real-world applications, htc often faces one or multiple out of the following three significant challenges. First, there may be a shortage of annotated data, particularly as the cost of manually labeling custom data at multiple hierarchical levels is prohibitively high ( Chen et al., 2022 ) . This problem becomes even more severe in dynamic environments such as retail systems, where taxonomies evolve with new product lines. Second, practical taxonomies universally exhibit large-scale label spaces ( Zhang et al., 2024b ) . For instance, the hierarchy of the Amazon Product Review dataset contains over 500 leaf categories. 1 1 1 kaggle.com/datasets/kashnitsky/hierarchical-text-classification Third, real-world datasets in htc can exhibit highly imbalanced long-tail distributions, i.e., a small number of frequent categories dominates the dataset while most classes remain underrepresented. For instance, our statistical analysis reveals that the most frequent 15 % of categories account for 80 % of total instances in the third level of the Amazon Product Review dataset. In contrast, the bottom 50 % of categories collectively represent merely 6 % of the data volume. Figure 2: The overview pipeline of KG- htc . For these three reasons, and contrary to flat text classification, standard supervised approaches are not well-suited to htc in many industry settings ( Halder et al., 2020 ; Huang et al., 2019 ; Kowsari et al., 2017 ; Meng et al., 2019 ) . As a consequence, researchers have increasingly turned to zero-shot learning methods to approach htc ( Bongiovanni et al., 2023 ; Halder et al., 2020 ; Paletto et al., 2024 ) . We can group recent studies into three main approaches. The first approach leverages the in-context learning of pre-trained LLMs through carefully designed prompts to accomplish accurate classification. Halder et al. (2020) transforms any text classification task into a universal binary classification problem, where LLMs assign a binary value (true or false) for each label in the label space. However, due to htc ’s extensive label space, this method requires multiple iterations to complete a single classification. The second approach utilizes embedding models converted from pre-trained llm ( llm ) to calculate the distance between input text and labels for classification. Bongiovanni et al. (2023) proposed Z-STC to propagate similarity scores up the hierarchy and leverage this propagated information to optimize classification for upper-level labels. The third method combines embedding models with LLM-based classification. Paletto et al. (2024) introduced HiLA, where llm generate new label layers inserted into the bottom of the current taxonomy. Then, Paletto follows Z-STC for classification. However, Bongiovanni et al. (2023) ’s and Paletto et al. (2024) ’s methods exhibit low classification performance for deeper-level labels. In this paper, we propose KG- htc , a new method to enhance htc by integrating kg ( kg ) into llm for htc . To this end, we will focus on the strict zero-shot learning setting. Since dag ( dag ) can represent the hierarchical structure of labels in htc , the combination of llm and knowledge graphs is especially promising for this purpose. We represent the taxonomy as a DAG-based knowledge graph and compute the cosine similarity between the text and the embeddings of labels at each level. By applying preset thresholds, candidate labels that are highly semantically relevant to the input text are chosen at every hierarchical level. Then, leveraging these candidate labels, the system dynamically retrieves the most pertinent subgraph from the complete label knowledge graph corresponding to the given text. For the retrieved subgraph, an upwards propagation algorithm is employed to systematically enumerate all possible hierarchical paths from the leaf nodes to the root, with each path representing a complete reversed hierarchical label sequence. These structured sequences are subsequently concatenated into a prompt, which is fed into an LLM to perform the zero-shot classification task. We evaluate our approach using three public datasets and achieve new state-of-the-art results for all of them. Without relying on any annotated data, the KG-HTC method significantly enhances the model’s capability to overcome the issue of long-tail and sparse labels. We find that compared to the approaches of Bongiovanni et al. (2023) and Paletto et al. (2024) , our KG- htc exhibits significantly smaller performance degradation as the label hierarchy deepens. As such, the contributions of this paper are threefold: 1. We present a novel approach – KG-HTC – to integrate kg into llm for htc under a strict zero-shot setting. 2. We implement a novel pipeline that semantically retrieves relevant subgraphs from the label taxonomy based on cosine similarity with the input text and transforms it to a structured prompt. 3. We conduct an in-depth assessment of KG-HTC, comparing it with the previous state-of-the-art on three open-source htc datasets. The