Icon

01. GenAI Learnathon_Exercise

<p>GenAI Learnathon: Enrich Data Analytics with GenAI<br><br>During this hands-on learnathon, you will get familiar with the free low-code tool KNIME Analytics Platform, techniques for fraud detection, and the use of GenAI via the KNIME AI Extension.<br><br>Without any coding experience you will learn to:</p><ul><li><p>Detect fraud in investment contracts visually and using statistical techniques</p></li><li><p>Prompt engineer an LLM via the OpenAI integration</p></li><li><p>Create a vector store from a corpus of different types of investment contracts (the knowledge base)</p></li><li><p>Build and deploy a data app to display email alerts and make it available to authenticated users on a web browser</p></li></ul><p>Other KNIME AI integrations we will discuss include GPT4All, Hugging Face, Chroma, FAISS and more.</p>

URL: KNIME AI Extension https://hub.knime.com/knime/extensions/org.knime.python.features.llm/latest/
URL: KNIME for Generative AI https://hub.knime.com/knime/collections/KNIME%20for%20Generative%20AI~D4ckx2q_J5FPBQXu

Annotations and comments
  • A) Analytics Workflow: Visual Detection for Fraud Step 1: Blend extracted contracts data with a database Search, drag and drop a Value Lookup to create a single table with all the available information you have on contracts. Step 2: Prepare data for visualization Search, drag and drop a Sorter to sort the rows by date. Step 3: Visualize contract data Visually inspect the 'payment' column to spot fraud via at least two view nodes. We recommend: Bar Chart, Scatter Plot, Histogram and Box Plot. Step 4: Create a dashboard data app with multiple charts To display all your chart in the same view, you need to create a Component. Select all the view nodes (Ctrl + Left Click) then Right Click > Create Component. Next, go inside the component (Right Click > Component > Open component) and customize the layout (Open layout editor in top toolbar). Step 5: Visually detect frauds in the data app Open the component composite view. Can you visually detect fraud by investigating odd values in the payment column? You can optionally add: a title via a Text View, and interactivity by adding a Table View inside the component and configure it to 'Show only selected rows'.
  • B) Analytics Workflow: Outlier Detection for Fraud Step 1: Perform outlier detection Search, drag and drop a Numeric Outliers to perform an automated detection of extreme values for the column 'payments' using the interquartile range. Step 2: Inspect the detected outliers Search, drag and drop a Tile View to visualize the first output of the Numeric Outliers. Are those the same contracts you visually detected in Part A? What happens if you change k in the Numeric Outliers settings? Step 3: Save outlier detection model for Part E Search, drag and drop a Model Writer to save the last output of the Numeric Outlier node (blue port) in the 'models' folder (located in Relative to > Current workflow). This will save the model for later when we want to apply the same technique on a new contract.
  • C) Enriching Analytics with GenAI: Prompting for Email Alerts Step 1: Get API key If you are solving this exercise in a KNIME learnathon event, provide the username and password in the "Get API Key" component to access the OpenAI API keys. Seek guidance from the organizers on how to get the credentials. If you're solving this exercise at home, drag and drop the Credentials Configuration. Paste in the settings 'password' your own OpenAI API key. Pass the credential flow variable to the downstream Authenticator. Execute the OpenAI Authenticator to check if the API key is working. Step 2: Select an LLM model Search, drag and drop an OpenAI LLM Connector. You can use default settings initially and come back to this later. Recommended: 'gpt-3.5-turbo-instruct'. Step 3: Engineer a prompt for email alerts and feed it to the LLM Search, drag and drop a String Manipulation, and connect it to the output of Part B. Structure a prompt to create an email alert for each of the contracts. Next, prompt the LLM with an LLM Prompter. Experiment with different prompts and model settings. What happens when the temperature in the OpenAI LLM Connector changes? Step 4: Visualize the LLM output Visualize the alert message produced by the LLM Prompter with a String Format Manager (set 'between words') and Table View (set 'Row Height > Custom > 500').
  • D) Enriching Analytics with GenAI: Providing Context for Email Alerts Step 1: Segment knowledge base PDF in sections Search, drag and drop a Sentence Extractor and apply it to the PDF Parser output, that is the document describing different types of investments. This will segment the document into rows, each containing a different sentence from the PDF. Step 2: Create a vector store from the segmented knowledge base Search, drag and drop a FAISS Vector Store Creator to convert the text sections in vectors and store them in a FAISS vector store. Connect the input embeddings model from the OpenAI Embeddings Connector. Save the Vector Store for Part E in the 'models' folder by adding a Model Writer node. Step 3: Retrieve text describing the contract type of detected fraud Search, drag and drop a Vector Store Retriever to search in the vector store the relevant sentences describing the contract types for the detected frauds in Part B. Connect as first input the vector store, and as second input the Tile View output from Part B. Select 'type' in the settings. Step 4: Engineer a prompt for email alerts with contract type context Similarly to Step 3 of Part C, search, drag and drop a String Manipulation to engineer the prompt generating the alert emails. This time add the context from the vector store to explain the contract type. Step 5: Perform retrieval augmented generation (RAG) Like in Part C, search, drag and drop an LLM Prompter, and feed it with the output of the String Manipulation. Finally, visualize the generated emails via the provided component.
  • Fraud Detection via Analytics
  • Advanced GenAI Adoption for generating an alert email
  • Data Wrangling: Access, Blending, Manipulation
  • Simple GenAI Adoption for generating an alert email
  • E) Deploy Fraud Detection with GenAI Alert on KNIME Business Hub (OPTIONAL) See workflow 02. GenAI Learnathon_Deployment_Exercise in learnathon folder.
  • keep only responses
  • Save responses
  • Download email alerts
  • Remove leading/trailing whitespaces
  • Footnote
  • line
  • boolean-input
  • with or without link?
  • page?
  • doc?
  • hex-code-type-page
  • line break
  • text-size
  • font-color
  • font-family
  • text-position
  • font-weight
  • text-input
  • hex codes
  • title-size
  • sub-title-size
  • Page-type-size
  • all inputs
  • title-color
  • sub-title-color
  • page-type-color
  • title-icon
  • graphics
  • title-tooltip
  • Title
  • short-description
  • string-input-page-type
  • string-input-link-title
  • text
  • color hex codes
  • icon
  • html grahics
  • line below
  • Without link
  • withpage
  • without page
  • image
  • With link 2
  • "Investment Agreement
  • KNOW ALL
  • euros
  • the amount of
  • . Name & Signature
  • Agreement , on
  • . IN WITNESS WHEREOF ,
  • is via email
  • contract id
  • payment
  • date
  • Extract Text of each PDF
  • Application password
  • Select API key name
  • Join API name and SecretID
  • API key names and secretID
  • prompt engineering

Nodes

Extensions

Links