{"id":52230,"date":"2025-09-17T00:00:00","date_gmt":"2025-09-17T07:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/sentiment-analysis-on-product-reviews-using-openai\/"},"modified":"2026-03-30T11:23:51","modified_gmt":"2026-03-30T18:23:51","slug":"sentiment-analysis-on-product-reviews-using-openai","status":"publish","type":"post","link":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/","title":{"rendered":"Sentiment Analysis on Product Reviews using OpenAI"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>This article explores a practical implementation of sentiment analysis on product reviews using OpenAI&#8217;s large language models (LLMs) and GridDB. The project involves extracting review data, analyzing sentiment using AI, and efficiently storing and querying the results. It&#8217;s an example of how modern AI tools and database systems can be combined to process and understand massive amounts of customer feedback.<\/p>\n<h2>Why Use AI for Sentiment Analysis?<\/h2>\n<p>Manual analysis of customer sentiment is impossible at scale due to the sheer volume of user-generated content. Artificial intelligence, especially LLMs like OpenAI\u2019s GPT, enables automated analysis with human-level language understanding.<\/p>\n<p>Key advantages include:<\/p>\n<ul>\n<li><strong>Scalability<\/strong>: AI can process millions of reviews quickly and consistently.<\/li>\n<li><strong>Context Awareness<\/strong>: LLMs are capable of identifying sarcasm, subtle opinions, and emotional tone.<\/li>\n<li><strong>Language Versatility<\/strong>: These models handle slang, informal language, and multilingual text more effectively than rule-based systems.<\/li>\n<\/ul>\n<p>AI-driven sentiment analysis helps businesses track public opinion, improve customer service, and guide product development based on real user feedback.<\/p>\n<h2>Running the Project<\/h2>\n<h3>Clone the Repository<\/h3>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">git clone https:\/\/github.com\/junwatu\/sentiment-analysis-griddb.git\ncd app\nnpm install<\/code><\/pre>\n<\/div>\n<h3>Setup Environment Variables<\/h3>\n<p>Create a <code>.env<\/code> file in the <code>app<\/code> directory of the project and add the following environment variables:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">OPENAI_API_KEY=\nGRIDDB_WEBAPI_URL=\nGRIDDB_USERNAME=\nGRIDDB_PASSWORD=\nVITE_BASE_URL=http:\/\/localhost:3000<\/code><\/pre>\n<\/div>\n<p>You can copy the <code>.env.example<\/code> file to <code>.env<\/code> and fill in the values. To get the OpenAI API key, read this <a href=\"#openai\">section<\/a> and for GridDB Cloud, read this <a href=\"#griddb-cloud-setup\">section<\/a>. By default, the <code>VITE_BASE_URL<\/code> is set to <code>http:\/\/localhost:3000<\/code> but you can change it to your own domain.<\/p>\n<h3>Run the Project<\/h3>\n<div class=\"clipboard\">\n<pre><code>npm run start<\/code><\/pre>\n<\/div>\n<h3>Access the Project<\/h3>\n<p>If you don&#8217;t change the <code>VITE_BASE_URL<\/code>, open your browser and navigate to <code>http:\/\/localhost:3000<\/code> to access the project.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png\" alt=\"\" width=\"2560\" height=\"1451\" class=\"aligncenter size-full wp-image-32433\" srcset=\"\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png 2560w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-300x170.png 300w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-1024x580.png 1024w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-768x435.png 768w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-1536x871.png 1536w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-2048x1161.png 2048w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-150x85.png 150w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-600x340.png 600w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<h2>Technologies Used<\/h2>\n<h3>Node.js<\/h3>\n<p>You need Node.js installed because this project uses <a href=\"https:\/\/vite.dev\/\">Vite<\/a> based project. Install the Node LTS version from <a href=\"https:\/\/nodejs.org\/id\/download\">here<\/a>.<\/p>\n<h3><strong>OpenAI<\/strong><\/h3>\n<p>AI models are used for natural language processing and sentiment analysis.<\/p>\n<p>Create the OpenAI API key <a href=\"https:\/\/platform.openai.com\/\">here<\/a>. You may need to create a project and enable a few models. We will use the <code>gpt-4o<\/code> model.<\/p>\n<h3>GridDB Cloud Setup<\/h3>\n<p>The GridDB Cloud offers a free plan tier and is officially available worldwide.<\/p>\n<p>You need these GridDB environment variables in the <code>.env<\/code> file:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">GRIDDB_WEBAPI_URL=\nGRIDDB_USERNAME=\nGRIDDB_PASSWORD=<\/code><\/pre>\n<\/div>\n<h4>Sign Up for GridDB Cloud Free Plan<\/h4>\n<p>If you would like to sign up for a GridDB Cloud Free instance, you can do so in the following link: <a href=\"https:\/\/form.ict-toshiba.jp\/download_form_griddb_cloud_freeplan_e\">https:\/\/form.ict-toshiba.jp\/download_form_griddb_cloud_freeplan_e<\/a>.<\/p>\n<p>After successfully signing up, you will receive a free instance along with the necessary details to access the GridDB Cloud Management GUI, including the <strong>GridDB Cloud Portal URL<\/strong>, <strong>Contract ID<\/strong>, <strong>Login<\/strong>, and <strong>Password<\/strong>.<\/p>\n<h4>GridDB WebAPI URL<\/h4>\n<p>Go to the GridDB Cloud Portal and copy the WebAPI URL from the <strong>Clusters<\/strong> section. It should look like this:<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-scaled.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-scaled.png\" alt=\"\" width=\"2560\" height=\"1265\" class=\"aligncenter size-full wp-image-32431\" srcset=\"\/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-scaled.png 2560w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-300x148.png 300w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-1024x506.png 1024w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-768x380.png 768w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-1536x759.png 1536w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-2048x1012.png 2048w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-portal-600x297.png 600w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<h4>GridDB Username and Password<\/h4>\n<p>Go to the <strong>GridDB Users<\/strong> section of the GridDB Cloud portal and create or copy the username for <code>GRIDDB_USERNAME<\/code>. The password is set when the user is created for the first time, use this as the <code>GRIDDB_PASSWORD<\/code>.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-cloud-users-scaled.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-cloud-users-scaled.png\" alt=\"\" width=\"2560\" height=\"1351\" class=\"aligncenter size-full wp-image-32432\" srcset=\"\/wp-content\/uploads\/2025\/09\/griddb-cloud-users-scaled.png 2560w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-300x158.png 300w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-1024x540.png 1024w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-768x405.png 768w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-1536x810.png 1536w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-2048x1080.png 2048w, \/wp-content\/uploads\/2025\/09\/griddb-cloud-users-600x317.png 600w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<p>For more details, to get started with GridDB Cloud, please follow this <a href=\"https:\/\/griddb.net\/en\/blog\/griddb-cloud-quick-start-guide\/\">quick start guide<\/a>.<\/p>\n<h4>IP Whitelist<\/h4>\n<p>When running this project, please ensure that the IP address where the project is running is whitelisted. Failure to do so will result in a 403 status code or forbidden access.<\/p>\n<p>You can use a website like <a href=\"https:\/\/whatismyipaddress.com\/\">What Is My IP Address<\/a> to find your public IP address.<\/p>\n<p>To whitelist the IP, go to the GridDB Cloud Admin and navigate to the <strong>Network Access<\/strong> menu.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/ip-whitelist-scaled.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/ip-whitelist-scaled.png\" alt=\"\" width=\"2560\" height=\"1095\" class=\"aligncenter size-full wp-image-32425\" srcset=\"\/wp-content\/uploads\/2025\/09\/ip-whitelist-scaled.png 2560w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-300x128.png 300w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-1024x438.png 1024w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-768x329.png 768w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-1536x657.png 1536w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-2048x876.png 2048w, \/wp-content\/uploads\/2025\/09\/ip-whitelist-600x257.png 600w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<h2>Project Architecture<\/h2>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/architecture.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/architecture.png\" alt=\"\" width=\"2010\" height=\"1382\" class=\"aligncenter size-full wp-image-32429\" srcset=\"\/wp-content\/uploads\/2025\/09\/architecture.png 2010w, \/wp-content\/uploads\/2025\/09\/architecture-300x206.png 300w, \/wp-content\/uploads\/2025\/09\/architecture-1024x704.png 1024w, \/wp-content\/uploads\/2025\/09\/architecture-768x528.png 768w, \/wp-content\/uploads\/2025\/09\/architecture-1536x1056.png 1536w, \/wp-content\/uploads\/2025\/09\/architecture-600x413.png 600w\" sizes=\"(max-width: 2010px) 100vw, 2010px\" \/><\/a><\/p>\n<p>The diagram illustrates the flow of data in the sentiment analysis system:<\/p>\n<ol>\n<li>Product Review Data is fed into the system.<\/li>\n<li>The OpenAI API analyzes this data for sentiment.<\/li>\n<li>The sentiment results and associated metadata are then stored in GridDB.<\/li>\n<li>Finally, the sentiment analysis results are presented through a user interface.<\/li>\n<\/ol>\n<p>This represents a pipeline where raw review data is processed, analyzed for sentiment, stored in GridDB, and then made available for viewing.<\/p>\n<h2>Dataset Preparation<\/h2>\n<p>You can use any data review for this project. For example, you can use the <a href=\"https:\/\/cseweb.ucsd.edu\/~jmcauley\/datasets.html#amazon_reviews\">Amazon Review Dataset<\/a> or just copy-paste a review from one of the product reviews on Amazon.<\/p>\n<h2>Server<\/h2>\n<p>The server is built using Node.js and Express.js. It is a simple server that provides a few API routes. You can see the server code in the <code>server.ts<\/code> file.<\/p>\n<h3>API Routes<\/h3>\n<table>\n<thead>\n<tr>\n<th>Method<\/th>\n<th>Endpoint<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>POST<\/strong><\/td>\n<td><code>\/api\/sentiment<\/code><\/td>\n<td>Sentiment analysis for a review and persist the result in GridDB<\/td>\n<\/tr>\n<tr>\n<td><strong>GET<\/strong><\/td>\n<td><code>\/api\/sentiments<\/code><\/td>\n<td>Retrieve <strong>all<\/strong> stored review records<\/td>\n<\/tr>\n<tr>\n<td><strong>GET<\/strong><\/td>\n<td><code>*<\/code> (any non\u2011API path)<\/td>\n<td>Serve main UI<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Running Sentiment Analysis with OpenAI<\/h2>\n<p>We use the OpenAI API (e.g., GPT-4o) to evaluate the sentiment of each review. The input is a text prompt that asks the model to categorize the sentiment.<\/p>\n<h3>System Prompt<\/h3>\n<p>We will use a system prompt to guide the model to understand the task. The system prompt is as follows:<\/p>\n<div class=\"clipboard\">\n<pre><code>You are a sentiment\u2011analysis classifier for Amazon user\u2011review records. You will receive one JSON object that contains the fields \"title\" and \"text\" (and sometimes \"rating\" which you must ignore). Your task:n1. Read the natural\u2011language content (title + text).n2. Predict the sentiment label and an estimated star rating without looking at any numeric \"rating\" field.n3. Respond ONLY with a JSON object in this schema:n{n  \"label\": \"positive | neutral | negative\",n  \"predicted_rating\": 1 | 2 | 3 | 4 | 5,n  \"confidence\": 0-1n}nMapping rule (aligned to the Amazon Reviews dataset):n\u2022 1\u20132 stars \u21d2 negativen\u2022 3 stars   \u21d2 neutraln\u2022 4\u20135 stars \u21d2 positivenIf the review text is empty, off\u2011topic, or nonsense, return:n{\"label\":\"neutral\",\"predicted_rating\":3,\"confidence\":0.0}nNever add commentary or extra keys.<\/code><\/pre>\n<\/div>\n<p>Basically, it tells the model to behave like a sentiment analysis classifier for Amazon user-review records.<\/p>\n<h3>Few Shots<\/h3>\n<p>A few shots are used to guide the model in understanding the task. The few shots used in this project are as follows:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-javascript\">const FEW_SHOTS = [\n {\n    role: 'user',\n    content: JSON.stringify({\n      title: 'Rock\u2011solid mount',\n      text:\n        \"I've tried dozens of phone mounts\u2014this one finally stays put on bumpy roads. Five minutes to install and rock\u2011solid!\",\n }),\n },\n {\n    role: 'assistant',\n    content: '{\"label\":\"positive\",\"predicted_rating\":5,\"confidence\":0.96}',\n },\n {\n    role: 'user',\n    content: JSON.stringify({\n      title: 'Broke in a week',\n      text:\n        \"Looks nice, but the zipper broke after one week and Amazon wouldn't replace it.\",\n }),\n },\n {\n    role: 'assistant',\n    content: '{\"label\":\"negative\",\"predicted_rating\":1,\"confidence\":0.93}',\n },\n {\n    role: 'user',\n    content: JSON.stringify({\n      title: 'Meh',\n      text:\n        'These were lightweight and soft but much too small for my liking. I would have preferred two of these together to make one loc.',\n }),\n },\n {\n    role: 'assistant',\n    content: '{\"label\":\"neutral\",\"predicted_rating\":3,\"confidence\":0.55}',\n },\n] as const;<\/code><\/pre>\n<\/div>\n<p>Few-shot examples are used to help a model quickly learn a specific task or format by demonstrating correct input-output pairs. In this context, these few shots serve as demonstrations to guide the sentiment analysis model, illustrating:<\/p>\n<ul>\n<li>Expected input format: Reviews consisting of a title and text.<\/p>\n<\/li>\n<li>Expected output structure: A JSON response containing:\n<ul>\n<li><code>label<\/code>: sentiment classification (&#8220;positive&#8221;, &#8220;negative&#8221;, &#8220;neutral&#8221;).<\/p>\n<\/li>\n<li>\n<p><code>predicted_rating<\/code>: numerical rating estimation (1\u20135).<\/p>\n<\/li>\n<li>\n<p><code>confidence<\/code>: confidence score for the prediction.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The model leverages these examples to understand precisely how to classify and score new reviews in a similar structured manner.<\/p>\n<h3>Call OpenAI API<\/h3>\n<p>The sentiment analysis was done by OpenAI using the <code>gpt-4o<\/code> model. The code is available in the <code>server.ts<\/code> file.<\/p>\n<p>Here is the important code snippet:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-javascript\">const completion = await openai.chat.completions.create({\n    model: 'gpt-4o',\n    temperature: 0,\n    messages: [\n { role: 'system', content: SYSTEM_PROMPT },\n ...FEW_SHOTS,\n {\n          role: 'user',\n          content: JSON.stringify({ title, text }),\n },\n ],\n});<\/code><\/pre>\n<\/div>\n<p>The <code>text<\/code> is the review text and the <code>title<\/code> is the review title.<\/p>\n<h2>Storing Results in GridDB<\/h2>\n<p>GridDB is used to persist the processed review data. We use a collection container to store the data.<\/p>\n<h3>Container Schema<\/h3>\n<p>The container schema is as follows:<\/p>\n<ul>\n<li><code>id<\/code>: <code>INTEGER<\/code><\/li>\n<li><code>title<\/code>: <code>STRING<\/code><\/li>\n<li><code>review<\/code>: <code>STRING<\/code><\/li>\n<li><code>sentiment<\/code>: <code>STRING<\/code><\/li>\n<\/ul>\n<h3>Saving Data to GridDB<\/h3>\n<p>This is the example data format that is saved to GridDB:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-bash\">{\n  id: 4495,\n  title: 'US Version',\n  review: \"US version of the game so DLC can't be downloaded. Returned for a refund\",\n  sentiment: '{\"label\":\"negative\",\"predicted_rating\":2,\"confidence\":0.88}'\n}<\/code><\/pre>\n<\/div>\n<p>The <code>reviewData<\/code> is inserted into GridDB using the <code>insertData<\/code> function.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-javascript\">const reviewData: GridDBData = {\n    id: generateRandomID(),\n    title,\n    review: text,\n    sentiment: JSON.stringify(parsed),\n};\nawait dbClient.insertData({ data: reviewData });<\/code><\/pre>\n<\/div>\n<p>The code to insert data is available in the <code>griddb.ts<\/code> file. Basically, this function takes the data and inserts it into GridDB using the HTTP method.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-javascript\">async function insertData({\n  data,\n  containerName = 'sentiments',\n}: {\n  data: GridDBData;\n  containerName?: string;\n}): Promise<GridDBResponse> {\n  try {\n    const row = [\n      parseInt(data.id.toString()),\n      data.title,\n      data.review,\n      data.sentiment,\n ];\n\n    const path = `\/containers\/${containerName}\/rows`;\n    return await makeRequest(path, [row], 'PUT');\n } catch (error) {\n    if (error instanceof GridDBError) {\n      throw error;\n }\n\n    const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n    throw new GridDBError(`Failed to insert data: ${errorMessage}`, undefined, undefined, error);\n }\n}<\/code><\/pre>\n<\/div>\n<p>The API route used to insert data in GridDB Cloud is:<\/p>\n<div class=\"clipboard\">\n<pre><code> `${GRIDDB_WEB_API_URL}\/containers\/sentiments\/rows`<\/code><\/pre>\n<\/div>\n<p>and by using the HTTP PUT method, the data can be easily inserted into the database.<\/p>\n<h3>Query All Data<\/h3>\n<p>To query all data from the <code>sentiments<\/code> container, you can use the following API route:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-javascript\">app.get('\/api\/sentiments', async (req: express.Request, res: express.Response) => {\n  try {\n    \/\/ Search all data\n    const results = await dbClient.searchData([{ type: 'sql', stmt: 'SELECT * FROM sentiments' }]);\n\n    res.json({ data: results });\n } catch (error) {\n    res.status(500).json({ error: error.message });\n }\n});<\/code><\/pre>\n<\/div>\n<p>The code above uses SQL SELECT statement to query all data from the <code>sentiments<\/code> container and if you query the data directly from the browser, you can use the following URL <code>https:\/\/localhost:3000\/api\/sentiments<\/code><\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/query-all-data.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/query-all-data.png\" alt=\"\" width=\"2284\" height=\"1262\" class=\"aligncenter size-full wp-image-32426\" srcset=\"\/wp-content\/uploads\/2025\/09\/query-all-data.png 2284w, \/wp-content\/uploads\/2025\/09\/query-all-data-300x166.png 300w, \/wp-content\/uploads\/2025\/09\/query-all-data-1024x566.png 1024w, \/wp-content\/uploads\/2025\/09\/query-all-data-768x424.png 768w, \/wp-content\/uploads\/2025\/09\/query-all-data-1536x849.png 1536w, \/wp-content\/uploads\/2025\/09\/query-all-data-2048x1132.png 2048w, \/wp-content\/uploads\/2025\/09\/query-all-data-600x332.png 600w\" sizes=\"(max-width: 2284px) 100vw, 2284px\" \/><\/a><\/p>\n<h2>User Interface<\/h2>\n<p>The UI is built using React and Vite. The <code>&lt;SentimentAnalysis \/&gt;<\/code> component is the main component of the UI. It is a simple form that allows users to input a review title and text, and then submit the form to the <code>\/api\/sentiment<\/code> endpoint.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png\" alt=\"\" width=\"2560\" height=\"1451\" class=\"aligncenter size-full wp-image-32433\" srcset=\"\/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-scaled.png 2560w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-300x170.png 300w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-1024x580.png 1024w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-768x435.png 768w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-1536x871.png 1536w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-2048x1161.png 2048w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-150x85.png 150w, \/wp-content\/uploads\/2025\/09\/griddb-sentiment-ui-600x340.png 600w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<p>After submitting the form and processing the sentiment analysis, the UI receives the response data that has JSON format, for example:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-bash\">{\n    \"label\": \"positive\",\n    \"predicted_rating\": 4,\n    \"confidence\": 0.85\n}<\/code><\/pre>\n<\/div>\n<p>The response data is then displayed in the UI. If the review is positive, the UI will display a green color, if it is negative, the UI will display a red color, and if it is neutral, the UI will display a yellow color. Also the UI will display the predicted rating and confidence level.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/sentiment-analysis-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2025\/09\/sentiment-analysis-1.png\" alt=\"\" width=\"2252\" height=\"1574\" class=\"aligncenter size-full wp-image-32427\" srcset=\"\/wp-content\/uploads\/2025\/09\/sentiment-analysis-1.png 2252w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-300x210.png 300w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-1024x716.png 1024w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-768x537.png 768w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-1536x1074.png 1536w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-2048x1431.png 2048w, \/wp-content\/uploads\/2025\/09\/sentiment-analysis-1-600x419.png 600w\" sizes=\"(max-width: 2252px) 100vw, 2252px\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>This project demonstrates a real-world use case of combining AI and databases for sentiment analysis. Using OpenAI for intelligent sentiment analysis and GridDB for data storage enables fast, efficient processing of customer reviews. The same framework can be extended to other datasets and domains, including social media, customer support logs, or live feedback systems.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/developers.openai.com\/api\/docs\">OpenAI API Documentation<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI&#8217;s large language models (LLMs) and GridDB. The project involves extracting review data, analyzing sentiment using AI, and efficiently storing and querying the results. It&#8217;s an example of how modern AI tools and database systems can be combined to process and [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":52231,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-52230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI&#039;s large language models (LLMs) and GridDB.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI&#039;s large language models (LLMs) and GridDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-09-17T07:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-30T18:23:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.griddb.net\/wp-content\/uploads\/2025\/12\/cover-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1120\" \/>\n\t<meta property=\"og:image:height\" content=\"602\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/www.griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Sentiment Analysis on Product Reviews using OpenAI\",\"datePublished\":\"2025-09-17T07:00:00+00:00\",\"dateModified\":\"2026-03-30T18:23:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\"},\"wordCount\":1274,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2025\/12\/cover-1.jpg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\",\"url\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\",\"name\":\"Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/www.griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2025\/12\/cover-1.jpg\",\"datePublished\":\"2025-09-17T07:00:00+00:00\",\"dateModified\":\"2026-03-30T18:23:51+00:00\",\"description\":\"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI's large language models (LLMs) and GridDB.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2025\/12\/cover-1.jpg\",\"contentUrl\":\"\/wp-content\/uploads\/2025\/12\/cover-1.jpg\",\"width\":1120,\"height\":602},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.griddb.net\/en\/#website\",\"url\":\"https:\/\/www.griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/www.griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/www.griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/www.griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/www.griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT","description":"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI's large language models (LLMs) and GridDB.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/","og_locale":"en_US","og_type":"article","og_title":"Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT","og_description":"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI's large language models (LLMs) and GridDB.","og_url":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2025-09-17T07:00:00+00:00","article_modified_time":"2026-03-30T18:23:51+00:00","og_image":[{"width":1120,"height":602,"url":"https:\/\/www.griddb.net\/wp-content\/uploads\/2025\/12\/cover-1.jpg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#article","isPartOf":{"@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/"},"author":{"name":"griddb-admin","@id":"https:\/\/www.griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Sentiment Analysis on Product Reviews using OpenAI","datePublished":"2025-09-17T07:00:00+00:00","dateModified":"2026-03-30T18:23:51+00:00","mainEntityOfPage":{"@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/"},"wordCount":1274,"commentCount":0,"publisher":{"@id":"https:\/\/www.griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/12\/cover-1.jpg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/","url":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/","name":"Sentiment Analysis on Product Reviews using OpenAI | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/www.griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage"},"image":{"@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2025\/12\/cover-1.jpg","datePublished":"2025-09-17T07:00:00+00:00","dateModified":"2026-03-30T18:23:51+00:00","description":"Overview This article explores a practical implementation of sentiment analysis on product reviews using OpenAI's large language models (LLMs) and GridDB.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.griddb.net\/en\/blog\/sentiment-analysis-on-product-reviews-using-openai\/#primaryimage","url":"\/wp-content\/uploads\/2025\/12\/cover-1.jpg","contentUrl":"\/wp-content\/uploads\/2025\/12\/cover-1.jpg","width":1120,"height":602},{"@type":"WebSite","@id":"https:\/\/www.griddb.net\/en\/#website","url":"https:\/\/www.griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/www.griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/www.griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/www.griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/www.griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/www.griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/52230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/comments?post=52230"}],"version-history":[{"count":1,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/52230\/revisions"}],"predecessor-version":[{"id":55097,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/posts\/52230\/revisions\/55097"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media\/52231"}],"wp:attachment":[{"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/media?parent=52230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/categories?post=52230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.griddb.net\/en\/wp-json\/wp\/v2\/tags?post=52230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}