This repository contains an abstractive text summarization pipeline using a pre-trained encoder–decoder LLM (facebook/bart-base) fine-tuned on the BillSum dataset. The implementation follows the official Assignment 2 (Part IV) specification: fine-tune BART and evaluate using ROUGE, BLEU, and BERTScore.
- Task: Abstractive summarization of long-form legislative text
- Model:
facebook/bart-base(Transformer encoder–decoder) - Dataset: BillSum (US bills + human-written summaries)
- Framework: PyTorch + Hugging Face Transformers
- Metrics: ROUGE-1 / ROUGE-2 / ROUGE-L, BLEU, BERTScore
BillSum is a summarization dataset for US Congressional and California state bills, where the input is a legal document and the target is a human-written summary.
🔗 Dataset Link:
- Hugging Face: https://huggingface.co/datasets/billsum
Text and summaries are tokenized using BartTokenizer:
- Max input length:
1024tokens - Max target length:
256tokens - Truncation enabled to fit within model limits
Tokenized datasets are stored locally using load_from_disk() to avoid repeated preprocessing.
facebook/bart-base- Encoder–decoder Transformer designed for sequence-to-sequence generation
🔗 Model card:
The notebook fine-tunes BART using Hugging Face Trainer / Seq2SeqTrainer with generation enabled.
| Parameter | Value |
|---|---|
| Learning Rate | 5e-5 |
| Epochs | 3 |
| Train Batch Size | 4 |
| Eval Batch Size | 4 |
| Weight Decay | 0.01 |
| Evaluation Strategy | steps (eval_steps=100) |
| Generation Max Length | 128 |
| Checkpoint Saving | epoch (keep best 1) |
To make experimentation faster, the notebook trains and evaluates on a smaller subset:
- Train: 1000 samples
- Validation: 100 samples
- Test: 100 samples
The fine-tuned model achieves strong summarization performance on the test split.
| Metric | Score |
|---|---|
| ROUGE-1 | 0.4778 |
| ROUGE-2 | 0.2827 |
| ROUGE-L | 0.3507 |
| ROUGE-Lsum | 0.4064 |
- BLEU: 19.87
- BERTScore (F1 avg): 0.8820
These results exceed the expected thresholds mentioned in the assignment spec for BillSum.
Evaluation is performed using the evaluate library:
evaluate.load("rouge")evaluate.load("sacrebleu")evaluate.load("bertscore")
The notebook also prints example generated summaries vs reference summaries for qualitative inspection.
The workflow supports saving the best checkpoint during training (save_strategy="epoch") and reloading it later for evaluation / inference.
# Clone the repository
git clone https://github.com/<your-username>/bart-summarization-billsum.git
cd bart-summarization-billsum
# Install dependencies
pip install -r requirements.txt
# Run the notebook
jupyter notebook Summarization_using_LLMs.ipynbInside the notebook, you can generate a summary for any custom bill text:
- Tokenize input text
- Run
model.generate(...) - Decode tokens using
tokenizer.decode(...)
.
├── Summarization_using_LLMs.ipynb
├── README.md
├── requirements.txt
- Lewis et al., BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension (ACL 2020)
- Hugging Face BART model: https://huggingface.co/facebook/bart-base
- BillSum dataset: https://huggingface.co/datasets/billsum
evaluatelibrary: https://huggingface.co/docs/evaluate
This project was completed as part of CSE 676-B: Deep Learning at the University at Buffalo by Poojan Kaneriya (poojanra@buffalo.edu).
⭐ If this repo helped you, feel free to star it!