
{"id":6960,"date":"2024-09-10T09:57:21","date_gmt":"2024-09-10T08:57:21","guid":{"rendered":"https:\/\/dasini.net\/blog\/?p=6960"},"modified":"2024-09-10T09:57:24","modified_gmt":"2024-09-10T08:57:24","slug":"heatwave-genai-sentiment-analysis-made-easy-peasy","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2024\/09\/10\/heatwave-genai-sentiment-analysis-made-easy-peasy\/","title":{"rendered":"HeatWave GenAI: Sentiment Analysis Made Easy-Peasy"},"content":{"rendered":"\n<p>This article builds upon the concepts introduced in my previous blog posts,&nbsp;<a href=\"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/\" target=\"_blank\" rel=\"noopener\" title=\"&nbsp;HeatWave GenAI: Your AI-Powered Content Creation Partner\"><em>HeatWave GenAI: Your AI-Powered Content Creation Partner<\/em><\/a> and <a href=\"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/\" target=\"_blank\" rel=\"noopener\" title=\"In-Database LLMs for Efficient Text Translation with HeatWave GenAI\">In-Database LLMs for Efficient Text Translation with HeatWave GenAI<\/a>.<br>For a deeper understanding, also consider reading these articles.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So, you&rsquo;ve probably heard about AI getting \u00ab\u00a0<em>smarter<\/em>\u00a0\u00bb by the day. Well, one cool thing it can do now is read between the lines of what people say. <strong>It&rsquo;s like having a mind-reading machine for text<\/strong>! <br>This new AI tech, called generative AI (or GenAI), can dive deep into what people are saying and tell us if they&rsquo;re feeling <span style=\"text-decoration: underline;\">positive<\/span>, <span style=\"text-decoration: underline;\">negative<\/span>, or <span style=\"text-decoration: underline;\">neutral<\/span>. <br><strong>Let&rsquo;s see how <span style=\"text-decoration: underline;\">HeatWave GenAI<\/span>,  can help you to enhance your understanding of customer sentiment, improve decision-making, and drive business success<\/strong>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What is AI sentiment Analysis?<\/h2>\n\n\n\n<p>You can find a more formal and complete definition on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sentiment_analysis\" target=\"_blank\" rel=\"noopener\" title=\"Sentiment analysis\">Wikipedia<\/a>, but in few words, it is like having a computer that can understand human emotions. This technology can analyze text data and thus dive deep into what people are saying and tell us if they&rsquo;re happy, sad, or even mad.<\/p>\n\n\n\n<p><strong>By understanding the sentiment behind words, AI can help businesses gauge customer satisfaction, track brand reputation, and even predict market trends. <br><\/strong>It&rsquo;s a powerful tool that has a wide range of applications in fields like marketing, social media, and customer service.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What is HeatWave?<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.oracle.com\/heatwave\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave\"><strong>HeatWave<\/strong><\/a>&nbsp;is a fully-managed Oracle Cloud Infrastructure service. It offered different solutions for different workloads:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>HeatWave MySQL<\/strong>: built on MySQL, for your transactional needs.<\/li>\n\n\n\n<li><strong>HeatWave Analytics<\/strong>: get real-time analytics on your data.<\/li>\n\n\n\n<li><strong>HeatWave Lakehouse<\/strong>: query data in various formats in object storage<\/li>\n\n\n\n<li><strong>HeatWave AutoML<\/strong>: automate the pipeline to build, train, and explain ML models<\/li>\n\n\n\n<li><strong>HeatWave GenAI<\/strong>: integrated &amp; automated GenAI with in-database LLMs<\/li>\n<\/ul>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69dce2bcbb6f0&quot;}\" data-wp-interactive=\"core\/image\" class=\"wp-block-image size-large wp-lightbox-container\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"415\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=800%2C415&#038;ssl=1\" alt=\"Data processing with HeatWave\" class=\"wp-image-6723\" srcset=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=800%2C415&amp;ssl=1 800w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=300%2C156&amp;ssl=1 300w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=768%2C399&amp;ssl=1 768w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1536%2C797&amp;ssl=1 1536w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=2048%2C1063&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Agrandir\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p><strong>Oracle\u2019s&nbsp;<a href=\"https:\/\/www.oracle.com\/heatwave\/genai\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenaI\">HeatWave GenAI<\/a><\/strong>&nbsp;(starting with version 9.0.1) is at the forefront of this revolution, offering an integrated platform that combines in-database&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Large_language_model\" target=\"_blank\" rel=\"noreferrer noopener\">large language models<\/a>&nbsp;(LLMs),&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Vector_database\" target=\"_blank\" rel=\"noreferrer noopener\">vector stores<\/a>, and scale-out vector processing to streamline content generation.<\/p>\n\n\n\n<p>The key benefits of such architecture are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Effortless LLM Integration<\/strong>: Simple SQL queries unlock AI power.<\/li>\n\n\n\n<li><strong>Seamless Database Integration<\/strong>: No complex external connections.<\/li>\n\n\n\n<li><strong>Simplified Architecture<\/strong>: Easy management and scalability.<\/li>\n\n\n\n<li><strong>Scalable Performance<\/strong>: Handles large datasets and high traffic.<\/li>\n\n\n\n<li><strong>Always Up-to-Date Data<\/strong>: In-database LLMs ensure data freshness.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In this article I&rsquo;m using HeatWave&nbsp;<strong>9.0.1<\/strong>.<\/p>\n\n\n\n<div style=\"height:75px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For the purpose of this article, let&rsquo;s consider a scenario where you&rsquo;re a mobile phone manufacturer. In today&rsquo;s digital age, it&rsquo;s crucial to keep a pulse on customer sentiment. Your company actively monitors various social networks to stay informed about what customers are saying about your products.<br>For example, short messages like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>Just got my hands on the latest mobile phone and I&rsquo;m loving it! Thanks for creating such an awesome product!<\/em><\/li>\n\n\n\n<li><em>A mobile phone that prioritizes functionality and reliability over flashy features.<\/em><\/li>\n\n\n\n<li><em>Why does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!<\/em><\/li>\n<\/ul>\n\n\n\n<p>You get the idea!<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>So, how can you <strong>harnessing HeatWave GenAI for effortless sentiment analysis<\/strong>?<br>Like we have seen in <a href=\"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI: Your AI-Powered Content Creation Partner\">HeatWave GenAI: Your AI-Powered Content Creation Partner<\/a> &amp; <a href=\"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/\" target=\"_blank\" rel=\"noopener\" title=\"In-Database LLMs for Efficient Text Translation with HeatWave GenAI\">In-Database LLMs for Efficient Text Translation with HeatWave GenAI<\/a> the first step is to load the LLM in HeatWave memory.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Load the LLM in HeatWave memory<\/h2>\n\n\n\n<p>Use the <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hwaml-ml-model-load.html\" target=\"_blank\" rel=\"noopener\" title=\"ML_MODEL_LOAD\"><strong>ML_MODEL_LOAD<\/strong><\/a> stored procedure: <em>CALL sys.ML_MODEL_LOAD(&lsquo;&lt;LLM&gt;&rsquo;, NULL);<\/em><br>The model needs to be loaded only once before generating text. It remains accessible within HeatWave as long as the service is running. This means you don&rsquo;t have to reload the model for each text generation.<\/p>\n\n\n\n<p>At the time of writing (beginning of September 2024) the available models are <strong><a href=\"https:\/\/mistral.ai\/news\/announcing-mistral-7b\/\" target=\"_blank\" rel=\"noopener\" title=\"Mistral 7B\">Mistral 7B<\/a><\/strong> (<strong><em>mistral-7b-instruct-v1<\/em><\/strong>) and <strong><a href=\"https:\/\/llama.meta.com\/llama2\/\" target=\"_blank\" rel=\"noopener\" title=\"Llama 2\">Llama 2<\/a><\/strong> (<strong><em>llama2-7b-v1<\/em><\/strong>).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSELECT @@version, @@version_comment;\n+-------------+--------------------------+\n| @@version   | @@version_comment        |\n+-------------+--------------------------+\n| 9.0.1-cloud | MySQL Enterprise - Cloud |\n+-------------+--------------------------+\n\n\n-- Load Mistral 7B model\nCALL sys.ML_MODEL_LOAD('mistral-7b-instruct-v1', NULL);<\/code><\/pre>\n\n\n\n<p>Mistral is loaded. Now you can think about defining your prompt.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Define your prompt in natural language<\/h2>\n\n\n\n<p>To make it more convenient, let&rsquo;s use some variables. The sort messages above are now:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSET @customer_msgA=\"Just got my hands on the latest mobile phone and I'm loving it! Thanks for creating such an awesome product!\" ;\n\nSET @customer_msgB=\"A mobile phone that prioritizes functionality and reliability over flashy features.\" ;\n\nSET @customer_msgC=\"Why does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\" ;<\/code><\/pre>\n\n\n\n<p>The prompt contains a message and the inference instructions. <br>Let&rsquo;s start with a very simple instruction text, something like:<br><em>What is the feeling from the text above? <\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSET @instructions=\" What is the feeling from the text above?\";\n\nSET @prompt=CONCAT(@customer_msgA, @instructions);<\/code><\/pre>\n\n\n\n<p>The final prompt is the concatenation of 2 variables: @customer_msg{X} and @instructions.<\/p>\n\n\n\n<p>In order to have the optimal result, maybe you&rsquo;ll need to do some fine tuning to set up the inference.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Inference Setting<\/h2>\n\n\n\n<p>I use generation as a task and the Mistral model and I put temperature, top-k and top-p to zero because I do not want any creativity from the model \ud83d\ude42 .<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSET @inferenceSetup  = '{\"task\": \"generation\", \"temperature\": 0, \"top_k\": 0, \"top_p\": 0, \"model_id\": \"mistral-7b-instruct-v1\"}';<\/code><\/pre>\n\n\n\n<p>We have now all what we need to do <span style=\"text-decoration: underline;\">sentiment analysis<\/span>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Sentiment Analysis<\/h2>\n\n\n\n<p>Like we have seen in <a href=\"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI: Your AI-Powered Content Creation Partner\">HeatWave GenAI: Your AI-Powered Content Creation Partner<\/a> &amp; <a href=\"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/\" target=\"_blank\" rel=\"noopener\" title=\"In-Database LLMs for Efficient Text Translation with HeatWave GenAI\">In-Database LLMs for Efficient Text Translation with HeatWave GenAI<\/a> we must use the <strong>ML_GENERATE<\/strong> function. <\/p>\n\n\n\n<p>One way to display the result is to use the following query:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"SQL\" class=\"language-SQL\">SELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt;<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Result with: <em>SET @customer_msgA=\u00a0\u00bbJust got my hands on the latest mobile phone and I&rsquo;m loving it! Thanks for creating such an awesome product!\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"Just got my hands on the latest mobile phone and I'm loving it! Thanks for creating such an awesome product!\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt;\n+---------------------------------------------------------+\n| Answer                                                  |\n+---------------------------------------------------------+\n|  The feeling expressed in the text is happiness or joy. |\n+---------------------------------------------------------+\n<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>With <em>SET @customer_msgB=\u00a0\u00bbA mobile phone that prioritizes functionality and reliability over flashy features.\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"A mobile phone that prioritizes functionality and reliability over flashy features.\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt\\G\n*************************** 1. row ***************************\nAnswer:  The feeling conveyed in the text is one of practicality and pragmatism, with a focus on the importance of functionality and reliability in a mobile phone.\n<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>With <em>SET @customer_msgC=\u00a0\u00bbWhy does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"Why does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt\\G\n*************************** 1. row ***************************\nAnswer:  The feeling conveyed in the text above is frustration and disappointment.\n<\/code><\/pre>\n\n\n\n<p>Amazing!<br>The model provide a summary of the sentiment expressed in the message.<\/p>\n\n\n\n<p>But what if we want to use this feature more programmatically? Well we need to improve our prompt.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Sentiment Analysis in Code<\/h2>\n\n\n\n<p>Basically we can ask the LLM to generate the result in a specific format, other than raw text like JSON, CSV, &#8230; or an integer.<\/p>\n\n\n\n<p>Let&rsquo;s say we have the following code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Positive feeling: 1.<\/li>\n\n\n\n<li>Negative feeling: -1<\/li>\n\n\n\n<li>Neutral feeling or unknown:  0<\/li>\n<\/ul>\n\n\n\n<p>The goal is to automatically identify problematic messages \u2014 those that express non positive sentiments \u2014 and then take action.<\/p>\n\n\n\n<p>To do this, we only need to rewrite our prompt, improving the instruction part. For example we can have something like:<br><em>What is the feeling from the text above? <strong>if it is positive write 1. If it is negative write -1. if it is neutral or if you don&rsquo;t know write 0. Regarding to your analysis, write only -1 or 0 or 1<\/strong><\/em><\/p>\n\n\n\n<p>Still a basic prompt, far from being optimal, but good enough to keep this article simple and most important,  to do the job.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSET @instructions=\" What is the feeling from the text above? if it is positive write 1. If it is negative write -1. if it is neutral or if you don't know write 0. Regarding to your analysis, write only -1 or 0 or 1\";\n<\/code><\/pre>\n\n\n\n<p>All the other variables are<span style=\"text-decoration: underline;\"> the same<\/span> than the previous use case.<br>Let&rsquo;s see the result:<\/p>\n\n\n\n<p>Result with: <em>SET @customer_msgA=\u00a0\u00bbJust got my hands on the latest mobile phone and I&rsquo;m loving it! Thanks for creating such an awesome product!\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"Just got my hands on the latest mobile phone and I'm loving it! Thanks for creating such an awesome product!\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt;\n+--------+\n| Answer |\n+--------+\n|  1     |\n+--------+\n<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>With <em>SET @customer_msgB=\u00a0\u00bbA mobile phone that prioritizes functionality and reliability over flashy features.\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"A mobile phone that prioritizes functionality and reliability over flashy features.\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt;\n+--------+\n| Answer |\n+--------+\n|  0     |\n+--------+\n<\/code><\/pre>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>With <em>SET @customer_msgC=\u00a0\u00bbWhy does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\u00a0\u00bb ;<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\n\/* msg: \"Why does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\" *\/\n\nSELECT Answer-&gt;&gt;\"$.text\" AS \"Answer\" FROM (SELECT sys.ML_GENERATE(@prompt, @inferenceSetup) AS Answer ) AS dt;\n+--------+\n| Answer |\n+--------+\n|  -1    |\n+--------+\n<\/code><\/pre>\n\n\n\n<p>Awesome!<br>The model produces results based on the format chosen and needed in our code. It could have been a JSON format for example and the logic would have been the same.<\/p>\n\n\n\n<p>With such output you can easily integrate HeatWave in your data pipeline.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Sentiment Analysis into your data workflow with HeatWave<\/h2>\n\n\n\n<p>Imagine we store our customer messages in a (MySQL) table. A possible workflow involves regularly scanning this table for negative feedback. Once identified, these messages can be referenced in ( or be moved to) a separate table. This new table can then be used to populate the customer service team&rsquo;s dashboard. By tracking unsatisfied customers in this way, the team can work to improve overall customer satisfaction.<\/p>\n\n\n\n<p>A simplified data architecture could be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nCREATE SCHEMA sentimentAnalysis;\n\n\nCREATE TABLE `sentimentAnalysis`.`tweet` (\n  `tweet_id` int unsigned NOT NULL AUTO_INCREMENT,\n  `customer_msg` varchar(4000) DEFAULT NULL,\n  PRIMARY KEY (`tweet_id`)\n);\n\n\nCREATE TABLE `sentimentAnalysis`.`tweet_to_review` (\n  `tweet_to_review_id` int unsigned NOT NULL AUTO_INCREMENT,\n  `tweet_id_to_check` int unsigned NOT NULL,\n  `analysis_result` tinyint NOT NULL,\n  PRIMARY KEY (`tweet_to_review_id`)\n);\n<\/code><\/pre>\n\n\n\n<p>Table <em>tweet<\/em> contains the customer messages and a message ID..<br>The problematic messages (ie status 0 and -1) are referenced into table <em>tweet_to_review<\/em>, using the message ID. We also store the result of the sentiment analysis (0 or -1). Support may prefer to focus first on messages that are definitely negative (status -1).<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Just got my hands on the latest mobile phone and I'm loving it! Thanks for creating such an awesome product!\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Loving the features on my new mobile phone! It's like a whole new world in the palm of my hand.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Your mobile phone company is a joke. Can't believe I wasted my hard-earned money on your crappy products.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Hey, just wanted to say how much I love your product! It's been a game changer for me.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Recently upgraded my old mobile phone to something newer - let's see how it goes\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"A mobile phone that prioritizes functionality and reliability over flashy features.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Why does your mobile phone company insist on selling devices that are constantly glitching and breaking? Do better!\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Shoutout for making such an awesome product. I couldn't imagine my life without it!\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Just another day dealing with the incompetence of my mobile phone company. Seriously considering switching to a different provider.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"For those who want a device that just works.\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Big thanks for creating a top-notch mobile phone. You guys never disappoint!\");\nINSERT `sentimentAnalysis`.`tweet` (customer_msg) VALUES(\"Just got my hands on a new mobile phone and I'm excited to see what it can do!\");\n<\/code><\/pre>\n\n\n\n<p>Some data inserted in <em>tweet<\/em> table.<br>Most of these data were generated using <a href=\"https:\/\/www.hootsuite.com\/social-media-tools\/ai-tweet-generator\" target=\"_blank\" rel=\"noopener\" title=\"AI Tweet Generator\">AI Tweet Generator<\/a>.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSELECT * FROM `sentimentAnalysis`.`tweet` LIMIT 5\\G\n*************************** 1. row ***************************\n    tweet_id: 1\ncustomer_msg: Just got my hands on the latest mobile phone and I'm loving it! Thanks for creating such an awesome product!\n*************************** 2. row ***************************\n    tweet_id: 2\ncustomer_msg: Loving the features on my new mobile phone! It's like a whole new world in the palm of my hand.\n*************************** 3. row ***************************\n    tweet_id: 3\ncustomer_msg: Your mobile phone company is a joke. Can't believe I wasted my hard-earned money on your crappy products.\n*************************** 4. row ***************************\n    tweet_id: 4\ncustomer_msg: Hey, just wanted to say how much I love your product! It's been a game changer for me.\n*************************** 5. row ***************************\n    tweet_id: 5\ncustomer_msg: Recently upgraded my old mobile phone to something newer - let's see how it goes\n<\/code><\/pre>\n\n\n\n<p>Sample of the data.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The workflow of our data pipeline is quite simple:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Get the tweet content from the source (table <em>tweet<\/em>)<\/li>\n\n\n\n<li>Do the sentiment analysis using HeatWave GenAI<\/li>\n\n\n\n<li>Write problematic tweets (status &lt;&gt; 0) into the target (table <em>tweet_to_review<\/em>) for further processing<\/li>\n<\/ol>\n\n\n\n<p>It can be done with your favourite programing language. It can also be done on the database side using HeatWave <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/9.0\/en\/stored-routines.html\" target=\"_blank\" rel=\"noopener\" title=\"MySQL stored routines\">MySQL stored routines<\/a> capabilities.<br>If you are a javascript fan, you can now write your stored routine in that language since HeatWave MySQL 9.0: <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/9.0\/en\/stored-routines-js.html\" target=\"_blank\" rel=\"noopener\" title=\"MySQL 9.0 supports stored routines written in JavaScript:\">JavaScript Stored Programs<\/a><\/p>\n\n\n\n<p>That said, for the love of the (SQL) art, let&rsquo;s try something in SQL. But before diving into the code, let&rsquo;s break down the 3 steps above.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Get the tweet content from the source (table tweet)<\/h3>\n\n\n\n<p>In order to have a flexible stored procedure, the input parameters are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>source schema name: VARCHAR (<em>sentimentAnalysis<\/em>)<\/li>\n\n\n\n<li>source table name: VARCHAR (<em>tweet<\/em>)<\/li>\n\n\n\n<li>source column message: VARCHAR (<em>customer_msg<\/em>)<\/li>\n\n\n\n<li>source column primary key name: VARCHAR (<em>tweet_id<\/em>)<\/li>\n\n\n\n<li>tweet ID: INTEGER UNSIGNED (<em>ex: 1, 2, 3&#8230;.<\/em>)<\/li>\n\n\n\n<li>target schema name: VARCHAR (<em>sentimentAnalysis<\/em>)<\/li>\n\n\n\n<li>target table name: VARCHAR (<em>tweet_to_review<\/em>)<\/li>\n\n\n\n<li>target column result name: VARCHAR (<em>analysis_result<\/em>)<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To get the tweet content from the source the query is:<\/p>\n\n\n\n<p>SELECT &lt;source column message&gt; <br>FROM &lt;source schema name&gt;.&lt;source table name&gt; <br>WHERE &lt;source column primary key name&gt;=&lt;tweet ID&gt;<br>INTO @customer_msg<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Do the sentiment analysis using HeatWave GenAI<\/h3>\n\n\n\n<p>We&rsquo;ve already seen this part:<\/p>\n\n\n\n<p>Prompt instruction:<br>instructions=\u00a0\u00bb What is the feeling from the text above? if it is positive write 1. If it is negative write -1. if it is neutral or if you don&rsquo;t know write 0. Regarding to your analysis, write only -1 or 0 or 1&Prime;;<\/p>\n\n\n\n<p>Add the tweet to the prompt:<br>prompt=CONCAT(&lsquo;\u00a0\u00bb&lsquo;, @customer_msg, instructions, &lsquo;\u00a0\u00bb&lsquo;);<br><br>Inference setup:<br>inferenceSetup  = &lsquo;\\'{\u00ab\u00a0task\u00a0\u00bb: \u00ab\u00a0generation\u00a0\u00bb, \u00ab\u00a0temperature\u00a0\u00bb: 0, \u00ab\u00a0top_k\u00a0\u00bb: 0, \u00ab\u00a0top_p\u00a0\u00bb: 0, \u00ab\u00a0model_id\u00a0\u00bb: \u00ab\u00a0mistral-7b-instruct-v1&Prime;}\\\u00a0\u00bb;<br><br>And the Inference:<br>SELECT Answer-&gt;&gt;\u00a0\u00bb$.text\u00a0\u00bb AS \u00ab\u00a0Answer\u00a0\u00bb FROM (SELECT sys.ML_GENERATE(prompt, inferenceSetup) AS Answer ) AS dt INTO @answer ;<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Write problematic tweets into the target for further processing<\/h3>\n\n\n\n<p>And finally store the ID of the problematic message (tweet ID) and its status (-1 or 0):<\/p>\n\n\n\n<p>INSERT INTO &lt;target schema name&gt;.&lt;target table name&gt; (&lt;target column message ID name&gt;, &lt;target column result name&gt;) VALUES (&lt;tweetID&gt;, &lt;@answer&gt;)<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">How it works?<\/h3>\n\n\n\n<p>The stored routine is called: <em>genai_sentimentAnalysis<\/em>. <br>In the following examples, it is run with tweet ID: <strong>1<\/strong>, <strong>3<\/strong> and <strong>10<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nCALL genai_sentimentAnalysis(\"sentimentAnalysis\", \"tweet\", \"customer_msg\", \"tweet_id\", 1, \"sentimentAnalysis\", \"tweet_to_review\", \"analysis_result\");\n+-----------------------------------------------+\n| INFO                                          |\n+-----------------------------------------------+\n| Tweet number 1 as been analyzed as  POSITIVE  |\n+-----------------------------------------------+\n1 row in set (2.4341 sec)\n\nQuery OK, 0 rows affected (2.4341 sec)\n\n\nCALL genai_sentimentAnalysis(\"sentimentAnalysis\", \"tweet\", \"customer_msg\", \"tweet_id\", 3, \"sentimentAnalysis\", \"tweet_to_review\", \"analysis_result\");\n+-----------------------------------------------+\n| INFO                                          |\n+-----------------------------------------------+\n| Tweet number 3 as been analyzed as  NEGATIVE  |\n+-----------------------------------------------+\n1 row in set (1.9574 sec)\n\nQuery OK, 0 rows affected (1.9574 sec)\n\n\nCALL genai_sentimentAnalysis(\"sentimentAnalysis\", \"tweet\", \"customer_msg\", \"tweet_id\", 10, \"sentimentAnalysis\", \"tweet_to_review\", \"analysis_result\");\n+-----------------------------------------------+\n| INFO                                          |\n+-----------------------------------------------+\n| Tweet number 10 as been analyzed as  NEUTRAL  |\n+-----------------------------------------------+\n1 row in set (1.8339 sec)\n\nQuery OK, 0 rows affected (1.8339 sec)\n<\/code><\/pre>\n\n\n\n<p>The stored procedure output is a  log that is displayed on the console.<br>The first call generates 1 (tweet ID 1 is positive), the second -1 (tweet ID 3 is negative) and the third 0 (tweet ID 10 is neutral).<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Let&rsquo;s check the <em>tweet_to_review<\/em> table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSELECT tweet_id_to_check, analysis_result FROM tweet_to_review;\n+-------------------+-----------------+\n| tweet_id_to_check | analysis_result |\n+-------------------+-----------------+\n|                 3 |              -1 |\n|                10 |               0 |\n+-------------------+-----------------+\n<\/code><\/pre>\n\n\n\n<p>Only , tweet 3 and 10 are selected for the customer service team.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>For their dashboard you can provide more details with a query like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">mysql&gt;\nSELECT tweet_id_to_check, analysis_result, customer_msg \nFROM tweet_to_review INNER JOIN tweet ON tweet_id=tweet_id_to_check \nORDER BY analysis_result\\G\n*************************** 1. row ***************************\ntweet_id_to_check: 3\n  analysis_result: -1\n     customer_msg: Your mobile phone company is a joke. Can't believe I wasted my hard-earned money on your crappy products.\n*************************** 2. row ***************************\ntweet_id_to_check: 10\n  analysis_result: 0\n     customer_msg: For those who want a device that just works.\n\n\n<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Show me the code<\/h2>\n\n\n\n<p>Here the stored procedure used. <br>As a disclaimer, this code is not meant to run in production, it is for demonstration purpose only \ud83d\ude42<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"SQL\" class=\"language-SQL\">mysql&gt;\nDELIMITER $$\nCREATE DEFINER=`MyHeatwaveUser`@`%` PROCEDURE `genai_sentimentAnalysis`(IN _sourceSchema VARCHAR(64), IN _sourceTable VARCHAR(64), IN _sourceColMsg VARCHAR(64), IN _sourceColPK VARCHAR(64), IN _tweetID INTEGER UNSIGNED, IN _targetSchema VARCHAR(64), IN _targetTable VARCHAR(64), IN _targetColResult VARCHAR(64))\n    SQL SECURITY INVOKER\nBEGIN\n    DECLARE sourceTableName, targetTableName, targetCols VARCHAR(129);\n    DECLARE instructions, inferenceSetup VARCHAR(512);\n    DECLARE prompt VARCHAR(5000);\n    DECLARE rep VARCHAR(100);\n    \n    \/* Get the tweet content from source table *\/\n    SET sourceTableName = CONCAT(\"`\",_sourceSchema, \"`.`\", _sourceTable, \"`\");\n    SET @txtStmt = CONCAT(\"SELECT \", _sourceColMsg, \" INTO @customer_msg FROM  \", sourceTableName, \" WHERE \", _sourceColPK, \" = \", _tweetID);\n    PREPARE getTweet FROM @txtStmt;\n    EXECUTE getTweet;\n    DEALLOCATE PREPARE getTweet;\n    \n    \/* Sentiment analysis using HeatWave GenAI *\/\n    -- Prompt instruction\n    SET instructions=\" What is the feeling from the text above? if it is positive write 1. If it is negative write -1. if it is neutral or if you don't know write 0. Regarding to your analysis, write only -1 or 0 or 1\";\n\t\n    -- Add the tweet to the prompt\n    SET prompt=CONCAT('\"', @customer_msg, instructions, '\"');\n\t\n    -- Inference setup\n    SET inferenceSetup  = '\\'{\"task\": \"generation\", \"temperature\": 0, \"top_k\": 0, \"top_p\": 0, \"model_id\": \"mistral-7b-instruct-v1\"}\\'';\n\n    -- Inference: if positive retunr 1 \/ if negative return -1 \/ if neutral or unknown return 0\n    SET @txtStmt = CONCAT(' SELECT Answer-&gt;&gt;\"$.text\" AS Answer FROM (SELECT sys.ML_GENERATE(', prompt, ' , ', inferenceSetup, ' ) AS Answer ) AS dt INTO @answer');\n    PREPARE analysis FROM @txtStmt;\n    EXECUTE analysis;\n    DEALLOCATE PREPARE analysis;\n\n    \/* Write problematic tweets (status &lt;&gt; 0) into the target table for further processing *\/\t\n    SET rep = CONCAT('Tweet number ', _tweetID, ' as been analyzed as ');\n    IF @answer &lt; 1 THEN\n        BEGIN\n            SET targetTableName = CONCAT(\"`\",_targetSchema, \"`.`\", _targetTable, \"`\");\n            SET targetCols = CONCAT(\"(tweet_id_to_check, \", _targetColResult,\")\");\n            SET @txtStmt = CONCAT('INSERT INTO ', targetTableName, targetCols, ' VALUES (', _tweetID, ', ', @answer, ')');\n            PREPARE ins FROM @txtStmt;\n            EXECUTE ins;\n            DEALLOCATE PREPARE ins;\n            \n            \/* Logging *\/\n            CASE @answer\n                WHEN 0 THEN SELECT CONCAT(rep, ' NEUTRAL ') AS 'INFO';\n                WHEN -1 THEN SELECT CONCAT(rep, ' NEGATIVE ') AS 'INFO';\n            END CASE;\n        END;\n    ELSE SELECT CONCAT(rep, ' POSITIVE ') AS 'INFO';\n    END IF;\n       \nEND$$\nDELIMITER ;<\/code><\/pre>\n\n\n\n<p>As you see, all the logic is coded inside the procedure. It would probably make sense to break the different tasks to separate procedures\/functions.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Areas for improvement<\/h2>\n\n\n\n<p>As you can imagine, the prompt is crucial. While I&rsquo;ve tried kept things simple for this tutorial, effective prompt engineering is essential for getting the desired results from an LLM.<\/p>\n\n\n\n<p>Remember to review the LLM&rsquo;s output carefully. Even though we expect an integer, the model might generate something unexpected (not handle in the stored procedure).<\/p>\n\n\n\n<p>As of {HeatWave} MySQL 9.0.0, you can now write stored routines in JavaScript. However, stored procedures aren&rsquo;t mandatory. Choose the language that best suits your needs and start experimenting! \ud83d\ude42 <\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Peroration<\/h3>\n\n\n\n<p>In this article, we&rsquo;ve explored how to <strong>leverage Oracle HeatWave GenAI to perform sentiment analysis on text data<\/strong>. By integrating in-database large language models <strong>HeatWave offers an easy, streamlined and efficient solution<\/strong> for understanding customer sentiment.<\/p>\n\n\n\n<p>We&rsquo;ve covered the essential steps involved, from loading the LLM into HeatWave memory to crafting effective prompts and analyzing the model&rsquo;s output. By following these guidelines, you can easily incorporate sentiment analysis into your data pipeline and gain valuable insights into customer feedback.<\/p>\n\n\n\n<p>Remember that effective prompt engineering is key to obtaining accurate and meaningful results. Experiment with different prompts and refine your approach to achieve the desired outcomes.<\/p>\n\n\n\n<p><strong>With HeatWave GenAI, you have a powerful tool at your disposal for extracting valuable information from text data<\/strong>. By harnessing its capabilities, you can enhance your understanding of customer sentiment, improve decision-making, and drive business success.<\/p>\n\n\n\n<p>Stay tuned for more insights!<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><a href=\"https:\/\/www.linkedin.com\/groups\/12524512\/\" target=\"_blank\" rel=\"noopener\" title=\"Olivier DASINI on Linkedin\">Follow me on Linkedin<\/a><\/p>\n\n\n\n<p>Watch my videos on my <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier's MySQL Channel\">YouTube channel<\/a> and <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\/?sub_confirmation=1\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Subscribe\">subscribe<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/www.slideshare.net\/freshdaz\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Slideshare\">Slideshare account<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/speakerdeck.com\/freshdaz\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Speaker Deck\">Speaker Deck account<\/a>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Thanks for using HeatWave &amp; MySQL!<\/strong><\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This new AI tech, called generative AI (or GenAI), can dive deep into what people are saying and tell us if they\u2019re feeling positive, negative, or neutral.<br \/>\nLet\u2019s see how HeatWave GenAI, can help you to enhance your understanding of customer sentiment, improve decision-making, and drive business success.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[1694,203,339],"tags":[1700,1697],"class_list":["post-6960","post","type-post","status-publish","format-standard","hentry","category-heatwave-en","category-mysql-en","category-tuto-en","tag-genai","tag-heatwave-fr-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-1Og","jetpack-related-posts":[{"id":7363,"url":"https:\/\/dasini.net\/blog\/2025\/03\/13\/build-an-ai-powered-search-engine-with-heatwave-genai-part-1\/","url_meta":{"origin":6960,"position":0},"title":"Build an AI-Powered Search Engine with HeatWave GenAI (part 1)","author":"Olivier DASINI","date":"13 mars 2025","format":false,"excerpt":"Discover how to build an AI-powered search engine for your applications using HeatWave GenAI. This approach leverages large language models (LLMs) for semantic search, offering a smarter alternative to traditional SQL and full-text search methods. By using embeddings\u2014vector representations of words\u2014the search engine understands context and intent, delivering more relevant\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7711,"url":"https:\/\/dasini.net\/blog\/2025\/04\/15\/build-an-ai-powered-search-engine-with-heatwave-genai-part-3\/","url_meta":{"origin":6960,"position":1},"title":"Build an AI-Powered Search Engine with HeatWave GenAI (part 3)","author":"Olivier DASINI","date":"15 avril 2025","format":false,"excerpt":"In this latest post, the final part of my series on building an AI-powered search engine with HeatWave GenAI, I dive into enhancing AI-powered search by embedding full article content into HeatWave. By cleaning HTML, chunking content, generating embeddings, and running semantic similarity searches directly within HeatWave, we unlock highly\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6752,"url":"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/","url_meta":{"origin":6960,"position":2},"title":"HeatWave GenAI: Your AI-Powered Content Creation Partner","author":"Olivier DASINI","date":"7 ao\u00fbt 2024","format":false,"excerpt":"Generative artificial intelligence (GenAI) is reshaping the content creation landscape. By training on vast datasets, these \"intelligent\" systems can produce new, human-quality content across a multitude of domains. Oracle's HeatWave GenAI (starting with version 9.0.1) is at the forefront of this revolution, offering an integrated platform that combines in-database large\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7252,"url":"https:\/\/dasini.net\/blog\/2025\/02\/11\/building-an-interactive-llm-chatbot-with-heatwave-using-python\/","url_meta":{"origin":6960,"position":3},"title":"Building an Interactive LLM Chatbot with  HeatWave Using Python","author":"Olivier DASINI","date":"11 f\u00e9vrier 2025","format":false,"excerpt":"AI-powered applications require robust and scalable database solutions to manage and process large amounts of data efficiently. HeatWave is an excellent choice for such applications, providing high-performance OLTP, analytics, machine learning and generative artificial intelligence capabilities. In this article, we will explore a Python 3 script that connects to an\u2026","rel":"","context":"Dans &quot;HeatWave&quot;","block_context":{"text":"HeatWave","link":"https:\/\/dasini.net\/blog\/category\/heatwave-en\/"},"img":{"alt_text":"simple but robust chatbot system leveraging HeatWave GenAI and its in-database Mistral LLM","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":8393,"url":"https:\/\/dasini.net\/blog\/2025\/10\/07\/let-your-ai-dba-assistant-write-your-mysql-queries\/","url_meta":{"origin":6960,"position":4},"title":"Let Your AI DBA Assistant Write Your MySQL Queries","author":"Olivier DASINI","date":"7 octobre 2025","format":false,"excerpt":"Having explored the innovative MySQL HeatWave technology that converts Natural Language into SQL (Ask Your Database Anything: Natural Language to SQL in MySQL HeatWave), our next article in this series, dives into a practical use case demonstrating how an AI DBA Assistant can significantly simplify your query generation workflow. In\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/10\/reltime_monitor.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/10\/reltime_monitor.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/10\/reltime_monitor.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/10\/reltime_monitor.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":6825,"url":"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/","url_meta":{"origin":6960,"position":5},"title":"In-Database LLMs for Efficient Text Translation with HeatWave GenAI","author":"Olivier DASINI","date":"13 ao\u00fbt 2024","format":false,"excerpt":"While HeatWave GenAI excels at generating English text, its capabilities extend to translation as well. Let's explore how we can effectively translate English content into French using this powerful tool.","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/6960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=6960"}],"version-history":[{"count":96,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/6960\/revisions"}],"predecessor-version":[{"id":7163,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/6960\/revisions\/7163"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=6960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=6960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=6960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}