Icon

Build a Chat Bot on a Knowledge Base

Solution - Build your own AI-powered chatbot without writing a line of code.
Activity 2. Use an LLM for a Completion Task via the Knowledge Base

  1. Authenticate with OpenAI and select an LLM model

    • Similarly to the past exercise use the OpenAI Authenticator with the Credentials Configuration flow variable input.Then add an OpenAI LLM Connector and select "gpt-3.5-turbo".

  2. LLM Hyperparameter Tuning

    • Inside the OpenAI LLM Connector customize the parameters "max tokens" and "temperature".

  3. Adopt the Knowledge Base from the Vector Store

    • The Model Reader node reads from the workflow data area the vector store you previously created. Reading again from disk the vector store is good practice to learn how to deploy with a fixed knowledge base. You can also use the output of the FAISS Vector Store Creator from the past exercise.

  4. Connect to the Vector Store Retriever and the LLM Prompter

    • Drag in the Vector Store Retriever node and the LLM Prompter node,

      in-between add a String Manipulation node for Prompt Engineering.

  5. Export Results to an Excel File

    • You can save the table via an Excel Writer node. Optionally you can compare with a Table View node the answers by the LLM and the ones we imported with the questions for reference.



Activity 1. Create Knowledge Base

  1. Authenticate with OpenAI

    • Search, drag and drop OpenAI Authenticator, add the flow variable connection from the Credential Configuration node. Configure the node by selecting "credentials", then execute.

  2. Select embedding model to create vectors

    • Search, drag and drop OpenAI Embedding Connector node and execute with default settings. This will pick the AI embedding model "text-embedding-ada-002" to create vectors from the input sentences.

  3. Divide PDF text into sentences

    • Search, drag and drop Sentence Extractor node and execute on the column "Document" from the "PDF Parser" node. This will split the document cell in multiple rows: one row for each sentence. Then use a Row Filter node to remove all sentences below 5 terms.

  4. Create the vector store

    • Search, drag and drop FAISS Vector Store Creator node, connect to the OpenAI Embeddings Connector and your string sections output. Execute the node on the column with the strings to create the vector store.

  5. Save the vector store

    • Save the vector store by adding a Model Writer node. To save properly you can use a relative path: selected "Relative to" then "Workflow Data Area" and specify the name of the vector store such as "vector_store.model"



Activity 3. Create Chat Bot Data App on Knowledge Base

  1. Authenticate with OpenAI and select a chat model

    • Similarly to the past exercise use the OpenAI Authenticator with the Credentials Configuration flow variable input.Then add an OpenAI Chat Model Connector and select "gpt-3.5-turbo".

  2. Chat Model Hyperparameter Tuning

    • Inside the OpenAI Chat Model Connector customize the parameters "max tokens" and "temperature".

  3. Adopt the Knowledge Base from the Vector Store

    • Add a Model Reader node to read from the workflow data area the vector store you previously created. Reading again from disk the vector store is good practice to learn how to deploy a data app with a fixed knowledge base.

  4. Connect to the input of the Component

    • Connect the Connector output to the top input of the component, the Reader output to the bottom input. Then open the component (Ctrl + Double Left Click on it) for the next steps.



Build a Custom Chatbot

Learning objective: In this exercise, you will build your own AI-powered, custom chatbot.


Workflow description: This workflow shows how to create a domain-specific knowledge base, use an LLM for a completion task via the knowledge base and create a chatbot data app on the knowledge base.


You’ll find the instructions for the exercises in the yellow annotations.

LLM Prompter
OpenAI Credentials
Credentials Configuration
FAISS Vector Store Creator
Excel Reader
knowledge base
Model Reader
Model Writer
Excel Writer
OpenAI Credentials
Credentials Configuration
Table View (JavaScript)
Column Appender
OpenAI Authenticator
compare correct answerswith LLM answers
Table View (JavaScript)
OpenAI Chat Model Connector
extract sentencesin different rows
Sentence Extractor
OpenAI Credentials
Credentials Configuration
remove sentences with less than 5 terms
Row Filter
open this viewto see the last executionwhere questions about thecoffee machine where askedthrough the data app UI
Table View (JavaScript)
to open:Ctrl + Double Left Click
Custom Chat Bot on Manual Book
OpenAI LLM Connector
Vector Store Retriever
prompt engineering
String Manipulation
OpenAI Authenticator
double click to open
Prompt Engineering Hint
OpenAI Authenticator
remove groundtruth
Column Filter
OpenAI Embeddings Connector
knowledge base
Model Reader
keep onlyLLM response
Column Filter
Strip text from PDFs
PDF Parser

Nodes

Extensions

Links