Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    ChatGPT AI - Product Review Summary (Difficulty 4)

    Tutorials
    1
    1
    882
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by info-creaticode

      Introduction

       

      AI models like ChatGPT can be used for much more than chat applications. For example, they can read, write and understand natural languages, so they can be used to build text-processing tools, such as text summarization. Today, we are surrounded by massive amounts of information — websites, books, blog posts — and reading everything is often impossible. A tool that can automatically generate a concise summary can save readers a lot of time.

      In this tutorial, you’ll use ChatGPT to summarize product reviews. For example, a popular product on Amazon may have thousands of reviews in different languages. Since it’s not practical to read through them all, we’ll build a solution where ChatGPT reads the reviews and produces a summary for us.

      As the tool runs, ChatGPT will continually refine the summary as it processes more reviews:

      c2.gif

       
       

      Step 1 - Start from a Template Project

       
      Let’s begin by remixing the following starter project:

      play.creaticode.com/projects/ca4bbe666a1934bab795661b

       
      This project already includes a table named “reviews” containing 100 reviews for a toy product. Each entry includes a star rating, subject and review details.

      c1.gif

       
      There are many ways to collect such review data, but that part is outside the scope of this tutorial. Here, we’ll focus on using ChatGPT to process and summarize the reviews.

       
       

      Step 2 - Understand the Core Idea

       
      Before we jump into coding, let’s break down the main challenge.

      We know ChatGPT can summarize any given text. The problem is that we can’t send a lot of reviews at once. For example, 1000 reviews averaging 20 words each would be 20,000 words total — far more than what ChatGPT can handle.

      So, how do we make ChatGPT read all the reviews and still produce a single coherent summary?

      Think of it like adding up 1000 numbers, but you can only add 2 numbers at a time. You’d add the first two, then add the result to the next number, and so on.

      We’ll use the same strategy here:

      1. Get an initial summary of the first few reviews.
      2. Give ChatGPT a batch of new reviews along with the previous summary, and ask it to update the summary.
      3. Repeat this process until all reviews are processed.

      This method is called incremental summarization — and we’re going to build it step by step.

       
       

      Step 3 - Print the First Review

       
      Let’s start small. Read the first review in the reviews table and print it out.

      We’ll ignore the star rating and just use the “subject” and “details” columns. Here’s how to store them in two variables, combine them, and print to the console:
       

      97015a8b-bf3c-425e-ad90-494762697ec5-image.png

       
       

      Step 4 - Print the First 20 Reviews

       
      Next, use a loop to read the first 20 rows of the reviews table, one by one. Start with an empty string in the reviews variable, then append each review to it:

      f765ed54-bbdf-40c2-a23a-29e498a0e93f-image.png

       
      Note that we include a “\n” after each review, so the next review will start on a new line. Here is what we get in the console panel:

       
      22403c30-1ec0-4b52-8973-2c201221a3fc-image.png
       

      Even with just 20 reviews, it’s already hard to read and find patterns. Let’s automate that.

       
       

      Step 5 - Create a “get reviews” Block

       
      Since we’ll be reading different sets of reviews many times, let’s turn this into a reusable block called get reviews.

      It should take two inputs: the first row number and the last row number, and store the result in the reviews variable:

      a9ffc306-6f24-4962-9f98-bfa8b1906251-image.png

       
       

      Step 6 - Generate the Initial Summary

       
      Now that we’ve collected 20 reviews, it’s time to generate the initial summary using ChatGPT. The prompt will start with "Summarize these product reviews: ", and then we will append the 20 reviews we have collected.

      b5e3fa9c-23ab-4f4b-a862-a51758806646-image.png

       
      We’re using the waiting mode here for simplicity. You should get something like this printed:

      aa05fd07-6592-4d44-a7c4-2adf7e66c9a1-image.png

       
       

      Step 7 - Improve the Summary Format

       
      The single long paragraph isn’t very readable. Let’s improve it by asking ChatGPT to return bullet points of pros and cons. Note this is a very concise prompt composed of a Task and an Instruction, based on the TIRE prompting method.

      a3b3645c-71c0-4624-8887-11882dd03833-image.png

       
      Now you’ll get something much easier to skim:

      a5198b54-122a-4773-b909-187f2295c502-image.png

       
       

      Step 8 - Reduce Duplicates

       
      Now let’s tackle another common problem in the response: repetition. You may notice similar points like:

      • “Fragile and not made of sturdy plastic”
      • “Not made as sturdy as old transformers”

       
      We can try to ask ChatGPT to improve the answer like this:


      Summarize these product reviews as bullet points with pros and cons. Skip similar points.


      Still, you might get too many overlapping items:

      3d17eefc-ce55-419a-be3a-d859f0172103-image.png

       
      It appears that ChatGPT is not well-trained in removing similar points. Can you find a clever way to solve this issue?

       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       

      ✅ Better Fix: Limit the Number of Bullet Points
      You can control this better by simply limiting the number of items:

      Summarize these product reviews as bullet points with the top 3 pros and cons.

       
      Now the summary is cleaner and more focused:

      aa52722e-2e6c-40ed-b5bd-2c79d9c4d72f-image.png

       
       

      Step 9 - Load the Next 20 Reviews

       
      Let’s read the next 20 reviews and print them out:

      d41982a9-eecd-4221-923e-6c9016b11bba-image.png

       
      They look like this in the console panel:

      976641c5-67bc-4355-9237-acbf542e6ddd-image.png

       
       

      Step 10 - Update the Summary

       
      Now we’ll use both the existing summary and the new reviews to create an updated summary.

      Your prompt will include:

      1. The current summary + the current summary
      2. The new batch of reviews + all the new reviews
      3. Instruction to update the summary

      Here’s the structure:

      Part 1:

      Here is a summary of a product from some customer reviews:

       
      Part 2:

      Here are some new customer reviews:

       
      Part 3:

      Now please update the summary above based on the new customer reviews above. Use the same format of bullet points of the top 3 pros and cons.

       
      And here’s the code to build and send this prompt by joining 5 variables into one prompt:

      20e9526c-43e8-4f22-a5fe-08883d9c8bb6-image.png

       

      Here is the updated summary we get, which is based on all 40 reviews:

      05284dde-7d27-42c0-9e5e-3f1147fb5a64-image.png

       
       

      Step 11 - Process All Reviews in Batches

       
      Now loop through the remaining reviews. Use a variable called start row, and increment it by 20 each time (e.g., 21, 41, 61, 81). The end row is always start row plus 19 for each batch.

      c04a8ddc-6977-413a-9de3-f3a45d6da556-image.png

       
       

      Step 12 - Show the Summary on Stage

       
      Instead of printing the final summary to the console, display it in a textbox on the stage.

      Add the textbox at the start of your program and update its value with the summary:

      924e36e4-8a29-4e26-9dbf-d0df23d3c641-image.png

       
      Here is what we will get when we run the program:

      c2.gif

       
       

      Additional Challenges

       
      Ready to extend the project? Try some of these ideas:

      • Filter by Category: Add a dropdown menu for users to choose a category (e.g., “ease of use”, “durability”, “appearance”). Summarize only reviews that match that category.
      • Summarize Other Content: Apply this technique to summarize other sources — like school-wide survey responses, news articles, or even book chapters.
      • Answer a Specific Question: Instead of creating a general summary, allow the user to input a custom question — such as “Is this toy suitable for 8-year-olds?” Then process all the reviews in batches and have ChatGPT generate an answer based on all the reviews.
      1 Reply Last reply Reply Quote 0
      • Pinned by  info-creaticode info-creaticode 
      • First post
        Last post