A method and system for constructing a question and answer knowledge base of a large language model

CN122693789APending Publication Date: 2026-09-04CHINA UNITED NETWORK COMM GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610554718.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-24
Publication Date
2026-09-04

AI Technical Summary

Technical Problem

[0004]但是,LLM仅按固定提示词一次性抽取固定的头-关系-尾数据存储到知识库中,知识库中数据无法随领域变化扩展实体/关系类型,图谱元素来源不明,相对孤立,无法进行整体性的关联分析,导致问答系统在依赖当前知识库回答宏观性问题等时精准度不高

Benefits of technology

[0016]This embodiment addresses the inherent limitations of traditional large language models' fixed extraction paradigms through specific processes such as atomic text splitting, dynamic extraction constrained by predefined knowledge graph patterns, subgraph set generation, and global fusion. The predefined knowledge graph patterns can flexibly adapt to domain changes to expand entity and relation types. Atomic fragment processing improves the accuracy of triple extraction. The structure combining subgraphs and the overall graph ensures that graph elements are no longer isolated, enabling global correlation analysis. This enhances the automated construction capability, domain adaptability, and scalability of the question-answering knowledge base, ultimately significantly improving the accuracy of knowledge retrieval and answering in macro-level question scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122693789A_ABST
    Figure CN122693789A_ABST
Patent Text Reader

Abstract

The embodiment of the application aims to provide a method and system for constructing a question and answer knowledge base of a large language model, wherein the method comprises: dividing text data used for constructing the question and answer knowledge base into a plurality of atomic segments; based on the atomic segments and a predefined knowledge graph pattern, constructing a target prompt word and inputting the large language model; the target prompt word is used to instruct the large language model to identify an entity, a relationship and an attribute triple that conforms to the predefined knowledge graph pattern from the atomic segments; obtaining the triple output by the large language model, collecting the triples derived from the same text data, and generating a knowledge base subgraph; fusing each knowledge base subgraph to obtain a knowledge base total graph; and based on each knowledge base subgraph and the knowledge base total graph, constructing the question and answer knowledge base in a hierarchical manner. The scheme can improve the accuracy of retrieving graph knowledge and the accuracy of answering when the question and answer system answers macroscopic problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of front-end testing technology, and in particular to a method and system for constructing a question-answering knowledge base based on a large language model. Background Technology

[0002] With the popularization of the internet and the rapid development of information technology, people's demand for quick and accurate information acquisition is increasing. How to transform these scattered, redundant, and heterogeneous document knowledge into computable, reasonable, and visualizeable knowledge assets has become a core challenge that urgently needs to be overcome in the fields of information retrieval and natural language processing. Existing RAG technologies largely rely on keyword matching or simple semantic understanding, making it difficult to accurately grasp the deeper meaning of questions and the complex relationships between knowledge points, resulting in inaccurate and incomplete answers. Therefore, transforming knowledge base corpora into knowledge graphs has become an important means to improve the semantic understanding and interpretability of RAG systems.

[0003] In recent years, Large Language Models (LLMs) have been rapidly introduced into the graph construction process due to their powerful natural language understanding and generation capabilities, forming the mainstream paradigm of LLM extraction - manual / rule verification - graph data storage - retrieval applied to question answering, which has significantly improved the accuracy and automation of graph structure generation.

[0004] However, LLM only extracts fixed head-relationship-tail data into the knowledge base once based on fixed prompts. The data in the knowledge base cannot expand the entity / relationship types as the domain changes. The source of graph elements is unclear, they are relatively isolated, and holistic association analysis cannot be performed. As a result, the question answering system is not accurate when answering macro-level questions based on the current knowledge base. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for constructing a question-answering knowledge base based on a large language model. Through atomic text processing, structured knowledge extraction and fusion, a question-answering knowledge base with both local accuracy and global relevance is constructed, thereby improving the accuracy of the question-answering system in retrieving knowledge graphs and answering macro-level questions.

[0006] To address the above problems, embodiments of the present invention provide a method for constructing a question-answering knowledge base based on a large language model, the method comprising: The text data used to construct the question-answering knowledge base is divided into multiple atomic fragments. Based on the atomic fragments and predefined knowledge graph patterns, target prompt words are constructed and input into a large language model. The target prompt words are used to instruct the large language model to identify entity, relation, and attribute triples that conform to the predefined knowledge graph patterns from the atomic fragments. The triples output by the large language model are obtained, and triples from the same text data are aggregated to generate a knowledge base subgraph. The knowledge base subgraphs are then merged to obtain a general knowledge base graph. The question-answering knowledge base is constructed hierarchically based on the knowledge base subgraphs and the general knowledge base graph.

[0007] In addition, as described above, dividing the text data used to construct the question-and-answer knowledge base into multiple atomic fragments includes: receiving raw data from multiple data sources and setting a unique identifier for each raw data; extracting text from each raw data as the text data; cleaning the text data and then dividing it into multiple atomic fragments; assigning a unique code to each atomic fragment; and binding the unique code and the unique identifier corresponding to the raw data to which the atomic fragment belongs as metadata to the atomic fragment.

[0008] In addition, as described above, the triples originating from the same text data are processed together to generate a knowledge base subgraph, including: determining the unique identifier corresponding to the triple based on the metadata of the atomic fragments corresponding to the triple; aligning all triples belonging to the same unique identifier, merging and deduplicating them to obtain the knowledge base subgraph.

[0009] In addition, the above-described fusion process of the knowledge base subgraphs to obtain the overall knowledge base graph includes: performing entity disambiguation and normalization on the entities in each knowledge base subgraph to obtain a preliminary fusion result; and performing connectivity and consistency checks on the preliminary fusion result to obtain the overall knowledge base graph that passes the checks.

