Construction of knowledge base, retrieval method and device

By combining the predicted scores of the large language model EOS with a tree-like knowledge structure, the semantic fragmentation problem caused by mechanical block division is solved, enabling efficient and accurate retrieval of the knowledge base. It is suitable for scenarios such as intelligent customer service, policy consultation, and enterprise knowledge management.

CN123068531APending Publication Date: 2026-11-10ZHEJIANG BIANQUE HEALTH TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611244933.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-17
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Existing knowledge bases lack stability and accuracy in retrieval when faced with logically rigorous and structurally complex industry professional documents. Mechanical segmentation leads to semantic fragmentation and information loss, affecting the retrieval accuracy and reliability of the knowledge base.

Method used

A dynamic semantic boundary calibration mechanism based on the prediction score of the large language model EOS is adopted. Through iterative processing, semantically complete knowledge fragments are formed and a tree-shaped knowledge structure is constructed. Combined with text retrieval and vector retrieval sub-libraries, multi-level knowledge organization and retrieval are realized.

Benefits of technology

It significantly improves the semantic coherence and independence of knowledge fragments, enhances the accuracy and recall quality of knowledge base retrieval, and supports efficient retrieval and user experience in complex query scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123068531A_ABST
    Figure CN123068531A_ABST
Patent Text Reader

Abstract

This specification discloses a method and apparatus for constructing a knowledge base. The method includes: first, determining multiple text blocks arranged in order based on the original text to form a text block sequence. Then, after initializing the current text block as the first text block in the text block sequence, performing multiple rounds of iterative processing to obtain multiple knowledge fragments, which are then stored in the knowledge base. Each round of iterative processing includes: first determining whether the current text block meets a preset condition, which includes: the prediction score of the large model for the semantic terminator following the current text block is greater than a preset score threshold; further, if not met, updating the current text block to the result of merging adjacent unprocessed text blocks in the text block sequence, and performing the determination again; if met, treating the current text block as a knowledge fragment, and updating the current text block to an adjacent unprocessed text block in the text block sequence for use in the next round of iterative processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and more particularly to a method and apparatus for constructing a knowledge base, a method and apparatus for retrieving a knowledge base, a computer-readable storage medium, and a computing device. Background Technology

[0002] With the rapid development of artificial intelligence technology, Large Language Models (LLMs) have made groundbreaking progress in the field of natural language processing. To overcome the limitations of LLMs in terms of knowledge timeliness and factual accuracy, Retrieval-Augmented Generation (RAG) technology has emerged and gained widespread application. By combining external knowledge bases with the generative capabilities of LLMs, RAG technology can provide users with accurate question-and-answer services based on domain-specific knowledge, thus playing an increasingly important role in scenarios such as intelligent customer service, policy consultation, legal assistance, and enterprise knowledge management.

[0003] In the RAG architecture, the quality of knowledge base construction and retrieval efficiency are key factors determining the overall system performance. An efficient knowledge base system needs to be able to effectively organize and store massive amounts of unstructured documents and respond quickly to queries.

[0004] However, in real-world high-precision applications, especially when dealing with logically rigorous and structurally complex industry-specific documents, existing knowledge base retrieval solutions still face challenges in terms of the stability and accuracy of retrieval results. Therefore, there is an urgent need for a method to further improve knowledge base retrieval performance to better support the implementation of upper-layer intelligent applications and other business applications. Summary of the Invention

[0005] This specification describes an embodiment of a knowledge base construction and retrieval method and apparatus that can solve the above-mentioned technical problems.

[0006] Based on the first aspect, a method for constructing a knowledge base is provided. This method includes:

[0007] Multiple text blocks arranged in a predetermined order based on the first text are formed into a text block sequence. After initializing the current text block as the first text block in the text block sequence, multiple rounds of iterative processing are performed to obtain multiple knowledge fragments. Each round of iterative processing includes: determining whether the current text block meets a preset condition; the preset condition includes: the prediction score of the large model for the semantic terminator following the current text block is greater than a preset score threshold; if not met, the current text block is updated to the result after merging adjacent unprocessed text blocks in the text block sequence, and the determination is performed again; if met, the current text block is treated as a knowledge fragment, and the current text block is updated to an adjacent unprocessed text block in the text block sequence for use in the next round of iterative processing. The multiple knowledge fragments are stored in a knowledge base.

[0008] In one embodiment, the preset condition further includes the length of the current text block being greater than a preset length threshold.

[0009] In one embodiment, before determining the multiple text blocks arranged in order based on the first text, the method further includes: dividing the original document into multiple chapter blocks based on the chapter titles in the original document; and using each chapter block as the first text.

[0010] In one embodiment, determining multiple text blocks arranged in order based on a first text includes: dividing the first text into multiple continuous and partially overlapping text blocks according to a preset sliding window size and overlap length.

[0011] In one embodiment, storing the plurality of knowledge fragments into a knowledge base includes: determining the vector representation corresponding to each knowledge fragment; performing clustering processing on the knowledge fragments based on the vector representation to obtain multiple clusters; generating a summary text for each cluster, and using the summary text as the parent node and the knowledge fragments in the cluster as the corresponding child nodes; iteratively executing the steps of clustering processing and generating parent nodes to construct a tree-shaped knowledge structure containing multi-level nodes from bottom to top; and storing the node identifiers, corresponding original texts, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the knowledge base.

[0012] Further, in a specific embodiment, the knowledge base includes a text retrieval sub-base and a vector retrieval sub-base; wherein, storing the node identifier, corresponding original text, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the knowledge base includes: storing the node identifier, corresponding original text content, and hierarchical metadata into the text retrieval sub-base; wherein, the method further includes: storing the node identifier, corresponding node vector, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the vector retrieval sub-base, wherein the node vector is obtained by encoding the original text corresponding to the node.

[0013] According to the second aspect, a method for retrieving knowledge bases is provided. The method includes: receiving query text input by a user; retrieving several knowledge fragments from the knowledge base using the query text; wherein the knowledge base is constructed based on the method provided in the first aspect.

