For the complete documentation index, see llms.txt. This page is also available as Markdown.

GenAI

Generative artificial intelligence (GenAI) can create certain types of images, text, videos, and other media in response to prompts ..

GenAI components

So does it work?

At its core, a GenAI system is built around a large language model (LLM) — a neural network trained on vast amounts of text. Through that training, it learns patterns in language: grammar, facts, reasoning styles, and how ideas connect. When you interact with it, the model isn't "looking things up" — it's generating responses based on those learned patterns.

Before the model generates anything, everything relevant gets assembled into a prompt context. This is the full picture the model sees: a system prompt (instructions defining how it should behave), your message, any documents retrieved from a knowledge source, and any results from tool calls made earlier in the conversation. The richer and more relevant this context, the better the output.

Knowledge sources extend what the model knows beyond its training data. Using a technique called RAG (Retrieval-Augmented Generation), the system searches a database or document store for content relevant to your query and injects it into the context. This is how GenAI systems can answer questions about your own documents or up-to-date information.

Tools give the model the ability to act — not just respond. During a conversation, the model can decide to call an external API, run a piece of code, or search the web. The result comes back into the context, and the model uses it to form its final answer. This loop is what makes agentic AI possible.

Finally, the inference engine takes the assembled context and generates a response token by token — each word (or part of a word) is predicted based on everything that came before it. This continues until the response is complete. The output might be plain text, structured data, or a trigger for another action.


Let's take a look at the GenAI steps availble as an EE plugin ..

  1. Start Pentaho Data Integration:

HTML Parser

The HTML Parser is a utility plugin for Pentaho Data Integration (PDI) that extracts desired text from HTML or XML files. Useful for cleaning data for natural language processing tasks like sentiment analysis and SEO keyword analysis.

  • Accepts input from both data streams and files

  • Supports parsing using Xpath expressions or CSS selectors

  • Can process single files or multiple inputs from a stream

  • Compatible with local and virtual file systems

The plugin utilizes jsoup, a Java library, that simplifies working with real-world HTML and XML. It offers an easy-to-use API for URL fetching, data parsing, extraction, and manipulation using DOM API methods, CSS, and Xpath selectors.

The step is located in the Input folder.


Select XPath or CSS Selectors as the parsing method:

XPath

XPath (XML Path Language) is a query language for selecting nodes from an XML or HTML document. While Jsoup doesn't natively support XPath, we can use a combination of Jsoup and Java's built-in XPath capabilities to achieve this.

Here's an overview of some common XPath syntax:

/ - Selects from the root node

// - Selects nodes anywhere in the document

. - Selects the current node

.. - Selects the parent of the current node

@ - Selects attributes

[] -Used for predicates (conditions)

Some examples:

  • //div - Selects all div elements in the document

  • //div[@class='content'] - Selects all div elements with class 'content'

  • //h1/text() - Selects the text content of all h1 elements

  • //div[@class='content']/p - Selects all p elements that are direct children of div elements with class 'content'


HTML Data Source


Select HTML source:

Filepath

HTML Parser - Xpath
  1. Open the following transformation.

Filepath

The data source is referenced in a path.

Linux

~/Projects/genai/html/HTML Parser - Xpath.ktr

  1. Double-click on the hp: html and configure with the following settings:

Set path to file

Leaving Xpath field blank will result in all tags being removed and all the content returned.

3. RUN and preview the results.

Results - no Xpath

These XPath queries will help you navigate and extract specific content from the homepage.html

Select the main title:

Select all navigation links:

Select all article titles (h3 elements within articles):

Select all paragraph content within articles:

Select all author names:

Select the latest news items:

Select the footer text:

Select all section titles (h2 elements that are direct children of section elements):

Select the second article:

Select all elements with a class attribute:

Filepath from stream

The data source is referenced as a filepath in a datastream field.

  1. Enable the hop between: dg: filepath from stream -> hp: parse html xpath.

  2. Disable the hop between: Data Grid -> hp: parse html xpath

dg: html from stream -> hp: parse html xpath

Filepath from stream
  1. Double-click on the hp: html and configure with the following settings:

Filepath from stream
  1. RUN and preview the results.