[0010] In addition, after obtaining the knowledge base graph, the method described above further includes: converting the attribute description text of each entity in the knowledge base graph into a feature vector through a pre-trained word vector model to calculate the semantic similarity between any two entities; if the semantic similarity between any two entities is greater than a threshold, generating a virtual edge between the two entities and using the semantic similarity as an additional weight for the virtual edge; fusing the virtual edge and the additional weight into the knowledge base graph to obtain an updated graph; and using a community detection algorithm to perform community partitioning on the updated graph to obtain community partitioning results.

[0011] In addition, as described above, the attribute description text of each entity in the knowledge base graph is transformed into a feature vector through a pre-trained word vector model to calculate the semantic similarity between any two entities; if the semantic similarity between any two entities is greater than a threshold, a virtual edge is generated between the two entities, and the semantic similarity is used as an additional weight of the virtual edge; the virtual edge and the additional weight are fused into the knowledge base graph to obtain an updated graph; a community detection algorithm is used to perform community partitioning on the updated graph to obtain the community partitioning result.

[0012] In addition, as described above, the question-answering knowledge base is constructed hierarchically based on each knowledge base subgraph and the knowledge base master graph, including: systematically storing each knowledge base subgraph, the knowledge base master graph, the community division results, and the community depth report to construct the question-answering knowledge base.

[0013] This invention also proposes a question-answering knowledge base construction system based on a large language model, comprising: a data extraction module, used to divide text data for constructing the question-answering knowledge base into multiple atomic fragments, and construct target prompt words based on the atomic fragments and a predefined knowledge graph pattern, and input them into the large language model; wherein, the target prompt words are used to instruct the large language model to identify entity, relation, and attribute triples that conform to the predefined knowledge graph pattern from the atomic fragments; a subgraph generation module, used to obtain the triples output by the large language model, and perform set processing on the triples from the same text data to generate knowledge base subgraphs; a master graph fusion module, used to fuse the knowledge base subgraphs to obtain a master knowledge base graph; and a knowledge base injection module, used to construct the question-answering knowledge base based on the knowledge base subgraphs and the master knowledge base graph.

[0014] This invention also proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the question-answering knowledge base construction method for a large language model as described above.

[0015] This invention also proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the question-answering knowledge base construction method for a large language model as described above.

[0016] This embodiment addresses the inherent limitations of traditional large language models' fixed extraction paradigms through specific processes such as atomic text splitting, dynamic extraction constrained by predefined knowledge graph patterns, subgraph set generation, and global fusion. The predefined knowledge graph patterns can flexibly adapt to domain changes to expand entity and relation types. Atomic fragment processing improves the accuracy of triple extraction. The structure combining subgraphs and the overall graph ensures that graph elements are no longer isolated, enabling global correlation analysis. This enhances the automated construction capability, domain adaptability, and scalability of the question-answering knowledge base, ultimately significantly improving the accuracy of knowledge retrieval and answering in macro-level question scenarios. Attached Figure Description

[0017] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0018] Figure 1 This is a flowchart illustrating the specific process of constructing a question-answering knowledge base for a large language model according to the first embodiment of the present invention. Figure 2 This is a specific flowchart of step 101 involved in the second embodiment of the present invention; Figure 3 This is a specific flowchart of step 102 in the third embodiment of the present invention; Figure 4 This is a flowchart illustrating the specific process of constructing a question-answering knowledge base for a large language model according to the fourth embodiment of the present invention. Figure 5 This is a schematic diagram of the structure of the question-answering knowledge base construction system of the large language model involved in the fifth embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of the electronic device according to the sixth embodiment of the present invention. Detailed Implementation

[0019] To enable those skilled in the art to better understand the technical solutions of this disclosure, and to fully understand and implement the process of how this disclosure applies technical means to solve technical problems and achieve corresponding technical effects, the technical solutions in 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, not all embodiments. The embodiments of this disclosure and the various features within them can be combined with each other without conflict, and the resulting technical solutions are all within the protection scope of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort should fall within the protection scope of this disclosure.

[0020] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0021] The first embodiment of this invention relates to a method for constructing a question-answering knowledge base based on a large language model, which is applied to a question-answering knowledge base construction system based on a large language model, such as... Figure 1 As shown, the method in this embodiment specifically includes the following steps 101-104: Step 101: Divide the text data used to build the question-answering knowledge base into multiple atomic fragments. Based on the atomic fragments and predefined knowledge graph patterns, construct target prompt words and input them into the large language model. Among them, the target prompt words are used to instruct the large language model to identify entity, relation and attribute triples that conform to the predefined knowledge graph pattern from atomic fragments.

[0022] Specifically, the process begins by acquiring a series of text data for constructing the question-and-answer knowledge base. This text data is tagged and divided based on factors such as file independence and data integrity. For example, a Word document can be considered an independent piece of text data, obtained from sources such as user input or external databases; this embodiment does not impose such limitations. After acquiring the text data, each piece of text data is divided into multiple atomic fragments. In this embodiment, an atomic fragment is the smallest semantically complete and independent text unit obtained after semantically decomposing the original text data. Specifically, it can be represented as a single sentence, a semantically simple phrase, or an independent knowledge statement paragraph. Atomizing and splitting the text data reduces the semantic complexity of long texts in the original text data, thereby avoiding LLM extraction errors caused by multiple entities and relationships, and improving the targeting of the extraction.

[0023] Target prompts are constructed by combining multiple atomic fragments derived from text data with a predefined knowledge graph schema. The knowledge graph schema is a customized knowledge structure framework designed for the target domain, containing core entity types (e.g., "enterprise," "product," "transaction" in finance), relationship types (e.g., "investment," "cooperation," "association" in finance), and attribute requirements (e.g., entity characteristics and relationship constraints). The knowledge graph schema provides domain constraints and guidance for LLM extraction, thereby avoiding meaningless extraction and ensuring the standardization of extraction results.