[0014] In one embodiment, the knowledge fragments in the knowledge base are organized into a tree-like knowledge structure, where the leaf nodes are knowledge fragments and the non-leaf nodes are summary texts of the knowledge fragments. The knowledge base includes a text retrieval sub-base and a vector retrieval sub-base, both of which store node identifiers and hierarchical metadata of the nodes in the tree-like knowledge structure. The text retrieval sub-base also stores the original text of the nodes, and the vector retrieval sub-base also stores the vector representations corresponding to the nodes.

[0015] The step of retrieving several knowledge fragments from the knowledge base using the query text includes: using the query text to search the text retrieval sub-base and the vector retrieval sub-base respectively to obtain several hit nodes; for each hit node, if the hit node is a leaf node, then the original text corresponding to the node is obtained and included in the candidate knowledge fragment set; if the hit node is a non-leaf node, then all descendant leaf nodes under the hit node are determined based on the hierarchical metadata, the original text corresponding to the descendant leaf nodes is obtained and included in the candidate knowledge fragment set; and the several knowledge fragments are selected from the candidate knowledge fragment set.

[0016] Furthermore, in a specific embodiment, selecting the plurality of knowledge fragments from the candidate knowledge fragment set includes: for each candidate knowledge fragment in the candidate knowledge fragment set, determining its first ranking in the vector retrieval results and calculating a first sub-score negatively correlated with the first ranking; determining its second ranking in the text retrieval results and calculating a second sub-score negatively correlated with the second ranking; performing a weighted summation of the first sub-score and the second sub-score to obtain a comprehensive score for the candidate knowledge fragment; and sorting the candidate knowledge fragment set in descending order based on the comprehensive score, selecting the top K candidate knowledge fragments as the recall results.

[0017] In one embodiment, the method further includes: inputting the query text and the recalled knowledge fragments into a large model to obtain generated answer content for feedback to the user.

[0018] According to a third aspect, an apparatus for constructing a knowledge base is provided. The apparatus includes:

[0019] The sequence construction module is configured to form a text block sequence by arranging multiple text blocks in a predetermined order based on the first text. The iterative processing module is configured to initialize the current text block as the first text block in the text block sequence and then perform multiple rounds of iterative processing to obtain multiple knowledge fragments. Each round of iterative processing is implemented through the following functional units: a judgment unit, configured to judge whether the current text block meets preset conditions; the preset conditions include: the prediction score of the large model for the semantic terminator following the current text block is greater than a preset score threshold; a first branch unit, configured to update the current text block to the result of merging adjacent unprocessed text blocks in the text block sequence if the condition is not met, and then perform the judgment again; a second branch unit, configured to treat the current text block as a knowledge fragment if the condition is met, and update the current text block to the adjacent unprocessed text block in the text block sequence for use in the next round of iterative processing. The storage module is configured to store the multiple knowledge fragments into a knowledge base.

[0020] According to a fourth aspect, a knowledge base retrieval device is provided. The device includes: a query receiving module configured to receive query text input by a user; and a recall module configured to recall several knowledge fragments from the knowledge base using the query text; wherein the knowledge base is constructed based on the device provided in the third aspect.

[0021] According to a fifth aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method provided in the first aspect.

[0022] According to a sixth aspect, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method provided in the first aspect.

[0023] In summary, by employing the methods and apparatus disclosed in the embodiments of this specification, and using a dynamic semantic boundary calibration mechanism based on the EOS prediction score of a large language model, the semantic fragmentation problem caused by traditional mechanical block segmentation is effectively solved, and the corresponding recalled knowledge fragments have high semantic integrity and independence. Attached Figure Description

[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This diagram illustrates the implementation architecture of the knowledge base construction scheme disclosed in the embodiments of this specification;

[0026] Figure 2 This diagram illustrates the flow steps of the knowledge base construction method disclosed in the embodiments of this specification;

[0027] Figure 3 This diagram illustrates the flow steps of the knowledge base retrieval method disclosed in the embodiments of this specification;

[0028] Figure 4 This specification illustrates the implementation architecture of the tree-based recursive retrieval disclosed in the embodiments.

[0029] Figure 5 A schematic diagram of the functional module structure of the knowledge base construction apparatus disclosed in the embodiments of this specification;

[0030] Figure 6 This is a schematic diagram of the functional module structure of the knowledge base retrieval device disclosed in the embodiments of this specification. Detailed Implementation

[0031] The solution provided in this specification will now be described with reference to the accompanying drawings.

[0032] As mentioned earlier, in practical high-precision application scenarios, especially when dealing with logically rigorous and structurally complex industry professional documents, existing knowledge base retrieval solutions still face challenges in terms of the stability and accuracy of retrieval results.

[0033] Specifically, existing knowledge base systems typically avoid treating entire documents or excessively long chapters as a single retrieval unit when processing document insertion. This is because large-granularity text blocks often contain a large amount of redundant information unrelated to the user's query intent. This noise can severely interfere with vector similarity calculations or keyword matching processes, leading to a decrease in the signal-to-noise ratio of the retrieval system. Consequently, the recall accuracy drops significantly, making it difficult to accurately locate key knowledge points from massive amounts of irrelevant content.

[0034] To address the low precision issues caused by large-granularity storage, existing technologies generally employ fixed-length segmentation methods, such as sliding windows based on the number of characters or tokens, or simple paragraph partitioning. However, this mechanical segmentation approach often fails to consider the inherent logical semantic boundaries of the text, easily leading to the forced truncation and dispersion of originally semantically complete and logically coherent knowledge units (such as a complete policy clause or a statement containing preconditions and exceptions) into multiple adjacent text blocks. The resulting text blocks suffer from semantic discontinuity or missing information, failing to independently and completely represent the original knowledge meaning. When a user queries a complete concept, this fragmented storage structure may cause the system to recall only fragments containing partial keywords but lacking crucial context, or the semantic discontinuity may make it difficult for the large model to accurately understand the text's intent, resulting in distorted search results and severely impacting the accuracy and reliability of knowledge base retrieval.

[0035] Therefore, this specification proposes an improved scheme in its embodiments. This scheme, based on mechanical segmentation using methods such as title or token count, further utilizes a large language model to calculate the predicted score of the End of Sequence (EOS) in the text sequence, such as the Logits value, to accurately locate the natural termination point of semantics. In this way, the proportion of independent units with complete context and semantic consistency in the generated knowledge fragments can be significantly increased; the vast majority of knowledge fragments can maintain semantic coherence and integrity, for example, forming a complete policy clause or a statement containing preconditions and exceptions.

[0036] like Figure 1 As shown, under the implementation architecture of the improved scheme, the knowledge base construction process mainly manifests as an iterative process based on semantic boundary calibration:

[0037] First, multiple text blocks arranged in a specific order based on a given text are used to form a text block sequence.

[0038] Subsequently, the system initializes the current text block as the first text block in the text block sequence and performs multiple rounds of iterative processing to obtain multiple knowledge fragments. In any round of iterative processing, the core steps include:

[0039] 1. Determine if the current text block meets preset conditions: such as Figure 1 As shown in the diamond-shaped decision box, the system calls the large language model to calculate the current text block ( Figure 1 The predicted score (such as the Logits value) is appended to the end of the symbolic terminator (EOS) marked as ci, and it is determined whether the score is greater than the preset score threshold.

[0040] 2. Perform the corresponding operation based on the judgment result:

[0041] 2.1) If the preset conditions are not met (e.g., the EOS value is less than the threshold, meaning the semantics are not complete), then a merge operation is performed: the current text block is updated to the result of merging adjacent unprocessed text blocks in the text block sequence (e.g., ...). Figure 1 (The process merges ci and cj into a new ci), and then returns to execute the judgment again.

[0042] 2.2) If preset conditions are met (e.g., an EOS value greater than or equal to a threshold, indicating semantic completeness), then output and shift operations are performed: the current text block is treated as a knowledge fragment (e.g., ... Figure 1 The output is a semantically complete ci), and the current text block is updated with the adjacent unprocessed text blocks in the text block sequence (such as...). Figure 1 Move it to cj) for the next round of iteration.

