Mixing retrieval method and device based on knowledge graph and vector, equipment and storage medium

By combining the knowledge map and vector retrieval technology, the CYPHER query, vector matching, AC automatic machine matching and recursive ranking fusion models are used to realize a hybrid retrieval method, solving the knowledge map and large language model in the existing technologies in information retrieval in information retrieval Limitation improves the accuracy and efficiency of retrieval.

CN119357376AInactive Publication Date: 2025-01-24XIAMEN YUANTING INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411902270.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-01-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing knowledge graphs and large language models have limitations in information retrieval. The semantic retrieval effect of the knowledge graph is not ideal. The training cost of large language models is high and the timeliness data cannot be updated in time, and there is a risk of data leakage.

Method used

Adopt a hybrid retrieval method based on knowledge maps and vectors. By obtaining the user's query statement, it is converted into CyPher to query and send it to the NEO4J engine to receive the query results of the knowledge map; convert the query statement to query vector, and from the vector from the vector The matching results in the database; call the pre -constructed AC automatic machine for automatic matching; finally, the call recursive ranking fusion model is fixed to multiple query results to output the final retrieval result.

Benefits of technology

Improve the accuracy and efficiency of information retrieval, overcome the limitations of knowledge maps and large language models alone, and achieve more comprehensive and efficient information retrieval results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357376A_ABST
    Figure CN119357376A_ABST
Patent Text Reader

Abstract

The invention provides a hybrid retrieval method, device and equipment based on a knowledge graph and a vector and a storage medium, and the method comprises the steps: firstly obtaining a query statement of a user, converting the query statement into a Cypher query, sending the Cypher query to a Neo4j engine, and receiving a first query result of the knowledge graph; then, converting the query statement into a query vector, and matching a second query result from a vector database according to the query vector; then, a pre-constructed AC automaton is called to automatically match the query statement to generate a third query result, and the AC automaton is constructed based on a knowledge graph; and finally, calling a recursive ranking fusion model, fusing the first query result, the second query result and the third query result based on a preset weight, and outputting a retrieval result, thereby solving the problem that the retrieval capability of the existing knowledge graph and large language model is limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a hybrid retrieval method, device, equipment and storage medium based on knowledge graph and vector. Background Art

[0002] With the development of artificial intelligence technology, knowledge graphs and large language models have played an important role in the fields of semantic understanding and information retrieval. Knowledge graphs are a structured data model used to represent entities and their relationships. They are widely used in search engines, recommendation systems, and natural language processing. By establishing semantic associations, knowledge graphs can improve the system's ability to understand and reason about complex relationships. Relying solely on knowledge graph retrieval technology also has certain limitations. For example, direct semantic retrieval does not work well. On the other hand, large language models such as GPT have powerful natural language processing capabilities and can generate text with high semantic relevance based on input. However, the training cost of retrieval through large models is high, and it is impossible to update time-sensitive data in a timely manner. In addition, when enterprises use third-party models, they face the risk of data leakage.

[0003] In view of this, this application is filed. Summary of the invention

[0004] The present invention discloses a hybrid retrieval method, apparatus, device and storage medium based on knowledge graph and vector, aiming to solve the problem that the retrieval capabilities of existing knowledge graphs and large language models are limited.

[0005] The first aspect of the present invention provides a hybrid retrieval method based on knowledge graph and vector, comprising: Obtain the user's query statement, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive the first query result of the knowledge graph; Convert the query statement into a query vector, and match a second query result from a vector database according to the query vector; Calling a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; The recursive ranking fusion model is called, and the first query result, the second query result, and the third query result are fused based on preset weights to output a retrieval result.

[0006] Preferably, the user's query statement is obtained, the query statement is converted into a Cypher query and sent to the Neo4j engine, and the first query result of the knowledge graph is received, specifically: The query statement is converted into a Cypher query using a large language model, and all tags in the knowledge graph are retrieved through a Neo4j engine and the Cypher query; Filter out a corresponding subgraph according to each of the labels, and use a random sampling strategy to check entities and relationships in the subgraph to generate a check result; The first query result is output after the inspection result is cleaned.

