tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Hugging Face > Text Summarization with Hugging Face BART

Text Summarization with Hugging Face BART

Author: Venkata Sudhakar

Text summarization condenses long documents into shorter, coherent summaries. This is especially useful in e-commerce settings where product specifications, user manuals, and customer feedback can be lengthy. Hugging Face provides a summarization pipeline backed by models like facebook/bart-large-cnn which is a BART model fine-tuned on the CNN/Daily Mail dataset for abstractive summarization. At ShopMax India, the product team uses summarization to condense lengthy vendor specifications into concise bullet points for the website.

The summarization pipeline accepts raw text and optional parameters like max_length and min_length to control the summary size. The model reads the full input and generates a shorter version in its own words, unlike extractive summarization which picks sentences directly from the source text.

The below example shows how to summarize a product specification document using the Hugging Face summarization pipeline.


It gives the following output,

Original length: 119 words
Summary: The ShopMax UltraBook Pro is a premium business laptop
for professionals. It features a 13th gen Intel Core i9, 32GB RAM,
2TB SSD, and a 15.6-inch 4K OLED display. It weighs 1.6kg and
starts at Rs 1,45,000.

The do_sample=False setting uses beam search decoding which produces more factual and consistent summaries compared to sampling. The max_length and min_length parameters are token counts, not word counts, so the actual word count of the summary may differ slightly. For batch processing at ShopMax India, you can pass a list of texts to the pipeline and it will return a list of summaries, significantly reducing the time needed to process large product catalogs.


 
  


  
bl  br