ChatGraph: Interpretable Text Classification by Converting ChatGPT Knowledge to Graphs

Yucheng Shi, Hehuan Ma, Wenliang Zhong, Qiaoyu Tan, Gengchen Mai, Xiang Li, Tianming Liu, Junzhou Huang

TL;DR

ChatGraph bridges the gap between the powerful knowledge retrieval capabilities of ChatGPT and the necessity for interpretable, data-efficient text classification. By shifting ChatGPT’s role from a direct classifier to a structured knowledge graph extractor, the framework builds explicit text graphs that train an inherently interpretable linear model. This approach significantly outperforms zero- and few-shot ChatGPT while offering transparent, word-level decision-making.

What Problem Does This Paper Address?

Large Language Models (LLMs) like ChatGPT have taken the NLP world by storm, often achieving incredible performance out-of-the-box. However, when applied to specialized downstream tasks like text classification, they hit two major roadblocks:

  1. Inflexibility in Data-Rich Scenarios: Because ChatGPT is a closed-source, black-box model, users cannot access its weights to fine-tune it on specific datasets. While in-context learning (few-shot prompting) helps, it struggles to scale when thousands of labeled examples are available or when documents exceed token length limits. In fact, direct ChatGPT prompting often underperforms traditional graph-based methods like TextGCN (see Figure 1).
  2. Lack of Interpretability: In high-stakes domains (like medicine or law), we need to know why a model made a decision. Traditional interpretability methods (like analyzing attention weights) are impossible to implement when the underlying model architecture is hidden behind a commercial API.

The authors tackle these challenges by proposing ChatGraph, a data-centric framework that extracts structured knowledge from text using ChatGPT and feeds it into a simple, fully transparent classifier.

TextGCN vs. ChatGPT Accuracy

Methods

Instead of forcing ChatGPT to output a final class label, ChatGraph uses a multi-step pipeline to distill raw text into an interpretable format:

  1. Text Refinement: ChatGPT is prompted to clean up the raw text—correcting typos, fixing grammar, and standardizing synonyms—ensuring high-quality input for the next stage.
  2. Knowledge Graph Extraction: Using a Chain-of-Thought (CoT) prompt, ChatGPT extracts entities and their relationships from the refined text, formatting them as structured triplets: (head entity, relation, tail entity).
  3. Text Graph Construction: These triplets are converted into a text graph $\mathcal{G}$, where distinct words become nodes and relationships form the edges. To boost performance, external statistical knowledge like TF-IDF weights can be seamlessly integrated into the graph's pooling matrix.
  4. Interpretable Classification: The text graph is fed into a 1-layer Graph Convolutional Network (GCN). Crucially, the authors remove all non-linear activation functions. This renders the model mathematically equivalent to a linear classifier, meaning the learned weights directly and transparently represent the importance of each word to the final label.
ChatGraph Framework Diagram

Datasets

The authors evaluated ChatGraph on four widely accepted text classification benchmarks:

  • 20-Newsgroups (20NG): 18,846 newsgroup documents evenly distributed across 20 categories.
  • R8 & R52: Two subsets of the Reuters-21578 dataset, containing 8 and 52 financial classifications, respectively.
  • Ohsumed: A medical abstract collection from the MEDLINE database, focusing on 7,400 single-label documents across various cardiovascular diseases.

Key Insights and Ideas

  • LLMs as Structurers, Not Deciders: The core "aha moment" is realizing that ChatGPT's strength lies in its broad semantic understanding and ability to structure messy data, whereas simple linear models excel at drawing clear, interpretable decision boundaries when given clean, structured features.
  • Bypassing Token Limits via Graphs: Direct few-shot prompting fails on long-text datasets like 20NG because appending multiple long examples quickly exceeds ChatGPT's context window. ChatGraph circumvents this by condensing documents into compact graphs before classification.
  • The Power of Simplicity: By restricting the GCN to a single layer with no non-linearities, the authors sacrifice the complex, uninterpretable abstractions of deep learning but gain total transparency without a massive drop in accuracy.

Key Results

ChatGraph consistently and significantly outperformed direct ChatGPT prompting across all datasets:

  • Accuracy Boost: On the R8 dataset, zero-shot ChatGPT achieved a modest 60.10% accuracy. ChatGraph boosted this to 96.39% (and 96.46% when enhanced with TF-IDF), nearly matching the performance of a fully black-box 2-layer TextGCN (97.07%).
  • Domain Resilience: On the highly specialized medical dataset (Ohsumed), zero-shot ChatGPT struggled at 39.93%. ChatGraph raised the bar to 63.63%.
  • Proven Interpretability: The authors verified their model's transparency using fidelity metrics (masking the most "important" words identified by the model). As shown in Table III, masking ChatGraph's top-tier words caused massive performance drops compared to random masking, proving that the model accurately pinpoints the truly decisive words in a document.

Limitations and Future Work

While promising, ChatGraph has a few limitations:

  • API Dependency and Cost: The initial text refinement and graph extraction steps rely heavily on querying ChatGPT, which can introduce latency and API costs when processing massive datasets.
  • Task Scope: The framework was only tested on text classification. The authors note that future work will include extending this graph-distillation approach to other complex NLP tasks like question answering and named entity recognition.

Summary updated

BibTeX
@inproceedings{shi2023chatgraph,
  author = {Yucheng Shi and Hehuan Ma and Wenliang Zhong and Qiaoyu Tan and Gengchen Mai and Xiang Li and Tianming Liu and Junzhou Huang},
  title = {{ChatGraph: Interpretable Text Classification by Converting ChatGPT Knowledge to Graphs}},
  booktitle = {Workshops @ ICDM},
  year = {2023},
  doi = {10.1109/icdmw60847.2023.00073},
}
Figure