Loading data...

vtucircle » BAIL657C Program 7

BAIL657C Program 7

PROGRAM:

# Required libraries (install before running this script):
# pip install transformers torch

from transformers import pipeline  # Import the summarization pipeline from Hugging Face Transformers

# Load a smaller and faster pre-trained model for summarization
# 't5-small' is lightweight and quick, ideal for small/medium passages
summarizer = pipeline("summarization", model="t5-small")

# Input text to be summarized
text = """
The Industrial Revolution, which took place from the 18th to the 19th centuries, was a period during which predominantly agrarian, rural societies in Europe and America became industrial and urban. Prior to the Industrial Revolution, manufacturing was often done in people’s homes, using hand tools or basic machines. Industrialization marked a shift to powered, special-purpose machinery, factories and mass production. The iron and textile industries, along with the development of the steam engine, played central roles in the Industrial Revolution, which also saw improved systems of transportation, communication and banking. While industrialization brought about an increased volume and variety of manufactured goods and an improved standard of living for some, it also resulted in often grim employment and living conditions for the poor and working classes.
"""

# Generate the summary of the input text
summary = summarizer(text, max_length=60, min_length=30, do_sample=False)

# Print the summarized output
print(summary[0]['summary_text'])

OUTPUT:

the Industrial Revolution took place from the 18th to the 19th centuries . the industrial revolution marked a shift to powered, special-purpose machinery, factories and mass production . iron and textile industries, along with the development of the steam engine, played central roles .
guest
1 Comment
Inline Feedbacks
View all comments
seemakhan
seemakhan
18-05-2025 1:29 PM

Sir please upload the codes for program no 4,8,9,10 asap

1
0
Would love your thoughts, please comment.x
()
x