This repository provides tools to train and evaluate a custom text summarization model. It includes:
- Training Script (
train.py
): Fine-tunes a BERT-based Encoder-Decoder model for summarization tasks. - Inference Script (
inference.py
): Generates summaries using the fine-tuned model. - API Script (
inference_API.py
): Enables web-based summarization via a Hugging Face-hosted API which is being used in the deployed Webapp.
- Custom Training: Fine-tune a summarization model on any dataset.
- Inference Locally: Use the trained model for local summarization.
- API Deployment: Leverage Hugging Face API for web app integration.
-
Clone this repository:
git clone https://github.com/BEASTBOYJAY/Ai-Summarizer.git cd Ai-Summarizer
-
Install dependencies:
pip install -r requirements.txt
-
Prepare your dataset.
- Default:
train.py
uses thecnn_dailymail
dataset. - Modify
train.py
to include your dataset if needed.
- Default:
-
Train the model:
python train.py
Output: A trained model saved in the
./results
directory.
-
Ensure the trained model is saved in a directory.
-
Use the
inference.py
script:python inference.py
Replace
model_path
with the directory containing your fine-tuned model.
-
Set up your Hugging Face model and API token:
- Upload your fine-tuned model to Hugging Face.
- Add your API token in
inference_API.py
.
-
Run the API script:
python inference_API.py
python train.py
from inference import TextSummarizer
summarizer = TextSummarizer(model_path="./results/last-checkpoint")
summary = summarizer.summarize("Your text here.")
print(summary)