[0043] Loop until end: The above iterative process continues until all text blocks have been processed (e.g., ...). Figure 1 (As shown in the diamond-shaped decision box on the right).

[0044] Finally, the system stores the multiple knowledge fragments obtained through the above semantic calibration into the knowledge base, thereby completing the construction of the knowledge base.

[0045] Next, with reference to more embodiments, the specific implementation steps of the knowledge base construction process in the improved scheme will be described. Figure 2 This illustrates the steps involved in building a knowledge base. It should be noted that the entity executing this method can be any device, platform, server, or equipment cluster with computing and processing capabilities, such as a knowledge base building system. Figure 2 The process of building a knowledge base can include the following steps:

[0046] Step S210: Based on the first text, determine multiple text blocks arranged in order to form a text block sequence.

[0047] First, it should be noted that the "first" in "first text" and similar terms such as "second" and "third" elsewhere in the text are used to distinguish similar things and do not have any other limiting function such as ranking.

[0048] In one embodiment, the first text may be derived from the original document that has undergone structured parsing.

[0049] Specifically, the system first intelligently parses the original document (such as PDF, Word, etc.), for example, using parsing tools that preserve the document's logical structure and visual layout (such as Docling), outputting well-organized text with hierarchical markers (such as Markdown headings). Then, based on the chapter titles or hierarchical markers in the original document, it divides the original document into multiple chapter blocks; and each chapter block is used as the first text. This structure-aware initial segmentation helps preserve the document's macroscopic logical structure.

[0050] In another embodiment, the first text can also be any continuous text that is directly collected, such as an article, a paragraph, or a string read from a database as the first text.

[0051] After determining the first text, this step aims to transform it into a sequence of fine-grained units suitable for subsequent processing. In one embodiment, the first text is segmented using a sliding window according to a preset sliding window size and overlap length, resulting in multiple continuous and partially overlapping text blocks. The sliding window size can be set according to the processing capacity of the large language model (e.g., 512 tokens), and the overlap length is used to prevent semantics from being rigidly cut off at boundaries. In this way, longer chapter blocks or articles can be transformed into a series of shorter initial text segments that are easier for the model to compute.

[0052] In another embodiment, the first text can be segmented according to punctuation marks (such as periods, question marks), line breaks, or paragraph marks to obtain multiple text blocks arranged in sequence.

[0053] As shown above, by performing preliminary segmentation on the first text, a sequence of text blocks formed by sequentially arranging multiple text blocks can be obtained, providing basic input for subsequent semantic boundary calibration.

[0054] Step S220: After initializing the current text block as the first text block in the text block sequence, perform multiple rounds of iterative processing to obtain multiple knowledge fragments, or knowledge units.

[0055] Each round of iterative processing includes the following sub-steps:

[0056] Step S221: Determine whether the current text block meets the preset conditions; the preset conditions include: the prediction score of the large model for the semantic terminator following the current text block is greater than the preset score threshold.

[0057] In one embodiment, the preset condition may further include: the length of the current text block is greater than a preset length threshold. This condition is introduced to consider computational resources and processing efficiency, preventing the merged text block from exceeding the maximum context window limit of the subsequent vector encoding model or LLM due to the length of the text itself (such as a lengthy review or complex clauses), thereby ensuring the technical feasibility and processing efficiency of the generated knowledge fragments.

[0058] In another embodiment, the preset condition may further include: the current text block is the last unprocessed text block in the text block sequence. This condition is introduced as a termination guarantee mechanism for iterative processing, ensuring that when the end of the sequence is reached, regardless of its semantic prediction score, the remaining text content can be output as an independent knowledge fragment, avoiding data loss or logical deadlock due to the inability to obtain subsequent text blocks for merging.

[0059] It should be noted that the predicted score can be a logits value or a probability value after normalization (such as the probability calculated by the Softmax function).

[0060] When using logits values, their advantage lies in directly reflecting the original score of the large language model output layer for the specific token EOS on the vocabulary, without the need for additional exponential and normalization calculations, thereby reducing computational overhead and improving judgment efficiency. At the same time, logits values ​​retain the original distribution information, which is more sensitive to distinguishing between "extremely high probability of ending" and "relatively high probability of ending", and is conducive to setting more refined thresholds to capture subtle semantic boundaries.

[0061] When using probability values, their advantage lies in the fact that the numerical range is fixed between [0, 1], which has an intuitive physical meaning and facilitates the unified setting and migration of thresholds for different models and different task scenarios. In addition, probability values ​​eliminate the influence of differences in vocabulary size or output scale of different models, making the configuration of preset score thresholds more universal and stable, and reducing the difficulty of parameter tuning in engineering deployment.

