Icon

GPT4All - Create your own LLM Vector Store

<p>Create your own LLM Vector Store with GPT4All local models<br><br>KNIME 5.3+ supports creating you own Knowledge base for LLMs, a local Vector Store to explore your own documents and question them with AI.<br><br>Workflow adapted from:<br><br>https://hub.knime.com/-/spaces/-/~WNe6bb2w2bemYBWE/current-state/<br><br>----<br><strong>MEDIUM Blog: Creating a Local LLM Vector Store from PDFs with KNIME and GPT4All</strong><br>https://medium.com/p/311bf61dd20e<br><br><br><strong>MEDIUM Blog: KNIME, AI and local Large Language Models&nbsp;(LLM)</strong><br>https://medium.com/p/cef650fc142b</p><p></p><p><strong>KNIME for Generative AI</strong></p><p>https://hub.knime.com/-/collections/~D4ckx2q_J5FPBQXu/</p>

URL: 4 levels of LLM customization - KNIME Blog https://www.knime.com/blog/4-levels-llm-customization
URL: AI Learnathons - KNIME Forum https://forum.knime.com/t/knime-ai-learnathons-are-here/73733
URL: How to Build AI-Powered Data Apps using KNIME - KNIME Webinar https://hopin.com/events/how-to-build-ai-powered-data-apps-using-knime-4bc6c73d-ae97-4c5f-be30-c0d8ea2dd52c
URL: MEDIUM Blog: KNIME, AI and local Large Language Models (LLM) https://medium.com/p/cef650fc142b
URL: GPT4All (download models) https://gpt4all.io/index.html
URL: forum entry (75594) https://forum.knime.com/t/gpt4all-embeddings/75594/5?u=mlauber71
URL: MEDIUM Blog: Creating a Local LLM Vector Store from PDFs with KNIME and GPT4All https://medium.com/p/311bf61dd20e
URL: HUB: AI Extension Example Workflows https://hub.knime.com/-/spaces/-/~CzxTTU_Gi4moY5Gz/
URL: Bug: offline settings for GPT4All models https://forum.knime.com/t/community-nodes-knime-ai-extensions-gpt4all-connectors-bug-when-used-offline/76021/6?u=mlauber71
URL: KNIME for Generative AI https://hub.knime.com/-/collections/~D4ckx2q_J5FPBQXu/

