With the arrival of chatbots like ChatGPT, there is now an AI-powered tool that can help summarize texts with remarkable speed and accuracy. ChatGPT has powerful natural language processing capabilities that allow it to analyze texts and identify key information to summarize.
Text summarization reduces a large body of text to a shorter, more manageable version that retains the main ideas and key points. It is an important skill for anyone who needs to quickly process large volumes of information, such as researchers, students, and professionals.
Fortunately, with natural language processing (NLP) technology advancements, tools such as ChatGPT is now available to make summarizing text easier and more efficient. ChatGPT is an open-source language model developed by OpenAI that uses deep learning algorithms to generate human-like responses to text inputs.
How to Use ChatGPT to Summarize Text?
Using ChatGPT for text summarization is a straightforward process that involves a few simple steps. Here is a step-by-step guide on how to use ChatGPT for text summarization:
Step 1 Go to the ChatGPT website and input the text you want to summarize.
Step 2 Choose the length of the summary in terms of sentences or words, then click “Enter.”
Step 3 Wait for ChatGPT to generate the summary, which may take a few seconds.
Step 4 Review and refine the summary for clarity and accuracy.
Additionally, you can include prompts such as “Summarize the following text in 200 words” or “Translate the following text into English and then summarize it in 200 words” to customize the summary length or language translation options.
import os
from openai import OpenAI
#adding api key as environment variable
os.environ["OPENAI_API_KEY"] = "Your API Key"
client = OpenAI()
def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = client.chat.completions.create(
model=model,
messages=messages,
temperature=0
)
return response.choices[0].message.content
prod_review = """
Got this panda plush toy for my daughter's birthday, \
who loves it and takes it everywhere. It's soft and \
super cute, and its face has a friendly look. It's \
a bit small for what I paid though. I think there \
might be other options that are bigger for the \
same price. It arrived a day earlier than expected, \
so I got to play with it myself before I gave it \
to her.
"""
prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site.
Summarize the review below, delimited by triple
backticks, in at most 30 words.
Review: ```{prod_review}```
"""
response = get_completion(prompt)
print(response)
Output: plush toy is loved by the reviewer’s daughter, but they feel it is a bit small for the price.
Summarize multiple product reviews
review_1 = prod_review
# review for a standing lamp
review_2 = """
Needed a nice lamp for my bedroom, and this one \
had additional storage and not too high of a price \
point. Got it fast - arrived in 2 days. The string \
to the lamp broke during the transit and the company \
happily sent over a new one. Came within a few days \
as well. It was easy to put together. Then I had a \
missing part, so I contacted their support and they \
very quickly got me the missing piece! Seems to me \
to be a great company that cares about their customers \
and products.
"""
# review for an electric toothbrush
review_3 = """
My dental hygienist recommended an electric toothbrush, \
which is why I got this. The battery life seems to be \
pretty impressive so far. After initial charging and \
leaving the charger plugged in for the first week to \
condition the battery, I've unplugged the charger and \
been using it for twice daily brushing for the last \
3 weeks all on the same charge. But the toothbrush head \
is too small. I’ve seen baby toothbrushes bigger than \
this one. I wish the head was bigger with different \
length bristles to get between teeth better because \
this one doesn’t. Overall if you can get this one \
around the $50 mark, it's a good deal. The manufactuer's \
replacements heads are pretty expensive, but you can \
get generic ones that're more reasonably priced. This \
toothbrush makes me feel like I've been to the dentist \
every day. My teeth feel sparkly clean!
"""
# review for a blender
review_4 = """
So, they still had the 17 piece system on seasonal \
sale for around $49 in the month of November, about \
half off, but for some reason (call it price gouging) \
around the second week of December the prices all went \
up to about anywhere from between $70-$89 for the same \
system. And the 11 piece system went up around $10 or \
so in price also from the earlier sale price of $29. \
So it looks okay, but if you look at the base, the part \
where the blade locks into place doesn’t look as good \
as in previous editions from a few years ago, but I \
plan to be very gentle with it (example, I crush \
very hard items like beans, ice, rice, etc. in the \
blender first then pulverize them in the serving size \
I want in the blender then switch to the whipping \
blade for a finer flour, and use the cross cutting blade \
first when making smoothies, then use the flat blade \
if I need them finer/less pulpy). Special tip when making \
smoothies, finely cut and freeze the fruits and \
vegetables (if using spinach-lightly stew soften the \
spinach then freeze until ready for use-and if making \
sorbet, use a small to medium sized food processor) \
that you plan to use that way you can avoid adding so \
much ice if at all-when making your smoothie. \
After about a year, the motor was making a funny noise. \
I called customer service but the warranty expired \
already, so I had to buy another one. FYI: The overall \
quality has gone done in these types of products, so \
they are kind of counting on brand recognition and \
consumer loyalty to maintain sales. Got it in about \
two days.
"""
reviews = [review_1, review_2, review_3, review_4]
for i in range(len(reviews)):
prompt = f"""
Your task is to generate a short summary of a product \
review from an ecommerce site.
Summarize the review below, delimited by triple \
backticks in at most 20 words.
Review: ```{reviews[i]}```
"""
response = get_completion(prompt)
print(i, response, "\n")
Output:
0 Panda plush toy is loved by daughter, soft and cute, but small for the price. Arrived early.
1 Great lamp with storage, fast delivery, excellent customer service, and easy assembly. Highly recommended.
2 The reviewer recommends the electric toothbrush for its impressive battery life, but criticizes the small brush head.
3 The reviewer found the price increase after the sale disappointing and noticed a decrease in quality.
Fascinating blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple tweeks would really make my blog shine. Please let me know where you got your design. Thanks a lot
Nice post. I was checking constantly this blog and I’m impressed! Very useful information specially the last part 🙂 I care for such information much. I was seeking this particular information for a long time. Thank you and best of luck.
Definitely, what a splendid site and illuminating posts, I will bookmark your site.All the Best!
I have realized some important things through your site post. One other subject I would like to mention is that there are numerous games on the market designed specially for toddler age children. They include things like pattern recognition, colors, creatures, and patterns. These generally focus on familiarization as an alternative to memorization. This will keep children and kids occupied without feeling like they are learning. Thanks
Hi this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding skills so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!