Knowledge base retrieval method and system based on mixed weight and knowledge graph

Through the use of hybrid weights and knowledge maps in the knowledge base search, the problem of low retrieval recall rate in existing technology and unable to find internal related information in existing technology, and achieved efficient and accurate knowledge base retrieval.

CN119377374APending Publication Date: 2025-01-28LUCULENT SMART TECHNOLOGIES CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411210013.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The existing knowledge base search technology has low recall rates when accurately retrieving specific information, and low recall rates when fuzzy search information or inaccurate descriptions, so it is impossible to effectively find information with intrinsic correlations.

Method used

Using the knowledge base search method based on the hybrid weight and the knowledge map, through the design of the body structure of the knowledge map, the long text is divided and merged into a semantic fragment, using the embedded model to calculate the semantic embedded vector and the vocabulary embedded vector, and establish the inverted indexes of the vector and the fragment. , And use the big model to extract the entity and relationship, generate retrieval statements, and judge the correlation between semantic fragments and user problems.

Benefits of technology

The balance of semantic retrieval and full text retrieval can be achieved, in -depth inquiries can be performed according to the internal connection of the knowledge, improving the efficiency and recall rate of the knowledge base search, and ensuring the accuracy and efficiency of information processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377374A_ABST
    Figure CN119377374A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of knowledge base retrieval, in particular to a knowledge base retrieval method and system based on a mixed weight and a knowledge graph. Segmenting the long text, and combining the text segments into semantic segments based on the semantic features; establishing inverted indexes of the vectors and the fragments; performing entity or relation extraction on the semantic segments by using a large model based on ontology design; calculating a semantic embedding vector and a vocabulary embedding vector of the user question by using the embedding model, and calculating the distance between the user question and a corresponding vector in the knowledge vector library to obtain semantic fragments corresponding to N vectors with the closest distance; performing retrieval statement generation and execution on the user question by using the large model based on ontology design to obtain a semantic fragment corresponding to a retrieval result node; the large model is used for judging whether the paragraph is related to the user question or not, and the method is easy to implement, high in portability and capable of being conveniently applied to knowledge file retrieval in various different fields.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge base retrieval technology, and in particular to a knowledge base retrieval method and system based on hybrid weights and knowledge graphs. Background Art

[0002] Among the existing knowledge base retrieval technologies, semantic retrieval and full-text retrieval each have their own shortcomings. Although semantic retrieval can understand the intent and semantic connections of user queries, and thus retrieve relevant texts, it can also find relevant information even if the user's wording is not accurate enough, which greatly improves the flexibility of retrieval and user experience. However, semantic retrieval performs poorly in situations where precise information is required because it is difficult to accurately locate specific data points. This limitation is particularly prominent in applications that require high-precision data.

[0003] In contrast, full-text search, with its ability to accurately lock keywords, performs well in ensuring search accuracy. It can directly match keywords in user queries and provide accurate search results. However, the limitation of this method is that once the user's expression deviates from the keywords in the data, the search effect will be greatly reduced. This expression deviation may lead to missed information, resulting in some relevant information not being retrieved, affecting the efficiency of information acquisition in practical applications.

[0004] In addition, whether it is full-text retrieval or semantic retrieval, when faced with the situation where knowledge is interrelated, only relevant information on the surface of the question itself can be retrieved, and related knowledge cannot be retrieved based on the inherent connection of knowledge. This means that when a user's query involves multiple interrelated knowledge points, it is difficult for existing retrieval technologies to fully cover all relevant information and cannot fully reveal the deep connections between knowledge. This limits the overall effectiveness of the knowledge base in complex knowledge management and utilization scenarios and cannot meet users' comprehensive query needs for related knowledge. Summary of the invention

[0005] In view of the above problems existing in the prior art, the present invention is proposed.

[0006] The main technical problems solved by the present invention are: the low recall rate of semantic retrieval when accurately retrieving specific information, the low recall rate of full-text retrieval when searching for fuzzy information or inaccurate descriptions, and the problem that existing retrieval methods cannot find information with intrinsic correlations.