[0062] Regardless of the form of the predicted score used, its core function is to quantify the rationality of the end of the current text block as a semantic termination point. Based on the judgment result, the subsequent process will be divided into two processing paths, which can be found in steps S222a and S222b.

[0063] Step S222a: If the condition is not met, the current text block is updated to the result of merging adjacent unprocessed text blocks in the text block sequence, and the judgment is performed again.

[0064] This processing path corresponds to the situation where the semantics of the current text block are not yet complete. Specifically, when the judgment result does not meet the preset conditions (e.g., a low EOS prediction score, or the length is insufficient and it is not the last block), it indicates that the current text block is in an intermediate state semantically, and forcibly truncating it will result in information loss.

[0065] Therefore, a merging operation is performed: the next unprocessed text block immediately adjacent to the current text block is obtained from the text block sequence, and the two are concatenated or merged to form a new, longer current text block. Subsequently, the process returns to step S221, using this merged new text block as input, to perform semantic integrity judgment again. Through this iterative mechanism of "judgment-merge-rejudgment", the system can dynamically aggregate multiple mechanically segmented short text blocks until a semantically coherent and logically complete unit is formed.

[0066] In step S222b, if the condition is met, the current text block is treated as a knowledge fragment, and the current text block is updated to the adjacent unprocessed text block in the text block sequence for use in the next round of iteration.

[0067] This processing path corresponds to the case where the semantics of the current text block are complete. Specifically, when the judgment result meets the preset conditions (e.g., the EOS prediction score is higher than the threshold, or the maximum length limit has been reached, or it is the last block in the sequence), it indicates that the current text block has constituted an independent knowledge representation unit.

[0068] Therefore, the output and shift operations are performed as follows: First, the current text block is identified as a final knowledge fragment (or knowledge unit) and added to the result set; second, in order to continue processing subsequent content, the system updates the current text block to the next adjacent unprocessed text block in the text block sequence. It should be noted that if, during the shift operation, it is found that there are no remaining unprocessed text blocks in the text block sequence (i.e., the current block is at the end of the sequence and has been output), it signifies the end of the multi-round iterative processing, and the process proceeds to the next step S230; otherwise, the next round of iterative processing will begin with the new current text block as the starting point.

[0069] It should be noted that by combining the "preliminary fine-grained segmentation" in the previous step S210 with the "dynamic calibration of semantic boundaries" in this step, a dual optimization of knowledge fragment granularity and semantic integrity can be achieved.

[0070] Specifically, in the previous step S210, if a sliding window with overlapping parts is used for initial segmentation, physical overlap ensures that potential semantic units are not forcibly truncated and retains contextual redundancy. If segmentation is based on natural language boundaries such as punctuation marks and line breaks, the inherent syntactic structure of the text is utilized, making the initial text blocks closer to natural semantic pauses and reducing the risk of semantics being forcibly fragmented. In the iterative processing of this step S220, the judgment of the EOS prediction score by the large model is further used as a "soft boundary" for semantic termination, dynamically determining when to stop merging. This combined strategy avoids semantic fragmentation caused by mechanical fixed-length segmentation and prevents excessively long fragments caused by unlimited merging, thus ensuring that each knowledge fragment generated in the end maintains semantic independence and integrity while its length is within a reasonable range suitable for subsequent vector encoding and large model processing.

[0071] Step S230: Store the multiple knowledge fragments into the knowledge base.

[0072] In one possible implementation, this step can adopt a conventional flat storage method, that is, the generated multiple knowledge fragments are directly stored in the database as independent entries, and corresponding indexes are established.

[0073] In another possible implementation, considering that documents such as regulations have a rigorous hierarchical structure (e.g., chapter-section-article-clause-item), the structure itself contains rich semantic information (e.g., the subordinate relationship between general provisions and specific provisions, general regulations and special regulations). If only flat storage is used, the hierarchy of knowledge structure will be lost, making it impossible for the retrieval system to understand the general and detailed relationships of knowledge points, and the retrieval results will lack interpretability.

[0074] To address this, a tree-structured knowledge building method based on a clustering-summarization iterative algorithm is proposed to achieve hierarchical organization of knowledge fragments and effective utilization of hierarchical semantics.

[0075] Specifically, this implementation may include the following sub-steps:

[0076] First, determine the vector representation corresponding to each knowledge fragment. For example, a pre-trained text embedding model (such as Sentence-BERT) can be used to encode the original text of each knowledge fragment, mapping it to a dense vector in a high-dimensional space. This vector can represent the deep semantic features of the knowledge fragment, making semantically similar knowledge fragments closer together in the vector space, thus providing a mathematical basis for subsequent similarity calculations and clustering.

[0077] Secondly, based on the vector representation, clustering is performed on the knowledge fragments to obtain multiple semantically similar clusters. For example, unsupervised clustering algorithms (such as K-Means or hierarchical clustering) can be used to calculate the cosine similarity or Euclidean distance between the vectors of each knowledge fragment, grouping knowledge fragments with vector distances less than a preset threshold or belonging to the same center into the same cluster. In this way, scattered, fine-grained knowledge fragments can be automatically summarized into several sets with a common theme or semantic focus. It should be understood that "several" in this text refers to one or more in number.

[0078] Next, a summary text is generated for each cluster. In one embodiment, the original text content of all knowledge fragments in the cluster can be input into the large language model, prompting the model to generate a summary text that summarizes the core content of the cluster. In another embodiment, to enhance the accuracy and structure of the summary, the hierarchical metadata of all knowledge fragments in the cluster in the first text (such as chapter titles, table of contents, paragraph numbers, etc.) can also be input into the large language model, enabling the model to combine the logical context of the document when generating the summary and generate a more context-aware description of the parent nodes.

[0079] Subsequently, the summary text is used as the parent node, and the knowledge fragments in the cluster are used as the corresponding child nodes to establish a parent-child relationship.

[0080] Finally, the above clustering and parent node generation steps are iteratively executed, that is, the parent nodes generated in the previous layer are clustered and summarized again, thereby building a tree-shaped knowledge structure containing multi-level nodes from bottom to top.