[0007] Preferably, the converting the query statement into a query vector, and matching the second query result from a vector database according to the query vector, specifically comprises: The query statement is cleaned and converted into a query vector, matched in the vector database according to the query vector, and a second query result is output from high to low according to the similarity between the query vector and the document vector in the vector database, wherein the documents in the vector database are encoded based on a deep neural network model and converted into vectors of fixed length.

[0008] Preferably, the calling of a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph, specifically: According to the query statement, matching the name of the entity or an identifier that can uniquely identify the entity as a keyword from a pre-built AC automaton; Create an empty root node as the starting point of the dictionary tree, traverse each keyword in the keyword set, start from the root node, build a path downward character by character, for each new character, create a new node and insert it into the tree; for the node representing the complete keyword, mark it as the keyword end node; Set a failure pointer for each node. The failure pointer of the root node points to itself. For non-root nodes, recursively set the failure pointer according to the preset rules: Receive input text, scan the text content character by character, and use the path in the dictionary tree to match the current character; when the character fails to match the current state, quickly transfer to the next possible state through the failure pointer until a matching keyword is found, report all matched keywords and their associated entity identifiers, and generate a third query result.

[0009] Preferably, after matching the name of the entity or the identifier that can uniquely identify the entity from the pre-built AC automaton according to the query statement as a keyword, the method further includes: The extracted keywords are split into sub-keywords by spaces or commas and stored in the form of key-value pairs, where the key is the split sub-keyword and the value is the unique identifier of the hittable entity.

[0010] Preferably, for the non-root node, the failure pointer is recursively set according to a preset rule, specifically: If the failure pointer of the parent node has a child node with the same character as the current node, the failure pointer of the current node points to the child node; If the above matching child node is not found, the failure pointer points to the failure pointer of the parent node; If the current node is a direct child of the root node, its failure pointer points to the root node.

[0011] Preferably, the calling of the recursive ranking fusion model and fusing the first query result, the second query result and the third query result based on a preset weight to output the retrieval result is specifically as follows: configuring preset weights for the recall paths of the first query result, the second query result, and the third query result respectively, calling the recursive ranking fusion model to calculate all documents of each recall path, and generating a fusion score; The search results are output after being sorted according to the fusion score of each recall path, wherein the expression of the recursive ranking fusion model is: ; in, is the score for each document, N is the number of recall paths, is the weight of the i-th path, K is the fusion coefficient, is the ranking of document d in the i-th path.

[0012] A second aspect of the present invention provides a hybrid retrieval device based on a knowledge graph and a vector, comprising: A first query result generating unit, used to obtain a query statement of a user, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive a first query result of the knowledge graph; A second query result generating unit, configured to convert the query statement into a query vector, and match a second query result from a vector database according to the query vector; A third query result generating unit, configured to call a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; The fusion unit is used to call the recursive ranking fusion model, and fuse the first query result, the second query result, and the third query result based on a preset weight, and output a retrieval result.

[0013] The third aspect of the present invention provides a hybrid retrieval device based on a knowledge graph and a vector, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of the above items.

[0014] The fourth aspect of the present invention provides a computer-readable storage medium, characterized in that it stores a computer program, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of the above items.

[0015] A hybrid retrieval method based on a knowledge graph and a vector provided by the present invention first obtains a query statement of a user, converts the query statement into a Cypher query and sends it to a Neo4j engine, and receives a first query result of the knowledge graph; then, converts the query statement into a query vector, and matches a second query result from a vector database according to the query vector; then, calls a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; finally, calls a recursive ranking fusion model, and fuses the first query result, the second query result, and the third query result based on a preset weight, and outputs a retrieval result, thereby solving the problem of limitations in the retrieval capabilities of existing knowledge graphs and large language models. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a flowchart of a hybrid retrieval method based on knowledge graph and vector provided by the first embodiment of the present invention; Figure 2 It is a module diagram of a hybrid retrieval device based on knowledge graph and vector provided in the second embodiment of the present invention. DETAILED DESCRIPTION

[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0018] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0019] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0020] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0021] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0022] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0023] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.

[0024] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0025] The present invention discloses a hybrid retrieval method, apparatus, device and storage medium based on knowledge graph and vector, aiming to solve the problem that the retrieval capabilities of existing knowledge graphs and large language models are limited.

