Skip to content

tashfiqul-islam/bengali-text-summarizer-website

Repository files navigation

Bengali Text Summarizer Logo Bengali Text Summarizer

An advanced web application for efficiently summarizing Bengali news articles.


Python PyTorch NumPy Pandas Hugging Face

NextJS React Node.js NPM TypeScript TailwindCSS Framer Motion Lucide React Lucide React ESLin Next License


πŸ“š Table of Contents


πŸ” Project Overview

Bengali Text Summarizer is a web application developed as part of the CSE499B Senior Design Project II for the B.Sc. final year project. It allows users to input Bengali news articles and generate concise summaries, addressing the challenge of navigating through vast amounts of Bengali news content efficiently.

🌐 Key Components

  1. Web Crawler: Initially developed to fetch articles from various Bengali newspaper portals.
  2. Data Collection: Gathered articles and summaries from multiple sources.
  3. Model Training: Utilized a pre-trained model (google/mt5-small) with a Seq2Seq architecture.
  4. Web Interface: Built using Next.js 15 and React 19 for a responsive and user-friendly experience.

🎯 Problem Statement

The proliferation of Bangla news portals presents a challenge in navigating so many articles within a limited time, compounded by the language's inherent complexity.

  • πŸ“ˆ Overwhelming volume of Bengali news content online
  • ⏳ Limited time for comprehensive reading
  • πŸ”€ Inherent complexity of the Bengali language
  • 🧠 Difficulty in quickly grasping essential information from articles

✨ Features

  • πŸ“ Input Bengali news articles
  • πŸ€– Generate concise summaries
  • πŸ“Š Responsive design for various devices
  • πŸŒ“ Dark mode support

🧠 Model Architecture

Our summarization model is based on the Seq2Seq architecture using the pre-trained google/mt5-small model and MT5Tokenizer.


πŸ“Š Dataset Statistics

Set Metric Text (token count) Summary (token count)
Training Mean length 1576.52 61.15
Max length 9645 316
Min length 23 5
Std length 943.45 25.43
Validation Mean length 1266.48 56.78
Max length 2559 105
Min length 153 22
Std length 540.35 17.93
Test Mean length 1302.62 57.51
Max length 2548 105
Min length 182 21
Std length 542.46 17.75

πŸ’» Model Code Snippet


import torch
from transformers import MT5ForConditionalGeneration, MT5Tokenizer

model_name = "google/mt5-small" tokenizer = MT5Tokenizer.from_pretrained(model_name) model = MT5ForConditionalGeneration.from_pretrained(model_name)

Tokenize the datasets

train_inputs = tokenize_data(df_4_train, max_length=512, max_target_length=100) val_inputs = tokenize_data(df_4_val, max_length=512, max_target_length=100) test_inputs = tokenize_data(df_4_test, max_length=512, max_target_length=100)

Training arguments

training_args = Seq2SeqTrainingArguments( output_dir="./results", eval_strategy="epoch", learning_rate=1e-5, per_device_train_batch_size=8, per_device_eval_batch_size=8, num_train_epochs=5, weight_decay=0.01, save_total_limit=2, predict_with_generate=True, save_safetensors=False )


πŸ“ˆ Training Results

Epoch Training Loss Validation Loss
1 1.046200 0.692979
2 1.015400 0.683604
3 1.027700 0.676918
4 0.988000 0.672858
5 0.994400 0.671896

πŸ“ Project Structure


src /
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── bts-summarize               // BTS summarization API endpoint
β”‚   β”œβ”€β”€ fonts                           // Custom fonts directory
β”‚   β”œβ”€β”€ globals.css                     // Global CSS styles
β”‚   β”œβ”€β”€ layout.tsx                      // Root layout component
β”‚   └── page.tsx                        // Home page component
β”œβ”€β”€ component/
β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”œβ”€β”€ footer.tsx                  // Footer component
β”‚   β”‚   └── NavigationBar.tsx           // Navigation bar component
β”‚   β”œβ”€β”€ page-contents/
β”‚   β”‚   β”œβ”€β”€ AdditionalContents/
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthDialog.tsx          // User authentication dialog
β”‚   β”‚   β”‚   β”œβ”€β”€ FacultyAdvisor.tsx      // Faculty advisor details
β”‚   β”‚   β”‚   β”œβ”€β”€ ProjectMetadata.tsx     // Brings back project metadata together
β”‚   β”‚   β”‚   β”œβ”€β”€ ProjectOverview.tsx     // Project overview section
β”‚   β”‚   β”‚   β”œβ”€β”€ StatsCard.tsx           // Statistical metrics card
β”‚   β”‚   β”‚   β”œβ”€β”€ TeamMembers.tsx         // Team members list
β”‚   β”‚   β”‚   └── TrainingChart.tsx       // Training data chart
β”‚   β”‚   └── SummaryGenerator/
β”‚   β”‚       β”œβ”€β”€ ArticleInput.tsx        // Input for articles to summarize
β”‚   β”‚       β”œβ”€β”€ ArticleList.tsx         // List of articles
β”‚   β”‚       β”œβ”€β”€ ArticleSummary.tsx      // Summarized article display
β”‚   β”‚       β”œβ”€β”€ CategoryList.tsx        // Article category list
β”‚   β”‚       β”œβ”€β”€ Header.tsx              // Header for Summary Generator
β”‚   β”‚       β”œβ”€β”€ MainContent.tsx         // Main content area
β”‚   β”‚       β”œβ”€β”€ Sidebar.tsx             // Sidebar navigation
β”‚   β”‚       └── SummaryGenerator.tsx    // Main Summary Generator component
β”‚   └── ui                              // Shadcn UI components
β”œβ”€β”€ context/
β”‚   └── ThemeContext.tsx                // Theme context for app theming
β”œβ”€β”€ hooks/
β”‚   └── useSummaryGenerator.tsx         // Custom hook for Summary Generator
└── lib/
    β”œβ”€β”€ constants.ts                    // Application-wide constants
    β”œβ”€β”€ errors.ts                       // Error handling utilities
    β”œβ”€β”€ huggingface.ts                  // Hugging Face API utilities
    β”œβ”€β”€ types.ts                        // TypeScript types and interfaces
    β”œβ”€β”€ utils.ts                        // Utility functions
    └── validation.ts                   // Data validation functions


πŸš€ Installation

  1. Clone the repository:
  2. git clone https://github.com/your-username/bengali-text-summarizer.git
  3. Navigate to the project directory:
  4. cd bengali-text-summarizer
  5. Install dependencies:
  6. npm install
  7. Start the development server:
  8. npm run dev

πŸ–₯ Usage

  1. Open your browser and navigate to http://localhost:3000
  2. Input a Bengali news article in the provided text area
  3. Click the "Summarize" button
  4. View the generated summary

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.