GithubHelp home page GithubHelp logo

linearized-attention-in-graph-transformers's Introduction

Evaluating the Impact of Linearized Attention vs Full-Attention in Graph Transformers

This project aims to investigate the impact of linearized attention mechanisms compared to the conventional full-attention mechanism. Specifically we explore Linformer and Performer adaptations from NLP to the graph domain.

Abstract

Transformers have revolutionized the field of Natural Language Processing (NLP). Its success has inspired adaptations across various domains, including graph representation learning. However, the conventional full-attention mechanism employed by transformers, suffers from quadratic time and memory complexity, which poses a challenge when dealing with large graphs. This project aims to assess the efficacy of linearized attention mechanisms in graph transformers, specifically comparing the traditional full-attention to the Linformer and Performer adaptations.

We evaluate the three mechanisms on three suitable benchmark datasets, based on their performance and efficiency. The findings show that while the full-attention model marginally outperforms the linearized models on most of the datasets, it requires significantly more memory on larger datasets. Our empirical evaluation indicates that the Performer model slightly surpasses the Linformer in performance, albeit at the cost of increased memory usage.

This research aims to make graph-based learning more scalable and efficient, thereby enabling broader application and research in this field.

Getting started:

Start by cloning the repository:

git clone https://github.com/anna-charlotte/linearized-attention-in-graph-transformers.git

Or via SSH:

git clone [email protected]:anna-charlotte/linearized-attention-in-graph-transformers.git

If you don't already have Poetry installed, by running the following command. More information on this can be found in the Poetry Documentation.

pip install poetry
poetry install --all-extras

Activate the virtual environment with:

poetry shell

You're now ready to replicate the study's findings.

Reproduce results:

Running the following commands will retrain the specified model on a dataset of your choice.

python src/graph-transformer/run_train.py  --model-type {MODELTYPE} --dataset {DATASET}

Set the model using --model-type {MODELTYPE} to be one of ["full-attention", "linformer", "performer"].
It defaults to full-attention".

Set the dataset using --dataset {DATASET} to be one of ["Citeseer", "Cora", "Pubmed"].
It defaults to Citeseer".

For example, the following retrains a linformer model on Citeseer:

python src/graph-transformer/run_train.py  --model-type linformer --dataset Citeseer

The evaluation scores are scored in plots/plotting_{DATASET}.json. To run the evaluation and plot the results, run:

python src/graph-transformer/plotting.py  --dataset {DATASET}

linearized-attention-in-graph-transformers's People

Contributors

anna-charlotte avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.