Views
No views yet

python==3.8.12, transformers==4.15.0, pytorch==1.10.0 with cuda 12.0. Please create a conda environment and install the required packages with requirements.txt.# Clone this repo
git clone https://github.com/skleee/GLEN.git
cd GLEN
# Set conda environment
conda create -n glen python=3.8
conda activate glen
# Install tevatron as editable
pip install --editable .
# Install dependencies
pip install -r requirements.txt
pip install torch==1.10.0+cu111 torchvision==0.11.0+cu111 torchaudio==0.10.0 -f https://download.pytorch.org/whl/torch_stable.htmlgit clone https://github.com/luyug/GradCache
cd GradCache
pip install .data folder. The structure of each folder is as follows.data
├── BEIR_dataset
│ ├── arguana
│ └── nfcorpus
├── nq320k
└── marco_passage/examples folder, we provide GLEN code for each phase: glen_phase1, glen_phase2. Please refer to src/tevatron for the trainer.
Run the scripts to train GLEN from the scratch for NQ320k or MS MARCO.# (1) Keyword-based ID assignment
sh scripts/train_glen_p1_nq.sh# (2) Ranking-based ID refinement
sh scripts/train_glen_p2_nq.sh# (1) Keyword-based ID assignment
sh scripts/train_glen_p1_marco.sh# (2) Ranking-based ID refinement
sh scripts/train_glen_p2_marco.sh
sh scripts/eval_make_docid_glen_nq.sh
sh scripts/eval_inference_query_glen_nq.shsh scripts/eval_make_docid_glen_marco.sh
sh scripts/eval_inference_query_glen_marco.sh# Arguana
sh scripts/eval_make_docid_glen_arguana.sh
sh scripts/eval_inference_query_glen_arguana.sh# NFCorpus
sh scripts/eval_make_docid_glen_nfcorpus.sh
sh scripts/eval_inference_query_glen_nfcorpus.sh @inproceedings{lee-etal-2023-glen,
title = "{GLEN}: Generative Retrieval via Lexical Index Learning",
author = "Lee, Sunkyung and
Choi, Minjin and
Lee, Jongwuk",
editor = "Bouamor, Houda and
Pino, Juan and
Bali, Kalika",
booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
month = dec,
year = "2023",
address = "Singapore",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.emnlp-main.477",
doi = "10.18653/v1/2023.emnlp-main.477",
pages = "7693--7704",
}1git clone <repository-url>
2cd GLEN-model1# Windows
2python -m venv .env
3.env\Scripts\activate
4
5# Linux/Mac
6python -m venv .env
7source .env/bin/activatepip install -r requirements.txt1mkdir -p logs/test_glen_vault
2mkdir -p data/the_vaultthe_vault_dataset directory:the_vault_dataset/
├── DOC_VAULT_train.tsv
├── GTQ_VAULT_train.tsv
└── GTQ_VAULT_dev.tsv1python scripts/preprocess_vault_dataset.py \
2 --input_dir the_vault_dataset/ \
3 --output_dir data/the_vault/ \
4 --sample_size 1000 \
5 --create_test_setbash scripts/test_small_training.shlogs/test_glen_vault/
├── GLEN_P1_test/ # Phase 1 model
├── GLEN_P2_test/ # Phase 2 model
└── GLEN_P2_test_docids.tsv # Generated document IDsbash scripts/train_full_vault.shlogs/glen_vault/
├── GLEN_P1/ # Phase 1 model
├── GLEN_P2/ # Phase 2 model
└── GLEN_P2_docids.tsv # Generated document IDs1python examples/glen_phase2/evaluate_glen.py \
2 --model_name_or_path logs/glen_vault/GLEN_P2 \
3 --infer_dir logs/glen_vault/GLEN_P2 \
4 --dataset_name the_vault \
5 --docid_file_name GLEN_P2_docids \
6 --per_device_eval_batch_size 1 \
7 --q_max_len 32 \
8 --num_return_sequences 5 \
9 --logs_dir logs/glen_vaultGLEN-model/
├── data/
│ └── the_vault/ # Processed dataset
├── examples/
│ ├── glen_phase1/ # Phase 1 implementation
│ └── glen_phase2/ # Phase 2 implementation
├── logs/
│ ├── test_glen_vault/ # Test run outputs
│ └── glen_vault/ # Full training outputs
├── scripts/
│ ├── preprocess_vault_dataset.py
│ ├── test_small_training.sh
│ └── train_full_vault.sh
├── .env/ # Virtual environment
├── requirements.txt # Python dependencies
└── README.md # This file