Table of Contents
Fetching ...

KG-HTC: Integrating Knowledge Graphs into LLMs for Effective Zero-shot Hierarchical Text Classification

Qianbo Zang, Christophe Zgrzendek, Igor Tchappi, Afshin Khadangi, Johannes Sedlmeir

TL;DR

This work tackles zero-shot hierarchical text classification (HTC) under large label spaces and long-tail distributions by fusing knowledge graphs with large language models. KG-HTC retrieves semantically relevant subgraphs from a knowledge graph using Retrieval-Augmented Generation, converts them into hierarchical label paths, and performs layer-wise, prompt-based in-context classification with structural constraints. Across Amazon, WoS, and Dbpedia, KG-HTC achieves state-of-the-art zero-shot performance, with especially large gains at deeper hierarchy levels, underscoring the benefit of structured semantic context for LLM-based HTC. The approach demonstrates robustness to depth and provides a practical framework for scalable HTC without labeled data, though it relies on accurate taxonomies and KG quality, suggesting future work on automatic KG construction and improved retrieval precision.

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 Knowledge Graphs for zero-shot Hierarchical Text Classification (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.

KG-HTC: Integrating Knowledge Graphs into LLMs for Effective Zero-shot Hierarchical Text Classification

TL;DR

This work tackles zero-shot hierarchical text classification (HTC) under large label spaces and long-tail distributions by fusing knowledge graphs with large language models. KG-HTC retrieves semantically relevant subgraphs from a knowledge graph using Retrieval-Augmented Generation, converts them into hierarchical label paths, and performs layer-wise, prompt-based in-context classification with structural constraints. Across Amazon, WoS, and Dbpedia, KG-HTC achieves state-of-the-art zero-shot performance, with especially large gains at deeper hierarchy levels, underscoring the benefit of structured semantic context for LLM-based HTC. The approach demonstrates robustness to depth and provides a practical framework for scalable HTC without labeled data, though it relies on accurate taxonomies and KG quality, suggesting future work on automatic KG construction and improved retrieval precision.

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 Knowledge Graphs for zero-shot Hierarchical Text Classification (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.
Paper Structure (28 sections, 6 equations, 2 figures, 5 tables, 3 algorithms)

This paper contains 28 sections, 6 equations, 2 figures, 5 tables, 3 algorithms.

Figures (2)

  • Figure 1: Visualization of the knowledge graph (tree) constructed from the multi-level taxonomy in the Amazon Product Review dataset. The red nodes represent labels in the first hierarchical level. The green nodes denote sub-categories (second level) interconnected through parent-child relationships. And the yellow nodes correspond to finally fine-grained leaf categories in the third level.
  • Figure 2: As the taxonomy deepens, KG-HTC exhibits a slower performance degradation on the WoS and Amazon datasets.