Large model retrieval method, device, equipment and storage medium based on prior graph
Through the large-scale model search method based on a priori map, the problem that RAG technology may miss or introduce error information during the search process is solved, and more accurate and efficient search results are achieved.
Patent Information
- Application Number
- CN202411930729.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2044-12-26
AI Technical Summary
The existing RAG technology may miss key content or introduce error information during the search process, and obtain a large number of irrelevant or duplicate documents, increasing the burden of processing large models.
A large-scale model search method based on a priori graph is adopted. By obtaining the user input questions, reconstructing the questions to generate a question set, extracting core keywords, generating search statements, extracting relevant nodes from the priori graph database, generating metadata filtering conditions, selecting related documents from the vector database, and processing and integrating documents through truncation algorithms.
It effectively reduces the occurrence of omissions or irrelevant content, improves the accuracy and relevance of search results, and reduces the burden of processing large models.
Smart Images

Figure CN119357366B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a large model retrieval method, device, equipment and storage medium based on a priori graph. Background Art
[0002] With the rapid development of Large Language Models (LLM), their performance in natural language processing tasks has gradually approached or even surpassed that of humans. However, in order to improve the accuracy and practicality of the results generated by large models, it is usually necessary to provide the model with external knowledge base support. This framework that combines retrieval and generation is called Retrieval Augmented Generation (RAG). The RAG method searches for content related to the question in the knowledge base and provides it as context to the large model to assist in answering.
[0003] Existing RAG technology mainly relies on vector retrieval technology, which screens out relevant content by calculating the similarity between questions and documents in the knowledge base. Since vector retrieval is essentially a fuzzy match, it may miss key content or introduce erroneous information, and may obtain a large number of irrelevant or duplicate documents during the retrieval process, increasing the processing burden of large models. At the same time, the retrieved documents contain a large number of attributes that are irrelevant to the subject or field involved in the user's question.
[0004] In view of this, this application is filed. Summary of the invention
[0005] The present invention discloses a large model retrieval method, device, equipment and storage medium based on a priori graph, aiming to solve the problem that RAG technology may miss or have irrelevant content during the retrieval process.
[0006] The first aspect of the present invention provides a large model retrieval method based on a priori graph, comprising:
[0007] Obtaining a question sentence input by a user, reconstructing the question sentence to generate a question set, and extracting core keywords of each sub-question in the question set;
[0008] Generate a search statement based on the core keywords, and extract relevant nodes from the prior graph database according to the search statement;
[0009] Generate metadata screening conditions according to the node IDs of the relevant nodes, and select a preset number of vector library documents from a pre-built vector database according to the metadata screening conditions and similarity, wherein the generation process of the vector database is: extract node data from the prior graph database based on cypher query statements, and divide the node data into basic attributes and additional attributes, generate a first document based on the basic attributes and a second document based on the additional attributes and the node associated with the additional attributes, and save the first document and the second document in the vector database after adding metadata;
[0010] The vector library documents corresponding to each sub-question in the question set are sorted, and the sorted vector library documents are truncated by a truncation algorithm, the processed documents are grouped according to node IDs, and the information of the same node is synthesized into a complete document.
[0011] Preferably, generating a search statement based on the core keyword and extracting relevant nodes from the prior graph database according to the search statement is specifically:
[0012] The core keywords of each sub-question are constructed into a cypher query statement, and the search is performed according to the following preset search order until the relevant documents are retrieved and the node information is saved;
[0013] The preset search sequence includes: search query of key information in pairs, search query of single key information, and search query of question vector similarity.
[0014] Preferably, before sorting the plurality of vector library documents corresponding to each sub-question in the question set, the method further includes: performing a deduplication operation on the plurality of vector library documents.
[0015] Preferably, the expression of the truncation algorithm is:
[0016]
[0017] in, is the current dynamic cutoff threshold, is the current document score, The weight given to the current document score, i is the position of the currently processed document in the ranking.
[0018] Preferably, the processed documents are grouped according to the node ID, and the information of the same node is synthesized into a complete document, specifically:
[0019] The documents to be processed are grouped by node unique identifiers, the sorted documents are traversed, and the node unique identifier of each document is checked to see whether it has been processed.
[0020] For unprocessed documents, document content is generated based on the node type, where:
[0021] For common nodes, the document content is generated using the basic attributes and tags of the nodes;
[0022] For relationship nodes, documents are generated according to different situations, specifically:
[0023] If there is relationship information, first generate a document describing the relationship, then generate a document describing the attributes;
[0024] If there is an attribute document in the node group, the attribute document is generated first, and then the relationship document is generated;
[0025] If there is no attribute document, a relationship document is directly generated; in the process of generating the document, the relationship type and basic attributes of the node are used to build a descriptive text, and after processing each document, its node unique identifier is recorded.
[0026] The second aspect of the present invention provides a large model retrieval device based on a priori graph, comprising:
[0027] A keyword extraction unit, used to obtain a question sentence input by a user, reconstruct the question sentence to generate a question set, and extract core keywords of each sub-question in the question set;
[0028] A node extraction unit, used to generate a search statement based on the core keyword, and extract relevant nodes from the prior graph database according to the search statement;
[0029] A document extraction unit, used for generating a metadata screening condition according to the node ID of the relevant node, and selecting a preset number of vector library documents from a pre-built vector database according to the metadata screening condition and similarity, wherein the generation process of the vector database is: extracting node data from the prior graph database based on a cypher query statement, and dividing the node data into basic attributes and additional attributes, generating a first document based on the basic attributes and a second document based on the additional attributes and the node associated with the additional attributes, and adding metadata to the first document and the second document and saving them in the vector database;
[0030] The document integration unit is used to sort the multiple vector library documents corresponding to each sub-problem in the problem set, truncate the sorted multiple vector library documents through a truncation algorithm, group the processed documents according to node ID, and synthesize the information of the same node into a complete document.
[0031] The third aspect of the present invention provides a large model retrieval device based on a prior graph, characterized in that it includes a memory and a processor, the memory stores a computer program, and the computer program can be executed by the processor to implement a large model retrieval method based on a prior graph as described in any one of the above.
[0032] 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 the device where the computer-readable storage medium is located to implement a large model retrieval method based on a priori graph as described in any one of the above items.
[0033] Based on the large model retrieval method, device, equipment and storage medium based on the prior graph provided by the present invention, the question sentence input by the user is obtained, the question sentence is reconstructed to generate a question set, and the core keywords of each sub-question in the question set are extracted; then, a search statement is generated based on the core keywords, and relevant nodes are extracted from the prior graph database according to the search statement; then, metadata filtering conditions are generated according to the node ID of the relevant node, and a preset number of vector library documents are selected from the pre-constructed vector database according to the metadata filtering conditions and similarity, and finally, the multiple vector library documents corresponding to each sub-question in the question set are sorted, and the sorted multiple vector library documents are truncated by a truncation algorithm, the processed documents are grouped according to the node ID, and the information of the same node is synthesized into a complete document. The RAG technology solves the problem of missing or irrelevant content in the retrieval process. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a flowchart of a large model retrieval method based on a priori graph provided by the first embodiment of the present invention;
[0035] Figure 2 It is a module schematic diagram of a large model retrieval device based on a priori graph provided in the second embodiment of the present invention. DETAILED DESCRIPTION
[0036] 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.
[0037] 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.
[0038] 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.
[0039] 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.
[0040] 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.
[0041] 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.
[0042] 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.
[0043] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0044] The present invention discloses a large model retrieval method, device, equipment and storage medium based on a priori graph, aiming to solve the problem that RAG technology may miss or have irrelevant content during the retrieval process.
[0045] See also Figure 1 In a first aspect, the present invention provides a large model retrieval method based on a priori graph, which can be performed by a large model retrieval device based on a priori graph (hereinafter referred to as a retrieval device), in particular, by one or more processors in the auxiliary device, to implement at least the following steps:
[0046] S101, obtaining a question sentence input by a user, reconstructing the question sentence to generate a question set, and extracting core keywords of each sub-question in the question set;
[0047] In this embodiment, the retrieval device is a terminal with data processing capabilities, such as a server, workstation, desktop computer, and laptop computer. The retrieval device may be installed with a corresponding operating system and application software, and the functions required by this embodiment are realized through the combination of the operating system and application software.
[0048] Specifically, in this embodiment, the retrieval device first preprocesses the question input by the user. The preprocessing includes removing unnecessary stop words, word segmentation, grammatical analysis, and sentence structure analysis. During the parsing process, prompt words can be used to interact with the large model to generate a set of questions. Prompt words can guide the large model to split complex questions into several independent sub-questions and ensure that each sub-question remains semantically complete, such as "Who is the person in charge of a project?" and "What is the latest progress of a project?". It effectively reduces the difficulty of subsequent retrieval while avoiding missing the details implied in the question.
[0049] For each sub-question in the generated question set, the retrieval device further extracts its core keywords. Keyword extraction uses a deep language model combined with a proper noun recognition algorithm to ensure that the extracted keywords not only cover the main content of the question, but also accurately identify proper names, abbreviations, and verbs or attributes with key significance. For example, for the question "Who is the person in charge of a certain project?", the retrieval device will extract "project name" and "person in charge" as core keywords. The extraction of core keywords can reduce the redundant information that is not related to the question from being included in subsequent processing.
[0050] Furthermore, when the user inputs a question that contains implicit intentions (such as a project mentioned in the context, but without specifying the specific details), the search device can complete the key information through the context understanding mechanism, so that the extracted keywords are more in line with actual needs. For example, when the user enters "How is the progress of this project?", the search device will dynamically extract "project name" and "progress" as keywords based on the "certain project" mentioned by the user in the previous text, thereby capturing implicit information.
[0051] S102, generating a search statement based on the core keyword, and extracting relevant nodes from a priori graph database according to the search statement;
[0052] First, the core keywords of each sub-question are converted into graph query statements. The core keywords are the key elements extracted from the user's question that best represent the content of the question. In the specific implementation, the retrieval device dynamically combines these core keywords to generate a series of Cypher query statements. Cypher, as a special language for graph databases, can efficiently search for nodes and edges in complex relationship networks. For example, for the sub-question "Who is the person in charge of a certain project", if the extracted core keywords are "project name" and "person in charge", the generated query statement will be based on these two keywords and try to find the nodes in the graph and their associations.
[0053] The retrieval process adopts a gradually optimized multi-level query strategy, that is, the query is executed layer by layer according to the preset retrieval order until the node that meets the conditions is retrieved and its information is saved. This retrieval order consists of three stages. The first stage is "retrieval query of key information in pairs". In this stage, the retrieval device combines two core keywords to generate a query statement containing two keywords. This can quickly lock highly relevant nodes in the initial stage of the query. For example, for the keywords "project name" and "person in charge", the generated statement may be "MATCH (n)-[r]->(m)WHERE n.name = 'project name' AND r.role = 'person in charge' RETURN m".
[0054] If the query in the first phase fails to obtain enough node information, the retrieval device will enter the second phase, namely the "single key information retrieval query". In this phase, the retrieval device generates a broader query statement for each single keyword to expand the search scope. For example, a query statement generated using only the keyword "person in charge" may try to match more nodes with lower probability but still potentially relevant.
[0055] If the above two stages do not obtain enough results, the retrieval device will enter the third stage, namely "question vector similarity retrieval query". In this stage, the retrieval device generates a vector based on the semantic representation of the question, and matches it with the semantic representation of the nodes in the graph to make up for the lack of explicit keyword matching. Through this vector retrieval method, some implicitly related nodes can be identified.
[0056] S103, generating metadata screening conditions according to the node IDs of the relevant nodes, and selecting a preset number of vector library documents from a pre-built vector database according to the metadata screening conditions and similarity;
[0057] Specifically, after the retrieval device obtains relevant nodes in the prior graph database, it extracts the unique identifiers of these nodes, namely the node IDs, and uses these node IDs to generate metadata filtering conditions. The generation of metadata filtering conditions depends on the uniqueness of the node ID and the additional information it carries, which may include the node's label, attribute category, or relationship information associated with it. Based on the filtering conditions, the retrieval device can quickly locate documents directly related to these nodes in the vector database, avoiding interference from irrelevant content. For example, for an ID representing a project node, the generated metadata filtering conditions may include "elementId IN [node ID set] AND label is 'project'", so that relevant documents in the vector library can be accurately matched.
[0058] After generating the metadata filter conditions, the retrieval device will further filter the documents in combination with the similarity calculation. Each document in the vector database is stored in the form of a vector, which is generated by encoding the content of the document into a high-dimensional semantic representation. During the screening process, the retrieval device uses the semantic features of the relevant nodes or the semantic vectors of the user's question as a benchmark to perform similarity calculations with the documents in the vector database one by one. The similarity calculation method can be cosine similarity or vector distance calculation. During the retrieval process, the retrieval device will sort from high to low according to the similarity score, and select a preset number of documents as the final result.
[0059] Among them, the generation process of the vector database is: the retrieval device extracts the required node data from the prior graph database through a preset Cypher query statement. The extracted node data is divided into "basic attributes" and "additional attributes", wherein the basic attributes refer to the core information of the node, usually including the name, ID, label or other concise and important characteristics; and the additional attributes include the descriptive or extended information of the node, such as introduction, detailed description, additional labels, etc. In order to realize the automation and precision of attribute division, this embodiment classifies the node data through rules or algorithms, for example, based on whether the attribute name conforms to the preset pattern, the length of the attribute value or the frequency of use. After the division is completed, the basic attributes and additional attributes will enter different document generation processes respectively.
[0060] Based on the basic attributes, the retrieval device generates a first document. The first document records the key information of the node in a concise text format, for example, it is organized in the form of "attribute name is attribute value" and each attribute content is separated by a period. Taking a scientific research project node as an example, its first document may include the following content: "The name is YYYY. The English abbreviation is Y." The first document ensures an intuitive description of the core information of the node and can quickly respond to subsequent retrieval needs.
[0061] The retrieval device generates a second document for the additional attributes and their associations. The second document is further expanded on the basis of the basic attributes, combining the additional attributes with the adjacency relationship of the nodes. For example, if the additional attribute of a node is "project introduction" and its association is "affiliated organization" or "project leader", the generated second document may be described as: "The introduction is that the Y project aims to improve capabilities through the use of advanced technologies. The project leader is XX·XXX, and his rank is ZZ." The information dimension of the node is supplemented, and the relationship network in the graph is mapped to the document in a linguistic way, thereby retaining the semantic association of structured information in vectorized storage.
[0062] After the generation of the first document and the second document is completed, the retrieval device adds metadata to these documents and stores them in the vector database. Metadata includes the unique identifier (ID) of the node, the label, the attribute category, and the link information with the relationship node. The introduction of metadata ensures the uniqueness and traceability of the document on the one hand, and provides data support for subsequent metadata-based screening and sorting on the other hand. Finally, all generated documents are stored in the vector database in the form of vectors, and the text content is converted into a high-dimensional vector representation through the encoding algorithm, so that the database can efficiently support semantic retrieval.
[0063] S104, sorting the plurality of vector library documents corresponding to each sub-problem in the problem set, truncating the sorted plurality of vector library documents by a truncation algorithm, grouping the processed documents by node ID, and synthesizing information of the same node into a complete document.
[0064] Specifically, in this embodiment, in order to avoid the accumulation of duplicate documents affecting the result quality, the retrieval device will perform deduplication processing on multiple vector library documents. The deduplication rule is based on the unique identifier of the node (such as the node ID) and the semantic similarity of the document content. By merging or filtering similar documents, the retrieval device can then sort the multiple vector library documents retrieved for each sub-question according to the relevance score of the document. The calculation of the relevance score depends on the similarity between the document content vector and the user question vector. The sorting process ensures that documents with high relevance are ranked first, reducing the risk of large models being interfered by low-relevance documents in subsequent processing.
[0065] After sorting is completed, the retrieval device will apply a truncation algorithm to the documents and dynamically adjust the retention range of the results. The truncation algorithm mainly adaptively selects documents that are highly relevant to the question based on the distribution characteristics of document relevance. The algorithm dynamically calculates the truncation threshold through the following formula:
[0066]
[0067] in, is the current dynamic cutoff threshold, is the current document score, The weight assigned to the current document score, i is the position of the currently processed document in the sorting. The truncation algorithm assigns higher weights to the first documents, making the first few documents have a more significant impact on the overall threshold, while dynamically smoothing the score fluctuations. Based on this, when the relevance score of a document is lower than the current truncation threshold, the retrieval device will terminate the processing of subsequent documents to avoid redundant documents affecting the quality of the retrieval results.
[0068] After truncation, the retrieval device groups the remaining documents by node unique identifiers (such as node IDs), and integrates the information corresponding to each node to generate a complete document. During the grouping process, the retrieval device traverses the sorted document collection and checks one by one whether the node unique identifier of each document has been processed. If not, the retrieval device selects an appropriate generation strategy based on the type of node. For ordinary nodes, the retrieval device extracts their basic attributes and label information to generate concise and intuitive document content; for relational nodes, the retrieval device combines the node's relationship type and basic attributes to generate a more descriptive document. For example, if a node has a "project leader" relationship, the generated document may be "The project leader is XX·XXX, and his rank is ZZ" to clearly describe the semantic association between nodes.
[0069] In addition, in the process of processing relationship nodes, the retrieval device has designed two generation orders to adapt to different situations. If the node has relationship information, the document describing the relationship is generated first, and then the document describing the attribute is generated; if the attribute document already exists in the node group, the attribute document is supplemented first, and then the relationship document is generated; if no attribute document is available, the relationship document is generated directly. The important information of the node is retained to the maximum extent, while avoiding repeated generation or missing key content. Finally, after processing each document, its node unique identifier (such as node ID) is recorded to avoid repeated processing.
[0070] See also Figure 2 The second aspect of the present invention provides a large model retrieval device based on a priori graph, comprising:
[0071] The keyword extraction unit 201 is used to obtain a question sentence input by a user, reconstruct the question sentence to generate a question set, and extract the core keyword of each sub-question in the question set;
[0072] A node extraction unit 202, used to generate a search statement based on the core keyword, and extract relevant nodes from the prior graph database according to the search statement;
[0073] The document extraction unit 203 is used to generate a metadata screening condition according to the node ID of the relevant node, and select a preset number of vector library documents from a pre-built vector database according to the metadata screening condition and similarity, wherein the generation process of the vector database is: extracting node data from the prior graph database based on a cypher query statement, and dividing the node data into basic attributes and additional attributes, generating a first document based on the basic attributes and a second document based on the additional attributes and the node associated with the additional attributes, and adding metadata to the first document and the second document and saving them in the vector database;
[0074] The document integration unit 204 is used to sort the multiple vector library documents corresponding to each sub-question in the question set, and truncate the sorted multiple vector library documents through a truncation algorithm, group the processed documents according to node ID, and synthesize the information of the same node into a complete document.
[0075] The third aspect of the present invention provides a large model retrieval device based on a prior graph, characterized in that it includes a memory and a processor, the memory stores a computer program, and the computer program can be executed by the processor to implement a large model retrieval method based on a prior graph as described in any one of the above.
[0076] 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 the device where the computer-readable storage medium is located to implement a large model retrieval method based on a priori graph as described in any one of the above items.
[0077] Based on the large model retrieval method, device, equipment and storage medium based on the prior graph provided by the present invention, the question sentence input by the user is obtained, the question sentence is reconstructed to generate a question set, and the core keywords of each sub-question in the question set are extracted; then, a search statement is generated based on the core keywords, and relevant nodes are extracted from the prior graph database according to the search statement; then, metadata filtering conditions are generated according to the node ID of the relevant node, and a preset number of vector library documents are selected from the pre-constructed vector database according to the metadata filtering conditions and similarity, and finally, the multiple vector library documents corresponding to each sub-question in the question set are sorted, and the sorted multiple vector library documents are truncated by a truncation algorithm, the processed documents are grouped according to the node ID, and the information of the same node is synthesized into a complete document. The RAG technology solves the problem of missing or irrelevant content in the retrieval process.
[0078] Exemplarily, the computer program described in the third and fourth embodiments of the present invention can 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 can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the device for implementing a large model retrieval device based on a priori graph. For example, the device described in the second embodiment of the present invention.
[0079] 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 large model retrieval method based on a priori graph, and uses various interfaces and lines to connect the various parts of the large model retrieval method based on a priori graph.
[0080] The memory can be used to store the computer program and / or module, and the processor realizes various functions of a large model retrieval method based on a priori graph 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.
[0081] 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.
[0082] 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.
[0083] 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 large model retrieval method based on prior graph, characterized in that: include: Obtaining a question sentence input by a user, reconstructing the question sentence to generate a question set, and extracting core keywords of each sub-question in the question set; Generate a search statement based on the core keywords, and extract relevant nodes from the prior graph database according to the search statement; Generate metadata screening conditions according to the node IDs of the relevant nodes, and select a preset number of vector library documents from a pre-built vector database according to the metadata screening conditions and similarity, wherein the generation process of the vector database is: extract node data from the prior graph database based on cypher query statements, and divide the node data into basic attributes and additional attributes, generate a first document based on the basic attributes and a second document based on the additional attributes and the node associated with the additional attributes, and save the first document and the second document in the vector database after adding metadata; Based on the sorting of the plurality of vector library documents corresponding to each sub-problem in the problem set, the sorted plurality of vector library documents are truncated by a truncation algorithm, the processed documents are grouped by node ID, and the information of the same node is synthesized into a complete document, specifically: the documents to be processed are grouped by node unique identifiers, the sorted documents are traversed, and the node unique identifier of each document is checked to see whether it has been processed; for unprocessed documents, the document content is generated according to the node type, wherein: for ordinary nodes, the document content is generated using the basic attributes and labels of the nodes; for relationship nodes, documents are generated according to different situations, specifically: If there is relationship information, first generate a document describing the relationship, then generate a document describing the attributes; If there is an attribute document in the node group, the attribute document is generated first, and then the relationship document is generated; If there is no attribute document, directly generate a relationship document; in the process of generating the document, use the relationship type and basic attributes of the node to build a descriptive text, and after processing each document, record its node unique identifier. The expression of the truncation algorithm is: in, is the current dynamic cutoff threshold, is the current document score, The weight given to the current document score, i is the position of the currently processed document in the ranking.
2. A large model retrieval method based on prior graph according to claim 1, characterized in that: The generating of a search statement based on the core keyword and extracting relevant nodes from the prior graph database according to the search statement is specifically: The core keywords of each sub-question are constructed into a cypher query statement, and the search is performed according to the following preset search order until the relevant documents are retrieved and the node information is saved; The preset search sequence includes: search query of key information in pairs, search query of single key information, and search query of question vector similarity.
3. The large model retrieval method based on prior graph according to claim 1 is characterized in that: Before sorting the plurality of vector library documents corresponding to each sub-question in the question set, the method further includes: performing a deduplication operation on the plurality of vector library documents.
4. A large model retrieval device based on a priori graph, characterized in that: include: A keyword extraction unit, used to obtain a question sentence input by a user, reconstruct the question sentence to generate a question set, and extract core keywords of each sub-question in the question set; A node extraction unit, used to generate a search statement based on the core keyword, and extract relevant nodes from the prior graph database according to the search statement; A document extraction unit, used for generating a metadata screening condition according to the node ID of the relevant node, and selecting a preset number of vector library documents from a pre-built vector database according to the metadata screening condition and similarity, wherein the generation process of the vector database is: extracting node data from the prior graph database based on a cypher query statement, and dividing the node data into basic attributes and additional attributes, generating a first document based on the basic attributes and a second document based on the additional attributes and the node associated with the additional attributes, and adding metadata to the first document and the second document and saving them in the vector database; The document integration unit is used to sort the plurality of vector library documents corresponding to each sub-problem in the problem set, and to truncate the sorted plurality of vector library documents by a truncation algorithm, to group the processed documents by node ID, and to synthesize the information of the same node into a complete document, and is specifically used to: group the documents to be processed by the node unique identifier, traverse the sorted documents, and check whether the node unique identifier of each document has been processed; for the unprocessed documents, generate the document content according to the node type, wherein: for ordinary nodes, the document content is generated using the basic attributes and labels of the nodes; for relationship nodes, the document is generated according to different situations, specifically: If there is relationship information, first generate a document describing the relationship, then generate a document describing the attributes; If there is an attribute document in the node group, the attribute document is generated first, and then the relationship document is generated; If there is no attribute document, directly generate a relationship document; in the process of generating the document, use the relationship type and basic attributes of the node to build a descriptive text, and after processing each document, record its node unique identifier. The expression of the truncation algorithm is: in, is the current dynamic cutoff threshold, is the current document score, The weight given to the current document score, i is the position of the currently processed document in the ranking.
5. A large model retrieval device based on a priori graph, 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 large model retrieval method based on a priori graph as described in any one of claims 1 to 3.
6. 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 large model retrieval method based on a priori graph as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Problem data processing method and device based on artificial intelligence, equipment and medium
CN117312535A
Military domain knowledge question and answer generation method based on knowledge graph and computer system
CN118798366A
Multi-source and multi-mode fused knowledge reasoning method, system and device and medium
CN119005340A