Annotations and comments
  • Create your own LLM Vector Store (from your documents) with GPT4All local models [please download the whole workflow group - https://hub.knime.com/-/spaces/-/latest/~17k4zAECNryrZw1X/] GPT4All is an ecosystem to train and deploy powerful and customized large language models that run locally on consumer grade CPUs. The goal is simple - be the best instruction tuned assistant-style language model that any person or enterprise can freely use, distribute and build on. GPT4All installer can be found here (https://gpt4all.io/index.html) You will also need the KNIME AI Extension - if you are behind a firewall see the box below To learn more about the workflow, click the left bar and check the description section. More models: https://gpt4all.io/index.html
  • Workflow has been adapted from this example utilizing OpenAI/ChatGPT (sending data to the internet) : https://hub.knime.com/-/spaces/-/~WNe6bb2w2bemYBWE/current-state/
  • A) Create Knowledge Base Step 1: Download the GPT4All models you want to use Place your GPT4All models (.gguf) in the ../gpt4all_models/ folder. [https://gpt4all.io/index.html]. You could try Mistral or Llama3 Step 2: Select your GPT4All model Select the model (.gguf) you want to use. The name will automatically be added to the text Step 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. Step 4: Create the vector store Search, drag and drop FAISS Vector Store Creator node, connect to the Embeddings4All Connector and your string sections output. Execute the node on the column with the strings to create the vector store. You can either download a suitable embedding like (all-MiniLM-L6-v2.gguf2.f16.gguf) or let the node download the default. Step 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" and specify the name of the vector store such as "vector_store.model". The models can become quite large. So be aware.
  • B) Use an LLM for a Completion Task via the Knowledge Base Step 1: Load the selected GPT4All model Load the model into the GPT4All Chat Model Connector. Here you can use the Flow Variable from the left side. Step 2: 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 part A). Step3: Check and if necessary edit the prompt You might want to edit some information and instructions around the question itself you want to ask. In the "GPT4All Chat Model Connector" you might also have to adapt the settings and the prompt template. You might have to read up in the model descriptions or try a few things. Step 4: Connect to the Vector Store Retriever and the LLM Prompter, run the questions thru the model and the Vector Store Drag in the Vector Store Retriever node and the LLM Prompter node, in-between add a String Manipulation node for Prompt Engineering. Step 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. Step 6: Inspect the results Inspect and compare the results.
  • You can consider further text preparations. You can test if combining Documents might help, if it is better to 'clean' the texts or leave the content as it is.
  • If you are behind a firewall you might take additional steps in order to load KNIME Python based extensions like "LLM Prompter" https://docs.knime.com/latest/pure_python_node_extensions_guide/index.html#_offline_installation install your extensions on a system that has full internet access collect all your Python packages thru the KNIME settings (Download required packages for offline installation to") It will download all the Python packages for all environments (Windows, Mac, Apple Silicon and Linux) bring the folder to your machine behind the firewall set up an environment variable "KNIME_PYTHON_PACKAGE_REPO_URL" with the path of this folder https://forum.knime.com/t/ai-extension-cannot-be-installed-on-knime-5-1/71368/15?u=mlauber71 install the extensions on the firewall-machine (it will use the local repository) if you encounter problems see the LOG file and find the folder with the generated list of PIP installed extensions (pip_pkg_urls.txt). Remove all references to external sites (like "https://files.pythonhosted.org/packages ...)" that might be there and try again There is a ticket out to fix the Proxy problem for Python based extensions (AP-20960): https://forum.knime.com/t/knime-ai-extension-proxy-settings-are-not-taken-over/72391/3?u=mlauber71
  • C) 'Live' Chat with your GPT4All model using your Vector Store Step 1: Load Model and Vector Store like before Load the model into the GPT4All Chat Model Connector. Here you can use the Flow Variable from the left side. Step 2: Select the initial Role for the prompt and the number of documents to be searched Besides your precise question there should be a role being defined and some additional instructions.
  • RLHF: Reinforcement Learning from Human Feedback May 2, 2023 • Chip Huyen https://huyenchip.com/2023/05/02/rlhf.html
  • Currently, there is a bug where, even when there is no internet connection, the GPT4All models still call their server. (A ticket has been created to fix this: AP-21736) https://forum.knime.com/t/community-nodes-knime-ai-extensions-gpt4all-connectors-bug-when-used-offline/76021?u=mlauber71 A workaround is to set an option in a Python file: https://forum.knime.com/t/community-nodes-knime-ai-extensions-gpt4all-connectors-bug-when-used-offline/76021/6?u=mlauber71
  • keep questions and LLM response
  • remove ground truth
  • keep only LLM response
  • current time
  • all-MiniLM-L6-v2-f16.gguf => edit the value of your local embedding
  • Embedding model like all-MiniLM-L6-v2-f16.gguf => if you choose "Download" a model will be loaded
  • ../script/questions.xlsx
  • <...model name...>.gguf load the .gguf model needs KNIME 5.3 you can change settings like choosing GPU
  • "engineered_prompt"
  • knowledge base ../model/product_manual_book.model
  • ../model/product_manual_book.model
  • Strip text from PDFs
  • var_embedding_model
  • remove sentences with less than 5 terms
  • extract sentences in different rows
  • prompt engineering cf. hints -> "engineered_prompt"
  • sample file to collect results
  • reload the current saved chat with GPT4All
  • compare correct answers with LLM answers
  • save chat as .table with timestamp
  • adapt the number of Documents provided for each question
  • my_Timestamp
  • Bubble shape
  • Top: first row Bottom:rest
  • Prompt
  • Response
  • css_header with subtitle
  • css_header without subtitle
  • Header
  • titles padding
  • image size
  • syntax check
  • logo image in base64 format.
  • padding to have image in middle position
  • predefined colors background
  • predefined colors text
  • title
  • Background Color Code
  • text Color Code
  • image base64 format
  • subtitle
  • colors
  • correct syntax
  • prepare for CSS
  • padding title
  • number-of-documents
  • var_title prompt
  • Ask the model
  • prompt engineering
  • Initial_Role Define initial role with regards to your document
  • reload history
  • save new history
  • white space
  • User message
  • stamp_day_txt
  • stamp_time_txt
  • model-name
  • var_file_name
  • var_model_path
  • var_file_name_html
  • var_file_name_pdf
  • var_file_name_xlsx
  • model-title
  • var_name_vector_store
  • var_file_name_part
  • browse folder with .bin models
  • stamp_day
  • stamp_time
  • stamp_*
  • bin-models-path

Nodes

Extensions

Links