[0007] Compared with the existing technology, this method achieves a balance between semantic retrieval and full-text retrieval, and realizes deep query based on the intrinsic association of knowledge, thereby improving the efficiency and recall rate of knowledge base retrieval.

[0008] In order to solve the above technical problems, the present invention provides the following technical solutions: a knowledge base retrieval method based on hybrid weights and knowledge graphs, comprising: designing a knowledge graph ontology structure of a field involved in extracting documents;

[0009] Segment long texts and merge text segments into semantic segments based on semantic features;

[0010] Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment, and establish the inverted index of the vector and the fragment;

[0011] Use large models to extract entities or relations from semantic fragments based on ontology design;

[0012] Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculate the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors. v ;

[0013] Use the big model to generate and execute retrieval statements for user questions based on ontology design, and obtain the semantic fragment P corresponding to the retrieval result node g ;

[0014] Using large models to determine P v , P g Whether each paragraph is relevant to the user's question, remove irrelevant paragraphs and merge them into P.

[0015] As a preferred solution of the knowledge base retrieval method based on hybrid weight and knowledge graph described in the present invention, wherein: the segmentation of the long text includes segmentation at the period, question mark, exclamation mark, and line break mark, and the long text is segmented into N shorter text segments;

[0016] The method of merging text segments into semantic segments based on semantic features includes calculating the semantic embedding vector e of the text segments using an embedding model. i ;

[0017] Calculate the adjacent semantic embedding vector e i The distance between i,j , expressed as,

[0018]

[0019] The distance d i,j After shrinking, It is expressed as,

[0020]

[0021] Among them, s represents the shrinkage factor;

[0022] Points greater than 95% are used as segmentation points, and the text segments are merged into N semantic segments, where N represents the number of texts.

[0023] As a preferred solution of the knowledge base retrieval method based on hybrid weights and knowledge graph described in the present invention, the embedding model includes adding a learnable special token at the beginning of a semantic segment, and the hidden state of the token contains the semantic information of the entire text; using a pre-trained BERT model to calculate the hidden state h of each token in the semantic segment, and the token includes information about the context in which it is located; inputting the hidden state of the special token into a multi-layer perceptron MLP1 to obtain a semantic embedding vector e of the entire semantic segment; inputting the hidden state except the special token into a multi-layer perceptron MLP2 to obtain the weight of each token, and averaging the weights of the same token to obtain a vocabulary embedding vector w of the semantic segment; using the HNSW algorithm to establish a semantic embedding vector and an inverted index of the vocabulary embedding vector and the semantic segment, and storing them in a database.

[0024] As a preferred solution of the knowledge base retrieval method based on hybrid weights and knowledge graph described in the present invention, the method comprises: extracting entities or relationships from semantic fragments based on ontology design using a large model, converting the ontology design into a structural description in JSON format, sending the structural description and the semantic fragments into the large model at the same time, specifying in the prompt word that the large model will output the extracted structure in JSON format, requiring the format to be the same as the structural description of the ontology design, and replacing nodes with entities; formatting the results output by the large model, and storing the entities, relationships and corresponding semantic fragments in a graph database.

[0025] As a preferred solution of the knowledge base retrieval method based on hybrid weight and knowledge graph described in the present invention, wherein: the calculation of the semantic embedding vector and vocabulary embedding vector of the user question includes selecting the first-layer graph constructed by HNSW as the current graph to calculate the cosine distance between all semantic embedding vectors and the semantic embedding vector of the user question, and selecting the vector with the closest distance as the entry of the next layer;

[0026] Enter the next layer, calculate the cosine distance between the connected vectors around the entry vector and the question vector, and select the node with the closest distance as the entry of the next layer; until the vector distances around the last layer of the graph or the next layer of the graph are all greater than the entry vector distance, select the N nodes with the closest distance in the historical path as the final retrieval result;

[0027] The calculation method of vocabulary embedding vector is similar to that of semantic embedding vector. The cosine distance is replaced by the dot product value. The vector with the largest dot product value is selected each time. The search results of semantic embedding vector and vocabulary embedding vector are combined and deduplicated to obtain P. v .

