Table of Contents
Fetching ...

From Text to Graph: Leveraging Graph Neural Networks for Enhanced Explainability in NLP

Fabio Yáñez-Romero, Andrés Montoyo, Armando Suárez, Yoan Gutiérrez, Ruslan Mitkov

TL;DR

This work addresses the explainability gap in large transformer-based NLP models by translating sentences into graph-structured representations that preserve semantic meaning. A complete pipeline converts text to constituency-tree graphs, converts those trees to directed graphs, fine-tunes a language model, and distills its behavior into a graph neural network for explainable predictions, augmented by post-hoc analyses. Using SubgraphX and AutoGOAL, the approach yields high-fidelity, sparse explanations that pinpoint critical textual components and provide semantic and structural interpretations, enabling model diagnostics and knowledge extraction. The methodology demonstrates promising results on AG News and SST-2, with the GNN closely mirroring LM classifications and offering a tractable, interpretable alternative for explainability and downstream knowledge-base construction.

Abstract

Researchers have relegated natural language processing tasks to Transformer-type models, particularly generative models, because these models exhibit high versatility when performing generation and classification tasks. As the size of these models increases, they achieve outstanding results. Given their widespread use, many explainability techniques are developed based on these models. However, this process becomes computationally expensive due to the large size of the models. Additionally, transformers interpret input information through tokens that fragment input words into sequences lacking inherent semantic meaning, complicating the explanation of the model from the very beginning. This study proposes a novel methodology to achieve explainability in natural language processing tasks by automatically converting sentences into graphs and maintaining semantics through nodes and relations that express fundamental linguistic concepts. It also allows the subsequent exploitation of this knowledge in subsequent tasks, making it possible to obtain trends and understand how the model associates the different elements inside the text with the explained task. The experiments delivered promising results in determining the most critical components within the text structure for a given classification.

From Text to Graph: Leveraging Graph Neural Networks for Enhanced Explainability in NLP

TL;DR

This work addresses the explainability gap in large transformer-based NLP models by translating sentences into graph-structured representations that preserve semantic meaning. A complete pipeline converts text to constituency-tree graphs, converts those trees to directed graphs, fine-tunes a language model, and distills its behavior into a graph neural network for explainable predictions, augmented by post-hoc analyses. Using SubgraphX and AutoGOAL, the approach yields high-fidelity, sparse explanations that pinpoint critical textual components and provide semantic and structural interpretations, enabling model diagnostics and knowledge extraction. The methodology demonstrates promising results on AG News and SST-2, with the GNN closely mirroring LM classifications and offering a tractable, interpretable alternative for explainability and downstream knowledge-base construction.

Abstract

Researchers have relegated natural language processing tasks to Transformer-type models, particularly generative models, because these models exhibit high versatility when performing generation and classification tasks. As the size of these models increases, they achieve outstanding results. Given their widespread use, many explainability techniques are developed based on these models. However, this process becomes computationally expensive due to the large size of the models. Additionally, transformers interpret input information through tokens that fragment input words into sequences lacking inherent semantic meaning, complicating the explanation of the model from the very beginning. This study proposes a novel methodology to achieve explainability in natural language processing tasks by automatically converting sentences into graphs and maintaining semantics through nodes and relations that express fundamental linguistic concepts. It also allows the subsequent exploitation of this knowledge in subsequent tasks, making it possible to obtain trends and understand how the model associates the different elements inside the text with the explained task. The experiments delivered promising results in determining the most critical components within the text structure for a given classification.

Paper Structure

This paper contains 27 sections, 6 equations, 6 figures, 3 tables, 1 algorithm.

Figures (6)

  • Figure 1: The proposed methodology covers converting the original texts into graphs and initialising their tensors automatically. Subsequently, explainability can be covered using neural network graphs, and relevant analyses of these results can be carried out.
  • Figure 2: Our approach achieves explainability in a human-interpretable form through graph structures. In this case, an encoder-only language model explains the results obtained in topic classification using Ag-news and sentiment analysis using Sst-2. We start with language models fine-tuned in this task to generate the embeddings of the graphs.
  • Figure 3: Interpretation of the subgraph obtained according to the classification performed. We see the positive subgraphs in green to obtain a correct prediction, while in red, we have the opposite case.
  • Figure 4: Methodology to obtain the most important words with semantic meaning, the minimum distance between the root node and the subgraph is obtained, dropping all the nodes with a distance below that minimum. From the obtained clusters, we keep only the one that contains the subgraph and then explore the graph to get the nodes with word labels $v_w$.
  • Figure 5: We generate word clouds for subgraphs classified as "Sci/Tech" in the AG News Dataset. We group the obtained words by their parent phrases according to the constituency tree structure and represent their frequency as word clouds.
  • ...and 1 more figures