[0024] In the construction of target prompts, this embodiment combines the semantic features of atomic fragments with the constraint rules of knowledge graph patterns. Following the design of target prompts that include extraction instructions, pattern definitions, and extraction format specifications, the LLM extracts knowledge elements conforming to the knowledge graph schema through the guidance of these prompts. In practical applications, a templated prompt design can be adopted, structurally embedding entity types, relation types, attribute constraints, and other content from the predefined knowledge graph schema into the prompt template. Simultaneously, domain-theme annotations are applied to atomic fragments to help the LLM quickly locate the key extraction points, instructing it to identify entity, relation, and attribute triples conforming to the predefined knowledge graph pattern from the input atomic fragments. Here, the triple is the core representation unit of the knowledge graph, containing three types of elements: entity, relation, and attribute. Specifically, it can be divided into entity-entity-relationship triples (e.g., ["Zhang San", "Li Si", "colleague"]) and entity-attribute triples (e.g., ["Zhang San", "age", "30 years old"]). This embodiment does not impose specific restrictions on the form of the triples output by the large model.

[0025] Step 102: Obtain the triples output by the large language model, process the triples from the same text data to generate a knowledge base subgraph, and merge the knowledge base subgraphs to obtain the overall knowledge base graph.

[0026] Specifically, after the LLM completes the triple output, this step performs centralized processing on the output results. All triples originating from the same text data are aggregated and integrated. Specific operations for this aggregation process include: deduplication, entity alignment, relation normalization, and semantic association binding of scattered triples belonging to the same text data, eliminating redundancy and representational differences within the same text. Specifically, semantic similarity calculation and domain thesaurus matching are used to normalize synonymous entities and relations. Duplicate triples are removed using hash matching. The normalized triples are then constructed into knowledge base subgraphs with entities as nodes, relations as edges, attributes as edges, or node features. Each knowledge base subgraph corresponds to a complete structured knowledge unit of a single original text data.

[0027] After obtaining the independent knowledge base subgraphs, a further fusion process is performed on the multiple subgraphs. This fusion process aims to overcome the boundary limitations of a single text subgraph and achieve knowledge connectivity between multiple subgraphs based on global entity alignment, relational association, and attribute complementarity rules, thus solving the problem of isolated and unrelated elements in traditional graphs. Specifically, the fusion process involves constructing a global entity index to merge nodes of entities that refer to common entities across subgraphs, validating and retaining legitimate cross-subgraph relationships according to a predefined knowledge graph pattern, and preserving the original attribution information of each subgraph. Finally, the fusion forms a comprehensive knowledge base graph covering all original text data and possessing global knowledge association capabilities. This comprehensive graph enables holistic knowledge association analysis, thereby providing data support for answering macro-level questions.

[0028] Step 103: Construct a question-and-answer knowledge base hierarchically based on each knowledge base subgraph and the overall knowledge base graph.

[0029] Specifically, the final question-answering knowledge base is constructed based on the individual knowledge base subgraphs and the globally integrated knowledge base master graph. A hierarchical knowledge architecture can be adopted during construction, using the knowledge base subgraphs as precise retrieval units and the knowledge base master graph as macro-level associative reasoning units. These two complement each other and synchronously meet the needs of local knowledge retrieval and global knowledge analysis. For example, entity-level fine-grained indexes are established for the knowledge base subgraphs to support rapid knowledge matching for specific questions, while global associative path indexes and reasoning rules are established for the knowledge base master graph to achieve macro-level question-related retrieval and analysis across texts and knowledge points. Simultaneously, information such as triple source, subgraph affiliation, and associative paths are embedded into the knowledge base to achieve the hierarchical construction of the final question-answering knowledge base.

[0030] Compared with related technologies, this embodiment solves the inherent defects of the fixed extraction paradigm of traditional large language models by implementing specific processes such as atomic text splitting, dynamic extraction constrained by predefined knowledge graph patterns, subgraph set generation, and global fusion. The predefined knowledge graph patterns can flexibly adapt to domain changes to expand entity and relation types. Atomic fragment processing improves the accuracy of triple extraction. The structure combining subgraphs and the overall graph makes graph elements no longer isolated and has global association analysis capabilities. This enhances the automated construction capability, domain adaptability, and scalability of the question-answering knowledge base, and ultimately significantly improves the accuracy of knowledge retrieval and answering in macro-level question scenarios.

[0031] The second embodiment of this invention relates to a method for constructing a question-answering knowledge base based on a large language model. This embodiment supplements the foregoing embodiments, specifically by refining step 101, which involves dividing the text data used to construct the question-answering knowledge base into multiple atomic fragments. Figure 2 As shown, the specific steps include 201-203.

[0032] Step 201: Receive raw data from multiple data sources and set a unique identifier for each raw data.

[0033] Specifically, the various data sources in this embodiment cover all types of information carriers required for building a question-and-answer knowledge base, including but not limited to publicly available domain literature, structured text in databases, publicly available online data, and user-generated text. This embodiment does not impose specific restrictions on the data sources. A unique identifier is assigned to each piece of raw data. This unique identifier is a globally unique identification code assigned to each piece of raw data as its exclusive identity, providing an indexing basis for the subsequent association of atomic fragments, triples, subgraphs, and raw data. The unique identifier can be generated using a random encoding sequence or a data source type prefix superimposed with a timestamp. This embodiment does not impose specific restrictions on the generation rules of the unique identifier.

[0034] Step 202: Extract the text from each original data as text data, perform data cleaning on the text data, and then divide it into multiple atomic fragments.

