Skip to content

About

AI summarizer and highlighter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

Repository files navigation

AI Text Summarizer

An AI-powered text summarization application built using Python, Streamlit, and Hugging Face Transformers.

The application helps users turn long pieces of text into shorter, easier-to-understand summaries. Users can paste text directly into the application or upload PDF and TXT documents. The application then uses pretrained Artificial Intelligence (AI) models, such as BART and T5, to generate a summary automatically.

1. Project Overview

Imagine you have a 20-page chapter to study, but you want to understand its main points quickly. Instead of reading every sentence again, you can use this application to generate a shorter version of the content.

The AI reads the provided text, identifies important information, and generates a concise summary.

Project detail Description
Project name AI Text Summarizer
Project type AI / Natural Language Processing (NLP)
Programming language Python
User interface Streamlit
AI framework Hugging Face Transformers
AI models BART and T5
Input formats Direct text, PDF, TXT
Output AI-generated text summary
Main objective Reduce lengthy text into shorter, meaningful content

2. Problem Statement

People often need to read large amounts of information from textbooks, research papers, reports, articles, and other documents.

Reading all this information takes time. Finding the most important points can also be difficult, especially when the document contains unnecessary details.

The AI Text Summarizer aims to solve this problem by automatically generating shorter versions of lengthy text while preserving its main ideas.

Project objectives

  • Reduce the time needed to review long documents.
  • Help students understand lengthy study materials more quickly.
  • Allow users to summarize text without manually rewriting it.
  • Provide a simple interface for text entry and document uploads.
  • Explore how pretrained AI models can be used for real-world NLP applications.

3. Features

Feature What it does
Direct text input Allows users to paste text into a text area.
PDF upload Allows users to upload PDF documents for text extraction and summarization.
TXT upload Allows users to upload plain-text files.
Multiple AI models Supports BART and T5 for summarization.
Adjustable summary length Allows users to set minimum and maximum summary lengths.
Cached model loading Helps avoid repeatedly loading the same model during a Streamlit session.
Custom interface Uses a pink, black, and white visual theme.
Background image Uses the custom chats.jpg image.
Two-column layout Separates the input and summary sections.
File name display Shows the name of the uploaded document.
Error handling Helps display errors when processing or summarization fails.

4. How the Application Works

The application follows a sequence of steps. Each step has a specific purpose.

System architecture

flowchart TD
    A["User"] --> B["Enter Text or Upload PDF/TXT"]
    B --> C["Extract Text from Document"]
    C --> D["Choose AI Model and Summary Length"]
    D --> E["BART or T5 Model"]
    E --> F["Generate Summary"]
    F --> G["Display Summary in Streamlit"]
    
    style A fill:#f7d6e6,stroke:#333,color:#222
    style B fill:#ffffff,stroke:#333,color:#222
    style C fill:#ffffff,stroke:#333,color:#222
    style D fill:#f7d6e6,stroke:#333,color:#222
    style E fill:#e8ddff,stroke:#333,color:#222
    style F fill:#ffffff,stroke:#333,color:#222
    style G fill:#f7d6e6,stroke:#333,color:#222
Loading

Step-by-step explanation

  1. Input: The user pastes text or uploads a PDF or TXT document.
  2. Text extraction: If a file is uploaded, the application extracts its readable text.
  3. Model selection: The user selects an available summarization model.
  4. Length settings: The user sets the minimum and maximum lengths of the summary.
  5. AI processing: The selected model processes the text and generates a summary.
  6. Output: The generated summary appears in the application interface.

The quality of the result depends on the original content, the selected model, the document length, and the model's limitations.

5. What Is the Input?

The input is the information the user gives to the application.

Input type Example What the application does
Direct text A paragraph copied from a textbook Processes the entered text
PDF file research_paper.pdf Extracts readable text from the PDF
TXT file chapter_notes.txt Reads the text contained in the file
Model selection BART or T5 Selects the AI model to use
Minimum summary length A user-defined value Sets a lower target for generated length
Maximum summary length A user-defined value Sets an upper target for generated length