Results

x

x

x

HTML from stream

The data source is referenced as <html> in a data stream field.

Pentaho's data streams often use binary fields to handle various types of data, including large text objects like HTML. By using binary datum, you ensure that the entire HTML content is treated as a single, uninterpreted chunk of data within the Pentaho pipeline - represented as 0 or 1.

Storing the HTML as binary datum allows you to pass the raw content through various steps in your Pentaho transformation without Pentaho trying to interpret or modify the HTML prematurely.

  1. Enable the hop between: dg: html from stream -> hp: parse html xpath.

  2. Disable the hop between: dg: filepath from stream -> hp: parse html xpath

Data Grid -> hp: parse html xpath

html from stream
  1. Double-click on the hp: html and configure with the following settings:

html from stream
  1. RUN and preview the results.

Results

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It's widely used for transmitting data over media that are designed for textual data.

The BASE64 step is located in the Transform folder.

Consider the sentence Hi, where the \n represents a newline. The first step in the encoding process is to obtain the binary representation of each ASCII character. This can be done by looking up the values in an ASCII-to-binary conversion table.

Text to ASCII bianry

ASCII uses 8 bits to represent individual characters, but Base64 uses 6 bits. Therefore, the binary needs to be broken up into 6-bit chunks.

ASCII binary to 6-bit Base64

Finally, these 6-bit values can be converted into the appropriate printable character by using a Base64 table.

6-bit converted to character

Since Base64 uses 24-bit sequences, padding is needed when the original binary cannot be divided into a 24-bit sequence. You have probably seen this type of padding before represented by printed equal signs (=). For example, Hi without a newline is represented by only two 8-bit ASCII characters (for a total of 16 bits). Padding is removed by the Base64 encoding schema when data is decoded.

Base64 with padding

Base64 is not necessarily used to protect information. It has the advantage that it can convert mostly any type of byte encoding into a human-readable ASCII.

  1. Open the following transformation.

Base64

Windows

C:/Projects/genai/base64/Base64 Encode.ktr

Linux

~/Projects/genai/base64/Base64.ktr.

  1. Double-click on the Base64 Encoder step and configure with the following settings:

Base64 encode an image
  1. Check the Select values step.

Select values - encoded_output
  1. RUN and preview the results.

Encoded image-92.jpg

RAW Text

The Data grid holds the RAW Text that will be encoded.

  1. Enable the hop between: Data grid - Raw Text Input -> Base64 Encoder.

  2. Disable the hop between: Data grid -> Base64 Encoder

Get file names images -> Base64 Encoder

RAW Text
  1. Double-click on the Data grid -Raw Input Text step - Data tab

Data grid
  1. Check the Select values.

Select values - RAW Text
  1. RUN and preview the results

Results - RAW Text

Multiple Files

Encode multiple files.

  1. Enable the hop between: Get file names - Images -> Base64 Encoder

  2. Disable the hop between: Data grid - Raw Text Input -> Base64 Encoder.

Data grid -> Base64 Encoder

Multiple files
  1. Double-click on the Get File names - Images step.

Expose all file names with .jpg extension
  1. Double-click on the Base64 Encoder and configure with the following settings:

File name paths are held in the filename field
  1. Check the Select values.

  1. RUN and preview the results.

Results - multiple images

Pentaho GenAI is an extension of the Pentaho Data Integration that incorporates generative AI capabilities. It aims to enhance data workflows processes by leveraging large language models and other AI technologies.

OpenAI released an API platform that enables the creation of 'assistants' that can perform a wide range of tasks:

Natural Language Querying: Users can ask questions or provide prompts to large language models (LLMs) like OpenAI and Azure OpenAI, allowing for natural language interaction with data and systems.

Document Analysis: The plugin supports attaching documents for LLMs to process, enabling users to analyze and extract insights from text files and related documents.

Sentiment Analysis: The plugin can, for example, be used to determine the sentiment of text data, such as tweets.

Log Analysis: Process and analyze log files, potentially for troubleshooting or identifying patterns.

Structured Data Generation: The plugin supports generating responses in both text and JSON formats, allowing for the creation of structured data from natural language inputs.

