The official Pytorch implementation of the paper "Fourier Transformer: Fast Long Range Modeling by Removing Sequence Redundancy with FFT Operator" (ACL 2023 Findings)
Python
40
1 commits
updated Mar 7, 2024
This is the official Pytorch implementation of paper Fourier Transformer: Fast Long Range Modeling by Removing Sequence Redundancy with FFT Operator
git clone https://github.com/LUMIA-Group/FourierTransformer.git
cd FourierTransformer
pip install -e .
For faster training, install NVIDIA's apex library following fairseq.
# Download files for preprocessing
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/encoder.json'
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/vocab.bpe'
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/dict.txt'
# BPE
for SPLIT in train val test; do \
python -m examples.roberta.multiprocessing_bpe_encoder \
--encoder-json encoder.json \
--vocab-bpe vocab.bpe \
--inputs pile/${SPLIT}.raw.en \
--outputs pile/${SPLIT}.bpe.en \
--keep-empty \
--workers 120; \
done
# Binarize
fairseq-preprocess \
--only-source \
--source-lang "en" \
--srcdict dict.txt \
--trainpref pile/train.bpe \
--validpref pile/val.bpe \
--testpref pile/test.bpe \
--destdir pile-bin \
--workers 60
rename files in pile-bin by removing ".en".
Download, Preprocess and Binarize: Follow this script.
Fine-tuning Fourier Transformer on CNN-DM summarization task:
cd Summarization
sh submits/cnn-dm.sh
Evaluate:
For calculating rouge, install files2rouge from here.
sh submits/eval-cnn-dm.sh
Download, Preprocess and Binarize: Follow this script.
Fine-tuning Fourier Transformer on ELI5 QA task:
cd Summarization
sh submits/eli5.sh
Evaluate:
sh submits/eval_eli5.sh
As mentioned in our paper, the code for LRA is build from this repository. Please follow the scripts there to prepare the datasets.
To run LRA experiments,
cd LRA/code
sh run_tasks.sh
Feel free to play with different settings by modifying lra_config.py
Python
95.5%
Shell
2.9%
The official Pytorch implementation of the paper "Fourier Transformer: Fast Long Range Modeling by Removing Sequence Redundancy with FFT Operator" (ACL 2023 Findings)
Python
40
1 commits
updated Mar 7, 2024
This is the official Pytorch implementation of paper Fourier Transformer: Fast Long Range Modeling by Removing Sequence Redundancy with FFT Operator
git clone https://github.com/LUMIA-Group/FourierTransformer.git
cd FourierTransformer
pip install -e .
For faster training, install NVIDIA's apex library following fairseq.
# Download files for preprocessing
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/encoder.json'
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/vocab.bpe'
wget -N 'https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/dict.txt'
# BPE
for SPLIT in train val test; do \
python -m examples.roberta.multiprocessing_bpe_encoder \
--encoder-json encoder.json \
--vocab-bpe vocab.bpe \
--inputs pile/${SPLIT}.raw.en \
--outputs pile/${SPLIT}.bpe.en \
--keep-empty \
--workers 120; \
done
# Binarize
fairseq-preprocess \
--only-source \
--source-lang "en" \
--srcdict dict.txt \
--trainpref pile/train.bpe \
--validpref pile/val.bpe \
--testpref pile/test.bpe \
--destdir pile-bin \
--workers 60
rename files in pile-bin by removing ".en".
Download, Preprocess and Binarize: Follow this script.
Fine-tuning Fourier Transformer on CNN-DM summarization task:
cd Summarization
sh submits/cnn-dm.sh
Evaluate:
For calculating rouge, install files2rouge from here.
sh submits/eval-cnn-dm.sh
Download, Preprocess and Binarize: Follow this script.
Fine-tuning Fourier Transformer on ELI5 QA task:
cd Summarization
sh submits/eli5.sh
Evaluate:
sh submits/eval_eli5.sh
As mentioned in our paper, the code for LRA is build from this repository. Please follow the scripts there to prepare the datasets.
To run LRA experiments,
cd LRA/code
sh run_tasks.sh
Feel free to play with different settings by modifying lra_config.py
Python
95.5%
Shell
2.9%