GBase 8c + DeepSeek Redefines On-Premises Knowledge Base Creation
What is an LLM?
LLM is the abbreviation for Large Language Model, an AI model based on deep learning that learns from massive text data to understand and generate human language. These models typically contain tens of billions (or more) of parameters, and through layered neural network structures, they learn and simulate the complex patterns of human language, achieving near-human text generation capabilities.
What is RAG?
RAG stands for Retrieval Augmented Generation, a method that combines information retrieval and natural language generation techniques. It aims to enhance the capabilities of generative models by introducing external knowledge bases, thereby improving the quality and accuracy of generated content.
Why Do You Need RAG When You Have an LLM?
Ø LLM Knowledge Limitations: LLM model knowledge originates from its training data, and mainstream large models' training sets are basically constructed datasets, which cannot access real-time, non-public or offline data, thus lacking this knowledge.
Ø LLM Hallucination Limitations: The underlying principle of LLMs is based on mathematical probability, and their model output is essentially a series of numerical operations, so LLMs sometimes make up plausible-sounding but incorrect information, especially in areas where they lack knowledge or are not proficient.
Ø LLM Data Security: In the current AI era, data security is paramount. No enterprise is willing to risk data leakage by uploading proprietary private data to third-party platforms for training. This forces applications relying solely on general-purpose LLMs to compromise between data security and effectiveness.
Why Choose GBase 8c V6 + DeepSeek?
Ø Powerful Performance, Stable and Efficient: As a leading Chinese distributed database, GBase 8c offers exceptional performance, enhanced security and stability. The V6 version integrates a self-developed distributed vector engine, with comprehensive optimizations to the optimizer and executor compared to V5, delivering significant performance gains. DeepSeek's RAG model accurately understands user needs.
Ø Flexible Customization, Infinite Possibilities: On-premises deployment allows users to freely customize knowledge base content and functionalities according to their needs, creating an AI assistant that truly understands them.
Ø Data Security, Privacy Assurance: Sensitive data is stored locally, eliminating the risk of information leakage and enabling worry-free use.
Ø Offline Availability, Reliable Stability: No network dependency required. Access your knowledge base anytime, anywhere with stability and smooth performance.
Ø Cost Control, Long-term Benefits: Deploy once, use indefinitely without the need for ongoing high cloud service costs.
Setting Up the Basic Environment
The operating system used in this experiment is CentOS 7 (x86_64), and Python 3.11 is used for the development environment.
Installing Python 3.11
If installing from source, the source package can be downloaded at https://www.python.org/ftp/python/3.11.11/
If the system's OpenSSL version is too low, you need to upgrade to OpenSSL 1.1.1.
When configuring, specify --with-openssl, then make and make install.
Run the following command to verify the installation:
$ python3 --versionPython 3.11.11
Installing Ollama Service
First, we need to download the Ollama PyPI package to access the Ollama service via Python:
[gbase@gbase8c-5-155 ~]$ pip3 install ollamaThen install the Ollama service (refer to https://github.com/ollama/ollama/blob/main/docs/linux.md). You can use the one-line installation command:
curl -fsSL https://ollama.com/install.sh | shAlternatively, manual installation:
curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgzsudo tar -C /usr -xzf ollama-linux-amd64.tgzStart the Ollama service:
ollama serveIn another terminal, check if the service started successfully:
Obtaining the Text Embedding Model
We selected nomic-embed-text.
nomic-embed-text is an open-source text embedding model with significant advantages in processing both short and long text tasks. It converts input text into 768-dimensional vector data, which is then stored in the GBase 8c database via psycopg2, providing robust support for subsequent retrieval and matching. Use the following command to obtain it:
$ ollama pull nomic-embed-text
Obtaining the Text Generation Model:
We selected DeepSeek-r1.
The DeepSeek-r1 model is developed based on advanced deep learning technologies, featuring a unique architecture and training method that captures semantic information more effectively, leading to superior text generation results. Use the following command to obtain it:
ollama pull deepseek-r1
Installing GBase 8c Database
Store private domain knowledge locally with the GBase 8c distributed vector database, enabling fast retrieval while providing more robust and secure data protection.
Obtain the GBase 8c installation package and refer to the 'GBase 8c V6_1.0.0 Installation and Deployment Guide' for database setup.
After successful deployment, check the cluster status:
Installing psycopg2
pip3 install psycopg2Connect to GBase 8c via psycopg2 to view version information:
Output as follows:
Building a RAG Instance: Efficient Knowledge Retrieval and Generation
Preparing Corpus Data
Using a portion of GBase corpus data as private domain knowledge, with some content as follows:
Corpus Processing, Embedding, and Import
After execution, the table structure and data in the GBase 8c database are as follows:
Query and Retrieval
Retrieval using only DeepSeek:
The answer content is as follows:
Retrieval using GBase 8c V6 + DeepSeek:
First, convert the question into a vector, then search in the GBase 8c vector knowledge base. Use the retrieved results as context, create a prompt for the large model, and finally ask the question:
The answer content is as follows:
As can be seen, the RAG application built with DeepSeek and GBase 8c not only leverages DeepSeek's powerful text generation and precise embedding capabilities, but also utilizes GBase 8c's outstanding vector database for efficient storage and fast retrieval of vector data. This significantly improves the accuracy and reliability of answers, effectively avoids the hallucination problem of large language models, and delivers superior localized knowledge services for enterprises.
Summary
Based on Ollama, we successfully built a simple RAG application from scratch using GBase 8c and DeepSeek, and obtained the required knowledge data. In this process, we gained a deeper understanding of RAG technology and the GBase 8c vector database, and truly experienced their role in addressing real-world LLM application challenges. This simple application is just a starting point; readers can flexibly adjust and optimize relevant aspects according to their own needs to better meet the requirements of different scenarios.