Data Extraction and Transformation: The plugin can be used within Pentaho Data Integration (PDI) workflows, assisting in extracting and transforming data as part of larger ETL processes.

Question Answering: The plugin supports using document embeddings to efficiently answer multiple questions about a document(s), making it useful for information retrieval and FAQ-style applications.

Prompt Engineering: Users can create structured templates and use PDI environment variables for dynamic prompt generation, allowing for flexible and customizable interactions with LLMs.

Moderation and Content Filtering: The plugin includes options for response moderation, which can be used to filter / flag potentially harmful or inappropriate content.

Resources

Link to OpenAI
Link to OpenAI Assisants
Link to a great blog by the one and only Mr AI - Rishu Shrivastava

Pentaho Data Integration

Pentaho Data Integration + OpenAI Assistant

Let's start exploring some simple chat scenarios:

  • Enter the prompt directly.

  • Pass the prompt and 'role' in data stream fields.

  • Configure the step to use your own OpenAI account details.

The step is located in the AI folder.

Enter Prompt

  1. Enable the hop between: Data Grid -> AI Chat.

  2. Disable the hop bewteen: User Input -> AI Chat.

Simple AI Chat
  1. Open the following transformation:

Windows

C:/Projects/genai/ai chat/.ktr

Linux

~/Projects/genai/html/HTML Parser - Xpath.ktr

  1. Double-click on the hp: html and configure with the following settings:

  2. Double-click on the AI Chat step and configure with the following settings:

Enter your question?

Run Instruction for LLM

Role-playing with Large Language Models (LLMs), such as ChatGPT, is an emerging field that explores the interaction between AI and creative, narrative-driven experiences. It leverages the advanced capabilities of LLMs to simulate human-like dialogue and human behavior within a role-playing context.

This process enables the AI to engage in dynamic conversations, mimic various characters, and respond to user inputs in a manner that aligns with the character’s predefined traits and narrative context, making use of powerful computation of large corpus of text data. In this way, this role-playing technique enhances its efficiency in tasks that require specific skills or knowledge, such as acting like a historian or providing historical facts and analyses.

  1. Click on the Model tab.

Model Configuration

The temperature value ranges from 0 to 2, with lower values indicating greater determinism and higher values indicating more randomness.

The moderations endpoint is a tool you can use to check whether text is potentially harmful. Developers can use it to identify content that might be harmful and take action, for instance by filtering it.

Moderation
  1. RUN and preview the result.

Results

Prompt from Data Stream fields

You can send multiple questions to ChatGPT.

However, there are limits to the number of requests an LLM model can accept. The response will fail if the threshold limit is reached.

Prompt & Role set from data stream fields
  1. Disable the hop between: Data Grid -> AI Chat.

  2. Enable the hop bewteen: User Input -> AI Chat.

  3. Double-click on the User Input step and the Data tab.

User Input
  1. Double-click on the AI Chat step and configure with the following settings:

Stream - Message & 'Role'
  1. RUN and preview result.

Multiple prompts & 'roles'

Configure Model with your own account details

The 'pipeline' configuration is the same as the previous scenario.

You will require to enter your own OpenAI key.

  1. Double-click anywhere on the canvas to configure the Parameters.

Parameters
  1. Double-click on the AI Chat step and configure with the following settings.

Configure Model
  1. RUN and preview the result. Should be the same as the previous scenario ..!!

RAG (Retrieval-Augmented Generation) is a technique in artificial intelligence that combines information retrieval with text generation. It's particularly useful for keeping AI systems updated without constant retraining and for providing responses grounded in specific, retrievable facts.

Non-persistant RAG

So .. in the data folder you will find a story about Charlie the happy go lucky carrot who, with his friends, lives in Veggeville ..

If you don't attch the document then the response will ask for more information as it can't place Charlie in any context.

  1. Enable the hop between: Data Grid -> AI Chat.

RAG
  1. Double-click on the AI Chat step and configure with the following settings:

Attach the Veggeville story for context
  1. Click on the Embedding tab.

An embedding model converts words, phrases, or other data into numerical vectors. These vectors serve as a bridge between raw data and machine learning algorithms by creating meaningful, computable representations of complex information.

  1. RUN and preview the result.