Example input

A user enters the following paragraph:

Artificial Intelligence is a branch of computer science that focuses on building machines capable of performing tasks that usually require human intelligence. These tasks include learning, problem-solving, language understanding, and recognizing images. AI is used in healthcare, education, transportation, and many other industries.

The application sends this content to the selected summarization model.

6. What Is the Output?

The output is the shorter text generated by the AI model.

Example output

Artificial Intelligence enables machines to perform tasks such as learning, problem-solving, and language understanding. It is used in industries including healthcare, education, and transportation.

The summary is shorter than the original paragraph while retaining its central message.

Note: This is an illustrative example. The actual output will depend on the model and its settings.

Input versus output

Original text Generated summary
Contains more details and explanations Focuses on the main ideas
Usually longer Usually shorter
Provided by the user Generated by the AI
May be a PDF, TXT file, or pasted text Displayed as text in the application

The application does not automatically guarantee that every important detail will be retained. Users should check the generated summary before relying on it.

7. AI Models Used

The application uses pretrained models available through Hugging Face Transformers.

A pretrained model is an AI system that has already learned patterns from a large amount of data. Instead of building and training a model from the beginning, this project uses an existing model to generate summaries.

Model 1: BART

Model identifier: facebook/bart-large-cnn

BART is a transformer-based language model that can generate summaries by understanding the input text and producing a shorter version.

It is commonly used for summarizing news articles and other longer pieces of text.

Model 2: T5

Model identifier: t5-base

T5 stands for Text-to-Text Transfer Transformer. It treats many language tasks as converting one piece of text into another.

For summarization, the application provides the input text to the model and receives a shorter text as the output.

Model comparison

Property BART T5
Model identifier facebook/bart-large-cnn t5-base
Model family BART T5
Main approach Generates text using a sequence-to-sequence architecture Converts input text into output text
Typical use Summarization and other NLP tasks Summarization and other text-processing tasks
Training Pretrained and fine-tuned for summarization Pretrained; summarization performance depends on how it is prompted or fine-tuned
Main consideration Can miss details or generate inaccurate information May require appropriate task prompting and configuration

The two models may produce different summaries for the same document. Their quality and speed should be compared using the same input texts and evaluation criteria.

8. Technologies Used

Technology Purpose
Python Implements the application's processing logic
Streamlit Creates the interactive web interface
Hugging Face Transformers Loads and runs the pretrained AI models
BART Generates summaries using a summarization-oriented model
T5 Generates summaries using a text-to-text model
PDF-processing library Extracts text from PDF files
Python caching Reduces repeated model-loading work
HTML/CSS styling, if used Customizes the interface's appearance

The exact PDF-processing library and additional dependencies should be confirmed from the project's source code and requirements.txt.

9. Application Interface

The application has two main sections.

Input section

  • Paste text into the input area.
  • Upload a PDF or TXT document.
  • View the uploaded file name.
  • Select the AI model and adjust summary length, where supported by the interface.

Summary section

  • View the generated summary.
  • Compare the summary with the original content.
  • Review the result for missing details or incorrect statements.

The interface uses a pink, black, and white theme, a custom chats.jpg background, and a responsive two-column layout.

The interface is designed to make the process of submitting content and viewing the result straightforward.

10. Installation and Setup

Prerequisites

Install the following before running the project:

  • Python
  • pip, the Python package installer
  • A code editor such as Visual Studio Code
  • An internet connection for downloading pretrained models when they are not already cached

Step 1: Clone the repository

If the project is available on GitHub, open a terminal and run:

git clone <YOUR_GITHUB_REPOSITORY_URL>
cd <YOUR_PROJECT_FOLDER>

Replace the placeholders with your actual repository URL and project folder name.

Alternatively, download the repository as a ZIP file and extract it.

Step 2: Create a virtual environment

python -m venv venv

Activate it on Windows:

.\venv\Scripts\Activate.ps1

If you use Command Prompt instead of PowerShell:

venv\Scripts\activate.bat

Step 3: Install dependencies

