🚀 Live Demo: Try the application on Hugging Face Spaces
A full-stack web application that generates concise summaries from user-provided text. The backend uses a T5-small transformer model served through a FastAPI endpoint, while the frontend provides a minimal interface for text input and summary display.
- Text input via a web-based interface
- Server-side summarization using a T5-small model with beam search decoding
- Automatic device selection (CUDA, MPS, or CPU)
- Input preprocessing: whitespace normalization, HTML tag removal, case folding
- Asynchronous request handling via FastAPI
| Layer | Technology |
|---|---|
| Backend | Python, FastAPI, Uvicorn |
| Frontend | HTML, CSS, JavaScript |
| ML | Hugging Face Transformers, PyTorch |
| Model | T5-small |
| Templating | Jinja2 |
- Architecture: T5-small (Text-to-Text Transfer Transformer)
- Input format: Raw text prefixed with
summarize: - Tokenization:
T5Tokenizerwith padding and truncation at 512 tokens - Decoding: Beam search (
num_beams=4) withmax_length=150and early stopping - Inference: Runs under
torch.no_grad()for reduced memory usage
text-summarizer/
├── app/
│ ├── app.py # FastAPI application and inference logic
│ ├── static/
│ │ ├── style.css # Frontend styles
│ │ └── script.js # Client-side form handling and API calls
│ └── templates/
│ └── index.html # Main UI template (Jinja2)
├── requirements.txt # Python dependencies
├── test-cases.md # Test scenarios and expected outputs
└── .gitignore
1. Clone the repository
git clone https://github.com/unnat-git/Text-Summarizer.git
cd Text-Summarizer2. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows3. Install dependencies
pip install -r requirements.txt4. Run the application
uvicorn app.app:app --reloadThe application will be available at http://127.0.0.1:8000.
- Open the application in a browser.
- Enter or paste text into the input field.
- Click Summarize.
- The generated summary appears below the input area.
The /summarize endpoint also accepts direct POST requests:
curl -X POST http://127.0.0.1:8000/summarize \
-H "Content-Type: application/json" \
-d '{ "dialogue": "Your text here." }'- Support for additional input formats (PDF, URL extraction)
- Adjustable summary length parameter
- Response caching for repeated inputs
- Containerized deployment (Docker)
- Hosting on a cloud platform (Render, Railway)
Built with ❤️ as a portfolio project showcasing NLP, deep learning, and full-stack Python development.