[0028] As a preferred solution of the knowledge base retrieval method based on hybrid weight and knowledge graph described in the present invention, wherein: the design generates a retrieval statement for the user question, including converting the ontology design into a JSON format structure description, inputting the structure description and the user question into a large model, and generating a Cypher query statement; executing the Cypher query statement in the graph database, deduplicating the semantic fragments corresponding to the queried nodes to obtain P g .

[0029] As a preferred solution of the knowledge base retrieval method based on hybrid weight and knowledge graph described in the present invention, wherein: the method of using a large model to judge P v , P g Whether each paragraph is relevant to the user's question includes combining each semantic fragment with the user's question, sending them to the big model, and the big model outputs the relevance as True or False, and eliminating irrelevant semantic fragments to obtain P.

[0030] Another object of the present invention is to provide a knowledge base retrieval system based on hybrid weights and knowledge graphs, which realizes efficient segmentation of long texts and merging of semantic fragments, ensuring the accuracy and efficiency of information processing. With the help of the embedding model, the system constructs a vector index of semantic fragments, which greatly improves the retrieval speed and processing power. The large model extracts entities and relationships from semantic fragments based on ontology design, enriching knowledge resources. The calculation of the semantic embedding vectors of user questions enables the system to quickly match the most relevant semantic fragments in the knowledge base, and accurately answer user questions through the retrieval statement generation module. Through the screening of the relevance judgment merging module, the accuracy of the answer and the integrity of the information are ensured, thereby significantly improving the overall performance and user satisfaction of the question-answering system.

[0031] As a preferred solution of the knowledge base retrieval system based on hybrid weight and knowledge graph described in the present invention, it includes: a design module, a segmentation module, a vector indexing module, an entity relationship extraction module, a semantic vector retrieval module, a retrieval statement generation module, and a relevance judgment merging module;

[0032] Design module, design the knowledge graph ontology structure of the field involved in the extracted document;

[0033] The segmentation module segments long texts and merges text segments into semantic segments based on semantic features.

[0034] The vector indexing module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment and establish the inverted index of the vector and the fragment;

[0035] The entity relationship extraction module uses a large model to extract entities or relationships from semantic fragments based on ontology design;

[0036] The semantic vector retrieval module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculates the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors. v ;

[0037] The search statement generation module uses the large model to generate and execute search statements for user questions based on the ontology design, and obtains the semantic fragment P corresponding to the search result node g ;

[0038] The correlation judgment merging module uses a large model to judge P v , P g Whether each paragraph is relevant to the user's question, remove irrelevant paragraphs and merge them into P.

[0039] A computer device includes a memory and a processor, wherein the memory stores a computer program, and is characterized in that when the processor executes the computer program, the steps of any one of the methods for knowledge base retrieval based on hybrid weights and knowledge graphs are implemented.

[0040] A computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the steps of any one of the methods for knowledge base retrieval based on hybrid weights and knowledge graphs are implemented.

[0041] Beneficial effects of the present invention: The present invention calculates the semantic embedding vector and vocabulary embedding vector of semantic fragments by using an embedding model, and performs retrieval in combination with a knowledge graph, thereby significantly improving the accuracy and relevance of the retrieval results. The present invention divides long texts into semantic fragments based on semantic features, and determines the separation points of semantic changes through shrinkage processing and percentile calculation, so as to more flexibly segment long texts, ensure that each semantic fragment contains a single semantic information, and improve the accuracy of retrieval. The present invention adopts the HNSW algorithm to establish an inverted index of semantic embedding vectors and vocabulary embedding vectors, and greatly reduces the computational complexity and improves the retrieval speed through the pruning method. The present invention generates a query statement for chain retrieval by integrating knowledge graph retrieval, and can mine relevant knowledge that is deeply associated with knowledge, thereby improving the efficiency of knowledge retrieval and acquisition. The method proposed in the present invention is simple to implement and highly portable, and can be easily applied to knowledge document retrieval in a variety of different fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0043] Figure 1 A flowchart of a knowledge base retrieval method based on hybrid weights and knowledge graph is provided for one embodiment of the present invention.

[0044] Figure 2 A schematic diagram of the design of an equipment fault diagnosis graph ontology for a knowledge base retrieval method based on hybrid weights and knowledge graphs provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0045] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0046] Example 1