[0035] Specifically, text recognition can be used to extract text from the original data as text data, which is then cleaned. The purpose of data cleaning is to remove noise and invalid content from the text data, ensuring that the text input to subsequent processing stages has semantic integrity and is standardized and effective. Cleaning operations can include: for redundant information in the text, using duplicate content detection algorithms, such as cosine similarity-based text deduplication, to remove duplicate paragraphs or sentences; for formatting noise, using regular expression matching to remove special symbols, garbled characters, meaningless spaces, etc.; for semantically invalid content, using a domain dictionary to filter out generic words, modal particles, and meaningless statements unrelated to the target domain; and for grammatical errors and non-standard expressions, using a grammar correction model from natural language processing to optimize the text. After cleaning, atomic fragment segmentation is performed. Specifically, the segmentation can be achieved by: integrating syntactic analysis and semantic boundary recognition technologies, using punctuation marks as the basis for segmentation nodes, and combining dependency parsing to identify the semantic core components and modifying components within the sentence. For long complex sentences, independent semantic units are split off as atomic fragments based on the subject-verb-object structure. For paragraphs containing multiple factual statements, short sentences expressing the same topic are aggregated into an atomic fragment based on semantic similarity clustering algorithms, while ensuring that the aggregated fragments still meet the requirement of semantic unity. Segmentation methods are selected as needed to complete the segmentation of multiple atomic fragments.

[0036] Step 203: Assign a unique code to each atomic fragment, and bind the unique code and the unique identifier corresponding to the original data to which the atomic fragment belongs as metadata to the atomic fragment.

[0037] Specifically, a unique code is a unique identifier assigned to each atomic fragment. The unique code and the unique identifier corresponding to the original data to which the atomic fragment belongs are bound to the atomic fragment as metadata. In this embodiment, metadata refers to data used to describe the basic attributes and source information of the atomic fragment, which includes at least the unique code of the atomic fragment and the unique identifier of the original data. It may also include relevant information such as the atomic fragment segmentation time and text length; this embodiment does not impose specific limitations on this. To facilitate subsequent querying, a metadata index can be established, supporting quick queries of corresponding atomic fragments and related information using keywords such as code and original data identifier.

[0038] In one example, step 102 involves set processing of triples from the same text data to generate a knowledge base subgraph, including: Based on the metadata of the atomic fragments corresponding to the triples, determine the unique identifier corresponding to the triples; Align all triples belonging to the same unique identifier, merge and remove duplicates to obtain the knowledge base subgraph.

[0039] Specifically, since each atomic fragment has been bound with metadata containing a unique identifier of the original data in step 203, the atomic fragment from which it was extracted can be inversely associated through the triple. Furthermore, the metadata of the atomic fragment can be used to locate the corresponding unique identifier of the original data, and the unique identifier can be used to confirm whether the triple belongs to the same text data. In practical applications, when the large language model outputs triples, the unique code of the atomic fragment from which the triple originates can be recorded simultaneously, constructing a mapping table of "triple-atomic fragment code". Then, the unique code of the atomic fragment can be used to quickly query the corresponding unique identifier of the original data, and this unique identifier can be used as the attribution label to the corresponding triple. For the same triple generated from multiple atomic fragments, its attribution label is still based on the unique identifier of the original data to which the atomic fragment belongs.

[0040] Because entities within the same original text may have aliases, abbreviations, synonyms, or inconsistent expressions, such as "artificial intelligence" and "AI," to avoid the same entity being misjudged as multiple independent nodes due to inconsistent expressions, thus disrupting the semantic coherence and knowledge integrity of the subgraph, this embodiment aligns all triples belonging to the same unique identifier, merges them, and removes duplicates to obtain the knowledge base subgraph. Entity alignment refers to the process of uniformly standardizing entities with different names but the same or highly related semantics within a set of triples under the same original data. In practical applications, the specific process can be as follows: An entity alignment rule base is constructed using a domain-specific thesaurus and a semantic similarity calculation model. For entities appearing in the text, initial alignment is performed using regular expression matching with the thesaurus. Then, a pre-trained language model is used to convert entities into semantic embedding vectors, and vector similarity is calculated. Entities with similarity higher than a threshold are determined to be the same entity and assigned a unified standard name. For the conversion between entity abbreviations and full names, alignment can be performed using preset mapping relationships in the domain rule base. In the merging and deduplication process, the aligned triples are first subjected to structured hash verification. The standard representations of the head entity, relation, and tail entity are combined into hash keys, and completely duplicate triples are quickly eliminated through hash comparison. Next, for semantically duplicated triples, relation normalization is performed based on the relation type specifications in the predefined knowledge graph schema, and the triples are merged into unified triples. Finally, the aligned and deduplicated triples are constructed according to the knowledge graph storage specifications, using entities as nodes, relations as directed edges, and attributes as additional features of nodes / edges, to form a knowledge base subgraph. This knowledge base subgraph fully reflects the structured knowledge of the original data pointed to by the corresponding unique identifier.

[0041] Compared with related technologies, this embodiment improves the manageability of atomic fragments through a data processing flow of multi-source data unique identifier allocation, text cleaning, fine segmentation of atomic fragments, and metadata binding. It achieves the collection of triples through metadata tracing, and then completes the integration of triples through entity alignment and deduplication. The generated knowledge base subgraph has unified semantics and maintains its association with the original data, ensuring the independence and integrity of the subgraph as a local knowledge unit, and providing a reliable knowledge foundation for subsequent micro-level problem retrieval.

[0042] The third embodiment of this invention relates to a method for constructing a question-answering knowledge base using a large language model. This embodiment supplements the foregoing embodiments, specifically by providing a more detailed explanation of the process in step 102 of merging the various knowledge base subgraphs to obtain the overall knowledge base graph. Figure 3 As shown, the specific steps include 301-302.

