https://github.com/amazon-science/label-aware-pretrain
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: amazon-science
- License: apache-2.0
- Language: Python
- Default Branch: main
- Size: 741 KB
Statistics
- Stars: 18
- Watchers: 8
- Forks: 2
- Open Issues: 7
- Releases: 0
Metadata Files
README.md
Label Semantic Aware Pre-training for Goal-oriented Dialogue
This repository contains code for replicating the experiments of our project, Label Semantic Aware Pre-training for Goal-oriented Dialogue. In particular, we focus on few-shot intent classification.
Training scripts are located in scripts/. PyTorch code is located in models/. Data and preprocessing scripts are located in data/.
Dependencies
- python==3.8.0
- torch==1.8.1
- transformers==4.6.0
Use the environment.yml file to replicate our conda environment: conda env create -f environment.yml.
Data Format
For our experiments, we convert the intent labels into a natural language format like "Book hotel" or "airline". Each dataset is preprocessed into .json files, where train, dev, and test examples are of the following format:
{"translation": {"src": <utterance>, "tgt": <intent>, "prefix": "intent classification: "}}
The placement of the MASK tokens depends on the format used during preprocessing.
Preprocessing
Our preprocessing script is in models/preprocessor.py. This script roughly replicates the preprocessing logic of the TensorFlow code used in the original T5 paper, while also adding additional preprocessing methods. We found label noising to be the most effective approach, and the most robust to noisy data. To run preprocessing, first ensure that you have a .json file in the format specified above.
Then, run the following command:
python preprocessor.py <json_data> --labelsemantics <label_semantics_type>
where <label_semantics_type> can be one of the following:
- concat: append intents to utterances, noise spans in the source sequence using the same 15% span noising approach as T5. Reconstruct noised spans in the target sequence.
- full label: append MASK token after utterance in source sequence. Target sequence is the intent.
- multiple choice: use the format "intents:
This will output a file in the same directory as the <json_data> file, with the .tok suffix added as well as a suffix indicating the label semantics type.
Continued Pre-training
To run continued pre-training, use the cpt bash scripts in the scripts folder. These scripts call the models/run_cpt.py script, which performs continued pre-training (i.e., a second stage of pre-training after the first) using T5 as the pre-trained base model. We use a batch size of 128 and initial learning rate of 5e-4 for our experiments, using defaults otherwise.
We generally find that the best results occur at epochs 3--4, though we train our models for 10 epochs such that we can verify convergence.
Evaluation
Use the finetune scripts in the scripts folder to run fine-tuning on the evaluation sets. We use finetune_t5_full.sh to run evaluation in the full-resource setting.
To replicate our evaluation setup in the low-resource case, use analysis/fewshot_graph.py by moving to the analysis directory and running the following command:
python fewshot_graph.py <fewshot_dir> <test_file>
where <fewshot_dir> is a directory containing files named train_<num_examples>_examples.json, with <num_examples> being the number of utterances per intent. This script will produce the following:
- A graph of intent classification accuracy at each few-shot split size, where accuracy is averaged across 5 random seeds for each split size. Also plots std. dev. in shaded regions around the means.
- Macroaveraged IC accuracies across split sizes for each model.
- A table of statistical significances between the mean IC accuracies of each model at each split size.
Security
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.
Owner
- Name: Amazon Science
- Login: amazon-science
- Kind: organization
- Website: https://amazon.science
- Twitter: AmazonScience
- Repositories: 80
- Profile: https://github.com/amazon-science
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 2
- Total pull requests: 9
- Average time to close issues: N/A
- Average time to close pull requests: about 2 months
- Total issue authors: 2
- Total pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 0.33
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 9
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- zhengyuyingzyy (1)
- tiangxiaohu (1)
Pull Request Authors
- dependabot[bot] (8)