[0047] Reference Figure 1 , which is the first embodiment of the present invention, provides a knowledge base retrieval method based on hybrid weight and knowledge graph, including:

[0048] 1) Design the knowledge graph ontology structure of the field involved in the extracted document; the construction of the knowledge graph depends on the pre-designed ontology structure, and the nodes and relationships in the ontology will be instantiated as entities and relationships during construction.

[0049] 2) Segment the long text into several shorter text segments, and merge the text segments into semantic segments based on semantic features;

[0050] 3) Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment, and establish an inverted index of the vector and the fragment;

[0051] 4) Use large models to extract entities / relationships from semantic fragments based on ontology design;

[0052] 5) Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculate the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors v ;

[0053] 6) Use the big model to generate and execute search statements for user questions based on ontology design, and obtain the semantic fragment P corresponding to the search result node g ;

[0054] 7) Use a large model to determine P v , P g Whether each paragraph is relevant to the user's question, remove irrelevant paragraphs and merge them into P.

[0055] The long text segmentation processing method designed according to step 2) is specifically segmented at identifiers such as periods, question marks, exclamation marks, and line breaks, so as to segment the long text into several shorter text segments.

[0056] According to the semantic feature-based merging text fragments designed in step 2), the specific method is as follows:

[0057] Use the embedding model to calculate the semantic embedding vector e of the text fragment i ;

[0058] Calculate the adjacent semantic embedding vector e i The distance between i,j , the calculation formula is:

[0059]

[0060] The distance d i,j After shrinking, The calculation formula is:

[0061]

[0062] Where s is the shrinkage factor (usually 0.3);

[0063] Will The points greater than the 95th percentile are used as separation points to merge the text segments into several semantic segments.

[0064] Since texts with similar cosine distances of semantic embedding vectors express similar meanings, by finding the 95th percentile of the cosine distance, we can find the point where the text semantics changes, thereby separating semantically unrelated segments. Shrinkage processing can smooth out irrelevant fluctuations while highlighting the peak, reducing the probability of mis-separating semantically similar segments. This method is more flexible than commonly used fixed-length segmentation, recursive segmentation and other methods, and can ensure that the semantic information contained in each semantic segment is as single as possible, thereby improving the accuracy of subsequent searches.

[0065] According to the design in step 3), the semantic embedding vector e and vocabulary embedding vector w of the calculated semantic fragment are calculated as follows:

[0066] Add a learnable special token at the beginning of the semantic segment. The hidden state of this token contains the semantic information of the entire text.

[0067] Use the pre-trained BERT model to calculate the hidden state h of each token in the semantic fragment. These tokens contain information about their context; BERT is a component of the embedding model, a model structure.

[0068] Input the hidden state of the special token into the multi-layer perceptron MLP1 to obtain the semantic embedding vector e of the entire semantic segment;

[0069] Input all hidden states except special tokens into the multi-layer perceptron MLP2 to obtain the weight of each token, and take the average of the weights of the same token to obtain the vocabulary embedding vector w of the semantic fragment;

[0070] Use the HNSW algorithm to create semantic embedding vectors and vocabulary embedding vectors and inverted indexes of semantic fragments, and store them in a database, such as PostgreSQL with the pgvector extension enabled.

[0071] The hidden state calculated using the BERT model contains implicit information in the text context, and the implicit information can be extracted by inputting it into a multi-layer perceptron. Among them, by using MLP1, the semantic information contained in a special token can be extracted as a semantic embedding vector. For other tokens, MLP2 can be used to calculate the importance of each token in the entire semantic segment while taking into account its contextual information. Compared with vocabulary weight calculation methods such as BM25 and IF-IDF, this method can effectively integrate contextual information, and the weights calculated by this method are more reasonable than those calculated by word frequency-based methods; and the semantic and vocabulary vectors share the same hidden state, which reduces the amount of calculation and can effectively improve the calculation speed.

[0072] The large model designed in step 4) extracts entities / relationships from semantic fragments based on ontology design. The specific method is as follows:

[0073] Convert the ontology design into a JSON format structure description. The specific format is:

[0074] nodes: ["node1", "node2", "node3", ...]

[0075] Relations: [{"from":"node1","relation":"relation1","to":"node2"},{"from":"node1","relation":"relation2","to":"node3"},{"from":"node2","relation":"relation3","to":"node3"},...]

[0076] The structure description and semantic fragments are simultaneously fed into the big model. In the prompt, the big model is specified to output the extracted structure in JSON format. The format is required to be the same as the structure description designed by the ontology, and the nodes are replaced by entities.

[0077] Format the output of the large model and store the entities, relationships, and corresponding semantic fragments in a graph database such as Neo4J.

[0078] According to the calculation designed in step 5), the distance between the corresponding vector in the knowledge vector library is obtained to obtain the semantic fragment P corresponding to the nearest N vectors v , the specific method is:

[0079] Select the first-layer graph constructed by HNSW as the current graph to calculate the cosine distance between all semantic embedding vectors and the user question semantic embedding vector, and select the vector with the closest distance as the entry for the next layer;

[0080] Enter the next layer, calculate the cosine distance between the connected vectors around the entry vector and the problem vector, and select the node with the closest distance as the entry of the next layer;

[0081] Repeat step (2) until the vector distances around the last layer of the graph or the next layer of the graph are greater than the entry vector distance. Select the N nodes closest to the historical path as the final retrieval result;

[0082] The calculation method of vocabulary embedding vector is similar to that of semantic embedding vector. The cosine distance is replaced by the dot product value, and the vector with the largest dot product value is selected each time.

[0083] The retrieval results of semantic embedding vectors and vocabulary embedding vectors are combined and deduplicated to obtain P v .

[0084] Since the semantic embedding vector contains the semantic information of the text, and the lexical embedding vector contains the lexical weight of the text, this method can calculate the semantic fragments that are most similar in semantics and contain specific information by means of vector calculation. And since this method uses the HNSW index, compared with the full table scan and word-by-word comparison method of traditional full-text retrieval, the calculation complexity can be greatly reduced through pruning, and the system response speed can be improved.

[0085] According to the user question retrieval sentence designed in step 6), the specific method is:

[0086] Same as step 4), convert the ontology design into a JSON format structure description;

[0087] Input the structure description and user questions into the big model and specify it to generate Cypher query statements;

[0088] Execute the Cypher query statement in the graph database and remove the duplicate semantic fragments corresponding to the queried nodes to obtain P g .

[0089] This method generates chained search query statements by integrating knowledge graph retrieval. Compared with traditional retrieval methods that can only search for knowledge related to the question itself, this method can mine related knowledge that is deeply associated with the knowledge, thereby improving the efficiency of knowledge retrieval and acquisition.

[0090] According to the design in step 7), the big model is used to determine whether the semantic segment is relevant to the user question. The specific method is to combine each semantic segment with the user question, send them to the big model, and the big model outputs the relevance as True or False, thereby eliminating irrelevant semantic segments to obtain P.

[0091] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

[0092] Example 2

[0093] refer to Figure 2 , which is the second embodiment of the present invention, provides a knowledge base retrieval method based on hybrid weights and knowledge graphs. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through experiments.

[0094] Taking the equipment fault diagnosis document as an example, we first construct the equipment fault diagnosis graph ontology. The ontology structure is as follows: Figure 2 As shown in the figure, a fan fault maintenance manual is input to build a vector database and a graph database.

[0095] The target semantic fragments to be retrieved are:

[0096] Clip 1: The SP290 water pump is an advanced industrial equipment designed for efficient and reliable liquid transportation. The pump is equipped with a series of monitoring parameters to ensure its stable operation under various working conditions. The main monitoring parameters include:

[0097] Flow rate: Monitor the liquid delivery volume of the water pump in real time to ensure that the flow rate is within the set range.

[0098] Pressure: Monitor inlet and outlet pressures to prevent system overpressure or underpressure.

[0099] Temperature: Monitor the temperature of the pump and the pumped liquid to prevent overheating.

[0100] Vibration: Detect vibration during operation of the pump to prevent mechanical failure.

[0101] Current: Monitors the running current of the motor to prevent overload and electrical faults.