[0081] After constructing the tree-shaped knowledge structure, the node identifiers, corresponding original texts, and hierarchical metadata of each node in the tree-shaped knowledge structure are stored in the knowledge base. It should be noted that the hierarchical metadata is mainly used to record the topological relationships of nodes in the tree structure, specifically including parent node pointers and child node pointers. The parent node pointer points to the node identifier of the current node's direct parent node, while the child node pointer points to the set of node identifiers of all the current node's direct child nodes. By storing this pointer information, the knowledge base can completely preserve the subordinate and aggregation relationships between nodes, supporting recursive traversal and path reconstruction in subsequent retrieval processes.

[0082] Furthermore, in one possible design, the knowledge base includes a text retrieval sub-base and a vector retrieval sub-base, or a text index sub-base and a vector index sub-base. These two sub-bases employ different indexing mechanisms: the text retrieval sub-base uses the original text content of the nodes as the indexing basis, supporting precise matching based on keywords or the full text; while the vector retrieval sub-base uses the node vectors of the nodes as the indexing basis, supporting fuzzy retrieval based on semantic similarity. The node vectors are obtained by encoding the original text corresponding to the nodes.

[0083] It should be noted that although the two sub-databases have different index formats, the stored metadata remains consistent. Specifically, the node identifier and hierarchical metadata of the same node in the tree-like knowledge structure are stored in the two sub-databases respectively, while maintaining consistency in the node identifier. Through this unified node identifier, a logical association mapping is established between the text retrieval sub-database and the vector retrieval sub-database. This enables the system to accurately align the different representations (i.e., original text and vector) of the same knowledge object in the two sub-databases based on the same node identifier when performing multi-path retrieval (such as hybrid retrieval), thereby achieving the fusion and deduplication of retrieval results.

[0084] In summary, the knowledge base construction method proposed in the improved scheme has the following beneficial effects:

[0085] 1) A dynamic semantic boundary calibration mechanism based on the EOS prediction score of a large language model is adopted, effectively solving the semantic fragmentation problem caused by traditional mechanical block segmentation. This method ensures that almost every generated knowledge fragment is an independent unit with complete context and semantic consistency, avoiding the loss or dispersion of key information in multiple fragments due to forced truncation. This not only improves the semantic coherence of knowledge fragments, enabling the large model to more accurately understand textual intent during Retrieval Augmentation Generation (RAG), but also prevents fragments from becoming too long by controlling the merging logic, ensuring that the knowledge granularity is within the optimal range for vector encoding and model processing, thereby significantly improving the accuracy and recall quality of knowledge base retrieval.

[0086] 2) By introducing a tree-like knowledge structure constructed using a clustering-summarizing iterative algorithm, the method overcomes the semantic loss defect caused by traditional flat storage. For documents with rigorous logical structures, such as regulations and policies, this method can preserve and utilize hierarchical relationships such as "chapter-section-article-clause," enabling the retrieval system not only to locate specific knowledge points but also to understand their subordinate position and general meaning within higher-level concepts. This hierarchical organization enhances the interpretability of knowledge, supporting users in structured navigation and exploration from macro principles to micro details, and improving retrieval efficiency and user experience in complex query scenarios.

[0087] 3) By establishing a dual-path index architecture comprising a text retrieval sub-database and a vector retrieval sub-database, and utilizing unified node identifiers to achieve logical associations, the advantages of precise matching and semantic fuzzy retrieval are complemented. The text sub-database ensures the accuracy of keyword matching, while the vector sub-database provides semantic-level generalized retrieval capabilities. The combination of the two not only expands the retrieval coverage but also achieves seamless fusion and deduplication of multi-path retrieval results through node identifier alignment, further enhancing the robustness and response accuracy of the knowledge base system under diverse query requirements.

[0088] Based on the aforementioned constructed knowledge base, this specification also provides a knowledge base retrieval method adapted to it. Figure 3 A flowchart illustrating the knowledge base retrieval method is shown. It should be noted that the execution entity of this method can be any terminal, server, or distributed computing cluster with data processing capabilities, such as a knowledge base retrieval system deployed with a search engine. Figure 3 As shown, this retrieval method mainly includes the following steps:

[0089] Step S310: Receive the query text input by the user.

[0090] The query text can be any form of text information entered by the user in the natural language interface. In practical applications, such as in an intelligent customer service system, the query text can be a specific question asked by a customer (e.g., "What are the specific standards regarding **?"); in legal and regulatory retrieval scenarios, the query text can be a legal provision search request from a lawyer or legal professional (e.g., "Find compliance requirements regarding **"). This step aims to obtain the user's true intention, serving as the input basis for subsequent retrieval processes.

[0091] Step S320: Use the query text to retrieve several knowledge fragments from the knowledge base.

[0092] In one possible implementation, if the knowledge base adopts a conventional flat storage structure, the query text is directly used to perform vector similarity matching or keyword matching in the knowledge base to recall several knowledge fragments that are most relevant to the query intent.

[0093] In another implementation, the knowledge fragments in the knowledge base are organized into a tree-like knowledge structure. The leaf nodes of the tree structure correspond to specific knowledge fragments, and the non-leaf nodes correspond to summary text for their child nodes. The knowledge base includes a text retrieval sub-base and a vector retrieval sub-base. Both sub-bases store the node identifiers and hierarchical metadata (such as parent-child pointer relationships) of each node in the tree structure. Furthermore, the text retrieval sub-base stores the original text content of the nodes, and the vector retrieval sub-base stores the vector representations corresponding to the nodes (see the aforementioned embodiments for specific construction methods).

[0094] In this implementation, step S320 may specifically include Figure 4 The following process is shown:

[0095] First, a parallel dual-path retrieval is performed. The query text is used to independently search both the text retrieval sub-database and the vector retrieval sub-database, resulting in two sets of hit nodes. The union of these two sets of hit nodes may include one or more hit nodes.

[0096] For example, in the text retrieval sub-database, a keyword-based retrieval algorithm (such as BM25, TF-IDF, etc.) can be used to calculate the relevance score between the query text and the original text of each node, and recall several nodes with relevance scores higher than a preset threshold as text path hit nodes.

[0097] For example, in the vector retrieval sub-library, the query text is first encoded into a query vector using a text embedding model. Then, the similarity (such as cosine similarity) between the query vector and the node vectors stored by each node is calculated, and several nodes with similarity higher than a preset threshold are recalled as vector path hit nodes.

