Code Monkey home page Code Monkey logo

gape's Introduction

Bridging Graph Position Encodings for Transformers with Weighted Graph-Walking Automata

This repository contains the code for the paper "Bridging Graph Position Encodings for Transformers with Weighted Graph-Walking Automata" (Soga and Chiang, 2023).

Structure

There are 2 main directories in this repository. graphs contains code for running the graph dataset experiments, and mt contains code for running the machine translation experiments.

Setup

To set up the environment for graphs, we recommend creating a new virtual environment with Python 3.10. Run

python -m venv ~/.virtualenvs/gape-graphs

To install dependencies for graphs, run the following:

  1. cd graphs
  2. source ~/.virtualenvs/gape-graphs/bin/activate
  3. pip3 install -r requirements.txt

Dependencies for mt require an environment with Python 3.7 instead, which is easy to install separate from your main installation with Conda. Run the following after deactivating gape-graphs:

  1. cd mt
  2. conda env create -f environment.yml
  3. conda activate gape-mt

Run the shell scripts in graphs/data/ to download the graph datasets. Run any preparation scripts in each dataset's respective folder. The only exception is OGB-PCQM4Mv2 which is downloaded automatically upon running graphs/scripts/run_OGB_graph_regression.sh. The English-Vietnamese sentence pairs are already in mt/nmt/data.

Running the Experiments

Graphs

Bash scripts to test each PE per dataset are located in graphs/scripts. By default, the scripts assume only one GPU and run experiments for each PE in series over 4 random seeds. The evaluation metrics and training outputs are logged in DEBUG.log.

MT

To verify the BLEU scores in the paper, run python bleu.py OUT-[model]-[expected BLEU] nmt/data/en2vi/test.vi.tok substituting the model name and the expected BLEU score. To train a model, run train.sh replacing the PE variable in TASK=${SL}2${TL}_${PE} with the desired PE scheme. See nmt/configurations.py for the list of PE schemes and their hyperparameters.

References

Below is a table of all references and sources of code that is not ours.

Reference Code Repository
Dwivedi et al. (2020) Graph transformer implementation, data preparation, and training & evaluation code benchmarking-gnns
Dwivedi et al. (2022) Random walk PE implementation gnn-lspe
Kreuzer et al. (2021) Spectral attention node PE implementation SAN
Nguyen Transformer implementation for MT witwicky
Ying et al. (2021) Shortest-path distance & centrality PE and Floyd-Warshall implementation Graphormer

gape's People

Contributors

patricksoga avatar ajb117 avatar

Watchers

 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.