[0102] Voltage: Ensure that the power supply voltage is stable to prevent voltage fluctuations from damaging the equipment.

[0103] Liquid Level: Monitor the level of the conveyed liquid to avoid dry running or overflow situations.

[0104] Clip 2: Case number: GZ2023091200001

[0105] Case description: During a routine operation, a water pump model SP290 showed obvious abnormalities: the flow and pressure fluctuated violently, accompanied by abnormal vibration and noise. The operator immediately checked the equipment, first checking the inlet and outlet pressures and flows, and found that these parameters fluctuated beyond the normal range. Subsequently, the data from the temperature and vibration sensors also showed abnormalities, especially the vibration values ​​were far above the safety threshold. When the motor current was further checked, it was found that its current fluctuated greatly, indicating a mechanical imbalance problem. After detailed analysis, it was determined that the cause of the failure was an unbalanced rotor. The treatment measures included shutdown for maintenance, recalibration and balancing of the rotor, and replacement of damaged parts.

[0106] The user's question is:

[0107] Question 1: What types of water pumps are there?

[0108] Question 2: What are the monitoring parameters of SP290?

[0109] Question 3: What are the monitoring parameters of the water pump in fault case GZ2023091200001?

[0110] Test items:

[0111] Test items Fuzzy semantic retrieval Accurate information retrieval Related knowledge retrieval User Questions Question 1 Question 2 Question 3 Target semantic fragment Clip 2 Clip 1 Clip 1, Clip 2

[0112] Test results:

[0113]

[0114] It can be seen from the test results that this method inherits the advantages of full-text retrieval and semantic retrieval, while realizing in-depth query based on the intrinsic association of knowledge, thus improving the efficiency and recall rate of knowledge base retrieval.

[0115] Example 3

[0116] The third embodiment of the present invention is different from the first two embodiments in that:

[0117] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.

[0118] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0119] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0120] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0121] Example 4

[0122] A fourth embodiment of the present invention provides a knowledge base retrieval system based on hybrid weights and knowledge graphs, characterized by comprising: a design module, a segmentation module, a vector indexing module, an entity relationship extraction module, a semantic vector retrieval module, a retrieval statement generation module, and a relevance judgment merging module;

[0123] Design module, design the knowledge graph ontology structure of the field involved in the extracted document;

[0124] The segmentation module segments long texts and merges text segments into semantic segments based on semantic features.

[0125] The vector indexing module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment and establish the inverted index of the vector and the fragment;

[0126] The entity relationship extraction module uses a large model to extract entities or relationships from semantic fragments based on ontology design;

[0127] The semantic vector retrieval module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculates the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors. v ;

[0128] The search statement generation module uses the large model to generate and execute search statements for user questions based on ontology design, and obtains the semantic fragment P corresponding to the search result node g ;

[0129] The correlation judgment merging module uses a large model to judge P v , P g Whether each paragraph is relevant to the user's question, remove irrelevant paragraphs and merge them into P.

[0130] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A knowledge base retrieval method based on hybrid weight and knowledge graph, characterized by: include, Design the knowledge graph ontology structure of the field involved in the extracted documents; Segment long texts and merge text segments into semantic segments based on semantic features; Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment, and establish the inverted index of the vector and the fragment; Use large models to extract entities or relations from semantic fragments based on ontology design; Use the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculate the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors. v ; Use the big model to generate and execute retrieval statements for user questions based on ontology design, and obtain the semantic fragment P corresponding to the retrieval result node g ; Using large models to determine P v , P g Whether the paragraph is relevant to the user's question.

2. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 1, characterized in that: The segmentation of the long text includes segmentation at a period, a question mark, an exclamation mark, and a line break mark, so as to segment the long text into N text segments of a length not exceeding L; The method of merging text segments into semantic segments based on semantic features includes calculating the semantic embedding vector e of the text segments using an embedding model. i ; Calculate the adjacent semantic embedding vector e i The distance between i,j , expressed as, The distance d i,j After shrinking, It is expressed as, Among them, s represents the shrinkage factor; Points greater than 95% are used as segmentation points, and the text segments are merged into N semantic segments, where N represents the number of texts.

3. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 2, characterized in that: The embedding model includes adding a learnable special token at the beginning of the semantic segment; using the pre-trained BERT model to calculate the hidden state h of each token in the semantic segment; inputting the hidden state of the special token into the multi-layer perceptron MLP1 to obtain the semantic embedding vector e of the entire semantic segment. i ; Input the hidden states except the special tokens into the multi-layer perceptron MLP2 to obtain the weight of each token, and take the average of the weights of the same token to obtain the vocabulary embedding vector w of the semantic fragment i ; Use the HNSW algorithm to create the semantic embedding vector, vocabulary embedding vector and inverted index of semantic fragments and store them in the database.

4. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 3, characterized in that: The method of using the big model to extract entities or relationships from semantic fragments based on the ontology design includes converting the ontology design into a JSON format structure description, sending the structure description and the semantic fragments into the big model at the same time, specifying in the prompt word that the big model will output the extracted structure in JSON format, requiring the format to be the same as the structure description of the ontology design, and replacing nodes with entities; formatting the results output by the big model, and storing the entities, relationships and corresponding semantic fragments in a graph database.

5. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 4, characterized in that: The calculating of the semantic embedding vector and the vocabulary embedding vector of the user question includes selecting the first layer graph constructed by HNSW as the current graph to calculate the cosine distance between all the semantic embedding vectors and the semantic embedding vector of the user question, and selecting the vector with the closest distance as the entry of the next layer; Enter the next layer, calculate the cosine distance between the connected vectors around the entry vector and the question vector, and select the node with the closest distance as the entry of the next layer; until the vector distances around the last layer of the graph or the next layer of the graph are all greater than the entry vector distance, select the N nodes with the closest distance in the historical path as the final retrieval result; The calculation method of vocabulary embedding vector is the same as that of semantic embedding vector. The cosine distance is replaced by the dot product value. The vector with the largest dot product value is selected each time. The search results of semantic embedding vector and vocabulary embedding vector are combined and deduplicated to obtain P. v .

6. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 5, characterized in that: The design generates a search statement for a user question, including converting the ontology design into a JSON format structure description, inputting the structure description and the user question into a large model, generating a Cypher query statement; executing the Cypher query statement in the graph database, deduplicating the semantic fragments corresponding to the queried nodes, and obtaining a P g .

7. A knowledge base retrieval method based on hybrid weight and knowledge graph as claimed in claim 6, characterized in that: The use of large models to determine P v , P g Whether the paragraph is relevant to the user question includes combining each semantic segment with the user question, sending them to the big model, and the big model outputs the relevance as True or False, and eliminating irrelevant semantic segments to obtain P; where P represents the final retrieval result.

8. A system based on the knowledge base retrieval method based on hybrid weight and knowledge graph according to any one of claims 1 to 7, characterized in that: It includes design module, segmentation module, vector indexing module, entity relationship extraction module, semantic vector retrieval module, retrieval statement generation module, and relevance judgment merging module; Design module, design the knowledge graph ontology structure of the field involved in the extracted document; The segmentation module segments long texts and merges text segments into semantic segments based on semantic features. The vector indexing module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the semantic fragment and establish the inverted index of the vector and the fragment; The entity relationship extraction module uses a large model to extract entities or relationships from semantic fragments based on ontology design; The semantic vector retrieval module uses the embedding model to calculate the semantic embedding vector and vocabulary embedding vector of the user question, and calculates the distance with the corresponding vector in the knowledge vector library to obtain the semantic fragment P corresponding to the nearest N vectors. v ; The search statement generation module uses the large model to generate and execute search statements for user questions based on ontology design, and obtains the semantic fragment P corresponding to the search result node g ; The correlation judgment merging module uses a large model to judge P v , P g Whether each paragraph is relevant to the user's question, remove irrelevant paragraphs and merge them into P.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Global knowledge extraction method and system based on large model and RAG technology

    CN120317353A

  • High-performance knowledge base system based on multi-modal mixed retrieval

    CN120781933A

  • Aero-engine fault data processing method and system

    CN121636985A

  • Aero-engine fault data processing method and system

    CN121636985B