[0098] Secondly, perform recursive parsing of nodes and aggregation of leaf nodes. For all the hit nodes obtained from the above two retrieval methods, determine their node type one by one:

[0099] If the hit node is a leaf node, the original text corresponding to that node is directly obtained and included in the candidate knowledge fragment set.

[0100] If the hit node is a non-leaf node (such as a summary node or an intermediate layer node), then based on the stored hierarchical metadata (such as child node pointers), all descendant nodes of the node are recursively traversed downwards until all descendant leaf nodes are located; then, the original text corresponding to these descendant leaf nodes is obtained and they are included in the candidate knowledge fragment set.

[0101] This "recursive retrieval to leaf nodes" mechanism ensures that no matter which level of node the initial recall hits, the objects that eventually enter the candidate pool are always complete semantic units at the same granularity (i.e., leaf nodes), thus solving the problem that heterogeneous hierarchical results are difficult to directly compare and sort.

[0102] Finally, several knowledge fragments are selected from the candidate knowledge fragment set as the final recall result.

[0103] In one embodiment, a multi-path score fusion strategy is used for screening:

[0104] For each candidate knowledge fragment in the candidate knowledge fragment set, its first ranking in the vector retrieval results is determined, and a first sub-score negatively correlated with the first ranking is calculated. For example, using the inverse ranking fusion algorithm... ,in, This indicates the ranking position (rank) of the candidate knowledge fragment in the recall results list of the vector retrieval sub-library. This is a smoothing constant (usually 60 or other empirical values) used to prevent the denominator from being zero and to adjust the sensitivity of the ranking. Through this formula, nodes ranked higher receive a higher first sub-score, and the score decays rapidly as the ranking decreases, thus reflecting the importance of the top results.

[0105] Furthermore, determine its second ranking in the text retrieval results, and calculate a second sub-score that is negatively correlated with the second ranking, for example, by calculating... ,in, This indicates the ranking position (rank) of the candidate knowledge fragment in the recall results list of the text retrieval sub-database. As another smoothing constant, its effect is related to Similarly, it is used to balance the differences in scoring scales between different retrieval pathways, ensuring that the ranking of text retrieval results can be reasonably mapped to comparable scores.

[0106] Next, the first sub-score and the second sub-score are weighted and summed to obtain the comprehensive score of the candidate knowledge segment, for example, using the following formula (1). Wherein, the weight coefficients... and It can be configured according to business scenario requirements; generally speaking, > .

[0107] (1)

[0108] Finally, the candidate knowledge fragment set is sorted in descending order based on the comprehensive score, and the top K candidate knowledge fragments are selected as the final recall results. This sorting method, which first normalizes the granularity and then fairly integrates the results, significantly improves the accuracy and interpretability of the retrieval results.

[0109] In another embodiment, a re-ranking strategy based on a Large Language Model (LLM) can be used for screening. Specifically, firstly, the top N candidate knowledge fragments (N greater than K, e.g., N=20 or 50) are initially selected from the candidate knowledge fragment set to form a re-ranking candidate set. Then, a prompt word containing the query text and the original text of each candidate knowledge fragment is constructed and input into a pre-trained Large Language Model. The Large Language Model generates a relevance score for each candidate knowledge fragment based on the relevance, completeness, and logical matching degree between the query intent and the knowledge fragment content, or directly outputs the ranking result. Finally, the re-ranking candidate set is sorted in descending order according to the relevance score output by the Large Language Model, and the top K candidate knowledge fragments are selected as the final recall result. In this way, the deep semantic understanding capability of the Large Language Model can be utilized to more accurately identify the complex logical relationship between the query and the document, further improving the accuracy of the final recall result.

[0110] According to another embodiment, in the scenario of intelligent question answering service based on a large model, the method further includes: inputting the query text and several knowledge fragments finally recalled as context information into a generative large language model; the large language model performs semantic analysis and content generation based on the context information, outputs natural language answer content for the query text, and feeds back the answer content to the user, thereby realizing retrieval augmented generation (RAG) type intelligent question answering.

[0111] Furthermore, in standardized question-and-answer or customer service scenarios, the knowledge fragments in the knowledge base can also be associated with preset standard user questions and corresponding standard answers. In this case, the method further includes: calculating the semantic similarity between the query text and the standard user question associated with the recalled knowledge fragment (exemplarily, the recalled knowledge fragment itself is a standard user question); if the highest similarity exceeds a preset threshold, then the standard answer corresponding to the standard user question is directly obtained and returned to the user. This approach can significantly reduce the calling cost of large models and improve response speed while ensuring the accuracy of the answer.

[0112] In summary, the knowledge base retrieval method disclosed in the embodiments of this specification has the following beneficial effects:

[0113] First, thanks to the precise calibration of semantic boundaries of knowledge fragments during the aforementioned knowledge base construction process, the knowledge fragments recalled by this retrieval method possess a high degree of semantic integrity and independence. Since each knowledge fragment is generated while ensuring contextual coherence and appropriate length, this fundamentally avoids the semantic loss or ambiguity issues caused by mechanical text truncation in traditional retrieval. When these high-quality knowledge fragments are used as contextual input to a large model or directly for matching, they significantly improve the system's accuracy in understanding user query intent, thus laying a solid data foundation for subsequent answer generation or standard answer matching, and effectively improving the relevance and usability of the retrieval results.

[0114] Secondly, by introducing a "recursive retrieval to leaf nodes" mechanism, the system addresses the ranking injustice caused by hierarchical differences in traditional tree-structured retrieval. Regardless of whether the initial recall hits a high-level summary node or a low-level detail node, the system automatically traverses downwards until all corresponding leaf nodes (i.e., the smallest granularity of knowledge fragments) are obtained. This mechanism ensures that the objects ultimately participating in ranking and fusion are at the same semantic granularity, providing a prerequisite for fair comparison of multi-path retrieval results and significantly improving the accuracy and robustness of hybrid retrieval.

[0115] Furthermore, a multi-path score fusion strategy based on inverse ranking is adopted, effectively combining the semantic generalization ability of vector retrieval with the keyword precision matching advantage of text retrieval. By introducing a smoothing constant to transform the rankings of different retrieval paths into comparable scores and performing weighted summation, this method can achieve seamless fusion of multi-path results without complex score normalization processing. This not only expands the retrieval coverage and reduces the risk of missed detections caused by a single retrieval mode, but also optimizes the relevance ranking of the final recall results through a comprehensive scoring mechanism.

