Few shot learning framework for Intent Detection using PyTorch and Huggingface. We use cross-encoders and parametric similarity functions for pairwise matching query samples with support samples. We implement balanced and unbalanced samplers to simulate a real-world setting where each support set class may not have an equal number of samples.
We used the Banking77 and Clinc150 datasets and split them into train-test-validation splits with mutually exclusive classes. We chose the IntenDD model as our encoder since it is pre-trained on intent detection data. We also implemented a learnable parametric function for similarity scoring. For episodic training, we follow https://aclanthology.org/2023.eacl-main.135.pdf. Since the datasets mentioned above are class-balanced, the approach for unbalanced sampling mentioned in the above paper won't work. Hence, we perform uniform sampling for n-way and k_shot for each class in each episode.
clinc150: https://arxiv.org/pdf/1909.02027v1.pdf dataset: https://paperswithcode.com/dataset/clinc150
The paper also implements the Liu54 and Hwu64 datasets for the balanced setting and ATIS19, SNIPS7 and TOP18 for the unbalanced settings. These datasets have not been implemented or tested in the code.  The above image shows the number of episodes and classes in each dataset split.    The authors follow https://aclanthology.org/2021.acl-long.191.pdf for balanced sampling  The authors follow https://aclanthology.org/2020.nlp4convai-1.12.pdf for unbalanced sampling refer to section 6.1 of the above paper for detailed unbalanced episode construction NOTE: since I have implemented the code only on the balanced datasets, the unbalanced sampler does not follow the procedure mentioned in the paper. Sampling n-way and k-shot for each episode can be changed in the samplers.py file. Comments indicate which lines can be changed for the new implementation.
I referenced the code from https://github.com/UKPLab/eacl2023-few-shot-intent-classification
python main.py
ToDo [] Add links to files, checkpoints and other resources [] Add requirements.txt