[0043] Step 301: Perform entity disambiguation and normalization on the entities in each knowledge base subgraph to obtain preliminary fusion results.

[0044] Specifically, in this embodiment, entity disambiguation refers to identifying and distinguishing entities with the same name but different semantics across subgraphs, while entity normalization unifies entities with the same semantics but different names across subgraphs into a standard representation. Its implementation principle is consistent with the entity alignment in the aforementioned embodiments, but its application scope is extended to all subgraphs. The specific implementation method is as follows: A global entity information database is constructed, integrating entities and their entity attributes, relationships, source metadata, and other information from all knowledge base subgraphs. In the entity disambiguation stage, a multi-dimensional judgment method combining attribute features and semantic context can be used. A pre-trained language model is used to convert entities and their associated attributes and relationships into semantic embedding vectors. The vector distance between entities with the same name in different subgraphs is calculated. Combined with entity attribute features, entities whose vector distance exceeds a set threshold and whose attributes conflict are judged as different semantic entities, and assigned different globally unique entity IDs for distinction. In the entity normalization stage, the same entity alignment logic as in the aforementioned embodiments is used and extended globally, which will not be elaborated further in this embodiment. Through entity disambiguation and normalization processing, entities in each subgraph are unified into globally unique, semantically clear standard entities, forming a preliminary fused knowledge network.

[0045] Step 302: Perform connectivity and consistency checks on the preliminary fusion results to obtain the overall knowledge base graph that passes the checks.

[0046] Specifically, after obtaining the preliminary fusion results, a connectivity and consistency check is performed on the preliminary fusion results, i.e., the preliminary fused knowledge network. During the connectivity check, a graph traversal algorithm can be used to perform a global traversal of the preliminary fused knowledge network, identifying all connected components (i.e., interconnected entity clusters), and counting the number of isolated connected components and the types and origins of the entities they contain. For isolated entities that are indeed unrelated due to domain characteristics, their independent connected components are retained and labeled with domain tags. For entity clusters that should have connections but have not been established, relationship completion is triggered through predefined relation rules in the knowledge graph pattern, retrieving and verifying potential relationship paths between related entities, and completing legitimate relationships to improve network connectivity. The consistency check process is divided into relation consistency checks and attribute consistency checks. Relationship consistency checks, based on predefined knowledge graph schema rules, verify whether the relationships between entities conform to domain knowledge logic, marking and removing illegal relationships. Attribute consistency checks examine multiple attribute values ​​for the same global entity to check for logical conflicts. For example, if the "age" of the same entity is both "30 years old" and "50 years old," conflicting attribute values ​​are prioritized based on factors such as the credibility weight of the source metadata and the frequency of data occurrence. The attribute value with the highest credibility is retained, while conflicting attribute values ​​that cannot be determined are marked as "to be verified" and associated with source subgraph information for subsequent manual review. After connectivity and consistency checks, as well as subsequent conflict handling and association completion, a well-structured and semantically unified knowledge base graph is finally formed.

[0047] Compared with related technologies, this embodiment effectively integrates the subgraphs of each knowledge base through entity disambiguation and normalization, and ensures the integrity and logical accuracy of the global knowledge association through connectivity and consistency checks. The constructed knowledge base master graph not only integrates the structured knowledge of all original texts, but also has the ability to perform global association analysis. It effectively solves the defects of traditional methods in that the graph elements are isolated and cannot be analyzed in an overall manner, and provides reliable global knowledge support for question answering systems when dealing with macro-level questions.

[0048] The fourth embodiment of this invention relates to a method for constructing a question-answering knowledge base using a large language model. This embodiment is a supplement to the foregoing embodiments, such as... Figure 4 As shown, the method in this embodiment specifically includes the following steps 401-404: Step 401: Convert the attribute description text of each entity in the knowledge base graph into feature vectors through a pre-trained word vector model to calculate the semantic similarity between any two entities.

[0049] In this context, attribute description text refers to the text content corresponding to various attribute information bound to entities in the knowledge base graph. This includes both basic feature descriptions of the entities and descriptions of their associated attributes. Pre-trained word vector models refer to models trained on large-scale text data that can map natural language text into low-dimensional dense vectors. Specific models such as Word2Vec and BERT can be used, but this embodiment does not impose specific limitations on them.

[0050] Specifically, before vectorizing the attribute description text of each entity, the attribute description text of the entity is preprocessed, including word segmentation, removal of domain-irrelevant stop words, and filtering of special characters, to obtain standardized attribute text fragments; then the preprocessed attribute text is input into a pre-trained word vector model, and the cosine similarity algorithm is used to calculate the semantic similarity between any two entities, to obtain a similarity value in the range of [0,1]. The closer the value is to 1, the more similar the semantic relationship between the two entities is.

[0051] Step 402: If the semantic similarity between any two entities is greater than the threshold, then generate a virtual edge between the two entities and use the semantic similarity as an additional weight for the virtual edge.

[0052] Specifically, in this embodiment, a virtual edge refers to a graph structure element constructed based on implicit semantic relationships between entities, distinct from the original relational edges in the knowledge base graph. It makes explicit the implicit relationships obtained through semantic similarity calculation, establishing structured relationships between entities that originally had no direct explicit relationship but were semantically highly related, thereby enriching the relational dimensions of the knowledge base graph. For any two entities, if the semantic similarity calculation result is greater than a set threshold, it is determined that there is a valuable implicit semantic relationship between them, and a virtual edge is generated connecting the two entities. The calculated semantic similarity value is used as the additional weight of the virtual edge, and the weight value directly reflects the strength of the implicit relationship between entities. Furthermore, a unique edge type identifier can be assigned to the virtual edge to distinguish it from the type identifiers of the original relational edges.