[0116] Corresponding to the above-described construction and retrieval methods, embodiments of this specification also disclose a knowledge base construction apparatus and a retrieval apparatus. Specifically:

[0117] Figure 5 The knowledge base construction device 500 shown in the figure includes the following functional modules:

[0118] The sequence construction module 510 is configured to form a sequence of text blocks by arranging multiple text blocks in a determined order based on the first text.

[0119] The iterative processing module 520 is configured to initialize the current text block as the first text block in the text block sequence, and then perform multiple rounds of iterative processing to obtain multiple knowledge fragments. Each round of iterative processing is implemented through the following functional units: a judgment unit 521, configured to determine whether the current text block meets preset conditions; the preset conditions include: the prediction score of the large model for the semantic terminator following the current text block is greater than a preset score threshold. A first branch unit 522, configured to, if it is determined that the condition is not met, update the current text block to the result after merging adjacent unprocessed text blocks in the text block sequence, and perform the judgment again. A second branch unit 523, configured to, if it is determined that the condition is met, treat the current text block as a knowledge fragment and update the current text block to an adjacent unprocessed text block in the text block sequence for use in the next round of iterative processing.

[0120] Storage module 530 is configured to store the multiple knowledge fragments into a knowledge base.

[0121] In one embodiment, the preset condition further includes the length of the current text block being greater than a preset length threshold.

[0122] In one embodiment, the construction device 500 further includes a text determination module configured to: divide the original document into multiple chapter blocks based on the chapter titles in the original document; and use each chapter block as the first text.

[0123] In one embodiment, the sequence construction module 510 is specifically configured to: divide the first text into multiple continuous and partially overlapping text blocks according to a preset sliding window size and overlap length.

[0124] In one embodiment, the storage module 530 is specifically configured to: determine the vector representation corresponding to each knowledge fragment; perform clustering processing on the knowledge fragments based on the vector representation to obtain multiple clusters; generate summary text for each cluster, and use the summary text as the parent node and the knowledge fragments in the cluster as the corresponding child nodes; iteratively execute the steps of clustering processing and generating parent nodes to construct a tree-shaped knowledge structure containing multi-level nodes from bottom to top; and store the node identifiers, corresponding original texts, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the knowledge base.

[0125] Furthermore, in a specific embodiment, the knowledge base includes a text retrieval sub-base and a vector retrieval sub-base; wherein, the storage module 530 is configured to store the node identifier, corresponding original text, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the knowledge base, specifically including: storing the node identifier, corresponding original text content, and hierarchical metadata into the text retrieval sub-base; the storage module 530 is also configured to: wherein the method further includes: storing the node identifier, corresponding node vector, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the vector retrieval sub-base, wherein the node vector is obtained by encoding the original text corresponding to the node.

[0126] Figure 6 The knowledge base retrieval device 600 shown includes the following functional modules: a query receiving module 610, configured to receive query text input by a user; and a recall module 620, configured to recall several knowledge fragments from the knowledge base using the query text; wherein, the knowledge base is based on... Figure 5 It is constructed based on the device shown.

[0127] In one embodiment, the knowledge fragments in the knowledge base are organized into a tree-like knowledge structure, where the leaf nodes are knowledge fragments and the non-leaf nodes are summary texts of the knowledge fragments. The knowledge base includes a text retrieval sub-base and a vector retrieval sub-base, both of which store node identifiers and hierarchical metadata of the nodes in the tree-like knowledge structure. The text retrieval sub-base also stores the original text of the nodes, and the vector retrieval sub-base also stores the vector representations corresponding to the nodes.

[0128] The recall module 620 is specifically configured as follows: It uses the query text to search the text retrieval sub-library and the vector retrieval sub-library respectively, obtaining several hit nodes. For each hit node, if the hit node is a leaf node, the original text corresponding to the node is obtained and added to the candidate knowledge fragment set; if the hit node is a non-leaf node, all descendant leaf nodes under the hit node are determined based on the hierarchical metadata, and the original text corresponding to the descendant leaf nodes is obtained and added to the candidate knowledge fragment set. Several knowledge fragments are selected from the candidate knowledge fragment set.

[0129] Furthermore, in a specific embodiment, the recall module 620 is configured to select the plurality of knowledge fragments from the candidate knowledge fragment set, specifically including:

[0130] For each candidate knowledge fragment in the candidate knowledge fragment set, its first ranking in the vector retrieval results is determined, and a first sub-score negatively correlated with the first ranking is calculated; and its second ranking in the text retrieval results is determined, and a second sub-score negatively correlated with the second ranking is calculated. The first sub-score and the second sub-score are weighted and summed to obtain a comprehensive score for the candidate knowledge fragment. Based on the comprehensive score, the candidate knowledge fragment set is sorted in descending order, and the top K candidate knowledge fragments are selected as the recall results.

[0131] In one embodiment, the retrieval device 600 further includes a large model processing module, configured to input the query text and the recalled knowledge fragments into a large model to obtain generated answer content for feedback to the user.

[0132] It should be noted that for a description of the above-mentioned functional modules or functional units, please refer to the relevant description of the process method in the foregoing embodiments.

[0133] In the embodiments of this specification, the Large Language Model (LLM) may also be simply referred to as the Large Model. A Large Language Model is a natural language processing model based on deep learning technology. It has a high number of parameters, typically ranging from billions to hundreds of billions or even higher, and possesses powerful language understanding and generation capabilities. Large Language Models can employ the Transformer architecture or its variants (such as GPT, BERT, etc.). This architecture utilizes an attention mechanism to achieve global modeling of sequential data, efficiently handling long-distance dependencies and thus performing excellently in natural language tasks. Large Language Models can be used to perform various tasks such as text generation, language translation, text summarization, and question answering reasoning.

[0134] In some embodiments, large language models can also have the ability to understand and generate data from other modalities (such as visual, audio, etc.). In this case, large language models can also be called multimodal large language models (MLLMs). MLLMs provide a richer and more natural interactive experience by integrating multiple types of input and output, such as text, images, and sound.

