Graph-based Retrieval Augmented Generation for Dynamic Few-shot Text Classification
Yubo Wang, Haoyang Li, Fei Teng, Lei Chen
TL;DR
The paper tackles dynamic few-shot text classification under evolving label sets by proposing GORAG, a hyperparameter-free framework that uses a weighted keyword-label graph constructed online across rounds. Retrieval is performed via a minimum-cost spanning tree on the graph, yielding adaptive candidate labels without human thresholds, while an online indexing mechanism enriches the graph with new query keywords. Through extensive experiments on WOS, Reuters, and IFS-Rel, GORAG achieves superior accuracy and robustness to label updates, and ablations confirm the critical roles of edge weighting and online indexing. The approach reduces input length and noise for LLMs and offers scalable, context-rich augmentation for real-world dynamic DFSTC tasks.
Abstract
Text classification is a fundamental task in data mining, pivotal to various applications such as tabular understanding and recommendation. Although neural network-based models, such as CNN and BERT, have demonstrated remarkable performance in text classification, their effectiveness heavily relies on abundant labeled training data. This dependency makes these models less effective in dynamic few-shot text classification, where labeled data is scarce, and new target labels frequently appear based on application needs. Recently, large language models (LLMs) have shown promise due to their extensive pretraining and contextual understanding ability. Current approaches provide LLMs with text inputs, candidate labels, and additional side information (e.g., descriptions) to classify texts. However, their effectiveness is hindered by the increased input size and the noise introduced through side information processing. To address these limitations, we propose a graph-based online retrieval-augmented generation framework, namely GORAG, for dynamic few-shot text classification. Rather than treating each input independently, GORAG constructs and maintains a weighted graph by extracting side information across all target texts. In this graph, text keywords and labels are represented as nodes, with edges indicating the correlations between them. To model these correlations, GORAG employs an edge weighting mechanism to prioritize the importance and reliability of extracted information and dynamically retrieves relevant context using a minimum-cost spanning tree tailored for each text input. Empirical evaluations demonstrate that GORAG outperforms existing approaches by providing more comprehensive and precise contextual information.