[0053] Step 403: Integrate the virtual edges and additional weights into the knowledge base graph to obtain the updated graph.

[0054] Specifically, the virtual edges and the additional weights are integrated into the overall knowledge base graph to obtain an updated overall graph. While preserving the original structural relationships of the overall knowledge base graph, new virtual edges corresponding to implicit semantic associations are added, forming a two-layer association network, which improves the connectivity and semantic coverage of the graph. Specifically, an incremental update mechanism of a graph database can be used, writing the generated virtual edges and additional weights as new data into the overall knowledge base graph. During the writing process, the consistency of association between the virtual edges and the original nodes (entities) is ensured, that is, the two endpoints of the virtual edges accurately correspond to the target entities in the overall knowledge base graph.

[0055] It should be noted that a basic weight can be assigned to the edges in the original structural relationship of the knowledge base graph in advance. If the virtual edge coincides with the edge entity edge in the original structural relationship, the two can be merged into a new weight, for example, new weight = α × basic weight + (1-α) × additional weight (α is a coefficient).

[0056] After data fusion, the updated master graph is verified for completeness. This involves checking for issues such as incorrect node associations or missing weights in the virtual edges to ensure that the updated master graph structure is complete and the data is accurate. This results in a knowledge network that combines logical and implicit semantic relationships as the updated master graph.

[0057] Step 404: Use the community detection algorithm to divide the updated overall graph into communities and obtain the community division results.

[0058] Among them, a community refers to a cluster of entities in the updated master graph that are semantically closely related and formed around a specific theme. Entities within the same community form dense connections through explicit structural relationships or implicit virtual edges in the original knowledge base master graph, while the connections between different communities are relatively sparse.

[0059] Specifically, when dividing communities, a suitable community discovery algorithm can be selected based on the structural characteristics of the updated overall graph. For example, if the overall graph is large and the relationships are complex, the Louvain algorithm can be used. If more accurate community boundary division is required, a splitting algorithm based on edge betweenness or an unsupervised algorithm based on label propagation can be used. During algorithm execution, the additional weight of virtual edges is incorporated into the association strength calculation. That is, the basis for community division includes not only the explicit relational connections between entities but also the strength of implicit semantic associations, ensuring that the divided communities can truly reflect the comprehensive degree of association between entities. For each community, the core entities and topic keywords within the community are automatically extracted. At the same time, information such as the entity composition, internal association density, and association paths with other communities in each community are recorded to form a structured description of the community division results.

[0060] In one example, the method of this embodiment further includes: The corresponding local map is determined based on the community division results; The pre-defined large model agent performs deep reasoning based on the current structural connections of each local graph; deep reasoning includes at least multi-hop potential relationship mining and semantic link completion. The inference results output by the large model agent are used as community in-depth reports.

[0061] Specifically, after obtaining the community division results, the entity set and edge set (including explicit edges and virtual edges) corresponding to each community are extracted. Using the partition query function of the graph database, the subgraph structure specific to each community is separated from the updated overall graph as a local graph. Furthermore, each local graph can be bound with a corresponding community identifier, theme keywords, and a list of core entities to form a structured description document of the local graph.

[0062] A large language model instance, pre-adapted with target domain knowledge and loaded with inference rule templates, serves as a large model agent. This agent possesses the ability to understand structured knowledge and perform logical reasoning, enabling multi-hop latent relationship mining and semantic link completion based on the current structural connections of each local graph. Multi-hop latent relationship mining is based on existing explicit relationship edges and virtual semantic edges in the local graph, traversing intermediate entities to uncover implicit logical connections between entities that are not directly presented. Specifically, the large model agent first rapidly traverses the local graph to find direct connection paths between entities (1-hop connections), then, based on the domain's inference rule base (e.g., if A and B have a causal relationship, and B and C have a causal relationship, then A and C may have an indirect causal relationship), gradually expanding to 2-hop, 3-hop, and higher-level connection paths. Semantic rationality is verified for each multi-hop path, combining entity attribute text and domain knowledge to determine if the path is logically sound; for multi-hop connections that pass verification, a structured record of the reasoning is generated.

[0063] Furthermore, the system identifies instances where entities in the local graph have logical connections but broken links. By reasoning, it fills in the missing intermediate entities or connecting edges to form a complete semantic link. Specifically, the large model agent first uses the topic keywords and domain knowledge of the local graph to sort out the core logical link template under that topic; it then traverses entity pairs in the local graph to identify combinations that conform to the template logic but have incomplete links; and by retrieving entity attribute text, associated metadata, and information from existing edges, it deduces the missing intermediate links and generates a complete semantic link record after completion.

[0064] Each local graph output by the large model agent corresponds to a community depth report. The report is written in a structured format, and its core content includes: basic community information (such as community identifier, topic keywords, core entity list, and local graph size); a multi-hop potential relationship set (each record includes a head entity, potential relationship type, tail entity, inference path, confidence level, and associated metadata; the confidence level can be calculated based on the explicit edge base weight and the additional weight of the virtual edge); and semantic link completion results (e.g., original broken links, completed links, and the basis for completion). This embodiment does not impose specific limitations on the actual content included in the community depth report.

[0065] In this embodiment, step 103 may further include the following: The question-and-answer knowledge base is constructed by systematically storing the subgraphs of each knowledge base, the overall knowledge base graph, the community division results, and the community depth report.

