This project focuses on optimizing domain-specific question-answering (QA) systems using advanced fine-tuning and augmentation techniques. The goal is to enhance the performance of the Mistral 7B v0.2 model in medical HR applications, enabling accurate and efficient recruitment of medical professionals.
We evaluate three key approaches:
- Parameter-Efficient Fine-Tuning (PEFT)
- Retrieval-Augmented Generation (RAG)
- Retrieval-Augmented Fine-Tuning (RAFT)
- Base Model: Utilized the Mistral 7B v0.2 for its efficient architecture and strong NLP capabilities.
- Fine-Tuning: Implemented PEFT methods like LoRA and QLoRA for resource-efficient fine-tuning.
- Retrieval-Augmented Systems: Integrated RAG and RAFT to enhance response accuracy and context relevance.
- Domain-Specific Dataset: Trained and evaluated on the MedQuad-MedicalQnADataset.
- Hugging Face Account: Create an account here.
- Access Token: Generate a write-permissions token from your Hugging Face account.
-
Clone the repository:
git clone https://github.com/nimad70/mistral-qa-optimization.git cd mistral-qa-optimization -
Explore the repository for scripts and data relevant to your experiments.
- Notebook:
QADataset.ipynb - Steps:
- Run all cells to generate HR general and advanced medical QA datasets.
- Outputs are saved in both CSV and JSON formats.
- Notebook:
NLPProject_Dataset_MedicalQA.ipynb - Steps:
- Log in to Hugging Face with the generated access token.
- Load the
MedQuad-MedicalQnADatasetor other preferred datasets. - Adjust token limits and the
kparameter for dataset size. - Push the dataset to your Hugging Face repository.
- Notebook:
Mistral_7B_Instruct_v0_2_finetuning_medicaldb.ipynb - Steps:
- Define the base model (
Mistral 7B v0.2by default). - Customize fine-tuning parameters (temperature, top-p, etc.).
- Push the fine-tuned model to Hugging Face.
- Define the base model (
- Notebooks:
NLPProject_Mistral_7B_Intrsuct_v02_Prompting_QA(P1).ipynbNLPProject_Mistral_7B_Intrsuct_v02_Prompting_QA(P2-P5).ipynb
- Steps:
- Upload the HR and advanced medical QA datasets.
- Customize precision (
4-bitor8-bit) and pipeline parameters. - Save generated responses for evaluation.
- Notebooks:
NLPProject_Mistral2_7B_RAG.ipynbNLPProject_Mistral2_7B_RAG(FT).ipynb
- Steps:
- Upload research papers and QA datasets to the
papersdirectory in Colab. - Customize pipeline parameters.
- Save responses for evaluation.
- Upload research papers and QA datasets to the
- Notebook:
Mistral_7B_Instruct_v0_2_finetuning_medicaldb.ipynb - Steps:
- Upload research papers to the
papersdirectory in Colab. - Save and evaluate generated responses.
- Upload research papers to the
- Accuracy improved from 84.09% to 95.45%.
- Enhanced the model’s precision and contextual understanding through systematic tuning.
- Nima Daryabar
- Shakiba Farjood Fashalami
- Marcos Tidball
- Tobia Pavona
- Giacomo Ferrante
- Multilingual support.
- Real-time data integration.
- Scalability for larger LLMs.
Refer to the detailed Project Report for more insights into the methodologies and evaluations.
This project is licensed under the MIT License. See the LICENSE file for details.