Downloads · 30 days
0
dwivediishivam/indoml
indoml is a machine learning model from dwivediishivam. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains the source code and resources for the report on "Intent Detection in Conversational Systems Using Few-shot Multi-class Classification" by Shivam Dwivedi and Chehak Malhotra. The research focus…
Downloads · 30 days
0
Access
Public
Updated Oct 22, 2023
Repo size
1.5 GB
Likes
0
Public
Click a slice to open those files.
.data1.4 GB · 58%
From the Hugging Face model README
This repository contains the source code and resources for the report on "Intent Detection in Conversational Systems Using Few-shot Multi-class Classification" by Shivam Dwivedi and Chehak Malhotra. The research focuses on intent recognition within conversational systems, framing it as a few-shot multi-class classification problem.
This project involves a multi-phase machine learning workflow, with the development (dev) phase to be executed locally in a terminal or system environment, and the final phase to be run in Google Colab. The project leverages transfer learning, requiring specific setup for BERT model and tokenizer files.
Clone the repository from Hugging Face to your local machine.
git clone <huggingface-repository-url>
cd <repository-directory>
Install required packages. It's recommended to use a virtual environment.
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
All code for the dev phase should be run locally. Make sure you are in the project's main directory.
python script1.py
python script2.py
The final phase code is intended to be run in Google Colab.
filename.ipynb notebook to your Google Colab.datafile.zip from the Hugging Face repository and upload it to Google Colab.For the transfer learning part of the project, you will need to download the BERT model and BERT tokenizer files and upload them to your Google Drive.
from google.colab import drive
drive.mount('/content/drive')
Navigate to the directory containing the BERT files in your notebook and set up the transfer learning as required by the project.
NOTE - > The final two codes are named final 1 and final 2
Support If you encounter any issues or have any questions, please open an issue in the Hugging Face repository, and we will get back to you as soon as possible. Reach out to [email protected] for a faster response.
Shivam Dwivedi and Chehak Malhotra
The field of natural language processing (NLP) has witnessed substantial advancements in recent years, with intent detection emerging as a critical component in conversational systems. This report delves into a comprehensive study conducted as part of Datathon@IndoML, focusing on the challenging task of intent recognition framed as a few-shot multi-class classification problem. The competition consisted of two main phases, with the final phase being the central subject of this report.
Note -> Validation scores are based on a train-test split of the given training data, whereas test scores are obtained after submission to the Codalab platform, using the competition's blind test data.
Initially, the development phase of the competition involved a similar intent recognition task but encompassed multiple languages and was based on a larger database. During this phase, various models such as BERT, XLNet, RoBERTa, and T5 were experimented with. However, T5 failed to produce satisfactory results. The accuracy scores achieved were as follows:
Upon finalizing BERT as the model of choice, further fine-tuning led to the following results on the test set:
In the final phase, basic models such as BERT, RoBERTa, DeBERTa, BART, XLNet, and T5 were revisited. The code for these experiments is housed in 'code1_initial_tests.py'. These models yielded accuracy scores ranging from 83% to 87% during validation testing. The insights drawn were as follows:
After the initial round of experiments, ensemble models were trained using combinations of BERT, RoBERTa, DeBERTa, and BART. These models were fine-tuned, and their performance was evaluated on the validation set. DeBERTa, when used in ensembles, consistently showed superior performance. The best ensemble model comprised BERT, RoBERTa, DeBERTa, and BART, achieving an accuracy of 92.59%, an F1 score of 92.55%, and a precision of 94.08%.
Ensemble of BERT:
Ensemble of RoBERTa:
Ensemble of DeBERTa:
Ensemble of BART:
Ensemble of BERT, RoBERTa:
Ensemble of BERT, DeBERTa:
Ensemble of BERT, BART:
Ensemble of RoBERTa, DeBERTa:
Ensemble of RoBERTa, BART:
Ensemble of DeBERTa, BART:
Ensemble of BERT, RoBERTa, DeBERTa:
Ensemble of BERT, RoBERTa, BART:
Ensemble of BERT, DeBERTa, BART:
Ensemble of RoBERTa, DeBERTa, BART:
Ensemble of BERT, RoBERTa, DeBERTa, BART:
Despite the promising results on the validation set, the performance on the actual test set (obtained after submitting predictions on the competition portal) was slightly lower, with the ensemble of all four models achieving 88.3% and the ensemble of RoBERTa and DeBERTa achieving 89.88%. Now this was close to the target we wanted to reach, but we still wanted to explore multiple other possibilities.
Following the experiments with transfer learning models, we sought to evaluate the performance of GPT models on the same intent recognition task. We utilized GPT-2, GPT-3.5, and GPT-4 for this purpose. The respective code for each model is saved in "Code 6," "Code 7," and "GPT4 Folder".
The accuracy scores achieved by the GPT models on the validation set are as follows:
From these results, it was evident that the GPT models, particularly GPT-2, were not as effective for this specific intent recognition task as the other models we had experimented with. GPT-4 showed a competitive performance, but it still lagged behind the best ensemble models we had developed. This led us to conclude that for this particular application, the transfer learning models, and especially the ensemble approaches, were more optimal than the GPT-based models.
Hugging Face’s repository is a treasure trove of pre-trained models, developed and fine-tuned by the global AI community on a plethora of datasets and for diverse tasks. We meticulously selected seven pre-trained models from the repository for our experiments. The details and the code related to these experiments are meticulously documented and can be found in the ‘Code3_testing-massive-optimised-libraries’ directory.
For the sake of maintaining the anonymity of the model creators and to uphold the integrity of our report, we have decided to refer to these models numerically, from 1 to 7. The results from our experiments, based on the validation set (train-test split), rounded off to the nearest integer, are as follows:
Despite the diversity in the models and the robustness of transfer learning as a strategy, the accuracies obtained were consistently lower than our previous attempts with other architectures and methodologies. This was a pivotal moment in our experimentation phase, prompting a reevaluation of our approach.
In the journey to optimize our model's performance for the intent recognition task, we revisited the model we had trained during the development phase. This phase was marked by a multitude of experiments with various architectures, eventually leading us to fine-tune a BERT model. The details of the experiments and the codes are preserved in 'code_final1-devmodel++', 'bert_model', and 'bert_tokenizer' directories.
Utilizing the model from the development phase, we employed basic transfer learning techniques to adapt the model to the current task. Further, in an attempt to boost performance, we experimented with ensembling this transfer model with previously tried-and-tested models, namely BERT and RoBERTa.
Test Results:
While these results were promising, they did not entirely meet our expectations. The primary challenge stemmed from the lower accuracy of the model in the development phase itself. Despite this, we have chosen to include this approach in our final report, as it represents a comprehensive and theoretically sound strategy, embodying our most ideal approach to date.
Motivated by our incessant quest for improvement, we proceeded to explore additional models and strategies. The code for this part of the experiment can be found in 'Code_final2_rob+deb2.ipynb'.
Model Selection: In this iteration, we opted to use 'RoBERTa Large' and 'DeBERTa V2 Large', given their state-of-the-art performance in various NLP tasks.
Test Results: The results from our final evaluation on the test set were as follows:
| Metric | Value |
|---|---|
| Accuracy | 0.9030 |
| F1 Score | 0.9016 |
| Precision | 0.9074 |
| Recall | 0.9030 |
These results underscored the efficacy of using state-of-the-art models like RoBERTa Large and DeBERTa V2 Large, showcasing a significant improvement in performance across all metrics.
Throughout our extensive experimentation and rigorous testing, we conducted numerous other tests and explored various models and strategies. While not all of them made it to this final report due to their relevance and impact on the final results, they were instrumental in shaping our understanding and approach. All the code files and notebooks pertaining to these experiments are diligently stored and documented in our repository for future reference and transparency.
In conclusion, our journey from the development phase to the final implementation was marked by trials, errors, and invaluable learning. The results from "Final Model 1' and 'Final Model 2' represent our best efforts and the pinnacle of our performance in this intent recognition task, showcasing the power of state-of-the-art models and the significance of a well-thought-out strategy in the realm of Natural Language Processing.
In this section, we will delve deeper into the results obtained from various experiments conducted throughout the final phase of Datathon@IndoML, focusing on the task of intent recognition framed as a few-shot multi-class classification problem.
In the outset of the final phase, we revisited basic models including BERT, RoBERTa, DeBERTa, BART, XLNet, and T5. The aim was to establish a baseline performance and understand how these models fare individually in the intent recognition task. RoBERTa and DeBERTa emerged as the top performers during the validation phase, outperforming BERT by approximately 2.4% and 6.5% respectively. On the contrary, BART and XLNet showcased underwhelming performance, while T5 once again failed to yield satisfactory results.
This initial round of experimentation set the stage for subsequent trials, providing valuable insights into the models' capabilities and limitations. The discrepancy in performance between the validation scores and the test scores obtained post-submission prompted us to delve deeper, exploring ensemble models and advanced transformer models to bridge this gap.
Moving forward, we experimented with ensemble models, leveraging combinations of BERT, RoBERTa, DeBERTa, and BART. The ensemble of BERT, RoBERTa, DeBERTa, and BART demonstrated promising results on the validation set, achieving an accuracy of 92.59%, an F1 score of 92.55%, and a precision of 94.08%. However, the performance on the test set post-submission was slightly lower, indicating the need for further exploration and optimization.
In parallel, we explored GPT-based models, specifically GPT-2, GPT-3.5, and GPT-4. Despite GPT-4's potential, it did not surpass the performance of our ensemble models, thereby affirming our decision to focus on ensemble strategies and transfer learning models for this particular task. The GPT models showcased varied results, with GPT-4 being the only model that demonstrated competitive performance, albeit still lagging behind our best ensemble models.
Our final leg of experimentation involved transfer learning, utilizing both a BERT model pre-trained during the development phase and several massive pre-trained models from the Hugging Face repository. The BERT model from the development phase, when adapted to the current task, showcased promising results, with the ensemble of Transfer Model, BERT, and RoBERTa achieving an accuracy of 89.68%.
However, the pre-trained models from the Hugging Face repository yielded lower accuracies compared to our previous experiments. Despite the extensive range of models explored, and the robustness of transfer learning as a strategy, the performance did not meet our expectations, underscoring the challenges and intricacies of the few-shot multi-class classification problem at hand.
Table: Test results of "Final Model 1"
| Model | Accuracy |
|---|---|
| Final Model 1 | 0.8623 |
Table: Test results of "Final Model 1 (Ensemble)"
| Model | Accuracy |
|---|---|
| Final Model 1 (Ensemble) | 0.8968 |
Table: Test results of "Final Model 2"
| Metric | Value |
|---|---|
| Accuracy | 0.9030 |
| F1 Score | 0.9016 |
| Precision | 0.9074 |
| Recall | 0.9030 |
The contribution of this study lies in its exploration of intent detection in conversational systems through the lens of few-shot multi-class classification. The approach is distinctive in several ways:
This report presents a thorough investigation into the application of few-shot multi-class classification for intent detection in conversational systems, conducted as part of Datathon@IndoML. The study traversed a wide array of models, from basic transformers to advanced GPT variants, and innovative ensemble techniques.
The developmental phase pinpointed BERT as a promising model, achieving an accuracy of 81.37% on the test set. However, the realization that further refinements could potentially boost performance laid the groundwork for the extensive experiments conducted in the final phase.
The final phase saw a range of experiments, from revisiting basic models and exploring ensemble models to delving into advanced transformer models and transfer learning. The ensemble models, particularly those based on DeBERTa, exhibited exceptional performance on the validation set. However, the discrepancy in performance on the test set underscored the need for further exploration.
GPT-based models provided varied results, with GPT-4 showing potential, though it did not surpass the ensemble models. The transfer learning experiments, utilizing pre-trained models and a model from the developmental phase, provided insights, though they did not achieve the highest performance.
In essence, this study provides a comprehensive analysis of intent recognition in few-shot multi-class classification settings, offering valuable insights and directions for future research in this domain. The methodologies employed, the range of models explored, and the rigorous evaluation conducted collectively contribute to the broader understanding of intent detection and few-shot learning in NLP.
Our experiments and results pave the way for future research, emphasizing the importance of ensemble techniques, the potential of transfer learning, and the need for further exploration and optimization in few-shot learning settings. The challenges encountered and lessons learned throughout this study underscore the intricacies of intent detection in conversational systems, illuminating paths for future advancements and innovations in this exciting field of NLP.