Charlie the happy carrot ..

Embedding - Write

Let's change the embbedding to store to WRITE to persist the results as a file -

openai-embedding-store.json.

This file is particularly useful in RAG (Retrieval-Augmented Generation) systems, where quick access to embeddings is crucial for efficient information retrieval.

  1. Double-click on the AI Chat step and then on the Embedding tab.

  2. Configure with the following settings.

Persist the Embedding
  1. RUN & check that the embedding has been stored.


Embedding - READ

Now that a Veggeville embedding has been created, we can ask questions leveraging the vector store: openai-embeeding-store.json

  1. Double-click on the AI Chat step and configure with the following settings:

Enter new prompt ..
  1. Click on the Embedding tab and confiure with the following settings:

READ the embedding.
  1. RUN and preview the result.

Happy Veggeville

A prompt is essentially the input given to an AI model to elicit a desired output or behavior. It can range from simple questions to complex instructions or examples.

Prompt engineering is the art and science of crafting these inputs to optimize the AI's performance for specific tasks. This involves carefully selecting words, providing context, and structuring the prompt to guide the model towards producing the most accurate, relevant, and useful responses.

  1. Double-click anywhere on the canvas to set the parameters.

Parameters
  1. Double-click on the Chat AI step and configure with the following settings:

Prompt PDI variables.
  1. RUN and preview the result.

Results - JSON object

Prompt - Template

With a little prompt engineering, the response can populate a 'template'.

  1. Double-click on the Chat AI step and configure with the following settings:

  1. RUN and preview the result.

Result - yum

Let's run through some Use Cases:

Sentiment Analysis - Determine the sentiment of a tweet: Positive, Neutral, Negative.

Log Analysis - Analyze multiple log files for any errors. The errors are hopefully resolved by AI Chat with the results written to a CSV file.

Analyzes multiple log files to identify errors, then using AI Chat to provide with a resolution. The generated result is in JSON format and the processed output is stored as a CSV file.

  1. Open the following transformation:

Windows

C:/Projects/genai/aichat/Usecase - Log Analysis.ktr

Linux

~/Projects/genai/aichat/Usecase - Log Analysis.ktr

  1. Double-click on the hp: html and configure with the following settings:

Log Analysis

The Prompt has been engineered to analyze log files identifying errors. The errors are resolved using

  1. Double-click on the AI Chat step to view the settings.

AI Chat

Message / Prompt

Document

Determines location the data source:

File - Browse and enter the path to the data source

Stream - the data (or reference) is being passed in a data stream field. In this workshop the paths to the log files are being passed from the previous step in the filename data stream field.


Model

  1. Click on the Model tab.

Model options

The temperature value ranges from 0 to 2, with lower values indicating greater determinism and higher values indicating more randomness.

The moderations endpoint is a tool you can use to check whether text is potentially harmful. Developers can use it to identify content that might be harmful and take action, for instance by filtering it.


Embedding

  1. Click on the Embedding tab.

Embedding options

Enter your embedding model and whether you want to create and persist in a file or keep it as default In-Memory.

Take a look at the RAG workshop.


Response

  1. Click on the Response tab.

Response

The response is held as a JSON object in the result field.

The response JSON object needs to be parsed to create our data stream fields.

  1. Double-click on the Process generated JSON result step.

File tab - data source is being passed in the result field from the previous step.
  1. Click on the Fields tab.

Configure the path to the fields.

Take a look at the result field (preview data in AI Chat step) to determine the structure of the JSON object / array.

This should reflect the structure of the prompt template.

JSON Notation

JSON Exp
Description
Sample

$

Root object

$ returns the whole JSON structure

.

Child operator; it's used to access different levels of the JSON structure

$..Issue returns the Issue

  1. RUN and preview result - Output - log-analysis.csv

result - log analysis

The sentiment_analysis function analyzes the overall sentiment of the discussion. It considers the tone, the emotions conveyed by the language used, and the context in which words and phrases are used.

Sentiment Analysis
  1. Double-click on the AI Chat step.

AI Chat - Sentiment Analysis