[0135] It should be noted that the key technologies of large language models can be found in the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v18, published on March 8, 2026), and will not be repeated here.

[0136] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform... Figure 2 Or the method described in 3.

[0137] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement... Figure 2 or Figure 3 The method described.

[0138] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium.

[0139] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for constructing a knowledge base, comprising: Multiple text blocks arranged in order based on the first text are formed into a text block sequence; After initializing the current text block as the first text block in the text block sequence, perform multiple rounds of iterative processing to obtain multiple knowledge fragments; Each iteration process includes: Determine whether the current text block meets the preset conditions; the preset conditions include: the prediction score of the large model for the semantic terminator following the current text block is greater than the preset score threshold; If the condition is not met, the current text block is updated to the result of merging adjacent unprocessed text blocks in the text block sequence, and the judgment is performed again. If the conditions are met, the current text block is treated as a knowledge fragment, and the current text block is updated to the adjacent unprocessed text block in the text block sequence for use in the next round of iteration. The aforementioned knowledge fragments are stored in a knowledge base.

2. The method according to claim 1, wherein, The preset conditions also include that the length of the current text block is greater than a preset length threshold.

3. The method according to claim 1, wherein, Before determining the order of multiple text blocks based on the first text, the method further includes: Based on the chapter titles in the original document, the original document is divided into multiple chapter blocks; Each chapter block is used as the first text.

4. The method according to claim 1 or 3, wherein, Multiple text blocks arranged in order based on the first text include: The first text is divided into multiple continuous and partially overlapping text blocks by sliding window segmentation according to the preset sliding window size and overlap length.

5. The method according to claim 1, wherein, The multiple knowledge fragments are stored in a knowledge base, including: Determine the vector representation corresponding to each knowledge segment; Based on the vector representation, clustering is performed on the knowledge fragments to obtain multiple clusters; Generate a summary text for each cluster, and use the summary text as the parent node and the knowledge fragments in that cluster as the corresponding child nodes; Iteratively execute the clustering process and generate parent nodes to build a tree-like knowledge structure containing multi-level nodes from bottom to top; The node identifier, corresponding original text, and hierarchical metadata of the nodes in the tree-shaped knowledge structure are stored in the knowledge base.

6. The method according to claim 5, wherein, The knowledge base includes a text retrieval sub-base and a vector retrieval sub-base; The process of storing the node identifier, corresponding original text, and hierarchical metadata of the nodes in the tree-shaped knowledge structure into the knowledge base includes: storing the node identifier, corresponding original text content, and hierarchical metadata into the text retrieval sub-base; The method further includes storing the node identifier, the corresponding node vector, and the hierarchical metadata of the nodes in the tree-shaped knowledge structure into a vector retrieval sub-library, wherein the node vector is obtained by encoding the original text corresponding to the node.

7. A knowledge base retrieval method, comprising: Receive query text input by the user; The query text is used to retrieve several knowledge fragments from a knowledge base; wherein the knowledge base is constructed based on the method described in claim 1.

8. The method according to claim 7, wherein, The knowledge fragments in the knowledge base are organized into a tree-shaped knowledge structure, where the leaf nodes are knowledge fragments and the non-leaf nodes are summary texts of the knowledge fragments. The knowledge base includes a text retrieval sub-base and a vector retrieval sub-base. Both the text retrieval sub-base and the vector retrieval sub-base store the node identifiers and hierarchical metadata of the nodes in the tree-shaped knowledge structure. The text retrieval sub-base also stores the original text of the nodes, and the vector retrieval sub-base also stores the vector representation of the nodes. The step of retrieving several knowledge fragments from the knowledge base using the query text includes: The query text is used to search the text retrieval sub-library and the vector retrieval sub-library respectively to obtain several hit nodes; For each hit node, if the hit node is a leaf node, the original text corresponding to the node is obtained and included in the candidate knowledge fragment set; if the hit node is a non-leaf node, all descendant leaf nodes under the hit node are determined based on the hierarchical metadata, the original text corresponding to the descendant leaf nodes is obtained and included in the candidate knowledge fragment set. Select several knowledge fragments from the set of candidate knowledge fragments.

9. The method according to claim 8, wherein, Selecting the plurality of knowledge fragments from the candidate knowledge fragment set includes: For each candidate knowledge fragment in the candidate knowledge fragment set, determine its first ranking in the vector retrieval results and calculate a first sub-score that is negatively correlated with the first ranking; and determine its second ranking in the text retrieval results and calculate a second sub-score that is negatively correlated with the second ranking. The first sub-score and the second sub-score are weighted and summed to obtain the comprehensive score of the candidate knowledge segment; Based on the comprehensive score, the candidate knowledge fragment set is sorted in descending order, and the top K candidate knowledge fragments are selected as the recall results.

10. The method according to claim 7, wherein, The method further includes: The query text and the recalled knowledge fragments are input into a large model to obtain the generated answer content, which is then fed back to the user.

11. A knowledge base construction apparatus, comprising: The sequence construction module is configured to form a sequence of text blocks by arranging multiple text blocks in a predetermined order based on the first text. The iterative processing module is configured to initialize the current text block as the first text block in the text block sequence, and then perform multiple rounds of iterative processing to obtain multiple knowledge fragments. Each round of iterative processing is implemented through the following functional units: The judgment unit is configured to judge whether the current text block meets the preset conditions; the preset conditions include: the prediction score of the large model for the semantic terminator following the current text block is greater than the preset score threshold. The first branch unit is configured to update the current text block to the result of merging adjacent unprocessed text blocks in the text block sequence if it is determined that the condition is not met, and then execute the determination again. The second branch unit is configured to, if it is determined that the condition is met, treat the current text block as a knowledge fragment and update the current text block to the adjacent unprocessed text block in the text block sequence for the next round of iteration processing; The storage module is configured to store the multiple knowledge fragments into a knowledge base.

12. A knowledge base retrieval device, comprising: The query receiving module is configured to receive query text input by the user. The recall module is configured to recall several knowledge fragments from a knowledge base using the query text; wherein the knowledge base is constructed based on the apparatus of claim 11.

13. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed in the computer, it causes the computer to perform the method according to any one of claims 1-10.

14. A computing device comprising a memory and a processor, wherein, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-10.