Icon

02_Build a Chat Bot on a Knowledge Base_Exercise

There has been no title set for this workflow's metadata.

Exercise - Build your own AI-powered chatbot without writing a line of code.

Annotations and comments
  • Exercise 02 - 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.
  • Activity 1. Create Knowledge Base 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. 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. 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. 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. 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 2. Use an LLM for a Completion Task via the Knowledge Base 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". LLM Hyperparameter Tuning Inside the OpenAI LLM Connector customize the parameters "max tokens" and "temperature". 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. 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. 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 3. Create Chat Bot Data App on Knowledge Base 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". Chat Model Hyperparameter Tuning Inside the OpenAI Chat Model Connector customize the parameters "max tokens" and "temperature". 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. 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.
  • remove ground truth
  • OpenAI Credentials
  • Strip text from PDFs
  • Save conversation history
  • Conversation history
  • Save empty conversation history in workflow data area

Nodes

Extensions

Links