Learn how to use LLMs to summarize text — with length control, focus by attribute, information extraction, and batch summarization of multiple reviews.
review = """Got this panda plush toy for my daughter's birthday, who loves it
and takes it everywhere. It's soft and cute but a bit small for the price.
Arrived a day earlier than expected."""
prompt = f"""
Your task is to generate a short summary of a product review
from an e-commerce website.
Summarize the review below, delimited by triple backticks, in at most 30 words.
Review: ```{review}```
"""
print(get_completion(prompt))
✅ Output: Soft and cute panda plush toy loved by daughter, bit small for price, arrived early.
💡 You can swap
30 wordswith3 sentencesor280 charactersto control length differently.
Focus on Shipping:
prompt = f"""...Summarize in at most 30 words, focusing on any aspects
that mention shipping and delivery.
Review: ```{review}```
"""
✅ Output highlights: arrived a day earlier than expected
Focus on Price/Value:
prompt = f"""...Summarize in at most 30 words, focusing on aspects
relevant to price and perceived value.
Review: ```{review}```
"""
✅ Output highlights: price may be too high for the size
When you want only the specific info (no extras):