[0026] See also Figure 1 In a first aspect, the present invention provides a hybrid retrieval method based on a knowledge graph and a vector, which can be performed by a hybrid retrieval device based on a knowledge graph and a vector (hereinafter referred to as a retrieval device), and in particular, by one or more processors in the retrieval device to implement at least the following steps: S101, obtaining a user's query statement, converting the query statement into a Cypher query and sending it to the Neo4j engine, and receiving a first query result of the knowledge graph; In this embodiment, the retrieval device may be a server, workstation, desktop computer or other terminal with data processing capabilities. The corresponding operating system and application software may be installed in the retrieval device, and the functions required by this embodiment are realized through the combination of the operating system and application software.

[0027] It should be noted that after receiving the user's query statement, the search device first uses the large language model to perform semantic analysis and structural parsing on the query statement, and converts it into a query expression that conforms to the Cypher query syntax. For example, for the user input "the development history of artificial intelligence", the large language model can identify "artificial intelligence" as the core entity and "development history" as the query target attribute, and then generate the corresponding Cypher query statement: The generated query statement will be sent to the knowledge graph through the Neo4j engine for execution, thereby retrieving all the tags in the knowledge graph. These tags serve as organizational markers of the graph structure and represent core categories in the field, such as "technological development", "important events" or "field experts".

[0028] After obtaining these labels, the retrieval device will further filter out the subgraphs related to each label to ensure that the processing process is more efficient and accurate. When filtering subgraphs, the Cypher query statement will be dynamically adjusted; it can extract entities and their relationships related to the "technological development" label from the graph. The subgraph corresponding to each label may contain a large number of entities and complex relationship networks, which need to be further checked through random sampling strategies. The purpose of random sampling is to quickly evaluate the structural rationality and data integrity of the subgraph at a low computational cost, such as checking whether the entities have the necessary attributes and whether there are redundancies or inconsistencies in the relationships.

[0029] In the inspection results generated by random sampling, the retrieval device will clean the data. Specifically, for problematic entities (such as nodes with missing core attributes), the retrieval device will try to complete the missing information or directly remove the node; for situations where there are redundant or invalid connections in the relationship, the retrieval device will optimize the expression of the relationship according to preset rules. For example, if an entity "artificial intelligence" has a meaningless "related" relationship with multiple repeated event nodes, these repeated relationships will be merged or marked as invalid.

[0030] After cleaning, the subgraph data will be integrated into the first query result of the knowledge graph. For example, the first query result after cleaning may output the following content: Entity: "Artificial Intelligence" relation: "occurred at" -> "Dartmouth Conference" “Drive” -> “Deep Learning Revolution” Attributes: time, place, core events, etc.

[0031] S102, converting the query statement into a query vector, and matching a second query result from a vector database according to the query vector; In this embodiment, in order to achieve semantic matching between user query and document content, the retrieval device first converts the user's query statement into a query vector, and matches the second query result in the vector database based on the query vector. In this process, the retrieval device performs a series of cleaning operations on the query statement to ensure the structured and semantic integrity of the input content. For example, the query statement input by the user may be "the impact of the development of artificial intelligence on society", which contains redundant auxiliary words and redundant components. The retrieval device first removes irrelevant characters, punctuation or noise information through a text cleaning step, and simplifies the sentence to the core part "the impact of the development of artificial intelligence".

[0032] The cleaned query is encoded by a deep neural network model (such as BERT or GPT) and converted into a high-dimensional vector of fixed length. The pre-trained semantic feature extraction capability of the model can be used to capture the semantic information, contextual relationships, and potential key concepts in the query. For example, "the impact of the development of artificial intelligence" may be represented as a 300-dimensional vector after encoding: [0.25, -0.37, 0.84, ...], which can accurately describe the semantic features of the query in the vector space.

[0033] At the same time, the vector database in the retrieval device has completed the same vectorization processing for all pre-stored document contents. Each document is encoded through a deep neural network model and converted into a vector representation of the same dimension as the query vector. Among them, the document vector can be clustered and indexed before being stored to support efficient retrieval and matching operations.

