HeatWave GenAI: Your AI-Powered Content Creation Partner

August 7, 2024
Tags:

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 language models (LLMs), vector stores, and scale-out vector processing to streamline content generation.

This article explores how HeatWave GenAI is empowering businesses to produce high-quality content rapidly and effectively, making it an indispensable tool for industries demanding speed, accuracy, and security.

HeatWave GenAI brings LLMs directly into your database, enabling powerful AI capabilities and natural language processing.

The key benefits of such architecture are:

  • Effortless LLM Integration: Simple SQL queries unlock AI power.
  • Seamless Database Integration: No complex external connections.
  • Simplified Architecture: Easy management and scalability.
  • Scalable Performance: Handles large datasets and high traffic.
  • Always Up-to-Date Data: In-database LLMs ensure data freshness.

Generate text-based content using HeatWave GenAI is a very simple 4 steps process:

  1. Load the LLM in HeatWave memory
  2. Define your prompt in natural language
  3. Inference setting
  4. Generate text-based content using HeatWave GenAI

Load the LLM in HeatWave memory

Use the ML_MODEL_LOAD stored procedure: CALL sys.ML_MODEL_LOAD(‘<LLM>’, NULL);
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’t have to reload the model for each text generation.

At the time of writing (August 2024) the available models are Mistral 7B (mistral-7b-instruct-v1) and Llama 2 (llama2-7b-v1).

-- Load Mistral 7B model
mysql>
CALL sys.ML_MODEL_LOAD('mistral-7b-instruct-v1', NULL);

Define your prompt in natural language

Like with you prefered programming language, it is more convenient to use a session variable: SET @userPrompt=”My prompt”;

mysql>
SET @userPrompt="Explain what is Generative Artificial intelligence in one sentence";

or whatever your needs:

SET @userPrompt="How to connect to MySQL using Python 3?";
SET @userPrompt="Write a short email to schedule a meeting.";
...

As you likely know, the quality of the prompt significantly impacts the generated text.

Inference setting

Here, you select the desired task, choose the appropriate model, and fine-tune parameters to influence the output.

mysql> 
-- Inference setting
SET @inferenceSetup  = '{"task": "generation", "model_id": "mistral-7b-instruct-v1"}';

For simplicity, this example uses default parameters. A more complex example is provided below.

Generate text-based content using HeatWave GenAI

Last step is to pass the user prompt to the LLM using the ML_GENERATE function. The second parameter of this function is a JSON object that allows you to specify the task, the LLM, and some tuning options like the temperature.

mysql>
SELECT sys.ML_GENERATE(@userPrompt, @inferenceSetup)\G

The output in a JSON that is not really nice to read.
But SQL is very powerful and you can easily improve the output using JSON_TABLE function.

mysql>
SELECT GenContent AS GenContent FROM ( SELECT sys.ML_GENERATE(@userPrompt, @inferenceSetup) AS textGen ) AS dt INNER JOIN JSON_TABLE ( dt.textGen, "$" COLUMNS( GenContent text PATH "$.text") ) AS jt \G

You can influence LLM outputs by adjusting parameters like temperature, number of tokens, stop sequences, top_k, top_p, etc…

Text generation options include:

  • task
  • model_id
  • temperature
  • max_tokens
  • top_k
  • top_p
  • repeat_penalty
  • stop_sequences
  • token_likelihoods
  • echo
  • logprobs
  • stream
  • context


Below is a quick example:

mysql>
-- Define your prompt in natural language
SET @userPrompt="Explain what is Generative Artificial intelligence in one sentence";


-- Inference setting
SET @inferenceSetup  = '{"task": "generation", "temperature": 3, "repeat_penalty": 1, "top_k": 1, "max_tokens": 500, "model_id": "mistral-7b-instruct-v1"}';


-- Generate text-based content
SELECT GenContent AS GenContent FROM ( SELECT sys.ML_GENERATE(@userPrompt, @inferenceSetup) AS textGen ) AS dt INNER JOIN JSON_TABLE ( dt.textGen, "$" COLUMNS( GenContent text PATH "$.text") ) AS jt \G
*************************** 1. row ***************************
GenContent:  Generative Artificial Intelligence (AI) refers to a subset of AI that involves the creation of new, original content, such as images, music, or text, through the use of algorithms and machine learning models that can learn from and generate data.

And that’s all!
As you can see, it’s very simple and easy with HeatWave GenAI to create some exciting GenAI based applications like:

Enhancing Customer Experience

  • Intelligent Chatbots: Provide real-time, personalized customer support, answering queries, and resolving issues efficiently.
  • Sentiment Analysis: Understand customer feedback, identify trends, and tailor responses accordingly.

Boosting Content Creation

  • Content Generation: Create engaging blog articles, product descriptions, and social media posts at scale.
  • Personalized Recommendations: Offer tailored product suggestions based on customer preferences and behavior.
  • Social Media Management: Generate engaging content, schedule posts, and monitor performance.

Driving Business Insights

  • Text Classification: Categorize vast amounts of text data for efficient analysis and decision-making.
  • Market Research: Analyze customer sentiment, identify trends, and gain competitive insights.

Generative AI is a game-changer, offering endless possibilities to improve efficiency, enhance customer experiences, and drive business growth.

HeatWave GenAI: Your AI-Powered Content Creation Partner demo

Moving forward

While the examples provided offer a glimpse of generative AI’s potential, it’s important to note that significant improvements can be achieved through advanced prompt engineering techniques. Exploring these techniques in depth is beyond the scope of this article.

In upcoming articles, we’ll delve deeper into HeatWave GenAI’s capabilities, showcasing its application in text translation and Retrieval Augmented Generation (RAG).

Stay tuned for more insights!

Follow me on Linkedin

Watch my videos on my YouTube channel and subscribe.

My Slideshare account.

My Speaker Deck account.

Thanks for using HeatWave & MySQL!

Leave a Reply