Vector database question-answering processing method, device and storage medium integrating semantic graph
By constructing a vector database and a semantic database, and using similarity and distance to represent the relationships between answer vectors, the problem of low accuracy and efficiency in existing question-answering methods is solved, and accurate answer generation for complex queries and comprehensive utilization of multimodal data are achieved.
Patent Information
- Application Number
- CN202411097903.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-12
AI Technical Summary
Existing question-answering methods struggle to accurately understand users' true intentions, especially when dealing with complex or fuzzy queries, and they are inefficient at information retrieval and cannot provide accurate answers quickly.
By constructing a vector database and a semantic database, the answer vectors and their location information of multiple original documents are stored. Similarity and distance are used to represent the relationship between the answer vectors, and path search and vectorization are performed to generate the target answer.
It improves the accuracy and comprehensiveness of answer text, can still provide accurate answers when handling complex or fuzzy queries, and enhances the ability to utilize multimodal data.
Smart Images

Figure CN118643054B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of intelligent question-answering processing, and in particular to a vector database question-answering processing method, device and storage medium integrating semantic graphs. Background Art
[0002] In the field of natural language processing, question-answering processing methods related to the combination of large language models (LLM), retrieval-augmented generation (RAG) and vector databases can be used to process natural language, thereby promoting the intelligence and practicality of artificial intelligence. Specifically, the retrieval module in the RAG model can use a BERT-based vectorization method to map queries and documents into the same vector space, and quickly find the most relevant documents to the query by calculating the similarity between vectors. These documents are then passed to the generation module, which uses the generation capability of the LLM and combines the retrieved background information to generate coherent, accurate and informative answers.
[0003] However, this question-answering processing method relies on keyword matching and simple grammatical analysis, and it is difficult to accurately understand the user's true intentions, especially when processing complex or fuzzy queries. At the same time, when processing massive data, the information retrieval efficiency is low and it is difficult to quickly provide accurate answers. Summary of the invention
[0004] The purpose of this application is to address the deficiencies in the above-mentioned prior art and to provide a vector database question-answering processing method, device and storage medium that integrates semantic graphs, so as to solve the problem in the prior art that it is difficult to accurately understand the user's true intentions.
[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a vector database question-answering processing method integrating a semantic graph, the method comprising:
[0007] Constructing a vector database according to a plurality of original documents, wherein the vector database stores first data, the first data including: data of a plurality of original documents, the data of each original document including: a plurality of answer vectors corresponding to the text structure of the original document and position information of each answer vector, wherein the position information is used to indicate the corresponding position of the answer vector in the original document;
[0008] According to the vector database, a semantic database is constructed, wherein the semantic database stores second data, wherein the second data includes: similarities between each answer vector in the vector database, each answer vector and the position information of each answer vector;
[0009] Vectorize the query question input by the user to obtain a query vector;
[0010] Retrieving an answer text corresponding to the vector to be queried according to the first data stored in the vector database and / or the second data stored in the semantic database;
[0011] A target answer to the question to be queried is generated based on the answer text and the pre-trained large model.
[0012] In a possible implementation, retrieving the answer text corresponding to the query vector according to the first data stored in the vector database and / or the second data stored in the semantic database includes:
[0013] Retrieving at least one first intermediate vector corresponding to the vector to be queried from the vector database according to the first data stored in the vector database, and determining at least one second intermediate vector related to the position of each first intermediate vector according to the position information of each first intermediate vector, and taking each first intermediate vector and each second intermediate vector as a target intermediate vector and adding them to a target intermediate vector set;
[0014] According to the vector to be queried, the target intermediate vector set and the second data stored in the semantic database, an answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0015] In a possible implementation manner, determining, according to the position information of each first intermediate vector, at least one second intermediate vector related to the position of each first intermediate vector includes:
[0016] determining a level of the first intermediate vector in the original document;
[0017] At least one second intermediate vector related to the position of the first intermediate vector is determined according to the level of the first intermediate vector in the original document.
[0018] In a possible implementation, the retrieving an answer text corresponding to the vector to be queried from the semantic database according to the vector to be queried, the target intermediate vector set, and the second data stored in the semantic database includes:
[0019] Determine, according to the second data stored in the semantic database, a path search result of the target intermediate vector set based on a path search algorithm, wherein the path search result includes: at least one path, each of the paths includes at least one node adjacent to each other in sequence, wherein each node on the path is used to represent an answer vector in the semantic database;
[0020] Determine the distance between each node on each path and the vector to be queried according to the path search result;
[0021] The answer text corresponding to the vector to be queried is determined according to the distance between each node and the vector to be queried and the second data.
[0022] In a possible implementation manner, determining the path search result of the target intermediate vector set based on a path search algorithm according to the second data stored in the semantic database includes:
[0023] A. determining a current node from the target intermediate vector set;
[0024] B. Determine, based on the second data, at least one target vector whose similarity to the current node satisfies a preset condition, add the target vector to the path corresponding to the current node, obtain the path corresponding to the current node, and re-execute A;
[0025] C. Execute AB in a loop until all vectors in the target intermediate vector set are used as current nodes.
[0026] In a possible implementation, determining the answer text corresponding to the query vector according to the distance between each node and the query vector and the second data includes:
[0027] The distances between each node and the vector to be queried are sorted, and the answer text corresponding to the vector to be queried is determined according to the sorting result and the second data.
[0028] In a possible implementation, determining the answer text corresponding to the query vector according to the sorting result and the second data includes:
[0029] Determine at least one target answer vector that satisfies a first similarity condition according to the sorting result;
[0030] According to the target answer vector that meets the first similarity condition, an answer text corresponding to the vector to be queried is determined.
[0031] In a possible implementation, retrieving the answer text corresponding to the query vector according to the first data stored in the vector database and / or the second data stored in the semantic database includes:
[0032] Randomly extracting multiple answer vectors from the semantic database to form a random vector set;
[0033] According to the random vector set and the second data stored in the semantic database, an answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0034] In a second aspect, another embodiment of the present application provides a vector database question-answering processing device integrating a semantic graph, the device comprising:
[0035] A first construction module is used to construct a vector database according to a plurality of original documents, wherein the vector database stores first data, wherein the first data includes: data of a plurality of original documents, wherein the data of each original document includes: a plurality of answer vectors corresponding to the text structure of the original document and position information of each answer vector, wherein the position information is used to indicate a position corresponding to the answer vector in the original document;
[0036] A second construction module is used to construct a semantic database according to the vector database, wherein the semantic database stores second data, and the second data includes: similarities between each answer vector in the vector database, each answer vector and the position information of each answer vector;
[0037] A vectorization module is used to vectorize the query question input by the user to obtain a query vector;
[0038] A retrieval module, configured to retrieve an answer text corresponding to the query vector according to the first data stored in the vector database and / or the second data stored in the semantic database;
[0039] The generation module is used to generate a target answer to the question to be queried based on the answer text and the pre-trained large model.
[0040] In a possible implementation, the retrieval module is specifically used to:
[0041] According to the first data stored in the vector database, at least one first intermediate vector corresponding to the vector to be queried is retrieved from the vector database, and according to the position information of each first intermediate vector, at least one second intermediate vector related to the position of each first intermediate vector is determined, and each first intermediate vector and each second intermediate vector are respectively used as a target intermediate vector and added to a target intermediate vector set;
[0042] According to the vector to be queried, the target intermediate vector set and the second data stored in the semantic database, an answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0043] In a possible implementation, the retrieval module is specifically used to:
[0044] determining a level of the first intermediate vector in the original document;
[0045] At least one second intermediate vector related to the position of the first intermediate vector is determined according to the level of the first intermediate vector in the original document.
[0046] In a possible implementation, the retrieval module is specifically used to:
[0047] Determine, according to the second data stored in the semantic database, a path search result of the target intermediate vector set based on a path search algorithm, wherein the path search result includes: at least one path, each path includes at least one node adjacent to each other in sequence, wherein each node on the path is used to represent an answer vector in the semantic database;
[0048] Determine the distance between each node on each path and the vector to be queried according to the path search results;
[0049] The answer text corresponding to the vector to be queried is determined according to the distance between each node and the vector to be queried and the second data.
[0050] In a possible implementation, the retrieval module is specifically used to:
[0051] A. determining a current node from the target intermediate vector set;
[0052] B. Determine, based on the second data, at least one target vector whose similarity to the current node satisfies a preset condition, add the target vector to the path corresponding to the current node, obtain the path corresponding to the current node, and re-execute A;
[0053] C. Execute AB in a loop until all vectors in the target intermediate vector set are used as current nodes.
[0054] In a possible implementation, the retrieval module is specifically used to:
[0055] The distances between each node and the vector to be queried are sorted, and the answer text corresponding to the vector to be queried is determined according to the sorting result and the second data.
[0056] In a possible implementation, the retrieval module is specifically used to:
[0057] Determine at least one target answer vector that satisfies a first similarity condition according to the sorting result;
[0058] According to the target answer vector that meets the first similarity condition, an answer text corresponding to the vector to be queried is determined.
[0059] In a possible implementation, the retrieval module is specifically used to:
[0060] Randomly extracting multiple answer vectors from the semantic database to form a random vector set;
[0061] According to the random vector set and the second data stored in the semantic database, an answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0062] In the third aspect, another embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of any method described in the first aspect above.
[0063] In a fourth aspect, another embodiment of the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any method described in the first aspect are executed.
[0064] The beneficial effects of the present application are: a vector database storing first data is constructed through multiple original documents, and a semantic database storing second data is constructed through the vector database, which can store answer vectors in multiple original documents and the association relationship between each answer vector, and on this basis, the question to be queried input by the user is vectorized to obtain the vector to be queried, and the answer text corresponding to the vector to be queried is retrieved according to the first data stored in the vector database and / or the second data stored in the semantic database, so that the target answer to the question to be queried can be generated according to the answer text and the large model obtained by pre-training. The present application allows the corresponding answer text to be retrieved from the vector database and / or the semantic database when searching for the question to be queried input by the user, thereby improving the flexibility in the process of obtaining the answer text, and is no longer limited to keyword matching and simple grammatical analysis, and can improve the accuracy of the obtained answer text.
[0065] At the same time, since the vector database stores multiple answer vectors corresponding to the text structure of the original document and the location information of each answer vector, and the semantic database stores each answer vector and the location information of each answer vector, the text structure of the original document can be represented as a whole, so that the retrieved answer text includes other content such as pictures or formulas in the original document, thereby ensuring the richness and accuracy of the answer text.
[0066] In addition, by using similarity or distance to characterize the correlation between answer vectors in the semantic database, the connection between multiple original documents can be taken into consideration, so that more and more comprehensive answer texts related to the query question can be obtained, and the deep connection between a single text slice and the global text slice can be reflected, providing a breadth search capability that goes beyond the vector database, which can not only improve the accuracy of the answer text obtained, but also improve the comprehensiveness of the answer text obtained, and can also obtain accurate answer text when processing complex or fuzzy queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0068] Figure 1 A schematic diagram of a flow chart of a vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application;
[0069] Figure 2A schematic diagram of a process for retrieving an answer text corresponding to a vector to be queried in a vector database question-answering processing method integrating a semantic graph provided in an embodiment of the present application;
[0070] Figure 3 A schematic diagram of a flow chart for determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application;
[0071] Figure 4 A schematic diagram of determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application;
[0072] Figure 5 Another schematic diagram of determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application;
[0073] Figure 6 A schematic diagram of a process for retrieving an answer text corresponding to a vector to be queried from a semantic database in a vector database question-answering processing method integrating a semantic graph provided in an embodiment of the present application;
[0074] Figure 7 A schematic diagram of a process for determining the path search results of the target intermediate vector set in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application;
[0075] Figure 8 A schematic diagram of a process for determining an answer text corresponding to a vector to be queried in a vector database question-answering processing method integrating a semantic graph provided in an embodiment of the present application;
[0076] Fig. 9 A schematic diagram of determining the answer text corresponding to the vector to be queried in the vector database question-answering processing method integrating the semantic graph provided in an embodiment of the present application;
[0077] Fig.10 Another schematic diagram of a process for retrieving an answer text corresponding to a vector to be queried in the vector database question-answering processing method for integrating a semantic graph provided in an embodiment of the present application;
[0078] Fig.11 A schematic diagram of a vector database question-answering processing device integrating a semantic graph provided in an embodiment of the present application;
[0079] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0081] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0082] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0083] The existing intelligent question-answering systems rely on keyword matching and simple grammatical analysis, which makes it difficult to accurately understand the user's true intentions, especially when dealing with complex or fuzzy queries. At the same time, when dealing with massive amounts of data, the information retrieval efficiency is low and it is difficult to quickly provide accurate answers. In addition, most of the existing intelligent question-answering systems only process text information and cannot comprehensively utilize multimodal data such as images, audio, and video to enhance question-answering capabilities.
[0084] Based on the above problems, the embodiment of the present application proposes a vector database question-answering processing method integrated with a semantic graph, which constructs a vector database storing first data through multiple original documents, and constructs a semantic database storing second data through the vector database. On this basis, the question to be queried input by the user is vectorized to obtain the vector to be queried, and the answer text corresponding to the vector to be queried is retrieved based on the first data stored in the vector database and / or the second data stored in the semantic database, so that the target answer to the question to be queried can be generated based on the answer text and the pre-trained large model. When searching for the question to be queried input by the user, the corresponding answer text can be retrieved from the vector database and / or the semantic database, which is no longer limited to keyword matching and simple grammatical analysis, and the accuracy of the obtained answer text can be improved.
[0085] The following is a detailed description of the vector database question-answering processing method integrating semantic graphs provided in an embodiment of the present application.
[0086] Figure 1 A flowchart of a vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application is provided. Figure 1 As shown, the execution subject of the method can be any electronic device with processing capability, and the method includes:
[0087] S101. Construct a vector database according to a plurality of original documents.
[0088] It can be understood that before querying the question to be queried input by the user, the knowledge can be stored first, and the association relationship between the knowledge can be established, so that the answer to the question to be queried input by the user can be retrieved. Specifically, multiple original documents can be processed to obtain first data, and the first data can be stored in a vector database to realize the construction of the vector database.
[0089] Optionally, multiple original documents may be parsed separately to obtain the contents of the parsed original documents, and the parsed original documents may be structurally aligned and vectorized using a pre-trained text vector model before being stored in a vector database.
[0090] The vector database stores first data, which includes data of multiple original documents, and the data of each original document includes multiple answer vectors corresponding to the text structure of the original document and position information of each answer vector, and the position information is used to indicate the corresponding position of the answer vector in the original document. Exemplarily, the corresponding position of the answer vector in the original document can be represented by the parent node or child node corresponding to the answer vector in the text structure of the original document. Optionally, the data of each original document may also include pictures or formulas in each original document, and the first data may also include primary key values in the vector database, etc.
[0091] Exemplarily, the original document may be an original document in different file formats, such as Portable Document Format (PDF type), Microsoft Word Document (doc) format or Microsoft Office Open XML Word Document (docx) format, and the original document may include text, pictures, formulas and other contents.
[0092] Exemplarily, different parsing functions may be called to parse the original document according to different file formats to identify the text structure of the original document, wherein the text structure of the original document may include a title, body content, and other content (pictures or formulas, etc.).
[0093] Exemplarily, after obtaining the text structure of the original document, the title and body content in the original document can be assigned to parent-child nodes according to the text structure of the original document, and other content can be embedded in the body content according to the position in the original document. The body content of the original document obtained after processing is vectorized through the BAAI General Embedding Model 3 (bge-m3 for short) text vector model, and multiple answer vectors obtained after vectorization are stored according to the position of the answer vector in the original document, thereby realizing the construction of a vector database.
[0094] Specifically, the text in the body of the original document obtained after processing is vectorized through the bge-m3 text vector model, and other content in the body of the original document obtained after processing is directly stored so that the original document can be stored according to the text structure in the original document.
[0095] That is to say, when constructing a vector database, the original document is parsed, and each sentence in the original document is extracted, and each sentence is processed as a node, so that each node has a corresponding parent node or child node, and other content in the original document can be associated with the node in the original document. On this basis, the original document is vectorized and converted into multiple answer vectors according to the text structure of the original document, and the multiple answer vectors, the corresponding positions of the answer vectors in the original document, and other content in the original document are stored in the vector database to obtain a vector database, which can increase the structurality of the first data stored in the vector database, thereby improving the accuracy and richness of the obtained answer text.
[0096] S102. Construct a semantic database based on the vector database.
[0097] It can be understood that after the vector database is constructed, the first data in multiple original documents can be stored. On this basis, the association relationship between the first data in the vector database can be represented by constructing a semantic database.
[0098] Optionally, the first data stored in the vector database may be processed to obtain second data, which is then stored in a semantic database to implement the construction of the semantic database. The semantic database stores the second data, which includes: the similarity between each answer vector in the vector database, each answer vector, and the position information of each answer vector.
[0099] Exemplarily, each answer vector in the first data stored in the vector database may be respectively regarded as a node, and the similarity between the nodes is calculated, and the similarity between the nodes and each node are stored in the semantic database.
[0100] Exemplarily, the distance between each node can be obtained according to the similarity between each node, and each node can be rendered according to the distance between each node to obtain a semantic graph corresponding to the semantic database.
[0101] That is to say, in the semantic database, the association relationship between the answer vectors can be characterized by similarity or distance. The greater the similarity between the answer vectors, the shorter the distance between the answer vectors. The smaller the similarity between the answer vectors, the greater the distance between the answer vectors. The association relationship between the multiple answer vectors obtained based on the multiple original documents can be characterized by the similarity or distance between the answer vectors, that is, the association between the multiple original documents can be characterized. Exemplarily, the relationship between the similarity and distance between the answer vectors can be: the sum of the similarity and distance between the answer vectors is 1.
[0102] S103: vectorize the query question input by the user to obtain a query vector.
[0103] It can be understood that after the vector database and the semantic database are constructed, the query questions input by the user can be obtained, and the target answers to the query questions input by the user can be obtained through processing, and then replied to the user.
[0104] Optionally, the query question input by the user may be preprocessed and then vectorized using the bge-m3 text vector model to obtain a query vector corresponding to the query question, so that the query vector can be queried in a vector database and / or a semantic database. The preprocessing may include word segmentation, stop word removal, part-of-speech tagging, and spelling correction.
[0105] S104: retrieve answer text corresponding to the query vector according to the first data stored in the vector database and / or the second data stored in the semantic database.
[0106] It can be understood that after obtaining the query vector corresponding to the query question, the query vector can be retrieved according to the first data stored in the vector database and / or the second data stored in the semantic database, so as to obtain the answer text corresponding to the query vector. In other words, the answer text corresponding to the query vector is stored in both the vector database and the semantic database, and the answer text corresponding to the query vector can be retrieved from the vector database, or from the semantic database, or the answer text corresponding to the query vector can be retrieved according to the vector database and the semantic database.
[0107] Optionally, the answer text corresponding to the query vector can be retrieved based on the first data stored in the vector database. Specifically, based on the query vector, the first data stored in the vector database can be searched according to the similarity between each answer vector and the query vector to obtain the answer vector that meets the similarity condition, and the answer text corresponding to the query vector can be obtained based on the position information of the answer vector.
[0108] Optionally, the answer text corresponding to the query vector can be retrieved based on the second data stored in the semantic database. Specifically, the second data stored in the semantic database can be searched according to similarity to obtain the answer text corresponding to the query vector.
[0109] Optionally, the answer text corresponding to the query vector can be retrieved based on the first data stored in the vector database and the second data stored in the semantic database. Specifically, one or more answer vectors related to the query vector can be first searched from the vector database, and based on the one or more answer vectors, the semantic database is searched according to the similarity or distance between the answer vectors to obtain the answer text corresponding to the query vector.
[0110] By retrieving the answer text corresponding to the vector to be queried through the first data stored in the vector database and / or the second data stored in the semantic database, the flexibility in the process of obtaining the answer text can be improved.
[0111] S105: Generate a target answer to the question to be queried based on the answer text and the pre-trained large model.
[0112] Optionally, after obtaining the answer text, the answer text may be input into a pre-trained large language model, which processes the answer text to generate a target answer to the question to be queried and provide a chain reply to the user.
[0113] Exemplarily, after obtaining the answer text, the answer text can be input into a pre-trained large language model, and the large language model will judge the answer text. If it is judged to be an answer text that directly answers the question, the large language model will directly generate a target answer to the question to be queried based on the answer text; if it is judged to require a retrieval augmented generation (rag) strategy, the large language model can process the answer text to generate a target answer to the question to be queried.
[0114] In this embodiment, a vector database storing first data is constructed through multiple original documents, and a semantic database storing second data is constructed through the vector database, which can store answer vectors in multiple original documents and the association relationship between each answer vector. On this basis, the question to be queried input by the user is vectorized to obtain the vector to be queried, and the answer text corresponding to the vector to be queried is retrieved based on the first data stored in the vector database and / or the second data stored in the semantic database, so that the target answer to the question to be queried can be generated based on the answer text and the pre-trained large model. The present application allows the corresponding answer text to be retrieved from the vector database and / or the semantic database when searching for the question to be queried input by the user, thereby improving the flexibility in the process of obtaining the answer text, and is no longer limited to keyword matching and simple grammatical analysis, which can improve the accuracy of the answer text obtained.
[0115] At the same time, since the vector database stores multiple answer vectors corresponding to the text structure of the original document and the location information of each answer vector, and the semantic database stores each answer vector and the location information of each answer vector, the text structure of the original document can be represented as a whole, so that the retrieved answer text includes other content such as pictures or formulas in the original document, thereby ensuring the richness and accuracy of the answer text.
[0116] In addition, by using similarity or distance to characterize the correlation between answer vectors in the semantic database, the connection between multiple original documents can be taken into consideration, so that more and more comprehensive answer texts related to the query question can be obtained, and the deep connection between a single text slice and the global text slice can be reflected, providing a breadth search capability that goes beyond the vector database, which can not only improve the accuracy of the answer text obtained, but also improve the comprehensiveness of the answer text obtained, and can also obtain accurate answer text when processing complex or fuzzy queries.
[0117] Figure 2 A schematic diagram of a flow chart for retrieving an answer text corresponding to a vector to be queried in a vector database question-answering processing method integrating a semantic graph provided in an embodiment of the present application.
[0118] In one possible implementation, referring to Figure 2 As shown, in the above step S104, when the answer text corresponding to the query vector is retrieved according to the first data stored in the vector database and / or the second data stored in the semantic database, it includes:
[0119] S201. According to first data stored in a vector database, retrieve at least one first intermediate vector corresponding to a vector to be queried from the vector database, and according to position information of each first intermediate vector, determine at least one second intermediate vector related to the position of each first intermediate vector, and take each first intermediate vector and each second intermediate vector as a target intermediate vector and add them to a target intermediate vector set.
[0120] Optionally, the first data stored in the vector database can be searched to obtain at least one first intermediate vector that satisfies a preset first vector similarity condition with the vector to be queried, and based on the position information of each first intermediate vector, at least one second intermediate vector related to the position of each first intermediate vector is determined, and each first intermediate vector and each second intermediate vector are respectively taken as a target intermediate vector and added to a target intermediate vector set.
[0121] Exemplarily, based on the vector to be queried, the first data stored in the vector database can be searched, and the answer vector that meets the preset first vector similarity condition can be used as the first intermediate vector, and the answer vector corresponding to the parent node or child node corresponding to the first intermediate vector can be used as the second intermediate vector, and the first intermediate vector and the second intermediate vector can be used as a target intermediate vector respectively and added to the target intermediate vector set.
[0122] Exemplarily, the preset first vector similarity condition may be a quantity threshold condition satisfied by the first intermediate vector, or may be a similarity value requirement satisfied by the first intermediate vector with the vector to be queried. For example, the preset first vector similarity condition may be: taking the answer vector whose similarity with the vector to be queried is greater than the similarity threshold as the first intermediate vector, or taking the answer vectors with the top K similarity values after sorting the similarity with the vector to be queried as the first intermediate vector, where K is a positive integer and may be configured in advance by the user.
[0123] S202: According to the vector to be queried, the target intermediate vector set and the second data stored in the semantic database, retrieve the answer text corresponding to the vector to be queried from the semantic database.
[0124] Optionally, after obtaining the target intermediate vector set, a search may be performed in the second data stored in the semantic database based on the query vector and each target intermediate vector in the target intermediate vector set, so as to obtain an answer text corresponding to the query vector.
[0125] That is to say, when the answer text corresponding to the vector to be queried is retrieved based on the first data stored in the vector database and the second data stored in the semantic database, the target intermediate vector that may serve as the answer text can be first retrieved from the first data stored in the vector database according to the similarity between the vectors, and a target intermediate vector set can be obtained. Thus, based on the vector to be queried, the target intermediate vector set, and the second data stored in the semantic database, all answer vectors that have an association relationship with the target intermediate vector can be retrieved, and based on the obtained similarity or distance, the answer text corresponding to the vector to be queried can be obtained, which can not only improve the accuracy of the obtained answer text, but also improve the comprehensiveness of the obtained answer text.
[0126] Figure 3 A schematic flow chart of determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application.
[0127] In one possible implementation, referring to Figure 3As shown, in the above step S201, when determining at least one second intermediate vector related to the position of each first intermediate vector according to the position information of each first intermediate vector, it includes:
[0128] S301: Determine the level of a first intermediate vector in an original document.
[0129] Optionally, after obtaining the first intermediate vector, the level of the first intermediate vector in the original document may be determined according to the position information of the first intermediate vector, that is, the parent node and the child node of the first intermediate vector in the original document may be determined.
[0130] S302: Determine at least one second intermediate vector related to the position of the first intermediate vector according to the level of the first intermediate vector in the original document.
[0131] Optionally, after obtaining the level of the first intermediate vector in the original document, at least one second intermediate vector that is position-related to the first intermediate vector may be determined, wherein position correlation means that the second intermediate vector and the first intermediate vector are parent nodes or child nodes in the text structure of the original document, or the second intermediate vector and the first intermediate vector have the same parent node or child node in the text structure of the original document.
[0132] For example, Figure 4 A schematic diagram of determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application, with reference to Figure 4 As shown, assuming that the text structure of the original document includes Title 1, Title 2, and multiple levels of sub-nodes under Title 1 and Title 2, and assuming that the first intermediate vector determined at this time is the answer vector corresponding to "Main Text 2.2.1.1", in a possible example, continue to refer to Figure 4 As shown, the answer vector corresponding to all contents under the parent node of "Main Text 2.2.1.1" can be used as the second intermediate vector, that is, the answer vector corresponding to all contents under "Title 2.2.1" can be used as the second intermediate vector to obtain multiple second intermediate vectors related to the position of "Main Text 2.2.1.1".
[0133] For example, Figure 5 Another schematic diagram of determining at least one second intermediate vector related to the position of each first intermediate vector in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application, referring to Figure 5As shown, assuming that the text structure of the original document includes Title 1, Title 2, and multiple levels of child nodes under Title 1 and Title 2, and assuming that the first intermediate vector determined at this time is the answer vector corresponding to "Main Text 2.2.1.1", in a possible example, the answer vector corresponding to all the contents under the parent node of the parent node of "Main Text 2.2.1.1" can be used as the second intermediate vector, that is, the answer vector corresponding to all the contents under "Title 2.2" can be used as the second intermediate vector, and multiple second intermediate vectors related to the position of "Main Text 2.2.1.1" can be obtained.
[0134] By determining the level of the first intermediate vector in the original document and determining at least one second intermediate vector related to the position of the first intermediate vector based on the level of the first intermediate vector in the original document, the text structure of the original document can be taken into consideration in the process of determining the answer text, thereby increasing the structure and comprehensiveness of the obtained answer text.
[0135] Figure 6 A schematic diagram of a flow chart of retrieving answer text corresponding to a vector to be queried from a semantic database in a vector database question-answering processing method integrating a semantic graph provided in an embodiment of the present application.
[0136] In one possible implementation, referring to Figure 6 As shown, in the above step S202, when the answer text corresponding to the query vector is retrieved from the semantic database according to the query vector, the target intermediate vector set and the second data stored in the semantic database, it includes:
[0137] S601 . Determine a path search result of a target intermediate vector set based on a path search algorithm according to second data stored in a semantic database.
[0138] It can be understood that after obtaining the target intermediate vector set, that is, determining the target intermediate vectors that may serve as the answer text, then, each target intermediate vector in the target intermediate vector set can be used as a starting point to search the second data stored in the semantic database by similarity or distance to obtain the path search results of each target intermediate vector, so that the answer text corresponding to the vector to be queried can be obtained based on the path search results of each target intermediate vector.
[0139] The path search result includes: at least one path, and each node on the path is used to represent an answer vector in the semantic database. The path search algorithm can be a shortest path algorithm without negative weight edges, such as Dijkstra algorithm (Dijkstra algorithm for short), or other path search algorithms, such as Bellman-Ford algorithm (Bellman-Ford algorithm for short), Floyd algorithm (Floyd algorithm for short), and shortest path fast algorithm (SPFA algorithm for short).
[0140] That is to say, since similarity or distance is used to characterize the association relationship between each answer vector in the semantic database, when searching the second data in the semantic database, the answer vector with a high similarity to the target intermediate vector can be determined based on the target intermediate vector, and the answer vectors with a high similarity to the answer vector can be determined respectively, so that the path search results of the target intermediate vector can be finally formed through the nodes corresponding to the searched answer vectors, the distances between the nodes and the search path.
[0141] By using the second data stored in the semantic database, the path search results of each target intermediate vector in the target intermediate vector set are determined based on the path search algorithm, and similar answer vectors between multiple original documents can be searched, so that more and more comprehensive answer texts related to the question to be queried can be obtained, and at the same time, the search efficiency and search speed can be improved.
[0142] S602: Determine the distance between each node on each path and the vector to be queried according to the path search results.
[0143] Optionally, after obtaining the path search results of the target intermediate vector set, multiple answer vectors that may serve as answer texts are obtained. On this basis, the distance between each node on each path and the vector to be queried can be calculated according to the path search results, so that the multiple answer vectors can be screened by the distance between each node on each path and the vector to be queried to obtain the answer text corresponding to the vector to be queried.
[0144] S603: Determine the answer text corresponding to the query vector according to the distance between each node and the query vector and the second data.
[0145] Optionally, after obtaining the distance between each node and the vector to be queried, the similarity between the answer vector corresponding to each node and the vector to be queried can be characterized by the distance between each node and the vector to be queried. That is, the similarity between the answer vector corresponding to each node in the second data and the vector to be queried can be determined based on the distance between each node and the vector to be queried. Therefore, the similarity between the answer vector corresponding to each node in the second data and the vector to be queried can be determined, and the answer vectors in the second data can be screened, and the answer vector with a higher similarity to the vector to be queried can be used as the answer text corresponding to the vector to be queried.
[0146] By determining the answer text corresponding to the vector to be queried through the path search results in the target intermediate vector set and the second data, the accuracy of the obtained answer text can be guaranteed.
[0147] Figure 7 A schematic flow chart of determining the path search results of the target intermediate vector set in the vector database question-answering processing method for integrating semantic graphs provided in an embodiment of the present application.
[0148] In one possible implementation, referring to Figure 7 As shown, in the above step S601, when determining the path search result of the target intermediate vector set based on the path search algorithm according to the second data stored in the semantic database, it includes:
[0149] S701. Determine a current node from a target intermediate vector set.
[0150] Optionally, when determining the path search results of the target intermediate vector set, the path search can be performed separately according to each target intermediate vector in the target intermediate vector set, that is, the current node can be determined from the target intermediate vector set first, and the current node can be a target intermediate vector in the target intermediate vector set.
[0151] S702. Determine, based on the second data, at least one target vector whose similarity to the current node satisfies a preset condition, add the target vector to the path of the current node, obtain the path corresponding to the current node, and re-execute S701.
[0152] Optionally, after obtaining the current node, the target vector with the shortest distance to the current node can be searched in the second data, and the target vector is added to the path of the current node as the new current node in the path. Taking the new current node as the starting point, continue to search in the second data for the target vector with the shortest distance to the new current node, and continue to add the searched target vector to the path of the current node, and continue to loop until there is no target vector whose similarity with the new current node meets the preset conditions, and the path of the current node is obtained after the loop ends.
[0153] Optionally, after obtaining the path of the current node, S701 may be re-executed to determine a new current node, ie, the next target intermediate vector, and search for the path of the new current node, and add it to the path search result of the target intermediate vector set.
[0154] S703, executing S701-S702 in a loop until all vectors in the target intermediate vector set have been used as current nodes.
[0155] Optionally, S701 - S702 are executed in a loop until all target intermediate vectors in the target intermediate vector set are used as current nodes, and a path search result of the target intermediate vector set is obtained.
[0156] That is to say, in order to obtain the path search result of the target intermediate vector set, each target intermediate vector in the target intermediate vector set can be used as a search starting point to search for a path with the shortest distance, thereby obtaining the path search result of the target intermediate vector set, thereby ensuring the accuracy of the path search result of the target intermediate vector set.
[0157] In a possible implementation, in the above step S603, determining the answer text corresponding to the query vector according to the distance between each node and the query vector and the second data includes:
[0158] The distances between each node and the vector to be queried are sorted, and the answer text corresponding to the vector to be queried is determined according to the sorting result and the second data.
[0159] Optionally, after obtaining the distance between each node and the vector to be queried, the distance between each node and the vector to be queried can be sorted, that is, the similarity between each node in the path search result of the target intermediate vector set and the vector to be queried is sorted, and based on the sorting result, multiple answer vectors that have a similarity relationship with the vector to be queried are obtained, and the answer text corresponding to the vector to be queried is obtained from the multiple answer vectors that have a similarity relationship with the vector to be queried in the second data.
[0160] Figure 8 Another flowchart diagram of determining the answer text corresponding to the vector to be queried in the vector database question and answer processing method integrated with the semantic graph provided in the embodiment of the present application.
[0161] In one possible implementation, referring to Figure 8 As shown, the above steps determine the answer text corresponding to the query vector according to the sorting result and the second data, including:
[0162] S801. Determine at least one target answer vector that meets a first similarity condition according to the sorting result.
[0163] Optionally, at least one target answer vector satisfying the first similarity condition may be obtained from the sorting results in order of similarity from high to low.
[0164] S802: Determine the answer text corresponding to the query vector according to the target answer vector that meets the first similarity condition.
[0165] Optionally, after obtaining at least one target answer vector satisfying the first similarity condition in order of similarity from high to low, the at least one target answer vector satisfying the first similarity condition may be used as the answer text corresponding to the vector to be queried.
[0166] Exemplarily, the text corresponding to at least one target answer vector that meets the first similarity condition may be restored to the content in the original document as the answer text corresponding to the query vector.
[0167] For example, Fig. 9 A schematic diagram of determining the answer text corresponding to the query vector in the vector database question-answering processing method for integrating the semantic graph provided in the embodiment of the present application, referring to Fig. 9 As shown, the target intermediate vector can be the answer vector corresponding to nodes A1, A2 and A3, the path search result of node A1 can be the path corresponding to "A1-B1-C1-D1-E1-F1", the path search result of node A2 can be the path corresponding to "A2-B2-C2-D2-E2-F2-G2", and the path search result of node A3 can be the path corresponding to "A3-B3-C3-D3-E3", and the nodes "B1, C1, D1, E1, F1, B2, C2, D2, E2, F2, G2, B3, C3, D3, E3" are all added to the path search result of the target intermediate vector set.
[0168] For example, continue to refer to Fig. 9 As shown, the similarities between all nodes in the path search results of the target intermediate vector set and the vector to be queried can be calculated respectively, and the similarities between all nodes and the vector to be queried can be sorted. The answer vectors corresponding to the S nodes with the largest similarity are selected, and vector restoration processing is performed to obtain the answer text corresponding to the vector to be queried, where S is a positive integer.
[0169] By sorting the results, at least one target answer vector satisfying the first similarity condition is determined, and based on the at least one target answer vector satisfying the first similarity condition, the answer text corresponding to the query vector is determined, which can not only improve the accuracy of the obtained answer text, but also improve the comprehensiveness of the obtained answer text.
[0170] Fig.10Another flowchart diagram of retrieving the answer text corresponding to the vector to be queried in the vector database question and answer processing method integrated with the semantic graph provided in the embodiment of the present application.
[0171] In one possible implementation, referring to Fig.10 As shown, in the above step S104, according to the first data stored in the vector database and / or the second data stored in the semantic database, the answer text corresponding to the query vector is retrieved, including:
[0172] S1001. Randomly extract multiple answer vectors from a semantic database to form a random vector set.
[0173] Optionally, a random extraction algorithm may be used to randomly extract S answer vectors from the semantic database to form a random vector set.
[0174] S1002: According to the random vector set and the second data stored in the semantic database, retrieve the answer text corresponding to the vector to be queried from the semantic database.
[0175] Optionally, after obtaining the random vector set, the second data stored in the semantic database may be searched based on each random vector in the random vector set, so as to obtain the answer text corresponding to the query vector. Specifically, when searching based on each random vector in the random vector set, the above steps S601-S603 may be referred to for execution.
[0176] That is to say, when the answer text corresponding to the vector to be queried is retrieved from the second data stored in the semantic database, several answer vectors can be randomly extracted from the second data stored in the semantic database as random vectors that may serve as the answer text, and a random vector set can be obtained. Then, the answer vector that has an association relationship with the random vector is searched based on the path search algorithm, and the answer text corresponding to the vector to be queried is obtained based on the obtained similarity or distance. This allows question and answer processing of the vector to be queried to be realized relying solely on the semantic database, and at the same time, the accuracy and comprehensiveness of the answer text obtained can be guaranteed.
[0177] Based on the same inventive concept, the embodiment of the present application also provides a vector database question and answer processing device for a fused semantic graph corresponding to the vector database question and answer processing method for a fused semantic graph. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the vector database question and answer processing method for a fused semantic graph mentioned above in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0178] Fig.11 A schematic diagram of a vector database question-answering processing device integrating a semantic graph provided in an embodiment of the present application, referring to Fig.11As shown, the device includes: a first construction module 1101, a second construction module 1102, a vectorization module 1103, a retrieval module 1104 and a generation module 1105.
[0179] A first construction module 1101 is used to construct a vector database according to a plurality of original documents, wherein the vector database stores first data, the first data including: data of a plurality of original documents, wherein the data of each original document includes: a plurality of answer vectors corresponding to the text structure of the original document and position information of each answer vector, wherein the position information is used to indicate the corresponding position of the answer vector in the original document;
[0180] The second construction module 1102 is used to construct a semantic database according to the vector database, wherein the semantic database stores second data, and the second data includes: similarities between answer vectors in the vector database, each answer vector and position information of each answer vector;
[0181] A vectorization module 1103 is used to vectorize the query question input by the user to obtain a query vector;
[0182] A retrieval module 1104 is used to retrieve an answer text corresponding to the query vector according to the first data stored in the vector database and / or the second data stored in the semantic database;
[0183] The generation module 1105 is used to generate a target answer to the question to be queried based on the answer text and the pre-trained large model.
[0184] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0185] According to the first data stored in the vector database, at least one first intermediate vector corresponding to the vector to be queried is retrieved from the vector database, and according to the position information of each first intermediate vector, at least one second intermediate vector related to the position of each first intermediate vector is determined, and each first intermediate vector and each second intermediate vector are respectively used as a target intermediate vector and added to a target intermediate vector set;
[0186] According to the vector to be queried, the target intermediate vector set and the second data stored in the semantic database, the answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0187] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0188] determining a level of the first intermediate vector in the original document;
[0189] At least one second intermediate vector related to the position of the first intermediate vector is determined according to the level of the first intermediate vector in the original document.
[0190] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0191] Determine, based on the second data stored in the semantic database, a path search result of the target intermediate vector set based on a path search algorithm, the path search result comprising: at least one path, each path comprising at least one node adjacent in sequence, wherein each node on the path is respectively used to represent an answer vector in the semantic database;
[0192] According to the path search results, determine the distance between each node on each path and the query vector;
[0193] The answer text corresponding to the vector to be queried is determined according to the distance between each node and the vector to be queried and the second data.
[0194] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0195] A. Determine the current node from the target intermediate vector set;
[0196] B. Determine, based on the second data, at least one target vector whose similarity to the current node satisfies a preset condition, add the target vector to the path corresponding to the current node, obtain the path corresponding to the current node, and re-execute A;
[0197] C. Loop through AB until all vectors in the target intermediate vector set are used as current nodes.
[0198] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0199] The distances between each node and the vector to be queried are sorted, and the answer text corresponding to the vector to be queried is determined according to the sorting result and the second data.
[0200] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0201] Determine at least one target answer vector that satisfies a first similarity condition according to the sorting result;
[0202] An answer text corresponding to the query vector is determined according to the target answer vector that meets the first similarity condition.
[0203] In a possible implementation, the retrieval module 1104 is specifically configured to:
[0204] Randomly extract multiple answer vectors from the semantic database to form a random vector set;
[0205] According to the random vector set and the second data stored in the semantic database, the answer text corresponding to the vector to be queried is retrieved from the semantic database.
[0206] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0207] The present application also provides an electronic device, such as Fig.12 As shown, Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application includes: a processor 1201, a memory 1202, and optionally, a bus 1203. The memory 1202 stores machine-readable instructions executable by the processor 1201 (for example, Fig.11 The device includes the first construction module 1101, the second construction module 1102, the vectorization module 1103, the retrieval module 1104 and the execution instructions corresponding to the generation module 1105, etc.), when the electronic device is running, the processor 1201 communicates with the memory 1202 through the bus 1203, and when the machine-readable instructions are executed by the processor 1201, the steps of the vector database question and answer processing method integrating the semantic graph are executed.
[0208] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the vector database question-answering processing method for integrating semantic graphs are executed.
[0209] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0210] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function 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 this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.
[0211] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A vector database question answering processing method integrating semantic graph, characterized in that: include: Constructing a vector database according to a plurality of original documents, wherein the vector database stores first data, the first data including: data of a plurality of original documents, the data of each original document including: a plurality of answer vectors corresponding to the text structure of the original document and position information of each answer vector, wherein the position information is used to indicate the corresponding position of the answer vector in the original document; According to the vector database, a semantic database is constructed, wherein the semantic database stores second data, wherein the second data includes: similarities between each answer vector in the vector database, each answer vector and the position information of each answer vector, and the semantic graph is a semantic graph corresponding to the semantic database; Vectorize the query question input by the user to obtain a query vector; Retrieving an answer text corresponding to the vector to be queried according to the first data stored in the vector database and / or the second data stored in the semantic database; Generate a target answer to the question to be queried based on the answer text and the pre-trained large model; The retrieving the answer text corresponding to the vector to be queried according to the first data stored in the vector database and / or the second data stored in the semantic database includes: Retrieving at least one first intermediate vector corresponding to the vector to be queried from the vector database according to the first data stored in the vector database, and determining at least one second intermediate vector related to the position of each first intermediate vector according to the position information of each first intermediate vector, and taking each first intermediate vector and each second intermediate vector as a target intermediate vector and adding them to a target intermediate vector set; Retrieving an answer text corresponding to the vector to be queried from the semantic database according to the vector to be queried, the target intermediate vector set, and the second data stored in the semantic database; The step of determining at least one second intermediate vector related to the position of each first intermediate vector according to the position information of each first intermediate vector comprises: determining a level of the first intermediate vector in the original document; According to the level of the first intermediate vector in the original document, at least one second intermediate vector related to the position of the first intermediate vector is determined, and the position correlation refers to the relationship that the second intermediate vector and the first intermediate vector are parent nodes or child nodes in the text structure of the original document, or the relationship that the second intermediate vector and the first intermediate vector have the same parent node or child node in the text structure of the original document.
2. The vector database question-answering processing method integrating semantic graph according to claim 1 is characterized in that: The retrieving an answer text corresponding to the vector to be queried from the semantic database according to the vector to be queried, the target intermediate vector set, and the second data stored in the semantic database, comprises: Determine, according to the second data stored in the semantic database, a path search result of the target intermediate vector set based on a path search algorithm, wherein the path search result includes: at least one path, each of the paths includes at least one node adjacent to each other in sequence, wherein each node on the path is used to represent an answer vector in the semantic database; Determine the distance between each node on each path and the vector to be queried according to the path search result; The answer text corresponding to the vector to be queried is determined according to the distance between each node and the vector to be queried and the second data.
3. The vector database question-answering processing method integrating semantic graph according to claim 2 is characterized in that: The determining, based on the second data stored in the semantic database and based on a path search algorithm, a path search result of the target intermediate vector set includes: A. determining a current node from the target intermediate vector set; B. Determine, based on the second data, at least one target vector whose similarity to the current node satisfies a preset condition, add the target vector to the path corresponding to the current node, obtain the path corresponding to the current node, and re-execute A; C. Execute AB in a loop until all vectors in the target intermediate vector set are used as current nodes.
4. The vector database question-answering processing method integrating semantic graph according to claim 2 is characterized in that: The step of determining the answer text corresponding to the vector to be queried according to the distance between each node and the vector to be queried and the second data includes: The distances between each node and the vector to be queried are sorted, and the answer text corresponding to the vector to be queried is determined according to the sorting result and the second data.
5. The vector database question-answering processing method integrating semantic graph according to claim 4 is characterized in that: The step of determining the answer text corresponding to the query vector according to the sorting result and the second data includes: Determine at least one target answer vector that satisfies a first similarity condition according to the sorting result; According to the target answer vector that meets the first similarity condition, an answer text corresponding to the vector to be queried is determined.
6. The vector database question answering processing method for integrating semantic graphs according to any one of claims 1 to 5, characterized in that: The retrieving the answer text corresponding to the vector to be queried according to the first data stored in the vector database and / or the second data stored in the semantic database includes: Randomly extracting multiple answer vectors from the semantic database to form a random vector set; According to the random vector set and the second data stored in the semantic database, an answer text corresponding to the vector to be queried is retrieved from the semantic database.
7. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the vector database question-answering processing method for integrating semantic graphs as described in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the vector database question-answering processing method for fused semantic graphs as described in any one of claims 1 to 6.