[0034] In the vector matching stage, the retrieval device sorts the query vector and the document vector in the database according to the similarity between them. Preferably, the similarity calculation method can use cosine similarity, which can quantify the angle between two vectors in a high-dimensional space, thereby reflecting their semantic relevance. For example, the cosine similarity calculated between the query vector and the vector of document 1 is 0.92, and the cosine similarity with document 2 is 0.75, then document 1 has a higher relevance and is returned first.

[0035] The matching results will be sorted and outputted from high to low in terms of similarity, for example: 1. Document 1 (Similarity: 0.92): The impact of artificial intelligence on education 2. Document 2 (Similarity: 0.75): Development Trends of Artificial Intelligence 3. Document 3 (Similarity: 0.68): The relationship between deep learning and artificial intelligence S103, calling a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; Specifically, in this embodiment, the basis for constructing the AC automaton is to extract entity information related to the query from the knowledge graph, such as the name or unique identifier of the entity. In order to enhance the flexibility of matching, these entity keywords are further divided into smaller sub-keywords, usually divided by separators such as spaces or commas. The divided sub-keywords are stored in the form of key-value pairs, where the key is the divided sub-keyword and the value is an identifier that can uniquely identify the corresponding entity. Among them, the data structure can enhance the ability of the retrieval device to handle query diversity.

[0036] When actually building an AC automaton, we first create an empty root node as the starting point of the entire dictionary tree. The retrieval device traverses each keyword in the keyword set and builds a path from the root node downward character by character. When encountering a new character, the retrieval device creates a new node and inserts it into the tree. If the current node represents a complete keyword, the node is marked as a keyword end node so that the completed match can be quickly identified in the subsequent matching process.

[0037] In order to further optimize the matching process, a failure pointer is set for each node. The role of the failure pointer is that when the current character fails to match the path in the dictionary tree, the retrieval device can quickly jump to the next possible matching state through the failure pointer, thereby avoiding the overhead of starting the match from the root node again. When setting the failure pointer, the failure pointer of the root node points to itself by default, which is the initial state of the tree. For non-root nodes, the setting of the failure pointer follows the following rules: if the failure pointer of the parent node has a child node with the same character as the current node, the failure pointer of the current node will point to the child node; if such a child node is not found, the failure pointer points to the failure pointer of the parent node. For the direct child nodes of the root node, its failure pointer directly points to the root node. This recursive setting method ensures that when the match fails, the retrieval device can quickly transfer through the failure pointer, thereby improving the efficiency of matching.

[0038] After the construction of the AC automaton is completed, the retrieval device will receive the query statement input by the user and scan the text content corresponding to the query statement character by character. During the scanning process, the retrieval device uses the path in the dictionary tree to match the current character; if the character match fails, the retrieval device quickly transfers to the possible matching path through the failure pointer until one or more matching keywords are found. Whenever a match is completed, the retrieval device will record the keyword and its associated entity identifier. The whole process continues until the input text scanning is completed.

[0039] After the matching is completed, the retrieval device generates a third query result, which contains all the matched keywords and their associated entity information. For example, for the user input query "the latest development of artificial intelligence", the AC automaton may match the two keywords "artificial intelligence" and "development", and associate it with the "artificial intelligence" node in the knowledge graph and its relationship node with the "deep learning revolution" event. The final output result is a structured data set containing key entities and their relationships.

[0040] S104, calling a recursive ranking fusion model, and fusing the first query result, the second query result, and the third query result based on a preset weight, and outputting a retrieval result.

[0041] It should be noted that when the first query result (from knowledge graph retrieval), the second query result (from vector retrieval), and the third query result (from AC automaton matching) are generated respectively, the retrieval device will assign weights to their recall paths. For example, the knowledge graph retrieval path can be assigned a weight of 0.7 due to its high logical accuracy, while the vector retrieval and AC automaton matching paths can be assigned a weight of 0.5 respectively due to their respective advantages in semantic association and keyword matching. Among them, the weight allocation method can reflect the importance of each path in different scenarios; The expression of the recursive ranking fusion model is: ; in, is the score for each document, N is the number of recall paths, is the weight of the i-th path, K is the fusion coefficient, is the ranking of document d in the i-th path. K is usually a positive integer (such as 60 or 100) to smooth the differences between rankings. Through the recursive ranking fusion model, the retrieval device can effectively integrate the retrieval results of different paths, so that the paths with high weights contribute more to the document score, while the influence of the lower-ranked documents is significantly weakened due to the larger denominator.