Ensure that the project contains a requirements.txt file listing the required Python packages.

Run:

pip install -r requirements.txt

If installation fails, check the Python version and the package versions supported by your project.

Step 4: Run the application

If your Streamlit entry-point file is named app.py, run:

streamlit run app.py

If your main Python file has a different name, replace app.py with the correct filename.

Streamlit will provide a local URL, usually http://localhost:8501, where you can open the application in your browser.

Step 5: Start summarizing

  1. Open the application.
  2. Paste some text or upload a supported document.
  3. Select the model and summary settings.
  4. Run the summarization process.
  5. Review the generated summary.

11. Suggested Project Structure

The following is an example of how the project files could be organized. It is not a claim about the exact current folder structure.

AI-Text-Summarizer/
│
├── app.py
├── requirements.txt
├── README.md
├── chats.jpg
│
├── assets/
│   └── screenshots/
│
└── venv/

Explanation:

File or folder Purpose
app.py Contains the Streamlit application code, if this is the entry-point filename
requirements.txt Lists the Python packages needed to run the application
README.md Explains the project, installation, features, and limitations
chats.jpg Custom background image
assets/screenshots/ Optional location for application screenshots
venv/ Local virtual environment containing installed dependencies

Do not upload the local venv/ directory to GitHub. It can be recreated by installing the packages listed in requirements.txt.

12. Current Limitations

The current design provides a useful starting point, but there are several areas where its accuracy, performance, and usability can be improved.

Limitation Why it matters Possible improvement
Long document handling Transformer models have input-length limits, so very long documents may be truncated or rejected Split documents into smaller chunks and summarize them in stages
Summary accuracy The AI may omit important facts or generate statements that are not supported by the source Add source-summary comparisons and factuality checks
PDF text extraction Image-based or scanned PDFs may not contain extractable text Add Optical Character Recognition (OCR)
Processing speed Large models can take time to load and generate summaries Optimize inference and use suitable hardware
Hardware requirements Large models can require considerable RAM or GPU memory Offer smaller models and configurable resource usage
Summary length Minimum and maximum settings do not guarantee a particular word count in every situation Validate the settings and measure the final output length
Model differences BART and T5 can produce different results for identical input Add consistent model comparison and evaluation
Limited evaluation A summary may look readable but still omit important information Test with reference summaries and automated evaluation metrics
Language support Performance may vary across languages Evaluate and add models designed for additional languages
Error handling Invalid files, empty input, or model failures can interrupt the workflow Add clearer validation, error messages, and recovery options
Interface customization The current design primarily focuses on submitting text and viewing summaries Add summary download, word counts, and a history of recent results

These limitations describe potential issues with the current design. Their exact severity depends on the implementation and the documents being tested.

13. Future Improvements and Development Roadmap

The next development steps should focus on reliability first, followed by better summarization quality and additional user features.

Phase 1: Improve document processing

  • Add chunking for long documents.
  • Combine summaries from multiple chunks into one final summary.
  • Detect empty or unreadable PDF and TXT files.
  • Add OCR support for scanned PDFs.

Phase 2: Improve summary quality

  • Compare BART and T5 using the same collection of documents.
  • Add ROUGE scores to measure overlap with reference summaries.
  • Consider BERTScore or human evaluation to assess semantic similarity.
  • Add checks for missing facts and unsupported statements.

ROUGE and BERTScore provide useful evaluation signals, but neither guarantees factual correctness.

Phase 3: Improve the user interface

  • Add a download button for summaries in TXT or PDF format.
  • Show the original and summarized word counts.
  • Display the percentage reduction in text length.
  • Add a clear loading indicator during summarization.
  • Improve error messages for unsupported or unreadable files.
  • Add a document history feature, with appropriate privacy controls.

Phase 4: Improve speed and resource usage

  • Measure model loading time and summarization time.
  • Cache models to avoid unnecessary reloads.
  • Test CPU and GPU inference where supported.
  • Evaluate smaller models for devices with limited memory.

