Retrieval enhancement generation knowledge base construction method and device, equipment and storage medium
By constructing quality control standards in the retrieval enhancement generation system, and performing multi-stage clustering and knowledge asset integration, the problems of low quality and efficiency in RAG system construction were solved, achieving high-quality and efficient knowledge base construction and improving user experience.
Patent Information
- Application Number
- CN202611675073.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-28
- Publication Date
- 2026-11-24
AI Technical Summary
Existing Retrieval Augmentation (RAG) systems suffer from low quality and efficiency in building knowledge bases, making it difficult to effectively improve their performance in scenarios such as intelligent question answering, dialogue systems, and content creation assistance.
By constructing quality control standards, including redundancy control rules, representativeness control rules, and timeliness control rules, multi-stage clustering and knowledge asset integration are carried out. Initial question-answer pairs are extracted by combining large language models and audited to ensure that only audited knowledge assets enter the knowledge base.
It improved the quality and efficiency of knowledge base construction, reduced the redundancy of knowledge assets, increased the accuracy of standard questions and answers, ensured the timeliness of knowledge assets, and enhanced the user experience.
Smart Images

Figure CN123159494A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of database construction technology, and more specifically, to a method, apparatus, device, and storage medium for constructing a retrieval-enhanced knowledge base. Background Technology
[0002] Retrieval Augmented Generation (RAG) technology has attracted widespread attention as a key technical approach to improve the performance of Large Language Models (LLMs) in knowledge-intensive tasks. By combining the powerful generative capabilities of LLMs with the accurate information retrieval from external knowledge bases, RAG effectively alleviates the inherent "illusion" problem of LLMs (i.e., generating inaccurate or fictitious information) and enhances the factual consistency, reliability, and timeliness of the generated content.
[0003] Currently, RAG systems are widely used in various scenarios such as intelligent question answering, dialogue systems, report generation, and content creation assistance, becoming an important cornerstone for building next-generation intelligent applications. However, how to improve the build quality and efficiency of RAG systems is a technical problem that urgently needs to be solved. Summary of the Invention
[0004] This disclosure provides at least one method, apparatus, device, and storage medium for constructing a retrieval-enhanced generative knowledge base, which can improve the efficiency and quality of database construction.
[0005] In a first aspect, embodiments of this disclosure provide a method for constructing a retrieval-enhanced knowledge base, the method comprising: Acquire conversation data and extract it using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text; The question texts in the initial question-answer pair set are semantically vectorized, and the question vectors are clustered based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; A quality control specification is constructed, which includes redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules are used to constrain the semantic merging between different initial question clusters. The representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rules are used to constrain the validity period of knowledge assets. The redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold. A second clustering is performed on the multiple initial question clusters based on the second similarity threshold to obtain multiple target question categories; the second similarity threshold is less than the first similarity threshold; The representativeness control rules are used to integrate the initial question-answer pairs corresponding to each target question category to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question categories. Each target knowledge asset is audited and verified to obtain the corresponding audit verification result. Based on the audit verification result, a retrieval-enhanced knowledge base is constructed. The audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
[0006] In one possible implementation, the method further includes: If the audit verification result indicates that the audit has failed, the target issue category corresponding to the target knowledge asset will be determined as the audit failure category. Increase the second similarity threshold, and re-cluster the problem vectors of the initial problem clusters within the audit failure category based on the increased second similarity threshold to form multiple new target problem categories; Perform subsequent steps until the audit verification result indicates that it has passed, and add the corresponding target knowledge asset to the retrieval enhancement generation knowledge base.
[0007] In one possible implementation, the representativeness control rule includes: determining the mean of all question vectors within each target question category to obtain the corresponding category semantic center vector; calculating the distance between each question vector within the target question category and the category semantic center vector, and selecting the question with the closest distance as the standard question of the target question category.
[0008] In one possible implementation, the step of integrating knowledge from the initial question-answer pairs corresponding to each target question category using the representativeness control rules to obtain the corresponding target knowledge assets includes: For each target question category, knowledge integration is performed on the initial question-answer pairs corresponding to the target question category according to the representativeness control rules to obtain the standard question corresponding to the target question category; The answer quality of multiple answer texts within the target question category is evaluated, and the answer text with the highest answer quality is selected as the standard answer for the target question category based on the evaluation results; alternatively, multiple answer texts within the target question category are synthesized to generate the standard answer for the target question category.
[0009] In one possible implementation, the step of auditing and verifying each of the target knowledge assets to obtain the corresponding audit verification result includes: Cluster quality assessment is performed on each of the target knowledge assets to obtain the redundancy control rule check results; Perform a representative distance check on each of the target knowledge assets to obtain the representative control rule check results; Perform a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check results; When the results of the redundancy control rule check, the representativeness control rule check, and the timeliness control rule check all indicate that they have passed, the audit verification result is determined to be passed.
[0010] In one possible implementation, the step of performing clustering quality assessment on each of the target knowledge assets to obtain redundancy control rule check results includes: Determine the average cosine similarity between pairwise question vectors within the target question category; If the average value of the cosine similarity is not less than a preset threshold, the redundancy control rule check result is determined to be passed.
[0011] In one possible implementation, the step of performing a representative distance check on each of the target knowledge assets to obtain the representative control rule check result includes: For each target knowledge asset, determine whether the distance between the standard question of the target knowledge asset and the category semantic center vector is less than a preset distance threshold; If the distance is not less than the preset distance threshold, the representative control rule check result is determined to be passed.
[0012] In one possible implementation, the timeliness control rule includes a knowledge lifecycle rule, which indicates whether the target knowledge asset is within its valid lifecycle based on the metadata; the timeliness check for each target knowledge asset to obtain the timeliness control rule check result includes: For each target knowledge asset, the timeliness status of the target knowledge asset is determined based on the metadata corresponding to the target knowledge asset. If the timeliness status meets the knowledge lifecycle rule, the timeliness control rule check result is determined to be passed.
[0013] In one possible implementation, the second clustering of the plurality of initial question clusters based on the second similarity threshold includes: The mean vector of the problem vectors within each initial problem cluster is determined, and the mean vector is used as the group-level semantic representation of the corresponding initial problem cluster. Calculate the similarity between group-level semantic representations of different initial question clusters, and merge initial question clusters with similarity greater than or equal to the second similarity threshold into the same target question category.
[0014] In one possible implementation, the method further includes: Acquire new session data and extract new question-answer pairs from the new session data; The question text of the newly added question-answer pair is converted into a new question vector, and the new question vector is matched with the semantic vector corresponding to the standard question in the retrieval enhancement knowledge base; When a match is successful, the newly added question-answer pair is classified into the target question category, and the corresponding target knowledge asset is updated based on the newly added question-answer pair.
[0015] Secondly, embodiments of this disclosure also provide a retrieval-enhanced knowledge base construction apparatus, comprising: The data acquisition module is used to acquire conversation data and extract the conversation data using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text. The first clustering module is used to semantically vectorize the question texts in the initial question-answer pair set, and perform a first clustering on the question vectors based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; A specification construction module is used to construct quality control specifications, which include redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules are used to constrain the semantic merging between different initial question clusters. The representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rules are used to constrain the validity period of knowledge assets. The redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold. The second clustering module is used to perform a second clustering on the plurality of initial question clusters based on the second similarity threshold to obtain a plurality of target question categories; the second similarity threshold is less than the first similarity threshold; The knowledge integration module is used to integrate the initial question-answer pairs corresponding to each target question category using the representativeness control rules to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question category. The audit verification module is used to audit and verify each of the target knowledge assets, obtain the corresponding audit verification results, and construct a retrieval-enhanced knowledge base based on the target knowledge assets indicated by the audit verification results; the audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
[0016] In one possible implementation, the audit verification module is further configured to: If the audit verification result indicates that the audit has failed, the target issue category corresponding to the target knowledge asset will be determined as the audit failure category. The second clustering module is also used for: Increase the second similarity threshold, and re-cluster the problem vectors of the initial problem clusters within the audit failure category based on the increased second similarity threshold to form multiple new target problem categories.
[0017] In one possible implementation, the representativeness control rule includes: determining the mean of all question vectors within each target question category to obtain the corresponding category semantic center vector; calculating the distance between each question vector within the target question category and the category semantic center vector, and selecting the question with the closest distance as the standard question of the target question category.
[0018] In one possible implementation, the knowledge integration module is specifically used for: For each target question category, knowledge integration is performed on the initial question-answer pairs corresponding to the target question category according to the representativeness control rules to obtain the standard question corresponding to the target question category; The answer quality of multiple answer texts within the target question category is evaluated, and the answer text with the highest answer quality is selected as the standard answer for the target question category based on the evaluation results; alternatively, multiple answer texts within the target question category are synthesized to generate the standard answer for the target question category.
[0019] In one possible implementation, the audit verification module is specifically used for: Cluster quality assessment is performed on each of the target knowledge assets to obtain the redundancy control rule check results; Perform a representative distance check on each of the target knowledge assets to obtain the representative control rule check results; Perform a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check results; When the results of the redundancy control rule check, the representativeness control rule check, and the timeliness control rule check all indicate that they have passed, the audit verification result is determined to be passed.
[0020] In one possible implementation, the audit verification module is specifically used for: Determine the average cosine similarity between pairwise question vectors within the target question category; If the average value of the cosine similarity is not less than a preset threshold, the redundancy control rule check result is determined to be passed.
[0021] In one possible implementation, the audit verification module is specifically used for: For each target knowledge asset, determine whether the distance between the standard question of the target knowledge asset and the category semantic center vector is less than a preset distance threshold; If the distance is not less than the preset distance threshold, the representative control rule check result is determined to be passed.
[0022] In one possible implementation, the timeliness control rule includes a knowledge lifecycle rule, which is used to indicate whether the target knowledge asset is within its valid lifecycle based on the metadata; the audit verification module is specifically used for: For each target knowledge asset, the timeliness status of the target knowledge asset is determined based on the metadata corresponding to the target knowledge asset. If the timeliness status meets the knowledge lifecycle rule, the timeliness control rule check result is determined to be passed.
[0023] In one possible implementation, the second clustering module is specifically used for: The mean vector of the problem vectors within each initial problem cluster is determined, and the mean vector is used as the group-level semantic representation of the corresponding initial problem cluster. Calculate the similarity between group-level semantic representations of different initial question clusters, and merge initial question clusters with similarity greater than or equal to the second similarity threshold into the same target question category.
[0024] In one possible implementation, the apparatus further includes a knowledge base update module, the knowledge base update module being used for: Acquire new session data and extract new question-answer pairs from the new session data; The question text of the newly added question-answer pair is converted into a new question vector, and the new question vector is matched with the semantic vector corresponding to the standard question in the retrieval enhancement knowledge base; When a match is successful, the newly added question-answer pair is classified into the target question category, and the corresponding target knowledge asset is updated based on the newly added question-answer pair.
[0025] Thirdly, embodiments of this disclosure also provide an electronic device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps of the retrieval enhancement generative knowledge base construction method described in any possible embodiment of the first aspect are performed.
[0026] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the retrieval enhancement generative knowledge base construction method described in any possible embodiment of the first aspect.
[0027] Fifthly, embodiments of this disclosure also provide a computer program product that, when invoked by a computer, causes the computer to perform the steps of the retrieval enhancement generation knowledge base construction method described in any possible embodiment of the first aspect.
[0028] The retrieval enhancement knowledge base construction method, apparatus, electronic device, and storage medium provided in this disclosure first construct a quality control specification during the knowledge base construction process. This specification includes redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules constrain the semantic merging between different initial question clusters; the representativeness control rules constrain the determination of standard questions and answers; and the timeliness control rules constrain the validity period of knowledge assets. Thus, after the first-stage clustering, a second-stage clustering can be performed using the redundancy control rules, followed by knowledge asset integration using the representativeness control rules to obtain target knowledge assets. Finally, the target knowledge assets are audited and verified; only those that pass the audit are published to the knowledge base. Therefore, the redundancy and representativeness control rules reduce the redundancy of knowledge assets and improve the accuracy of standard questions and answers, while the timeliness control rules ensure the timeliness of knowledge assets, thereby improving the construction quality of the knowledge base. Furthermore, this method improves efficiency compared to manual methods.
[0029] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0031] Figure 1 A flowchart of a retrieval enhancement knowledge base construction method provided by an embodiment of this disclosure is shown.
[0032] Figure 2 A flowchart illustrating a method for auditing and verifying each target knowledge asset provided by an embodiment of this disclosure is shown.
[0033] Figure 3 A flowchart is shown for a method for handling when the audit verification result of a target knowledge asset fails, as provided in an embodiment of this disclosure.
[0034] Figure 4 A flowchart of a knowledge base update method provided by an embodiment of this disclosure is shown.
[0035] Figure 5 A schematic diagram of the structure of a retrieval enhancement knowledge base construction apparatus provided in an embodiment of this disclosure is shown.
[0036] Figure 6 A schematic diagram of another retrieval-enhanced knowledge base construction apparatus provided in an embodiment of this disclosure is shown.
[0037] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure is shown. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.
[0039] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0040] In this disclosure, the term "multiple" refers to two or more, and other quantifiers are similar. In this disclosure, the term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, the term "at least one" in this document means any combination of at least two of a plurality of objects, such as including at least one of A, B, and C, which can represent including any one or more elements selected from the set consisting of A, B, and C.
[0041] The terms "first," "second," and similar words in the specification, claims, and accompanying drawings of this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different subsets of alarm items or different alarm items. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein.
[0042] All user-related data involved in this disclosed technical solution are obtained with the user's authorization, such as through pop-up windows or by inviting individuals to upload their own data.
[0043] First, the terms used in this disclosure will be explained.
[0044] RAG (Retrieval Augmented Generation): An artificial intelligence technique that first retrieves information fragments relevant to user input from a large knowledge base, then provides these fragments as context to a generative model (such as a large language model), which generates a final, more accurate, and more informative answer.
[0045] LLM (Large Language Model): A deep learning model with a huge number of parameters, trained on massive amounts of text data through self-supervised learning and other methods, possessing powerful natural language understanding and generation capabilities.
[0046] Embedding (word embedding / vector representation): refers to the process of mapping discrete text units (such as words, sentences, and paragraphs) to a low-dimensional, dense, continuous numerical vector space. These vectors can capture the semantic information of the text, making semantically similar texts relatively close in distance in the vector space.
[0047] QA pairs (Question-Answer Pairs): These are structured data units consisting of a specific question and its corresponding answer, and are the basic building blocks of a knowledge base.
[0048] Clustering: An unsupervised machine learning method that aims to divide samples in a dataset into groups or clusters based on their inherent similarity or difference. Samples within the same cluster are highly similar to each other, while samples in different clusters are less similar.
[0049] Conversational data refers to textual data that records interactions between people or between people and machines, such as online chat logs, customer service conversation logs, forum discussion threads, and email correspondence. This type of data is usually unstructured and contains characteristics such as colloquial expressions and contextual dependencies.
[0050] A knowledge base is a collection of information used to store, organize, and manage knowledge in a specific domain. It can be structured (like facts in a database) or unstructured (like a collection of documents), designed to provide applications or users with the ability to query and retrieve knowledge.
[0051] Research has found that the main methods for constructing knowledge bases currently include the following: (1) Manual compilation and writing: This method relies on domain experts or knowledge engineers to manually collect common user questions, consult relevant materials, and write standard answers, ultimately forming FAQ documents, knowledge graph entries, or database records. Although this method can guarantee high initial quality and accuracy, it is extremely costly in terms of manpower, time-consuming, difficult to scale, and has a slow knowledge update speed, making it unable to adapt to rapidly changing business needs.
[0052] (2) Rule-based or template-based extraction: By predefining a series of lexical rules, syntactic patterns, or text templates, QA pairs are automatically identified and extracted from relatively well-structured documents (such as product manuals and operation guides). For example, sentences containing specific interrogative words (such as "how," "how," and "why") are identified as questions, and their subsequent sentences or paragraphs are identified as answers. This method may be effective when processing texts with uniform format and standardized language, but its generalization ability is poor, making it difficult to cope with the diversity and colloquial characteristics of natural language expression, and it is almost ineffective for unstructured conversational data.
[0053] (3) Information extraction techniques: Using traditional NLP techniques such as named entity recognition, relation extraction, and event extraction, potential question-and-answer information fragments are identified from the text. For example, product names, function points, and operation steps are identified, and then attempts are made to combine them into QA pairs. This method usually requires training on a large amount of labeled data for a specific domain and has limited ability to understand context.
[0054] (4) Simple text clustering: For question texts or document paragraphs containing potential answers extracted from the data source, traditional text clustering algorithms are used for preliminary classification. The aim is to aggregate topic-related content together. However, this method mainly relies on word frequency statistics or shallow semantic features, which often makes it difficult to accurately capture the deep semantic equivalence between questions, and the merging effect is not good for questions with diverse expressions but the same intent.
[0055] Based on the above research, this disclosure provides a method for constructing a retrieval-enhanced generative knowledge base, comprising: acquiring conversation data and extracting the conversation data using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text; semantically vectorizing the question text in the initial question-answer pair set, and performing a first clustering of the question vectors based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; constructing a quality control specification, the quality control specification including redundancy control rules, representativeness control rules, and timeliness control rules; the redundancy control rules are used to constrain the semantic merging between different initial question clusters; the representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rule is used to constrain the validity period of knowledge assets; the redundancy control rule includes constraining the re-aggregation of the initial question clusters with a second similarity threshold; performing a second clustering on the multiple initial question clusters based on the second similarity threshold to obtain multiple target question categories; the second similarity threshold is less than the first similarity threshold; using the representativeness control rule to perform knowledge integration on the initial question-answer pairs corresponding to each target question category to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question categories; each target knowledge asset is audited and verified to obtain the corresponding audit verification result, and a retrieval-enhanced knowledge base is constructed based on the target knowledge assets indicated by the audit verification result; the audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
[0056] The retrieval enhancement knowledge base construction method provided in this disclosure first constructs a quality control specification during the knowledge base construction process. This specification includes redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules constrain the semantic merging between different initial question clusters; the representativeness control rules constrain the determination of standard questions and answers; and the timeliness control rules constrain the validity period of knowledge assets. Thus, after the first-stage clustering, a second-stage clustering can be performed using the redundancy control rules, followed by the integration of knowledge assets using the representativeness control rules to obtain target knowledge assets. Finally, the target knowledge assets are audited and verified; only those that pass the audit are published to the knowledge base. Therefore, the redundancy and representativeness control rules reduce the redundancy of knowledge assets and improve the accuracy of standard questions and answers. Furthermore, the timeliness control rules ensure the timeliness of knowledge assets, thereby improving the construction quality of the knowledge base. In addition, this method improves efficiency compared to manual methods.
[0057] Based on the above analysis, this disclosure, through a closed loop of "extraction-constraint-integration-audit," transforms the construction of a knowledge base from a crude, information-piling process into a sophisticated engineering project that continuously produces high-quality, high-purity, and timely knowledge assets. This, in turn, improves the efficiency and quality of knowledge base construction and updates. Furthermore, by enhancing the quality of knowledge base construction, the accuracy of answers to user questions from question-answering systems and dialogue systems using this knowledge base can be improved, thereby enhancing the user experience.
[0058] In this embodiment of the disclosure, the retrieval enhancement generation knowledge base refers to a collection of knowledge data used to provide external knowledge support for the retrieval enhancement generation system. The knowledge base can be stored using a vector database, relational database, document database, graph database, or a combination of the above. Each piece of knowledge in the knowledge base can be considered a target knowledge asset, including at least a standard question and a standard answer, and may further include data such as the semantic vector, category identifier, source information, creation time, version information, and last access time corresponding to the standard question.
[0059] To facilitate understanding of this embodiment, the executing entity of the retrieval enhancement knowledge base construction method disclosed in this embodiment will first be described in detail. The executing entity of this retrieval enhancement knowledge base construction method can also be an electronic device with a certain computing power. This electronic device may include, for example, a terminal device, a server, or other processing device. The terminal device can be a user terminal, a handheld device, a computing device, an in-vehicle device, a wearable device, etc. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms.
[0060] Furthermore, this method for building a knowledge base with enhanced retrieval capabilities can also be implemented by having the processor call computer-readable instructions stored in memory.
[0061] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this disclosure.
[0062] See Figure 1 The diagram shown is a flowchart of a retrieval enhancement knowledge base construction method provided in this embodiment of the present disclosure. The method includes the following steps S101-S106: S101, acquire conversation data, and extract the conversation data using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text.
[0063] For example, the session data may originate from online customer service systems, e-commerce platforms, sales consultation platforms, after-sales service platforms, work order systems, instant messaging systems, or other systems capable of recording the interaction process between users and business personnel. For example, the session data may be the dialogue text between users and sales personnel, users and customer service representatives, or users and chatbots. The text format of the session data may include plain text files (.txt), comma-separated value files (.csv), JSON format files, database exported records, etc.
[0064] For example, the session data content may include user messages, customer service messages, message time, session identifier, speaker identifier, business type, order type, source channel, and session context. Session data can be acquired according to a preset time range, business scope, data source, or knowledge base update task.
[0065] For example, logistics consultation session data from an e-commerce platform within a preset time range can be obtained. This logistics consultation session data may include: QA1: {q: "Where is my package?", a: "Hello, please provide the order number...", ts: '2025-06-10'} QA2: {q: "How do I check the logistics information?", a: "You can click on 'My Orders' page...", ts:'2025-06-11'} QA3: {q: "Has this order not been delivered yet?", a: "I'll check for you, please wait...", ts: '2025-06-12'} QA4: {q: "How long does it usually take to ship?", a: "Usually within 24 hours of payment...", ts:'2025-06-13'} In one implementation, the conversation data can be preprocessed before extraction using a large language model, and the preprocessed conversation data can be input into the large language model. The large language model can identify the user's questioning intent, corresponding answers, and contextual information related to the questions and answers in the conversation according to preset extraction instructions, and generate structured initial question-answer pairs.
[0066] For example, preprocessing the conversation data may include at least one of the following: cleaning the conversation data, formatting, conversation turn segmentation, and speaker identification.
[0067] Cleaning can include removing duplicate messages, system prompts, meaningless characters, invalid links, and content irrelevant to the business issue. Formatting can include standardizing time formats, message field formats, and speaker field formats. Dialogue turn segmentation can divide consecutive messages according to time intervals, speaker changes, session identifiers, or business events. Speaker identification can be used to distinguish between user questions, customer service answers, and automated system replies.
[0068] In some implementations, each initial question-answer pair may include question text, answer text, and metadata corresponding to the question text and answer text. The metadata may include time information and source information. In other implementations, the metadata may also include at least one of session identifier, message identifier, business category, source channel, knowledge version, last access time, answer source, extraction confidence level, and data status.
[0069] For example, a large language model can extract initial question-answer pairs from a conversation data containing multiple turns of dialogue:
[0070] It should be noted that when a single conversation contains multiple questions and multiple answers, the large language model can establish a correspondence between questions and answers by combining contextual relationships. For example, for expressions like "I asked yesterday, but I still haven't received it. Can you help me check?" which rely on the preceding context, the large language model can identify the actual question as an order logistics status query based on the preceding context, rather than treating "I asked yesterday" as a separate question.
[0071] In some implementations, prompt words can be used to guide a large language model in performing a question-and-answer pair extraction task. For example, the large language model can be provided with the following instructional prompt: "Please extract all explicitly asked questions and direct answers to those questions from the following dialogue fragment. Output in the format of 'Question: [Extracted Question]' and 'Answer: [Extracted Answer]'. If there are multiple QA pairs, please list them separately. The dialogue fragment is as follows: [Insert preprocessed dialogue fragment here]". Here, by adjusting the wording and structure of the prompt words, the extraction behavior of the large language model can be controlled.
[0072] In other implementations, the large language model can be fine-tuned using training samples containing "conversation text, metadata, and ideal question-answer pairs" to improve the accuracy of initial question-answer pair extraction. The fine-tuned large language model can then identify implicit questions and filter out invalid statements based on the conversation context, and output question text, answer text, and metadata according to preset fields.
[0073] Through the above processing, the original unstructured session data can be transformed into a structured initial question-answer pair set, while retaining the source and time information required for subsequent clustering, knowledge integration, audit verification, and dynamic updates.
[0074] S102, the question texts in the initial question-answer pair set are semantically vectorized, and the question vectors are clustered based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs.
[0075] In one implementation, semantic vectorization (Embedding) can be performed on each question text in the initial question-answer pair set to obtain a question vector corresponding to the question text. Then, a first clustering is performed on the question vectors to merge questions with high semantic similarity into an initial question group.
[0076] For example, cosine similarity can be used to calculate the semantic similarity between two question vectors, and then a first clustering can be performed based on a first similarity threshold. Here, the first similarity threshold is used to filter question vectors that are semantically highly similar, so that the initial question clusters formed by the first-stage clustering have high semantic consistency.
[0077] Specifically, the question vectors can be traversed in a preset order, and the question vectors that have not yet been assigned can be used as the reference vectors of the current initial question cluster. The similarity between other question vectors and the reference vectors can be calculated, and the question vectors with similarity greater than or equal to the first similarity threshold and their corresponding initial question-answer pairs can be assigned to the current initial question cluster.
[0078] For example, the first similarity threshold can be set to 0.95 for a logistics consultation scenario: The semantic similarity between QA1 "Where is my package?" and QA2 "How do I check the logistics information?" is 0.95 or higher, so they can be classified into the initial question cluster A; QA3 "Has this order not been delivered yet?" has some semantic relevance to the questions in the initial question cluster A, but the score is less than 0.95, so it can form the initial question cluster B; QA4 "How long does it usually take for you to ship?" can form the initial question cluster C.
[0079] Understandably, in other embodiments, the first similarity threshold can be other values, such as 0.96, 0.94, 0.93, etc., and this disclosure does not limit it.
[0080] For the first cluster, a higher similarity threshold is used to avoid merging questions with large semantic differences too early in the initial clustering process, thereby preserving the fine-grained differences between the intentions of different questions and providing a relatively pure initial question cluster for the subsequent second cluster.
[0081] S103, construct a quality control specification, which includes redundancy control rules, representativeness control rules, and timeliness control rules; the redundancy control rules are used to constrain the semantic merging between different initial question clusters; the representativeness control rules are used to constrain the determination of standard questions and standard answers; the timeliness control rules are used to constrain the validity period of knowledge assets; the redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold.
[0082] The quality control specifications are used to uniformly constrain the re-aggregation of initial problem clusters, the knowledge integration of target problem categories, and the audit verification of target knowledge assets.
[0083] Specifically, redundancy control rules are used to constrain the semantic merging of different initial question clusters. These rules include at least a second similarity threshold to determine whether different initial question clusters can be merged at the topic level.
[0084] Representativeness control rules are used to constrain the determination of standard questions and standard answers. These rules can specify the selection methods for standard questions and standard answers, answer quality evaluation indicators, and distance requirements between standard questions and category semantic centers.
[0085] In some embodiments, the representativeness control rule may include: determining the mean of all question vectors within each target question category to obtain the corresponding category semantic center vector; calculating the distance between each question vector within the target question category and the category semantic center vector, and selecting the question with the closest distance as the standard question of the target question category. For example, the distance may be cosine distance or Euclidean distance.
[0086] In other implementations, the representativeness control rules may also include: among questions that are close to the semantic center of the category, further integrating factors such as question frequency, language standardization, clarity of expression, answer quality, and user evaluation to select the standard question.
[0087] Timeliness control rules are used to constrain the validity period of knowledge assets. For example, the timeliness control rules include knowledge lifecycle rules, which are used to indicate whether the target knowledge asset is within its valid lifecycle based on the metadata. Optionally, the timeliness control rules can determine whether the target knowledge asset is still within its valid lifecycle based on at least one of the following in the metadata: creation timestamp, information source identifier, last access time, and version information.
[0088] In one implementation, the quality control specifications can be stored using structured data objects. These structured data objects may include rule fields corresponding to redundancy control rules, representativeness control rules, timeliness control rules, and audit control rules, respectively.
[0089] For example, a quality control specification object in JSON format can be constructed: JSON (a structured data format) { "quality_control_spec (Quality Control Specification)": { "redundancy_control": { "method": "two-stage clustering" "stage2_threshold_T2 (Second stage threshold T2)": 0.85 }, "representativeness_control": { "method": "closest_to_centroid", "answer_strategy": "synthesize_or_best" }, "timeliness_control": { "rule": "delete_if_older_than (delete if the rule expires)", "retention_period_days": 180 }, "audit (audit configuration)": { "min_intra_cluster_similarity" (minimum average similarity within a cluster): 0.80, "require_all_layers_pass" (requires all layers to pass): true } } } Understandably, the structured data objects described above are merely examples. In practical applications, rule fields can be configured based on business type, knowledge category, knowledge update frequency, and historical audit results.
[0090] S104, perform a second clustering on the multiple initial question clusters based on the second similarity threshold to obtain multiple target question categories; the second similarity threshold is less than the first similarity threshold.
[0091] Here, a second clustering can be performed using the initial question clusters obtained from the first clustering as the clustering objects, based on a second similarity threshold. This second clustering can merge initial question clusters that are related in topic but differ in their question descriptions into the same target question category.
[0092] Specifically, when performing a second clustering of the plurality of initial problem clusters based on the second similarity threshold, the following (I) to (II) may be included: (I) Determine the mean vector of the problem vectors in each of the initial problem clusters, and use the mean vector as the group-level semantic representation of the corresponding initial problem cluster.
[0093] (II) Calculate the similarity between group-level semantic representations of different initial question clusters, and merge initial question clusters with similarity greater than or equal to the second similarity threshold into the same target question category.
[0094] Here, for each initial question cluster, the mean vector of all question vectors within that initial question cluster can be calculated, and this mean vector can be used as the group-level semantic representation of that initial question cluster. Then, the similarity between the group-level semantic representations of different initial question clusters is calculated. When the similarity between the group-level semantic representations of two initial question clusters is greater than or equal to a second similarity threshold, the two initial question clusters are merged into the same target question category.
[0095] For example, after performing the second clustering, we can obtain the target question category set {C1, C2,..., Cm}, as well as all the original QA pairs contained in each category Cj, which come from one or more initial question groups that constitute Cj.
[0096] In one implementation, the first similarity threshold can be set to 0.95, and the second similarity threshold can be set to 0.85. Since the second similarity threshold is lower than the first similarity threshold, the second clustering can merge the initial question clusters in the first cluster that do not meet the high similarity requirement but have a strong correlation in business topics. This can reduce the duplicate representation of the same business topic in the knowledge base.
[0097] Taking a logistics scenario as an example, the initial question cluster A mainly represents "querying logistics information"; the initial question cluster B mainly represents "order not yet delivered"; and the initial question cluster C mainly represents "how long will it take to ship". Although these three initial question clusters were not all merged in the first clustering, the similarity between their group-level semantic representations can reach the second similarity threshold of 0.85. Therefore, the initial question clusters A, B, and C can be merged into the target question category X, namely "logistics problem".
[0098] It should be noted that the specific values of the second similarity threshold and the first similarity threshold are not limited in the embodiments of this disclosure, as long as the second similarity threshold is less than the first similarity threshold.
[0099] Furthermore, the second clustering can employ hierarchical clustering or cluster merging based on a similarity matrix. For example, a similarity matrix can be constructed first among the initial question clusters, and then the initial question clusters to be merged can be determined based on a second similarity threshold. For the merged target question category, the category semantic representation can be recalculated and compared with other initial question clusters.
[0100] S105, using the representativeness control rules, knowledge integration is performed on the initial question-answer pairs corresponding to each target question category to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question category.
[0101] Here, for each target question category, all initial question-answer pairs contained in that target question category can be obtained, and knowledge integration of the initial question-answer pairs can be performed using representativeness control rules.
[0102] In some embodiments, when using the representative control rules to perform knowledge integration on the initial question-answer pairs corresponding to each target question category to obtain the corresponding target knowledge assets, the following (M)~(N) may be included: (M) For each target question category, according to the representativeness control rules, the initial question-answer pairs corresponding to the target question category are integrated to obtain the standard question corresponding to the target question category.
[0103] (N) Evaluate the answer quality of multiple answer texts within the target question category, and based on the answer quality evaluation results, take the answer text with the highest answer quality as the standard answer for the target question category; or, synthesize multiple answer texts within the target question category to generate the standard answer for the target question category.
[0104] Specifically, based on representativeness control rules, the mean of all question vectors within the target question category can be calculated to obtain the category semantic center vector. Then, the distance between each question vector within the target question category and the category semantic center vector is calculated, and the question with the closest distance is selected as the standard question for that target question category. For example, if the target question category X includes QA1, QA2, QA3, and QA4, after obtaining the category semantic center vector, it is determined that the question QA2, "How do I check the logistics information?", has the smallest distance to the category semantic center vector, and therefore it is selected as the standard question. Simultaneously, all answers are combined to generate a standard answer: "You can click 'View Logistics' on the 'My Orders' page to track your package; we usually ship within 24 hours."
[0105] In some embodiments, the target knowledge asset may include at least one of the following: standard question, standard answer, semantic vector corresponding to the standard question, category identifier of the target question category, creation time, information source identifier, version information, last access time, source initial question-answer pair identifier, and audit status.
[0106] In some embodiments, the answer quality evaluation includes at least one of completeness, accuracy, clarity, and relevance to the corresponding question. Completeness is used to determine whether the answer covers the main information involved in the question. Accuracy is used to determine whether the answer conforms to actual business rules. Clarity is used to determine whether the answer is easy for the user to understand. Relevance is used to determine whether the answer directly addresses the corresponding question. Weights can be assigned to each evaluation dimension, and a comprehensive answer quality score can be calculated.
[0107] Understandably, for scenarios with clearly defined standard answers, the answer with the highest overall score can be directly selected as the standard answer. For scenarios where multiple answers contain different valid information, these answers can be combined. For example, if multiple answers include "logistics query path," "shipping time," and "logistics exception handling method," the valid information from these multiple answers can be merged to form a standard answer that includes the query path, shipping time, and exception handling method.
[0108] S106, each of the target knowledge assets is audited and verified to obtain the corresponding audit verification result, and a retrieval-enhanced knowledge base is constructed based on the target knowledge assets indicated by the audit verification result; the audit verification includes redundancy control rule check, representativeness control rule check and timeliness control rule check.
[0109] The redundancy control rule check is used to determine whether the question vectors within a target question category have sufficient semantic consistency, and can also be used to determine whether there is excessive overlap between different target question categories. The representativeness control rule check is used to determine whether the standard question can represent the overall semantics of the target question category, and can also be used to determine whether the standard question meets preset representativeness conditions (such as preset distance thresholds). The timeliness control rule check is used to determine whether the target knowledge asset is within its effective lifecycle, and can also be used to determine whether the standard answer is still applicable to the current business environment.
[0110] In some embodiments, see Figure 2 As shown, in step S106, when auditing and verifying each of the target knowledge assets to obtain the audit verification result, steps S1061 to S1064 may be included: S1061, perform clustering quality assessment on each of the target knowledge assets to obtain the redundancy control rule check results.
[0111] Specifically, when performing clustering quality assessment on each of the target knowledge assets to obtain the redundancy control rule check results, the following may be included: Determine the average cosine similarity between pairwise question vectors within the target question category; if the average cosine similarity is not less than a preset threshold, the redundancy control rule check result is determined to be passed; if the average cosine similarity is less than the preset threshold, the redundancy control rule check result is determined to be failed.
[0112] Here, for any two question vectors within the target question category, the cosine similarity is calculated, and the average of the cosine similarities between all pairwise question vectors is taken. When the average cosine similarity is less than a preset threshold, it indicates that the semantics of the questions within the target question category are too divergent, and there may be multiple different business intentions being incorrectly merged. In this case, the redundancy control rule check result is determined to be unsuccessful. For example, if the preset threshold is 0.80, and the average cosine similarity of the pairwise question vectors of the target question category Y is 0.75, then the redundancy control rule check for this category fails.
[0113] S1062, Perform a representative distance check on each of the target knowledge assets to obtain the representative control rule check results.
[0114] Specifically, when performing a representative distance check on each of the target knowledge assets to obtain the representative control rule check result, it may include: For each target knowledge asset, determine whether the distance between the standard question of the target knowledge asset and the category semantic center vector is less than a preset distance threshold; if the distance is less than the preset distance threshold, determine that the representative control rule check result passes; if the distance is not less than the preset distance threshold, determine that the representative control rule check result fails.
[0115] Here, the distance between the question vector corresponding to the standard question of the target knowledge asset and the category semantic center vector can be determined, and this distance is compared with a preset distance threshold. If the distance is less than the preset distance threshold, it means that the standard question can well represent the overall semantics of the target question category, and the representativeness control rule check passes. If the distance is not less than the preset distance threshold, it means that the standard question may only reflect the local semantics of the target question category, and the representativeness control rule check fails. For example, if the preset distance threshold is 0.20, the check passes when the distance between the standard question and the category semantic center is 0.12; the check fails when the distance between the standard question and the category semantic center is 0.28.
[0116] S1063, Perform a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check results.
[0117] Specifically, when performing a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check result, it may include: For each target knowledge asset, the timeliness status of the target knowledge asset is determined based on the corresponding metadata. If the timeliness status meets the knowledge lifecycle rules, the timeliness control rule check result is determined to be passed. If the timeliness status does not meet the knowledge lifecycle rules, the timeliness control rule check result is determined to be failed.
[0118] For example, the timeliness status of a target knowledge asset can be determined based on its corresponding metadata. The metadata may include at least one of the following: creation timestamp, information source identifier, last access time, and version information. For instance, for knowledge related to logistics delivery timeliness, the effective lifecycle can be set to 180 days. It can be determined whether the knowledge asset exceeds 180 days based on its creation time, last update time, or the timestamp of the source question-and-answer pair; if it exceeds 180 days, the timeliness control rule check result is deemed unsuccessful; if it does not exceed 180 days, the timeliness control rule check result is deemed successful.
[0119] It should be noted that for knowledge whose business rules change frequently, a shorter lifecycle can be set. Conversely, for relatively stable knowledge, a longer lifecycle can be set.
[0120] S1064, when the redundancy control rule check result, the representative control rule check result, and the timeliness control rule check result all indicate that they have passed, the audit verification result is determined to be passed.
[0121] In this embodiment, the audit verification adopts a multi-layered joint judgment method. If any control layer fails the check, the audit verification result of the entire target knowledge asset is determined to be unsuccessful. Only when the redundancy control rule check, the representativeness control rule check, and the timeliness control rule check all pass, is the target knowledge asset written into the retrieval enhancement generation knowledge base. This can improve the quality of knowledge assets. For example, even if the standard answer content of a target knowledge asset is complete and accurate, if the semantic consistency of its internal question vector is insufficient, it still cannot be directly published to the knowledge base. As another example, even if the clustering quality and representativeness of a target knowledge asset meet the requirements, if its source information is expired or has exceeded its lifespan, it cannot be directly published.
[0122] Understandably, after confirming that the audit verification results are satisfactory, the target knowledge asset can be published to the retrieval-enhanced knowledge base. Standard questions can serve as the primary basis for retrieval, while standard answers can be returned to the user. Additionally, semantic vectors can be used for semantic similarity retrieval in response to user queries.
[0123] In addition, timeliness checks can be performed on target knowledge assets in the existing knowledge base. When a target knowledge asset exceeds its effective lifespan, or its information source becomes invalid, or its business version changes, it can be identified as an obsolete knowledge asset, and at least one of the following actions can be taken: Mark as inactive, remove from the searchable knowledge base, replace with new version knowledge, re-fetch session data and rebuild.
[0124] In some embodiments, see Figure 3 As shown, the method further includes the following steps S107~S109: S107, if the audit verification result indicates that the audit has failed, the target problem category corresponding to the target knowledge asset is determined as the audit failure category.
[0125] Specifically, when a target knowledge asset fails the audit verification, the target issue category corresponding to the target knowledge asset is identified as an audit failure category and isolated from the knowledge assets to be released.
[0126] S108, increase the second similarity threshold, and re-cluster the problem vectors of the initial problem clusters within the audit failure category based on the increased second similarity threshold to form multiple new target problem categories.
[0127] When an audit fails because the clustering quality score is below a preset threshold, it indicates insufficient semantic consistency within the target problem category. In this case, the second similarity threshold can be increased to make the merging conditions between subsequent initial problem clusters more stringent. For example, if the second similarity threshold is initially set to 0.85, and the clustering quality score of the target problem category Y is 0.75, which is below the preset threshold of 0.80, the second similarity threshold can be increased to 0.90, and the second clustering can be re-executed for the initial problem clusters within the target problem category Y. After re-clustering, the original target problem category Y can be split into multiple new target problem categories, such as: logistics query category, delivery anomaly category, or delivery timeliness category.
[0128] S109, proceed with the next steps until the audit verification result indicates that it has passed, and add the corresponding target knowledge asset to the retrieval enhancement generation knowledge base.
[0129] Here, the subsequent steps refer to Figure 1 Steps S105 and S106 in the process. That is, for a new target question category, the representativeness control rules are used to integrate the initial question-answer pairs corresponding to the new target question category to obtain the corresponding target knowledge assets, and the target knowledge assets are audited and verified to obtain the corresponding audit verification results. If the audit verification results pass, the target knowledge assets corresponding to the new target category are published; if the audit verification results fail, the process returns to step S107.
[0130] Understandably, the reprocessing process is only executed for audit-failed categories, without affecting other target question categories that have passed audit verification. Here, the initial question clusters, question vectors, answer texts, and metadata corresponding to the audit-failed categories can be retained, and the second-stage clustering can be re-executed based on the adjusted second similarity threshold. After re-clustering, the system re-executes standard question determination, standard answer determination, and audit verification for the new target question categories. Only after the new target question category passes audit is the corresponding target knowledge asset added to the retrieval-enhanced knowledge base. In this way, by feeding back the audit results to the second-stage clustering parameters, categories with insufficient semantic consistency can be re-splitled, forming a closed-loop processing flow of "clustering—integration—auditing—re-clustering".
[0131] In some implementations, if increasing the second similarity threshold still fails to bring the clustering quality score to the preset clustering score threshold, cluster splitting can be performed on the question vectors within the audit failure category. Cluster splitting can divide the original target question category into multiple subcategories based on the distance between the question vector and the category semantic center, the similarity between question vectors, the difference in answer topics, or the difference in business tags. After splitting, knowledge integration and audit verification are performed on each subcategory.
[0132] For example, if the target question category Y contains three types of questions simultaneously: "query logistics information," "order not delivered," and "how long will it take to ship," the audit will fail due to insufficient internal semantic consistency. In this case, by increasing the second similarity threshold, the target question category Y can be split into three new target question categories: "logistics query," "delivery anomaly," and "shipping timeliness." Then, standard questions and standard answers can be determined for each category, and the audit can be performed accordingly.
[0133] In one implementation, the increase in the second similarity threshold can be related to the difference between the clustering quality score and a preset quality score threshold. The larger the difference between the clustering quality score and the preset quality score threshold (the difference resulting from the clustering quality score being less than the preset quality score threshold), the higher the adjusted second similarity threshold, thus making the merging conditions during re-clustering more stringent. Furthermore, to prevent the second similarity threshold from increasing indefinitely, an upper limit can be set for the second similarity threshold.
[0134] In some embodiments, see Figure 4 As shown, the method further includes the following steps S201~S203: S201, Obtain newly added session data, and extract newly added question-answer pairs from the newly added session data.
[0135] S202, the question text of the newly added question-answer pair is converted into a new question vector, and the new question vector is matched with the semantic vector corresponding to the standard question in the retrieval enhancement knowledge base.
[0136] S203, when a match is successful, the newly added question-answer pair is classified into the matched target question category, and the corresponding target knowledge asset is updated based on the newly added question-answer pair.
[0137] In one implementation, after constructing the RAG knowledge base, new session data can be continuously acquired, and new question-answer pairs can be extracted from the new session data using a large language model. For each new question-answer pair, its question text is converted into a new question vector, and then matched with the semantic vector corresponding to an existing standard question in the retrieval-enhanced knowledge base. When the similarity between the new question vector and the semantic vector corresponding to a certain standard question reaches a preset matching threshold, a successful match is determined, and the new question-answer pair is classified into the target question category corresponding to that standard question. The corresponding target knowledge asset is then updated based on the new answer text, timestamp, and business rules. For example, the standard answer, update time, answer quality score, source question-answer pair set, or knowledge version can be updated.
[0138] When neither the semantic vector of the newly added question nor the semantic vector of the existing standard question reaches the preset matching threshold, the newly added question-answer pair can be used as data to be clustered, and the first and second stage clustering can be re-executed, and new target knowledge assets can be generated according to the quality control specifications.
[0139] For example, the standard question for the existing target knowledge asset is "How do I check logistics information?", and the new question is "Where can I check the delivery progress now?". When the similarity between the question vectors of the two reaches a preset matching threshold, the new question-answer pair can be classified into the "logistics question" category, and the new answer can be used to supplement or correct the standard answer.
[0140] When a new answer is consistent with an existing standard answer, only the update time and source record of the knowledge asset need to be updated; when a new answer contains more accurate or up-to-date business information, the answer quality evaluation can be re-executed, and the original standard answer can be replaced if the new answer has a higher quality score; when a new answer conflicts with an existing answer, it can be determined whether to trigger a re-audit based on the timestamp, source credibility, and business rule verification results.
[0141] In one implementation, the timeliness control rule may further include the following processing conditions: (a) The target knowledge asset has exceeded its preset validity period; (b) The target knowledge asset was not accessed within the preset time period; (c) The access frequency of the target knowledge asset is lower than the preset frequency; (d) The information source of the target knowledge asset is invalid; (e) The business version corresponding to the target knowledge asset has changed.
[0142] The method may further include: performing a lifecycle scan on existing knowledge assets in the RAG knowledge base according to a preset period. When any of the above conditions are met, the target knowledge asset can be identified as an outdated knowledge asset, and at least one of the following processes can be performed on it: marking it as inactive, deleting it, or replacing it.
[0143] Through the above dynamic update method, the knowledge base can not only receive new knowledge, but also update existing knowledge assets according to new session data, and identify and process outdated knowledge through lifecycle rules, so that the knowledge base can maintain good semantic consistency, representativeness and timeliness.
[0144] The RAG knowledge base construction method disclosed herein extracts initial question-answer pairs from unstructured conversation data using a large language model. It then performs a first clustering using a high similarity threshold to form semantically refined initial question clusters. A second similarity threshold below the first threshold is used for topic-level re-aggregation of these initial question clusters. Target knowledge assets are generated under joint constraints of redundancy control, representativeness control, and timeliness control. Through automatic post-integration auditing and a reprocessing mechanism for audit failures, knowledge redundancy is reduced, the representativeness of standard questions, the accuracy of standard answers, and the timeliness of knowledge assets are improved. Furthermore, it provides a more stable, accurate, and maintainable knowledge source for downstream retrieval enhancement generation systems.
[0145] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0146] See Figure 5 The diagram shown is a functional block diagram of a retrieval enhancement knowledge base construction device provided in an embodiment of this disclosure. The retrieval enhancement knowledge base construction device 500 includes: The data acquisition module 501 is used to acquire conversation data and extract the conversation data using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text; The first clustering module 502 is used to semantically vectorize the question texts in the initial question-answer pair set, and perform a first clustering on the question vectors based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; The specification construction module 503 is used to construct quality control specifications, which include redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules are used to constrain the semantic merging between different initial question clusters. The representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rules are used to constrain the validity period of knowledge assets. The redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold. The second clustering module 504 is used to perform a second clustering on the plurality of initial question clusters based on the second similarity threshold to obtain a plurality of target question categories; the second similarity threshold is less than the first similarity threshold; The knowledge integration module 505 is used to integrate the knowledge of the initial question-answer pairs corresponding to each target question category using the representativeness control rules to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question categories. The audit verification module 506 is used to audit and verify each of the target knowledge assets, obtain the corresponding audit verification results, and construct a retrieval-enhanced knowledge base based on the target knowledge assets indicated by the audit verification results; the audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
[0147] In one possible implementation, the audit verification module 506 is further configured to: If the audit verification result indicates that the audit has failed, the target issue category corresponding to the target knowledge asset will be determined as the audit failure category. The second clustering module 504 is also used for: Increase the second similarity threshold, and re-cluster the problem vectors of the initial problem clusters within the audit failure category based on the increased second similarity threshold to form multiple new target problem categories.
[0148] In one possible implementation, the representativeness control rule includes: determining the mean of all question vectors within each target question category to obtain the corresponding category semantic center vector; calculating the distance between each question vector within the target question category and the category semantic center vector, and selecting the question with the closest distance as the standard question of the target question category.
[0149] In one possible implementation, the knowledge integration module 505 is specifically used for: For each target question category, knowledge integration is performed on the initial question-answer pairs corresponding to the target question category according to the representativeness control rules to obtain the standard question corresponding to the target question category; The answer quality of multiple answer texts within the target question category is evaluated, and the answer text with the highest answer quality is selected as the standard answer for the target question category based on the evaluation results; alternatively, multiple answer texts within the target question category are synthesized to generate the standard answer for the target question category.
[0150] In one possible implementation, the audit verification module 506 is specifically used for: Cluster quality assessment is performed on each of the target knowledge assets to obtain the redundancy control rule check results; Perform a representative distance check on each of the target knowledge assets to obtain the representative control rule check results; Perform a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check results; When the results of the redundancy control rule check, the representativeness control rule check, and the timeliness control rule check all indicate that they have passed, the audit verification result is determined to be passed.
[0151] In one possible implementation, the audit verification module 506 is specifically used for: Determine the average cosine similarity between pairwise question vectors within the target question category; If the average value of the cosine similarity is not less than a preset threshold, the redundancy control rule check result is determined to be passed.
[0152] In one possible implementation, the audit verification module 506 is specifically used for: For each target knowledge asset, determine whether the distance between the standard question of the target knowledge asset and the category semantic center vector is less than a preset distance threshold; If the distance is not less than the preset distance threshold, the representative control rule check result is determined to be passed.
[0153] In one possible implementation, the timeliness control rule includes a knowledge lifecycle rule, which is used to indicate whether the target knowledge asset is within its valid lifecycle based on the metadata; the audit verification module 506 is specifically used for: For each target knowledge asset, the timeliness status of the target knowledge asset is determined based on the metadata corresponding to the target knowledge asset. If the timeliness status meets the knowledge lifecycle rule, the timeliness control rule check result is determined to be passed.
[0154] In one possible implementation, the second clustering module 504 is specifically used for: The mean vector of the problem vectors within each initial problem cluster is determined, and the mean vector is used as the group-level semantic representation of the corresponding initial problem cluster. Calculate the similarity between group-level semantic representations of different initial question clusters, and merge initial question clusters with similarity greater than or equal to the second similarity threshold into the same target question category.
[0155] In one possible implementation, see Figure 6As shown, the device further includes a knowledge base update module 507, which is used for: Acquire new session data and extract new question-answer pairs from the new session data; The question text of the newly added question-answer pair is converted into a new question vector, and the new question vector is matched with the semantic vector corresponding to the standard question in the retrieval enhancement knowledge base; When a match is successful, the newly added question-answer pair is classified into the target question category, and the corresponding target knowledge asset is updated based on the newly added question-answer pair.
[0156] Based on the same technical concept, this disclosure also provides an electronic device. (See also...) Figure 7 The diagram shown is a structural schematic of an electronic device 700 provided in an embodiment of this disclosure, including a processor 701, a memory 702, and a bus 703. The memory 702 is used to store execution instructions.
[0157] In this embodiment, the memory 702 is specifically used to store application code that executes the scheme of this application, and its execution is controlled by the processor 701. That is, when the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703, so that the processor 701 executes the application code stored in the memory 702, and then executes the method described in any of the foregoing embodiments.
[0158] The memory 702 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0159] Processor 701 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.
[0160] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 700. In other embodiments of this application, the electronic device 700 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0161] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the retrieval enhancement knowledge base construction method described in the above method embodiments.
[0162] This disclosure also provides a computer program product, including a computer program / instruction, which, when executed by the computer program / instruction processor, implements the retrieval enhancement generation knowledge base construction method provided in the various embodiments of this disclosure. For details, please refer to the above method embodiments, which will not be repeated here.
[0163] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0164] The methods in this disclosure can be implemented, in whole or in part, by software, hardware, firmware, or any combination thereof. When implemented in software, they can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are downloaded and executed on a computer, the processes or functions described in this application are performed, in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, network equipment, user equipment, core network equipment, OAM, or other programmable devices.
[0165] The computer program or instructions may be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions may be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; or an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0166] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0167] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0168] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0169] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, external hard drives, ROM, RAM, magnetic disks, or optical disks.
[0170] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A method for constructing a retrieval-enhanced knowledge base, characterized in that, The method includes: Acquire conversation data and extract it using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text; The question texts in the initial question-answer pair set are semantically vectorized, and the question vectors are clustered based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; A quality control specification is constructed, which includes redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules are used to constrain the semantic merging between different initial question clusters. The representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rules are used to constrain the validity period of knowledge assets. The redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold. A second clustering is performed on the multiple initial question clusters based on the second similarity threshold to obtain multiple target question categories; the second similarity threshold is less than the first similarity threshold; The representativeness control rules are used to integrate the initial question-answer pairs corresponding to each target question category to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question categories. Each target knowledge asset is audited and verified to obtain the corresponding audit verification result. Based on the audit verification result, a retrieval-enhanced knowledge base is constructed. The audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
2. The method according to claim 1, characterized in that, The method further includes: If the audit verification result indicates that the audit has failed, the target issue category corresponding to the target knowledge asset will be determined as the audit failure category. Increase the second similarity threshold, and re-cluster the problem vectors of the initial problem clusters within the audit failure category based on the increased second similarity threshold to form multiple new target problem categories; Perform subsequent steps until the audit verification result indicates that it has passed, and add the corresponding target knowledge asset to the retrieval enhancement generation knowledge base.
3. The method according to claim 1, characterized in that, The representative control rules include: determining the mean of all question vectors within each target question category to obtain the corresponding category semantic center vector; calculating the distance between each question vector within the target question category and the category semantic center vector, and selecting the question with the closest distance as the standard question of the target question category.
4. The method according to claim 3, characterized in that, The process of integrating knowledge from the initial question-answer pairs corresponding to each target question category using the representativeness control rules to obtain the corresponding target knowledge assets includes: For each target question category, knowledge integration is performed on the initial question-answer pairs corresponding to the target question category according to the representativeness control rules to obtain the standard question corresponding to the target question category; The answer quality of multiple answer texts within the target question category is evaluated, and the answer text with the highest answer quality is selected as the standard answer for the target question category based on the evaluation results; alternatively, multiple answer texts within the target question category are synthesized to generate the standard answer for the target question category.
5. The method according to claim 3, characterized in that, The audit verification of each of the target knowledge assets, to obtain the corresponding audit verification results, includes: Cluster quality assessment is performed on each of the target knowledge assets to obtain the redundancy control rule check results; Perform a representative distance check on each of the target knowledge assets to obtain the representative control rule check results; Perform a timeliness check on each of the target knowledge assets to obtain the timeliness control rule check results; When the results of the redundancy control rule check, the representativeness control rule check, and the timeliness control rule check all indicate that they have passed, the audit verification result is determined to be passed.
6. The method according to claim 5, characterized in that, The clustering quality assessment of each target knowledge asset to obtain the redundancy control rule check results includes: Determine the average cosine similarity between pairwise question vectors within the target question category; If the average value of the cosine similarity is not less than a preset threshold, the redundancy control rule check result is determined to be passed.
7. The method according to claim 5, characterized in that, The process of performing a representative distance check on each of the target knowledge assets to obtain the representative control rule check results includes: For each target knowledge asset, determine whether the distance between the standard question of the target knowledge asset and the category semantic center vector is less than a preset distance threshold; If the distance is not less than the preset distance threshold, the representative control rule check result is determined to be passed.
8. The method according to claim 5, characterized in that, The timeliness control rules include knowledge lifecycle rules, which are used to indicate whether the target knowledge asset is within its valid lifecycle based on the metadata. The timeliness check for each of the target knowledge assets, to obtain the timeliness control rule check result, includes: For each target knowledge asset, the timeliness status of the target knowledge asset is determined based on the metadata corresponding to the target knowledge asset. If the timeliness status meets the knowledge lifecycle rule, the timeliness control rule check result is determined to be passed.
9. The method according to claim 1, characterized in that, The second clustering of the multiple initial question clusters based on the second similarity threshold includes: The mean vector of the problem vectors within each initial problem cluster is determined, and the mean vector is used as the group-level semantic representation of the corresponding initial problem cluster. Calculate the similarity between group-level semantic representations of different initial question clusters, and merge initial question clusters with similarity greater than or equal to the second similarity threshold into the same target question category.
10. The method according to claim 1, characterized in that, The method further includes: Acquire new session data and extract new question-answer pairs from the new session data; The question text of the newly added question-answer pair is converted into a new question vector, and the new question vector is matched with the semantic vector corresponding to the standard question in the retrieval enhancement knowledge base; When a match is successful, the newly added question-answer pair is classified into the target question category, and the corresponding target knowledge asset is updated based on the newly added question-answer pair.
11. A retrieval-enhanced knowledge base construction apparatus, characterized in that, The device includes: The data acquisition module is used to acquire conversation data and extract the conversation data using a large language model to obtain an initial question-answer pair set; each initial question-answer pair includes question text, answer text, and metadata corresponding to the question text and answer text. The first clustering module is used to semantically vectorize the question texts in the initial question-answer pair set, and perform a first clustering on the question vectors based on a first similarity threshold to obtain multiple initial question clusters; each initial question cluster includes multiple semantically similar question vectors and their corresponding initial question-answer pairs; A specification construction module is used to construct quality control specifications, which include redundancy control rules, representativeness control rules, and timeliness control rules. The redundancy control rules are used to constrain the semantic merging between different initial question clusters. The representativeness control rules are used to constrain the determination of standard questions and standard answers. The timeliness control rules are used to constrain the validity period of knowledge assets. The redundancy control rules include constraining the re-aggregation of the initial question clusters with a second similarity threshold. The second clustering module is used to perform a second clustering on the plurality of initial question clusters based on the second similarity threshold to obtain a plurality of target question categories; the second similarity threshold is less than the first similarity threshold; The knowledge integration module is used to integrate the initial question-answer pairs corresponding to each target question category using the representativeness control rules to obtain the corresponding target knowledge assets; the target knowledge assets include the standard questions and standard answers corresponding to the target question category. The audit verification module is used to audit and verify each of the target knowledge assets, obtain the corresponding audit verification results, and construct a retrieval-enhanced knowledge base based on the target knowledge assets indicated by the audit verification results; the audit verification includes redundancy control rule checks, representativeness control rule checks, and timeliness control rule checks.
12. An electronic device, characterized in that, include: The electronic device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the retrieval enhancement generation knowledge base construction method as described in any one of claims 1-10 is performed.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the retrieval enhancement knowledge base construction method as described in any one of claims 1-10.
