A modular, scalable pipeline for transforming raw textual data into graph-structured datasets using dependency and sequential parsing. Designed to support large-scale graph-based learning tasks in natural language processing (NLP) and built upon PyTorch Geometric’s OnDiskDataset.
This repository introduces a dataset processing framework that converts labelled text corpora into graph representations suitable for graph neural networks (GNNs). It includes functionality for:
MultiDiGraph structures from text, integrating syntactic and sequential relations.OnDiskDataset to scale to large corpora without memory constraints.To set up the environment, please use the provided environment.yml file with Conda:
conda env create -f environment.yml
conda activate phd_env
This will install all the necessary dependencies, including PyTorch, PyTorch Geometric, SpaCy, and Transformers.
The src/pipelines directory contains several scripts to run the core functionalities of this project.
To convert a raw text corpus into a graph dataset, run the text_to_graph_pipeline.py script. You will need to configure the DATASET and LANG variables within the script to point to your data.
python src/pipelines/text_to_graph_pipeline.py
This repository supports training for different GNN models.
train_diffpool_pipeline.py script.gcn_baseline_pipeline.py.bert_baseline_pipeline.py.Example of running the DiffPool training:
python src/pipelines/train_diffpool_pipeline.py
Grid search for hyperparameters can be performed using the train_diffpool_gridsearch.py and train_diffpool_gridsearch_loss.py scripts. The results of these searches are stored in .xlsx files, which can be analyzed with the gridsearch_analysis.py script.
The explainability pipeline uses concept grounding to interpret the model's predictions. This can be run using the concept_grounding_pipeline.py script.
.
├── data/ # Datasets and external resources
│ ├── datasets/
│ ├── evaluation/
│ ├── explanations/
│ └── prompts/
├── notebooks/ # Jupyter notebooks for analysis and visualisation
├── src/ # Source code
│ ├── data/ # Data loading and processing
│ ├── models/ # GNN models and explainability methods
│ ├── multi_graph/ # Multi-level graph construction and models
│ ├── pipelines/ # End-to-end pipelines for different tasks
│ └── utils/ # Utility functions
├── README.md # This file
└── environment.yml # Conda environment file
This project includes a novel approach to GNN explainability through concept grounding. The src/models/graph_explainability directory contains the core components:
concept_grounding.py: The main module for generating explanations.llm_oracle.py: Uses a Large Language Model to generate concepts for hypernodes.embeddings_oracle.py: An embedding-based oracle for concept grounding.cg_evaluation_metrics.py: Implements metrics like "Concept Completeness" to evaluate the quality of explanations.If you use this work, please cite:
@misc{textualhgnn,
author = {Thiago Raulino {Dal Pont}},
title = {Textual Hierarchical Graph Neural Networks},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/thiagordp/TextualHGNN}}
}
This project is licensed under the MIT License. See the LICENSE file for details.
33 commits
Jupyter Notebook
84.0%
HTML
8.2%
Python
7.8%
A modular, scalable pipeline for transforming raw textual data into graph-structured datasets using dependency and sequential parsing. Designed to support large-scale graph-based learning tasks in natural language processing (NLP) and built upon PyTorch Geometric’s OnDiskDataset.
This repository introduces a dataset processing framework that converts labelled text corpora into graph representations suitable for graph neural networks (GNNs). It includes functionality for:
MultiDiGraph structures from text, integrating syntactic and sequential relations.OnDiskDataset to scale to large corpora without memory constraints.To set up the environment, please use the provided environment.yml file with Conda:
conda env create -f environment.yml
conda activate phd_env
This will install all the necessary dependencies, including PyTorch, PyTorch Geometric, SpaCy, and Transformers.
The src/pipelines directory contains several scripts to run the core functionalities of this project.
To convert a raw text corpus into a graph dataset, run the text_to_graph_pipeline.py script. You will need to configure the DATASET and LANG variables within the script to point to your data.
python src/pipelines/text_to_graph_pipeline.py
This repository supports training for different GNN models.
train_diffpool_pipeline.py script.gcn_baseline_pipeline.py.bert_baseline_pipeline.py.Example of running the DiffPool training:
python src/pipelines/train_diffpool_pipeline.py
Grid search for hyperparameters can be performed using the train_diffpool_gridsearch.py and train_diffpool_gridsearch_loss.py scripts. The results of these searches are stored in .xlsx files, which can be analyzed with the gridsearch_analysis.py script.
The explainability pipeline uses concept grounding to interpret the model's predictions. This can be run using the concept_grounding_pipeline.py script.
.
├── data/ # Datasets and external resources
│ ├── datasets/
│ ├── evaluation/
│ ├── explanations/
│ └── prompts/
├── notebooks/ # Jupyter notebooks for analysis and visualisation
├── src/ # Source code
│ ├── data/ # Data loading and processing
│ ├── models/ # GNN models and explainability methods
│ ├── multi_graph/ # Multi-level graph construction and models
│ ├── pipelines/ # End-to-end pipelines for different tasks
│ └── utils/ # Utility functions
├── README.md # This file
└── environment.yml # Conda environment file
This project includes a novel approach to GNN explainability through concept grounding. The src/models/graph_explainability directory contains the core components:
concept_grounding.py: The main module for generating explanations.llm_oracle.py: Uses a Large Language Model to generate concepts for hypernodes.embeddings_oracle.py: An embedding-based oracle for concept grounding.cg_evaluation_metrics.py: Implements metrics like "Concept Completeness" to evaluate the quality of explanations.If you use this work, please cite:
@misc{textualhgnn,
author = {Thiago Raulino {Dal Pont}},
title = {Textual Hierarchical Graph Neural Networks},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/thiagordp/TextualHGNN}}
}
This project is licensed under the MIT License. See the LICENSE file for details.
33 commits
Jupyter Notebook
84.0%
HTML
8.2%
Python
7.8%