Phase 5: Add advanced features

  • Generate summaries in bullet points.
  • Support multiple languages using suitable models.
  • Allow users to choose between short, medium, and detailed summaries.
  • Add keyword extraction and important-topic identification.
  • Explore question-answering over uploaded documents.

14. Recommended Next Improvement

The most useful next step is to implement long-document summarization using chunking.

Currently, a long document may exceed the input capacity of a model. Simply increasing the requested summary length does not solve this problem because the input text itself can exceed the model's limits.

How chunking works

flowchart TD
    A["Long PDF or TXT Document"] --> B["Extract All Readable Text"]
    B --> C["Split Text into Smaller Chunks"]
    C --> D["Summarize Chunk 1"]
    C --> E["Summarize Chunk 2"]
    C --> F["Summarize Chunk 3"]
    D --> G["Combine Intermediate Summaries"]
    E --> G
    F --> G
    G --> H["Generate Final Summary"]
    
    style A fill:#f7d6e6,stroke:#333,color:#222
    style C fill:#e8ddff,stroke:#333,color:#222
    style G fill:#ffffff,stroke:#333,color:#222
    style H fill:#f7d6e6,stroke:#333,color:#222
Loading

For example, a long document could be divided into 10 smaller sections. The application summarizes each section and then combines those intermediate summaries into one final summary.

The actual number of chunks depends on the document length and the model's token limit.

This improvement would make the application more practical for textbooks, reports, and research papers. The chunking process must preserve context and avoid losing important information between sections.

15. Testing and Evaluation

Before considering the project complete, test it with different types of input.

Test case Expected behavior
Short paragraph Generates a concise summary
Long article Summarizes the text or handles it through chunking
Valid TXT file Extracts and summarizes the text
Text-based PDF Extracts readable text and summarizes it
Scanned PDF Reports unreadable text or processes it using OCR, if implemented
Empty input Displays a validation message
Unsupported file type Rejects the file with a clear message
Invalid summary settings Displays an error or requests valid settings
Same text with BART and T5 Produces summaries that can be compared
Very long document Handles model input limits without silently losing critical content

Useful evaluation metrics

  • ROUGE: Measures overlap between a generated summary and a reference summary.
  • BERTScore: Measures semantic similarity using contextual language representations.
  • Processing time: Measures how long the model takes to generate a summary.
  • Compression ratio: Measures how much shorter the summary is than the original.
  • Human evaluation: Checks readability, relevance, factual accuracy, and whether important points were retained.

For a meaningful evaluation, use multiple documents and compare both models on the same inputs.

16. Privacy and Responsible Use

  • Do not upload confidential, personal, or sensitive documents unless the application's data handling and deployment environment are appropriate for that information.
  • Do not assume that uploaded documents are automatically stored or deleted; this depends on the implementation and hosting setup.
  • Review generated summaries before using them in academic, professional, or research work.
  • Treat the AI-generated text as assistance rather than a guaranteed replacement for the original document.
  • Respect copyright when uploading, summarizing, or distributing document content.

17. Learning Outcomes

Building this project provides practical experience with:

  • Python application development.
  • Streamlit-based user interfaces.
  • Natural Language Processing (NLP).
  • Pretrained transformer models.
  • Text extraction from PDF and TXT files.
  • Configurable text generation.
  • Model loading and caching.
  • Input validation and error handling.
  • AI evaluation and responsible development.

18. Conclusion

The AI Text Summarizer demonstrates how pretrained Generative AI models can turn lengthy text into shorter, more manageable summaries.

By combining Python, Streamlit, Hugging Face Transformers, BART, and T5, the project provides a simple interface for summarizing pasted text and uploaded documents.

The next stage should focus on reliable long-document processing, summary accuracy, systematic evaluation, and better user controls. These improvements can turn the current application into a more robust tool for students, researchers, and other users who work with large amounts of text.

19. Author and Contribution

This project can be extended with new summarization models, improved document processing, evaluation methods, and interface features.

Contributions may include reporting bugs, suggesting improvements, testing different document formats, or developing additional features.

About

AI summarizer and highlighter.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages