This is the code for the EACL2021 paper, [Few-shot Semantic Parsing for New Predicates].
- Cuda 10.2
conda env create -f environment.ymlconda activate few-shot-semantic-parsingpip install transformers
./pull_dependency.sh
Download the pre-trained models from Google Drive, and copy them to the corresponding folders.
- Copy [ATIS pre-trained model for one-shot learning] to
saved_models/atis/freq_0/and unzip it. - Copy [ATIS pre-trained model for two-shot learning] to
saved_models/atis/freq_50/and unzip it. - More pre-trained models will be provided if needed.
This is to generate the sequences of actions that could construct the logical forms.
- Atis
python preprocess_data/atis/generate_examples.py - Geo
python preprocess_data/geo/generate_examples.py - Jobs
python preprocess_data/jobs/generate_examples.py
You could either download the pre-trained models from the corresponding links or pre-train the parser yourself.
- ATIS one-shot:
./scripts/atis/one_shot/train.sh 0 1 pretrain - ATIS two-shot:
./scripts/atis/two_shot/train.sh 0 1 pretrain - Geo one-shot:
./scripts/geo/one_shot/train.sh 0 1 pretrain - Geo two-shot:
./scripts/geo/two_shot/train.sh 0 1 pretrain - Jobs one-shot:
./scripts/jobs/one_shot/train.sh 0 1 pretrain - Jobs two-shot:
./scripts/jobs/two_shot/train.sh 0 1 pretrain
- ATIS one-shot:
./scripts/atis/one_shot/fine_tune.sh saved_models/atis/freq_0/pretrained_model_name.bin [0..4] [1..2] - ATIS two-shot:
./scripts/atis/two_shot/fine_tune.sh saved_models/atis/freq_50/pretrained_model_name.bin [0..4] [1..2] - Geo one-shot:
./scripts/geo/one_shot/fine_tune.sh saved_models/geo/freq_0/pretrained_model_name.bin [0..4] [1..2] - Geo two-shot:
./scripts/geo/two_shot/fine_tune.sh saved_models/geo/freq_50/pretrained_model_name.bin [0..4] [1..2] - Jobs one-shot:
./scripts/jobs/one_shot/fine_tune.sh saved_models/jobs/freq_0/pretrained_model_name.bin [0..4] [1..2] - Jobs two-shot:
./scripts/jobs/two_shot/fine_tune.sh saved_models/jobs/freq_0/pretrained_model_name.bin [0..4] [1..2]
If you have any questions, please open an issue on Github or contact me via [email protected]. I am also happy to collobrate with others on the semantic parsing task based on this work. If you find this code useful, please cite:
@inproceedings{li2021few,
title={Few-Shot Semantic Parsing for New Predicates},
author={Li, Zhuang and Qu, Lizhen and Huang, Shuo and Haffari, Gholamreza},
booktitle={Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume},
pages={1281--1291},
year={2021}
}