Summarizing Text with Transformers and deploying it as Gradio App

Arsh Anwar
3 min readOct 14, 2022

--

We are in the 21st Century where everyone is busy in their small world. We don’t have time to read Large articles, texts, posts, or news. That is why we are always looking for something which can be understood at a glance while commuting, having coffee, or walking. Due to the time limitation apps like Inshorts, Google News is offering a summarised view of the article which can be easily glanced at. That summarised view is nothing but a summary of the whole article and the tech used in it is called Text Summarisation.

Text Summarisation can be achieved in two ways:

  • Extractive method: Choosing the n most significant sentences from the article that most likely capture its main ideas.
  • Abstractive Methods: Using LSTM (Long Short Term Memory) networks and other deep learning principles. Using this method creates a completely new summary of the article that includes sentences that aren’t even part of the original text.

We will be using Abstractive Methods for Text Summarisation.

Image Source: towardsai.net

In Today’s blog, we will create a Pipeline that not only Summarizes Text but also give Sentiment Analysis for that text.

We are going to create this pipeline with Transformers.

Let’s begin

Importing Libraries

import gradio as grfrom articles import * # this is a local module, you can find in code repofrom transformers import pipeline

Creating our Pipeline

Here, we are creating our summarise pipeline which first summarises the text and then runs the sentiment Analysis.
In this pipeline, Summarisation can be done with 3 models here:

  • Facebook’s Large BART
  • Distil BART
  • Google’s Pegasus XSum

Building Gradio App

We are going to create our Gradio App and run it on port 8080

Test Drive

Running our App

Voila! it runs, Now we will work on deploying this.

Deployment

We are going to use TrueFoundry for our deployment

Logging into TrueFoundry

Heading to Deployment Section

1) Creating a new deployment

2) Select the Service option and Workspace name

3) Fill out properties and submit

4) Deploying

5) Successful Deployment

6) Final Thoughts

After the deployment is done, you will be able to use the Gradio App.

The app is deployed here: https://text-summarizer-arsh-dev.tfy-ctl-euwe1-develop.develop.truefoundry.tech/

Video

Code

The above code is also present in my Repository

References:

  1. TrueFoundry: https://truefoundry.com/
  2. TrueFoundry App: https://app.truefoundry.com/
  3. TrueFoundry Docs: http://docs.truefoundry.com/
  4. Code: https://github.com/d4rk-lucif3r/Text-Summarisation-with-Sentiment-Analysis

--

--

Arsh Anwar
Arsh Anwar

Written by Arsh Anwar

AI/ML expert. Built LuciferML (120k+ downloads). Co-founder @Revca, building smart solutions for a sustainable future.

No responses yet