Downloads · 30 days
3
7% of all-time downloads
pkaustubh4/QnA_BERT
QnA_BERT is a question answering model from pkaustubh4. Use it when the input is a question plus a passage. It is set up for transformers. The card lists the license as mit.
This repository contains code to train a Question Answering model using the DistilBERT architecture on the SQuAD (Stanford Question Answering Dataset) dataset. The model is trained to answer questions based on a given…
Downloads · 30 days
3
7% of all-time downloads
All-time downloads
44
Public
Repo size
782 MB
Likes
0
Public
Click a slice to open those files.
.bin261 MB · 50%
From the Hugging Face model README
This repository contains code to train a Question Answering model using the DistilBERT architecture on the SQuAD (Stanford Question Answering Dataset) dataset. The model is trained to answer questions based on a given context paragraph. The training process utilizes PyTorch, the Hugging Face transformers library, and the datasets library.
Before running the code, make sure you have the following installed:
NVIDIA GPU (for faster training, optional but recommended) NVIDIA CUDA Toolkit (if using GPU) Python 3.x Jupyter Notebook or another Python environment
You can set up your environment by running the following commands:
!nvidia-smi # Check GPU availability
!pip install -q transformers datasets torch tqdm
Loading and Preprocessing Data: The code loads the SQuAD dataset and selects a subset for training. You can adjust the subset_size variable to control the size of the subset.
Tokenization and Dataset Creation: The QADataset class is defined to preprocess and tokenize the data for training. It converts question and context pairs into tokenized format suitable for DistilBERT input. It also prepares the start and end positions for the answers in the context.
Model Configuration: The model is based on the DistilBERT architecture, specifically the "distilbert-base-cased" version.
Training Loop: The code sets up a training loop for a specified number of epochs. It trains the model to predict the start and end positions of the answer span in the context paragraph.
Saving the Model: The final trained model is saved to a specified directory in Google Drive. You can adjust the final_model_output_dir variable to change the save location.
To train the model, follow these steps:
This code is provided under the MIT License. Feel free to modify and use it as needed.