Again a bit of prompt engineering enables the tweets from the Tweet data stream field.

  1. RUN and preview result - Text file output.

result - sentiment analysis

One of the most common problems for large, high-growth businesses is dealing with increasing volumes and varieties of financial data - more specifically, extracting the data from PDF documents such as quarterly reports, balance sheets, bank statements and cash flow statements.

Without a solution to handle these data extraction tasks at scale, operations quickly become error-prone and time-consuming. This is why a growing number of organisations are now implementing AI data extraction tools.

Analyze Finacial Reports

In this use case we're going to extract sales data from PDF reports, using Pentaho Data Integration.

Review the main steps of the

The Apache Tika™ toolkit detects and extracts metadata and text from over a thousand different file types (such as PPT, XLS, and PDF).

  1. The previous step - Get file names returns the paths to the PDFs.

Get file names
  1. Double-click on the Read Unstructured Document step to view settings.

Tika step

Based on the filenames passed in the filename field, the pdf contents are extracted and associated with the pdf_file_contents data stream field.

  1. Double-click on the AI Chat step to view the settings.

Message - Templated prompt

Under the Message tab, a templated prompt provides the model the instructions to extract the sales data, from the data stream field pdf_file_contents which has the extracted pdf.

  1. Click on the Model tab.

Model

Based on parameters set in the transformation properties, the OpenAI model, API Key and Temeprature, are set.

  1. Click on Embedding tab.

Embedding

Based on parameters set in the transformation properties, the Embedding model is set.

  1. Click on the Response tab.

The Response is returned as a JSON object associated with the generated_response data stream field.

This is where we have to put our thinking caps on ..

In the generated_response data stream field the SaleYear & SaleMonth sales data is defined as JSON objects with an array for each:

ProductCategory

UnitSold

Revenue

This will have to be a 2 stage process.

Stage 1 - is to extract the SaleYear & SaleMonth.

Record: SaleYear: SaleMonth:

  1. 2024 August

  2. 2024 July

Stage 2 - iterates through the SalesPerformanceByProduct[array] for each Stage 1 record.

So .. on the first iteration SaleYear = 2024 SaleMonth = August

ProductCategory: UnitSold: Revenue:

Eco-Gear 1,500 $150,000

Smart Home Devices 1,200 $180,000

Fitness Equipment 960 $96,000

Accessories 1,200 $74,000

This is repeated for Record 2 ..

generated_response

It would be interesting to give this a go using: Hierachical Data Type (HDT) EE plugin

The Select values step can perform all the following actions on fields in the data stream:

  • Select values

  • Remove values

  • Rename values

  • Change data types

  • Configure length and precision of values

  1. Double-click on the Select values step.

Select values
  1. RUN and preview the result.

result - Select values

The Microsoft Excel Writer step writes incoming rows from PDI out to an MS Excel file and supports both the .xls and .xlsx file formats.

The .xls files use a binary format which is better suited for simple content, while the .xlsx files use the Open XML format which works well with templates since it can better preserve charts and miscellaneous objects.

  1. Double-click on Write the Sales Forecast to Excel.

Excel writer

A 'Sales Report AI Generated' is created with an xlsx extension.

If the file exists, its replaced with 'new output file'.

The data set is written to active - Sheet 1.

  1. Click on the Content tab.

The beginning data set is written to cell A1

Any existing cells are overwritten.

Header cells are wriiten.

Get Fields - retrieves the data stream fields.

  1. RUN and open the file:

~/Projects/genai/Use Case - Analyzing Financial Reports/data/Sales Report AI Generated.xlsx

Sales Report

x

x

x

CSS selectors are powerful tools for targeting specific HTML elements, and they're used not only for styling but also for selecting elements when extracting data from HTML documents.

Below are some examples of the syntax used to extract HTML snippets

Basic Selectors

a) Element Selector:

b) Class Selector:

c) ID Selector:

d) Universal Selector:

Combinators

a) Descendant Selector (space):

b) Child Selector (>):

c) Adjacent Sibling Selector (+):

d) General Sibling Selector (~):

Attribute Selectors

a) [attribute]:

b) [attribute="value"]:

c) [attribute~="value"]:

d) [attribute^="value"]:

e) [attribute$="value"]:

f) [attribute*="value"]:

Pseudo-classes

Combining Selectors

HTML Data Source

x

x

x

Transformation

HTML Parser - CSS

Filepath

The data source is referenced in a path.

  1. Open the following transformation:

Windows

C:/Projects/genai/html/HTML Parser - CSS.ktr

Linux

~/Projects/genai/html/HTML Parser - CSS.ktr

  1. Double-click on the hp: html and configure with the following settings:

HTML Parser - CSS

Leaving CSS field blank will result in all tags being removed and all the content returned.

  1. RUN preview the results.

Set path to file - no CSS

These CSS queries will help you navigate and extract specific content from the landingpage.html

Select the main title:

Select all navigation links:

Select all product titles:

Select all product descriptions:

Select all product prices:

Select the "About Us" section:

Select the newsletter form:

Select all section titles (h2 elements):

Select the footer text:

Select all elements with a class of "product":

x

x


Filepath from stream

The data source is referenced as a filepath in a datastream field.

  1. Enable the hop between: dg: filepath from stream -> hp: parse html xpath.

  2. Disable the hop between: Data grid -> hp: parse html css

dg: html from stream -> hp: parse html css

filepath from stream
  1. Double-click on the hp: html and configure with the following settings:

Filepath from stream
  1. RUN preview results.

Results - Filepath from stream

HTML from stream

The data source is referenced as <html> in a data stream field.

Pentaho's data streams often use binary fields to handle various types of data, including large text objects like HTML. By using binary datum, you ensure that the entire HTML content is treated as a single, uninterpreted chunk of data within the Pentaho pipeline - represented as 0 or 1.

Storing the HTML as binary datum allows you to pass the raw content through various steps in your Pentaho transformation without Pentaho trying to interpret or modify the HTML prematurely.

  1. Enable the hop between: dg: html from stream -> hp: parse html css.

  2. Disable the hop between: dg: filepath from stream -> hp: parse html css

Data grid -> hp: parse html css

html from stream
  1. Double-click on the hp: html and configure with the following settings:

HTML from stream
  1. RUN preview results.

Results - HTML from stream

Apache Tika is a content analysis toolkit that extracts text, metadata, and language from a variety of file formats. It's commonly used in data processing to prepare data for further analysis.

  • Supports a wide range of document formats including PDFs, Word documents, and HTML files.

  • Extracts metadata such as author, title, creation date, and language.

  • Can be integrated into larger data processing pipelines for automated content extraction.

  • Facilitates full-text search indexing and content classification.

The step is located in the Input folder.

Link to Apache Tika

The data source is a word document.

The document type is referenced in a datastream field.

Word Document

  1. Open the following transformation:

Word document

Windows

C:/Projects/genai/tika/Read Unstructured Document- Word Doc.ktr

Linux

~/Projects/genai/tika/Read Unstructured Document- Word Doc.ktr

  1. Double-click on the Read Unstructured Document step and configure with the following settings:

Word document
  1. RUN and preview the results.

Results

The data source is a password protected PDF document.

The document type is referenced in a datastream field.

  1. Open the following transformation:

PDF password protected document

Windows

C:/Projects/genai/tika/Read Unstructured Document- Password PDF.ktr

Linux

~/Projects/genai/tika/Read Unstructured Document- Password PDF.ktr.

  1. Double-click on the Read Unstructured Document step and configure with the following settings:

PDF password protected
  1. RUN and preview the results.

PDF password protected

Multiple documents are referenced as the data source.

The Javascript step is used to add the PDF password.

  1. Open the following transformation:

Multiple documents

Windows

C:/Projects/genai/tika/Read Unstructured Document- Stream Multiple Files.ktr

Linux

~/Projects/genai/tika/Read Unstructured Document- Stream Multiple Files.ktr.

  1. Double-click on the Javascript: Add password column.

Add PDF password

A data stream field: filepass is associated with the password: qweasd

  1. Double-click on the Read Unstructured Document step and configure with the following settings:

Pass filenames + password
  1. RUN and preview the results.

Results

Last updated

Was this helpful?