[0042] In actual calculation, the retrieval device will traverse all documents in each recall path and calculate their comprehensive scores one by one. For example, for a user query, if document A ranks first in knowledge graph retrieval, second in vector retrieval, and third in AC automaton matching, its comprehensive score is calculated as follows: ; After calculating the scores of all documents, the retrieval device sorts the documents according to these scores, and the documents with higher scores are ranked higher. This sorting method can highlight highly relevant results while avoiding the interference of low-quality documents on the final retrieval results. For example, the top-ranked documents may be the core entity relationships inferred in knowledge graph retrieval, the highly semantically relevant article paragraphs in vector retrieval, and the keyword content quickly located in AC automaton matching.

[0043] See also Figure 2 The second aspect of the present invention provides a hybrid retrieval device based on knowledge graph and vector, comprising: The first query result generating unit 201 is used to obtain the user's query statement, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive the first query result of the knowledge graph; A second query result generating unit 202, configured to convert the query statement into a query vector, and match a second query result from a vector database according to the query vector; A third query result generating unit 203 is used to call a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; The fusion unit 204 is used to call the recursive ranking fusion model, and fuse the first query result, the second query result, and the third query result based on a preset weight, and output a search result.

[0044] The third aspect of the present invention provides a hybrid retrieval device based on a knowledge graph and a vector, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of the above items.

[0045] The fourth aspect of the present invention provides a computer-readable storage medium, characterized in that it stores a computer program, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of the above items.

[0046] A hybrid retrieval method based on a knowledge graph and a vector provided by the present invention first obtains a query statement of a user, converts the query statement into a Cypher query and sends it to a Neo4j engine, and receives a first query result of the knowledge graph; then, converts the query statement into a query vector, and matches a second query result from a vector database according to the query vector; then, calls a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; finally, calls a recursive ranking fusion model, and fuses the first query result, the second query result, and the third query result based on a preset weight, and outputs a retrieval result, thereby solving the problem of limitations in the retrieval capabilities of existing knowledge graphs and large language models.

[0047] Exemplarily, the computer program described in the third and fourth embodiments of the present invention may be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the device for implementing a hybrid retrieval method based on knowledge graphs and vectors. For example, the device described in the second embodiment of the present invention.

[0048] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the hybrid retrieval method based on knowledge graph and vector, and uses various interfaces and lines to connect the various parts of the hybrid retrieval method based on knowledge graph and vector.

[0049] The memory can be used to store the computer program and / or module, and the processor realizes various functions of a hybrid retrieval method based on knowledge graph and vector by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, a text conversion function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0050] Wherein, if the implemented module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0051] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0052] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A hybrid retrieval method based on knowledge graph and vector, characterized in that: include: Obtain the user's query statement, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive the first query result of the knowledge graph; Convert the query statement into a query vector, and match a second query result from a vector database according to the query vector; Calling a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; The recursive ranking fusion model is called, and the first query result, the second query result, and the third query result are fused based on a preset weight, and a search result is output, specifically: configuring preset weights for the recall paths of the first query result, the second query result, and the third query result respectively, calling the recursive ranking fusion model to calculate all documents of each recall path, and generating a fusion score; The search results are output after being sorted according to the fusion score of each recall path, wherein the expression of the recursive ranking fusion model is: ; in, is the score for each document, N is the number of recall paths, is the weight of the i-th path, K is the fusion coefficient, is the ranking of document d in the i-th path.

2. A hybrid retrieval method based on knowledge graph and vector according to claim 1, characterized in that: Obtain the user's query statement, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive the first query result of the knowledge graph, specifically: The query statement is converted into a Cypher query using a large language model, and all tags in the knowledge graph are retrieved through a Neo4j engine and the Cypher query; Filter out a corresponding subgraph according to each of the labels, and use a random sampling strategy to check entities and relationships in the subgraph to generate a check result; The first query result is output after the inspection result is cleaned.