[0066] Specifically, this embodiment systematically stores the acquired knowledge base subgraphs, the overall knowledge base graph, community partitioning results, and community depth reports. Each knowledge base subgraph corresponds to structured knowledge within a single original text and serves as the micro-level foundational unit of the question-and-answer knowledge base, suitable for specific, single-point question queries. The overall knowledge base graph integrates explicit and implicit semantic relationships across all texts, serving as the core carrier of global knowledge association and suitable for macro-level, cross-text comprehensive question queries. The community partitioning results achieve thematic aggregation of knowledge, helping LLM quickly locate knowledge clusters in specific domains or topics. The community depth reports provide in-depth reasoning results of local knowledge, suitable for complex question queries requiring logical deduction and in-depth analysis. During systematic storage, the metadata of the knowledge base subgraphs is uniquely identified by the original data; the entity nodes of the knowledge base subgraphs and the overall knowledge base graph are linked by global entity IDs; and the entity clusters, community partitioning results, and community depth reports of the overall knowledge base graph are linked by community identifiers. Ultimately, a full-link traceable knowledge base is formed, consisting of "original data - subgraph - overall graph - community - depth report". It also supports incremental updates and full lifecycle maintenance of the knowledge base.

[0067] Compared with related technologies, the question-answering knowledge base constructed in this embodiment completely solves the defects of traditional question-answering knowledge bases, such as single knowledge dimension, chaotic storage, and broken associations, through a hierarchical and systematic storage design. The constructed question-answering knowledge base covers not only precise knowledge at the micro-text level and global cross-text related knowledge, but also clustered knowledge of topic aggregation and reasoning knowledge of deep logic. The four-level knowledge architecture complements each other, enhancing the practicality and scalability of the question-answering knowledge base, realizing accurate knowledge matching and efficient retrieval, and significantly improving the answer coverage, accuracy, and depth of the question-answering system.

[0068] The fifth embodiment of the present invention relates to a question-answering knowledge base construction system based on a large language model, such as... Figure 5 As shown, it includes: The data extraction module 501 is used to divide the text data used to build the question-answering knowledge base into multiple atomic fragments, and construct target prompt words based on the atomic fragments and predefined knowledge graph patterns and input them into the large language model. The target prompt words are used to instruct the large language model to identify entity, relation, and attribute triples that conform to the predefined knowledge graph pattern from the atomic fragments. The subgraph generation module 502 is used to obtain the triples output by the large language model, and to process the triples from the same text data to generate a knowledge base subgraph. The master map fusion module 503 is used to merge the various knowledge base subgraphs to obtain the knowledge base master map; The knowledge base injection module 504 is used to construct a question-and-answer knowledge base based on each knowledge base subgraph and the overall knowledge base graph.

[0069] In one example, the system in this embodiment also includes a community division module.

[0070] The community partitioning module is used to transform the attribute description text of each entity in the knowledge base graph into feature vectors through a pre-trained word vector model to calculate the semantic similarity between any two entities. If the semantic similarity between any two entities is greater than a threshold, a virtual edge is generated between the two entities, and the semantic similarity is used as an additional weight for the virtual edge. The virtual edge and the additional weight are fused into the knowledge base graph to obtain the updated graph. The community detection algorithm is used to partition the updated graph into communities to obtain the community partitioning results.

[0071] In one example, the system in this embodiment also includes a deep inference module.

[0072] The deep reasoning module is used to determine the corresponding local graph based on the community segmentation results; it drives the preset large model agent to perform deep reasoning based on the current structural connection relationship of each local graph; deep reasoning includes at least multi-hop potential relationship mining and semantic link completion; and the reasoning results output by the large model agent are used as a community depth report.

[0073] In summary, it is not difficult to see that this embodiment is a system embodiment corresponding to the aforementioned method embodiments. The implementation details described in the above method embodiments are still applicable and effective in this embodiment, and will not be repeated here.

[0074] To better understand this application, two specific application scenarios are used below to illustrate the protection claimed in this application.

[0075] Scenario 1: A company needs to integrate internal technical documents, industry research reports, and patent databases to build an enterprise technical intelligence knowledge base to support R&D personnel in quickly understanding the technological landscape.

[0076] The system receives PDF technical white papers, TXT patent abstracts, and project records from the database, parses and segments them into atomic fragments. Using a pre-defined "Technology Field" schema (entities such as technical terms, companies, researchers; relationships such as belonging to, developing, being the basis), it extracts triples from the fragments via an LLM-Agent, such as (Company A, developed, algorithm B), and records that this triple originates from the 5th atomic fragment of the "Technical White Paper.pdf". A corresponding sub-graph is generated for each technical white paper and each patent data table. All sub-graphs are merged, revealing that "deep learning" and "deep neural networks" from different reports point to the same technical concept, which is then normalized to form a unified overall enterprise technology graph.

[0077] Community segmentation of the overall graph successfully identified several major technology clusters, including "Natural Language Processing," "Computer Vision," and "Autonomous Driving." Due to the enhanced attribute clustering (introduction of semantic virtual edges), entities within the "Autonomous Driving" community were highly relevant to words like "vehicle," "perception," and "control" in their descriptive texts. Within individual communities, such as the "Natural Language Processing" community, LLM-Agent, through multi-hop reasoning, discovered that the rise of "pre-trained models" is a key indirect factor driving the performance improvement of "semantic similarity calculation" technology, and this insight was included in the community report.

[0078] All structured and deeply understood knowledge is stored in graph and document databases. When researchers ask, "How does the pre-trained model affect semantic similarity calculation?", the question-answering system can not only return direct relationships but also provide a more macro-level interpretation by referencing community reports.

[0079] Application Scenario 2: Build a medical and health knowledge base that covers diseases, symptoms, drugs, and treatment plans.

