Build an enterprise knowledge base with PAI and Hologres

Updated at:

This topic describes how to use Compute Nest to deploy the required hardware and software resources for a large model-based Q&A knowledge base with Hologres in one click. This helps you quickly build an enterprise-grade Q&A knowledge base.

Background

  • Hologres is Alibaba's self-developed, one-stop real-time data warehouse product. It supports online analytical processing (OLAP) of massive data and online data services (Serving) with high concurrency and low latency. It is also deeply integrated with Proxima, a high-performance vector computing software library developed by DAMO Academy, to deliver high-performance, low-latency, and easy-to-use vector computing. For more information about how Proxima is used in Hologres, see Proxima vector computing.

  • PAI-EAS is Alibaba Cloud's online model serving platform. You can deploy models as online inference services or AI-Web applications in a single click. You can also deploy popular services and applications, such as large language model (LLM) inference and AIGC. PAI-EAS is suitable for various AI inference scenarios, including real-time inference and near-real-time asynchronous inference. It provides serverless automatic scaling and a comprehensive O&M and monitoring system. For more information, see Product architecture.

  • LangChain is an open-source framework that integrates large models, vector databases, and custom corpora to efficiently build dedicated Q&A knowledge bases. Hologres is now integrated with LangChain as a vector database. For more information, see LangChain-Hologres.

  • Compute Nest is a service management PaaS platform for service providers and users. It provides an efficient, convenient, and secure service experience. Service providers can better deploy, deliver, and manage services on Alibaba Cloud. Users can centrally manage the various services they subscribe to from different providers on Alibaba Cloud. With Compute Nest, you can provision the hardware and deploy the software required for a Q&A knowledge base in one click. For more information about Compute Nest, see Product modes.

Prerequisites

If you use a RAM user to build the knowledge base, ensure the RAM user has the required permissions. For the required permissions and how to grant them, see Authorize a RAM user.

Create a Compute Nest service instance

  1. Go to the Compute Nest Service Marketplace page, select Hologres+PAI 5-Minute Quick Deployment of Enterprise Q&A Knowledge Base, and then click Start Deployment.

  2. On the Create Service Instance page, configure the following parameters.

    Parameter

    Description

    Service Instance Name

    The name of the Compute Nest service instance.

    Region

    Select the region for the Hologres, PAI-EAS, and ECS instances.

    Billing Method Configuration

    Billing Method

    You can select pay-as-you-go or subscription based on your needs.

    Note

    ECS and Hologres instances support pay-as-you-go and subscription. PAI-EAS instances support only pay-as-you-go.

    Hologres Instance Configuration

    Number of Hologres Compute Cores

    Select the instance type for Hologres compute resources.

    Hologres storage resources are billed on a pay-as-you-go basis by default. We recommend that you purchase a suitable storage plan based on your data volume.

    PAI-EAS Large Model Configuration

    Select Large Model

    The large language model (LLM) to deploy.

    PAI Instance Type

    The instance type for deploying the large model with PAI-EAS.

    PAI-EAS WebUI Configuration

    PAI Instance Type

    The instance type for deploying the WebUI with PAI-EAS.

    VPC Configuration

    vSwitch Zone

    Select the zone for the vSwitch.

    Create VPC

    Specifies whether to create a new VPC. Valid values:

    • Enable: Automatically generates the corresponding VPC Instance ID and vSwitch Instance ID. When a Compute Nest service instance is created, the corresponding VPC information is also created.

    • Disable: Manually select the VPC instance ID and vSwitch instance ID.

    VPC Instance ID

    Select the ID of an existing VPC.

    vSwitch Instance ID

    Select the ID of an existing vSwitch.

    Tags and Resource Group

    Tag

    Select or enter a tag key and value to tag the service resources. You can add up to 20 tags to each resource.

    If no tag keys or values are available, you can create custom tags. For more information about how to create custom tags, see Create and add a custom tag.

    Resource Group

    Select the resource group to which your resources belong.

    Resource groups allow you to group your cloud resources by factors such as purpose, permission, and ownership. This enables hierarchical resource management for multiple users and projects in your organization. For more information, see Resource Group.

  3. Click Next: Confirm Order. On the confirmation page, review the dependency check and authorization information, and then click Create Now.

    After the service instance is created, you can view its status on the Service Instance Management page.

Use the knowledge base

  1. Configure and connect to the knowledge base.

    1. Go to the Service Instance Management page and click the ID of the deployed instance to open the Service Instance Details page.

    2. In the Instance Information section, click endpoint to open the Hologres+Large Model WebUI.

    3. On the Settings tab of the Hologres+Large Model WebUI, configure the following parameters.

      • User: The AccessKey ID of your Alibaba Cloud account or RAM user. You can obtain your AccessKey ID from the AccessKey Management page.

      • Password: The AccessKey Secret that corresponds to the AccessKey ID. You can obtain your AccessKey Secret from the AccessKey Management page.

      Note

      Compute Nest pre-configures the connection information for the embedding model, PAI-EAS online model service, and the Hologres instance. This includes the VPC Host, Port, and Database (default: chatbot). You do not need to modify it.

    4. Click Connect to Hologres.

      If the message Connected to Hologres successfully is displayed in the Connection Information section, the connection is successful.

  2. On the Upload tab, select your corpus file and click Upload. This topic uses an example corpus file.

    After the upload is complete, the message Successfully uploaded 1 file [ example_data.txt, ] ! is displayed in the Status section, indicating a successful upload.

    The Status section also displays the message The relevant content has been successfully encoded and uploaded to the vector database. You can start chatting now!, which indicates that the data is ready.

  3. On the Chat tab, configure the chat response parameters.

    Parameter

    Description

    Select Chat Mode

    • Vector Database: Answers questions by performing a vector-based approximate nearest neighbor search on your corpus in Hologres.

    • Large Language Model: Answers questions by using the original pre-trained large language model.

    • Vector Database + Large Language Model: Uses the corpus data you uploaded to Hologres to perform a vector approximate search, and then uses the large model to refine the search results to provide an optimized response.

    Query the k most relevant corpus entries

    The number of relevant corpus entries to retrieve. The default value is 3.

    Select prompt template

    The style of the response. You can select General, URL Extraction, or Custom.

    We recommend that you use the General template.

  4. Enter your question in the input box and click Submit.

    The left-side pane of the Chat tab provides options to select a chat mode (Vector Database, Large Language Model, or Vector Database + Large Language Model), set the number of most relevant corpus entries to query, and select a prompt template (General, URL Extraction, or Custom). After you submit a question, the model's answer appears in the Chatbot pane on the right. The Summarize and Clear Conversation buttons are at the bottom.

Note

You can use the connection information for the large model deployed by PAI-EAS to integrate the knowledge base with your applications, such as a DingTalk group chat. For more information, see Customize a dedicated chatbot for free based on Hologres and a large model.