3. According to claim 1, a hybrid retrieval method based on knowledge graph and vector is characterized in that: The converting the query statement into a query vector, and matching the second query result from a vector database according to the query vector, specifically comprises: The query statement is cleaned and converted into a query vector, matched in the vector database according to the query vector, and a second query result is output from high to low according to the similarity between the query vector and the document vector in the vector database, wherein the documents in the vector database are encoded based on a deep neural network model and converted into vectors of fixed length.

4. According to claim 1, a hybrid retrieval method based on knowledge graph and vector is characterized in that: The calling of the pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on the knowledge graph, specifically: According to the query statement, matching the name of the entity or an identifier that can uniquely identify the entity as a keyword from a pre-built AC automaton; Create an empty root node as the starting point of the dictionary tree, traverse each keyword in the keyword set, start from the root node, build a path downward character by character, for each new character, create a new node and insert it into the tree; for the node representing the complete keyword, mark it as the keyword end node; Set a failure pointer for each node. The failure pointer of the root node points to itself. For non-root nodes, recursively set the failure pointer according to the preset rules: Receive input text, scan the text content character by character, and use the path in the dictionary tree to match the current character; when the character fails to match the current state, quickly transfer to the next possible state through the failure pointer until a matching keyword is found, report all matched keywords and their associated entity identifiers, and generate a third query result.

5. A hybrid retrieval method based on knowledge graph and vector according to claim 4, characterized in that: After matching the name of the entity or the identifier that can uniquely identify the entity as a keyword from the pre-built AC automaton according to the query statement, the method further includes: The extracted keywords are split into sub-keywords by spaces or commas and stored in the form of key-value pairs, where the key is the split sub-keyword and the value is the unique identifier of the hittable entity.

6. A hybrid retrieval method based on knowledge graph and vector according to claim 4, characterized in that: For non-root nodes, the failure pointer is recursively set according to the preset rules, specifically: If the failure pointer of the parent node has a child node with the same character as the current node, the failure pointer of the current node points to the child node; If the above matching child node is not found, the failure pointer points to the failure pointer of the parent node; If the current node is a direct child of the root node, its failure pointer points to the root node.

7. A hybrid retrieval device based on knowledge graph and vector, characterized in that: include: A first query result generating unit, used to obtain a query statement of a user, convert the query statement into a Cypher query and send it to the Neo4j engine, and receive a first query result of the knowledge graph; A second query result generating unit, configured to convert the query statement into a query vector, and match a second query result from a vector database according to the query vector; A third query result generating unit, configured to call a pre-built AC automaton to automatically match the query statement to generate a third query result, wherein the AC automaton is built based on a knowledge graph; a fusion unit, used to call the recursive ranking fusion model, and fuse the first query result, the second query result, and the third query result based on a preset weight, and output a retrieval result, specifically used to: respectively configure preset weights for the recall paths of the first query result, the second query result, and the third query result, and call the recursive ranking fusion model to calculate all documents of each recall path, and generate a fusion score; The search results are output after being sorted according to the fusion score of each recall path, wherein the expression of the recursive ranking fusion model is: ; in, is the score for each document, N is the number of recall paths, is the weight of the i-th path, K is the fusion coefficient, is the ranking of document d in the i-th path.

8. A hybrid retrieval device based on knowledge graph and vector, characterized in that: It includes a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement a hybrid retrieval method based on a knowledge graph and a vector as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Intelligent question answering method and device based on medical knowledge graph

    CN113505243A

  • Intelligence intelligent question and answer method based on knowledge graph

    CN115422323A

  • Integrated retrieval dialogue method and system based on large model knowledge base and medium

    CN119088915A

  • Query techniques and ranking results for knowledge-based matching

    US20150169582A1

Cited By

  • Information retrieval method and device and medium

    CN119577126A

  • Military training method and device based on knowledge retrieval enhanced large model, equipment and medium

    CN119884329A

  • Game strategy retrieval method and device based on event-driven knowledge graph embedding

    CN120104814A

  • Retrieval enhancement letter text analysis method and system based on knowledge graph

    CN120386874A

  • A knowledge graph-based retrieval-enhanced letter text analysis method and system

    CN120386874B