[0080] The system receives and parses medical textbooks, drug instructions, and clinical guidelines. Based on the medical schema, it extracts triples such as (disease D, symptom, fever) and (drug Y, treatment, disease D); constructs subgraphs and a unified overall medical knowledge graph; through community segmentation, it may automatically cluster communities such as "respiratory diseases" and "cardiovascular diseases"; within each community, such as the "cardiovascular disease" community, the LLM-Agent may infer a potential risk path (2-hop association) between a certain antihypertensive drug (drug A) and a certain arrhythmia (symptom Z) that requires metabolic influence through another drug (drug B), thus supplementing previously missing warning information; and stores all data. When a user queries "What precautions should be taken when taking drug A?", the system can provide more comprehensive advice based on the identified potential risks.

[0081] The sixth embodiment of the present invention relates to an electronic device, such as... Figure 6As shown, it includes at least one processor 602; and a memory 601 communicatively connected to at least one processor 602; wherein the memory 601 stores instructions executable by at least one processor 602, the instructions being executed by at least one processor 602 to enable at least one processor 602 to perform any of the above method embodiments.

[0082] The memory 601 and processor 602 are connected via a bus, which may include any number of interconnecting buses and bridges. The bus connects various circuits of one or more processors 602 and memory 601 together. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 602 is transmitted over a wireless medium via an antenna, which further receives data and transmits it to processor 602.

[0083] Processor 602 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 601 can be used to store data used by processor 602 during operation.

[0084] Another embodiment of the present invention relates to a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements any of the above-described method embodiments.

[0085] Another embodiment of the present invention relates to a computer program product, including computer instructions that, when executed by a processor, implement any of the above-described method embodiments.

[0086] That is, those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0087] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0088] While the embodiments disclosed herein are as described above, the foregoing content is merely for the purpose of facilitating understanding of this disclosure and is not intended to limit this disclosure. Any person skilled in the art to which this disclosure pertains may make any modifications and changes in form and detail of the implementation without departing from the spirit and scope disclosed herein; however, the scope of patent protection of this disclosure shall still be determined by the scope defined in the appended claims.

Claims

1. A method for constructing a question-answering knowledge base based on a large language model, characterized in that, include: The text data used to build the question-answering knowledge base is divided into multiple atomic fragments. Based on the atomic fragments and predefined knowledge graph patterns, target prompt words are constructed and input into the large language model. The target prompt words are used to instruct the large language model to identify entity, relation, and attribute triples that conform to the predefined knowledge graph patterns from the atomic fragments. The triples output by the large language model are obtained, and the triples from the same text data are aggregated to generate a knowledge base subgraph. The knowledge base subgraphs are then merged to obtain the overall knowledge base graph. The question-and-answer knowledge base is constructed hierarchically based on each of the knowledge base subgraphs and the overall knowledge base graph.

2. The method according to claim 1, characterized in that, The text data used to construct the question-answering knowledge base is divided into multiple atomic fragments, including: Receive raw data from multiple data sources and set a unique identifier for each piece of raw data; The text is extracted from each of the original data as the text data, the text data is cleaned, and after cleaning, it is divided into multiple atomic fragments; Each atomic fragment is assigned a unique code, and the unique code and the unique identifier corresponding to the original data to which the atomic fragment belongs are bound to the atomic fragment as metadata.

3. The method according to claim 2, characterized in that, The step of processing the triples originating from the same text data to generate a knowledge base subgraph includes: Based on the metadata of the atomic fragment corresponding to the triple, determine the unique identifier corresponding to the triple; All triples belonging to the same unique identifier are aligned as entities, merged, and deduplicated to obtain the knowledge base subgraph.

4. The method according to claim 1, characterized in that, The process of merging the various knowledge base subgraphs to obtain the overall knowledge base graph includes: Entity disambiguation and normalization are performed on the entities in each knowledge base subgraph to obtain preliminary fusion results; The preliminary fusion results are subjected to connectivity and consistency checks to obtain the overall knowledge base graph that passes the checks.

5. The method according to claim 1, characterized in that, After obtaining the overall knowledge base graph, the method further includes: The attribute description text of each entity in the knowledge base graph is transformed into a feature vector through a pre-trained word vector model in order to calculate the semantic similarity between any two entities. If the semantic similarity between any two entities is greater than a threshold, a virtual edge is generated between the two entities, and the semantic similarity is used as an additional weight for the virtual edge. The virtual edges and the additional weights are integrated into the knowledge base graph to obtain the updated graph; The updated overall graph is divided into communities using a community detection algorithm to obtain the community division results.

6. The method according to claim 5, characterized in that, The method further includes: Based on the community division results, the corresponding local map is determined; The pre-defined large model agent performs deep reasoning based on the current structural connection relationships of each local graph; the deep reasoning includes at least multi-hop potential relationship mining and semantic link completion. The inference results output by the large model agent are used as a community depth report.

7. The method according to claim 6, characterized in that, The hierarchical construction of the question-answering knowledge base based on each of the knowledge base subgraphs and the overall knowledge base graph includes: The question-and-answer knowledge base is constructed by systematically storing the knowledge base subgraphs, the overall knowledge base graph, the community division results, and the community depth report.

8. A question-answering knowledge base construction system for a large language model, characterized in that, include: The data extraction module is used to divide the text data used to build the question-answering knowledge base into multiple atomic fragments, and construct target prompt words based on the atomic fragments and predefined knowledge graph patterns and input them into the large language model; The target prompt word is used to instruct the large language model to identify entity, relation, and attribute triples that conform to the predefined knowledge graph pattern from the atomic fragments; The subgraph generation module is used to obtain the triples output by the large language model, and to process the triples from the same text data to generate a knowledge base subgraph. The overall map fusion module is used to fuse the various knowledge base subgraphs to obtain the overall knowledge base map; The knowledge base injection module is used to construct the question-and-answer knowledge base based on each of the knowledge base subgraphs and the overall knowledge base graph.

9. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the question-answering knowledge base construction method for a large language model as described in any one of claims 1-7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the question-answering knowledge base construction method of a large language model as described in any one of claims 1-7.