This repository implements a SpanBERT-based Question Answering model enhanced with a Conditional Random Field (CRF) layer for improved answer span prediction on the SQuAD v2.0 dataset.
- Fine-tuned SpanBERT: Optimized for span-based QA tasks
- CRF Enhancement: Improved boundary detection for answer spans
- SQuAD v2.0 Support: Handles both answerable and unanswerable questions
- Reproducibility: Fully functional in Jupyter Notebook/Google Colab
- Custom Tooling: Specialized evaluation and prediction pipelines
├── spanbert-crf.ipynb # Main training/evaluation notebook
├── data/ # Dataset-copy (optional)
├── models/ # Saved model and checkpoints with weights & tokenizer
├── outputs/ # Training logs & prediction outputs
├── README.md # Project documentation
└── requirements.txt # Python dependencies
-
Clone the repository:
git clone https://github.com/riju-talk/SpanBERT-CRF.git cd SpanBERT-CRF
-
Install dependencies:
pip install -r requirements.txt
-
Run the notebook:
- Local Execution:
jupyter notebook spanbert-crf.ipynb
- Google Colab: Upload
spanbert-crf.ipynb
and run interactively
- Local Execution:
- Exact Match (EM): 90% (dev set, Base Model 90% using trainer objects from HuggingFace)
- Exact Match (EM): 57% (dev set, SPANBERT-CRF Model 90% using trainer objects from HuggingFace)
Predict answers from context/question pairs:
from inference import predict_answer
context = "The quick brown fox jumps over the lazy dog."
question = "What does the fox jump over?"
answer = predict_answer(context, question)
print(f"Predicted Answer: {answer}") # Output: "the lazy dog"
- Hyperparameter tuning experiments
- CLI/API interface for model serving
- FastAPI deployment setup
- Cross-dataset evaluation (HotpotQA, Natural Questions)