Answer generation method and device, equipment, storage medium and product

By constructing a knowledge graph vector library and vectorizing user questions, the problem of answer bias in intelligent question-answering systems has been solved, enabling more accurate and flexible answer generation.

CN118210893BActive Publication Date: 2026-11-27INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410318023.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-20
Publication Date
2026-11-27
Estimated Expiration
2044-03-20

AI Technical Summary

Technical Problem

Existing intelligent question-answering systems generate answers with biases and errors, and their accuracy needs to be improved.

Method used

By pre-storing the knowledge graph structure, pre-trained vector models, and multiple knowledge graph question-answering scenario information, a search vector library is constructed. User questions are processed in a vectorized manner, and answers are generated using vector search and concatenation.

Benefits of technology

It improves the accuracy and flexibility of answer generation, enhances the generalization ability of the question-answering system, and adapts to different types of questions and contextual understanding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118210893B_ABST
    Figure CN118210893B_ABST
Patent Text Reader

Abstract

The application provides an answer generation method and device, equipment, storage medium and product, and relates to the technical field of artificial intelligence. The method comprises the following steps: determining a to-be-searched vector library according to a pre-stored knowledge graph structure, a pre-trained vector model and a plurality of knowledge graph question and answer scene information; obtaining a user question, and performing vectorization processing on the user question by using the pre-trained vector model to obtain a to-be-searched question vector at a sentence level; performing vector search on the to-be-searched question vector in the to-be-searched vector library to obtain user question related information, and determining graph structure information according to the pre-stored knowledge graph structure; performing splicing processing on the graph structure information, the user question related information and the user question to obtain to-be-input information, and inputting the to-be-input information into a pre-stored question and answer large model to obtain a target answer. The method solves the problem that the answer generated by the intelligent question and answer system in the prior art for a user question is deviated and incorrect, and improves the accuracy of answer generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an answer generation method, apparatus, device, storage medium, and product. Background Technology

[0002] With the development of artificial intelligence technology, intelligent question-answering systems are being used more and more widely, and more and more industries are starting to use them. These systems can quickly generate corresponding answers to user questions, thereby saving manpower and improving user experience.

[0003] In existing technologies, compared to traditional human customer service, intelligent question-and-answer systems can save manpower, but they analyze the questions raised by users based on certain rules or question-and-answer templates and quickly generate corresponding answers.

[0004] The invention found that, in the existing technology, intelligent question-answering systems still have problems with biased and erroneous answers, and the accuracy of answer generation needs to be improved. Summary of the Invention

[0005] This application provides an answer generation method, apparatus, device, storage medium, and product to solve the problem of deviations and errors in the answers generated by existing intelligent question-answering systems for user questions, and to improve the accuracy of answer generation.

[0006] Firstly, this application provides a method for generating answers, including:

[0007] Based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-answering scenario information, a vector library to be searched is determined. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-answering index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-answering scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name.

[0008] The user questions are obtained and vectorized using a pre-trained vector model to obtain sentence-level search question vectors.

[0009] For the question vector to be searched, a vector search is performed in the search vector library to obtain user question-related information, and the graph structure information is determined according to the pre-stored knowledge graph structure.

[0010] The graph structure information, the user question information, and the user question are concatenated to obtain the input information, which is then input into a pre-stored question-and-answer model to obtain the target answer.

[0011] In one possible implementation, the step of determining a vector library to be searched based on a pre-stored knowledge graph structure, a pre-trained vector model, and multiple knowledge graph question-answering scenario information, wherein the vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-answering index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-answering scenario, and a vectorized entity index storing entity types, entity attribute names, relation types, and relation attribute names, including: storing a type of entity and entity attributes in the pre-stored knowledge graph structure as a first knowledge point, and using a pre-trained vector model to vectorize each first knowledge point to obtain a first vectorized knowledge point; storing a type of relation and entity attributes in the pre-stored knowledge graph structure as a first knowledge point; and storing a type of relation and entity attributes in the pre-stored knowledge graph structure as a first knowledge point. The starting entity, ending entity, and relation attributes corresponding to the relationship are stored as a second knowledge point, and each second knowledge point is vectorized using a pre-trained vector model to obtain a second vectorized knowledge point. All first and second vectorized knowledge points are stored as a vectorized graph index. Based on the question-and-answer scenario information of each knowledge graph, a batch of reference questions and corresponding graph query statements are initialized to obtain a question-and-answer index to be stored, and the question-and-answer index to be stored is vectorized using a pre-trained vector model to obtain a vectorized question-and-answer index. The entities and entity attributes in the pre-stored knowledge graph graph structure are stored as an entity index, and the entity index is vectorized using a pre-trained vector model to obtain a vectorized entity index.

[0012] In one possible implementation, after storing the entities and entity attributes in the pre-stored knowledge graph structure as an entity index, the method further includes storing word fields that are synonyms of the entities in the entity index.

[0013] In one possible implementation, the reference question and the corresponding graph query statement are either automatically generated from the pre-stored question-and-answer model or generated based on manual writing.

[0014] In one possible implementation, the pre-trained vector model is a word vector model or a sentence-level vector model.

[0015] In one possible implementation, the step of performing a vector search on the vector library to obtain user question-related information includes: using a vector search on the vectorized graph index in the vector library to obtain multiple entities, entity attributes or relationships, and relationship attributes most relevant to the user question as first relevant information; using a vector search on the vectorized question-answer index in the vector library to obtain multiple reference questions and corresponding graph query statements most relevant to the user question as second relevant information; using a vector search on the vectorized entity index in the vector library to obtain multiple entities most relevant to the user question, and querying the pre-stored knowledge graph structure based on the multiple entities and the preset query value degree relationship used to query the entities to obtain the preset query value degree relationship for each entity and the full attribute information of the entity.

[0016] In one possible implementation, the steps of using vector search to obtain the vectorized graph index in the search vector library for the user's question vector to obtain multiple entities, entity attributes or relationships, and relationship attributes most relevant to the user's question as first relevant information; using vector search to obtain the vectorized question-answer index in the search vector library for the user's question vector to obtain multiple reference questions and corresponding graph query statements most relevant to the user's question as second relevant information; and using vector search to obtain the vectorized entity index in the search vector library for the user's question vector to obtain multiple entities most relevant to the user's question, and querying the pre-stored knowledge graph structure according to the multiple entities and the query preset value degree relationship used to query the entities to obtain the query preset value degree relationship for each entity and the full attribute information of the entity are performed simultaneously.

[0017] In one possible implementation, the number of the multiple parameter questions is adjusted according to the needs of the knowledge graph question-answering scenario.

[0018] In one possible implementation, the method further includes: when it is detected that the target answer does not meet the user's requirements, in response to a manual maintenance operation for the user question corresponding to the target answer, obtaining question update vector information; and storing the question update vector information into the search vector library.

[0019] Secondly, this application provides an answer generation apparatus, comprising:

[0020] The information vectorization storage module is used to determine the vector library to be searched based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-and-answer scenario information. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-and-answer index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-and-answer scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name.

[0021] The acquisition module is used to acquire user questions and use a pre-trained vector model to vectorize the user questions to obtain sentence-level search question vectors;

[0022] The vector search module is used to perform a vector search in the vector library for the question vector to be searched, obtain relevant information about the user question, and determine the graph structure information based on the pre-stored knowledge graph structure.

[0023] The answer generation module is used to concatenate the graph structure information, the user question-related information, and the user question to obtain the input information, and then input the input information into a pre-stored question-and-answer model to obtain the target answer.

[0024] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0025] The memory stores computer-executed instructions;

[0026] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect.

[0027] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.

[0028] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0029] The answer generation method, apparatus, device, storage medium, and product provided in this application first vectorize and store pre-stored knowledge graph structures, pre-trained vector models, and multiple knowledge graph question-answering scenario information to obtain a search vector library. Then, the acquired user questions are vectorized to obtain sentence-level search question vectors. Next, a vector search is performed on the search vector library to obtain user question-related information, and the graph structure information is determined based on the pre-stored knowledge graph structure. Finally, the graph structure information, user question-related information, and the user question are concatenated to obtain input information, which is then input into a pre-stored question-answering model to obtain the target answer. The answer generation method provided in this application, based on vector search and sentence-level vectors, better captures the contextual information and semantic relationships of user questions, searches for input information from a pre-stored question-answering model that better matches the user's desired answer, improves the generalization ability of the pre-stored question-answering model, and thus improves the quality and flexibility of the generated target answer, as well as its accuracy. Attached Figure Description

[0030] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0031] Figure 1 This is a schematic diagram illustrating an application scenario of the answer generation method provided in the embodiments of this application;

[0032] Figure 2 A flowchart illustrating the answer generation method provided in this application embodiment;

[0033] Figure 3 This is a schematic diagram of the structure of the answer generation device provided in the embodiments of this application;

[0034] Figure 4 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application.

[0035] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation

[0036] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0037] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, processing, transmission, provision, disclosure, and application of the relevant data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation portals for users to choose to authorize or refuse.

[0038] Furthermore, the technical solution involved in this application, which involves big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.) and the use of artificial intelligence technology for automated decision-making, and makes decisions that have a significant impact on personal rights based on the results of automated decision-making, provides users with corresponding operation entry points for users to choose to agree to or reject the results of automated decision-making; if the user chooses to reject, the process will proceed to the expert decision-making process.

[0039] It should be noted that the answer generation method, apparatus, device, storage medium and product provided in this application can be used in the field of artificial intelligence technology, or in any field other than artificial intelligence. The application fields of the answer generation method, apparatus, device, storage medium and product in this application are not limited.

[0040] The inventors discovered that when using traditional intelligent question-answering systems in the existing technology, the accuracy and efficiency of the answers generated by traditional intelligent question-answering systems are limited for non-standard natural language questions. Furthermore, due to the lack of understanding of the question's background and context, the generated answers contain biases and errors.

[0041] To address the aforementioned technical problems, the inventors proposed the following technical concept: First, encoding the questions using a word vector model is applicable to different types of questions, eliminating the need for manually writing rules and better preserving the semantic and contextual information of the questions, thus further improving the system's generalization ability. Second, by providing key contextual background information such as graph structure information, graph query statement examples, subgraph query results, and user questions to the large model, the accuracy and efficiency of the question-answering system can be effectively improved. Finally, employing the large model to understand the question background and context based on the prompt information further improves the quality and flexibility of the answers.

[0042] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0043] Figure 1 This is a schematic diagram illustrating an application scenario of the answer generation method provided in the embodiments of this application, such as... Figure 1 As shown, it includes: terminal 101 and server 102.

[0044] The terminal 101 is used for users to ask questions and display generated answers. Terminal 101 can be a mobile terminal, a fixed terminal, such as a mobile phone, tablet computer, or laptop computer, or other hardware with information input and display functions. It can also be a hardware device consisting of a keyboard, mouse, and monitor. The server 102 is used to install the intelligent question-and-answer system and, in response to user questions, executes the answer generation method to generate answers. Server 102 can be a hardware device or a virtual server capable of installing and running the intelligent question-and-answer system.

[0045] Figure 2 This is a flowchart illustrating the answer generation method provided in this embodiment. The execution entity of this embodiment can be... Figure 1 The server 102 in the illustrated embodiment can also be other computer-related devices such as computers or mobile phones, and this embodiment is not particularly limited.

[0046] like Figure 2 As shown in the embodiments of this application, the answer generation method includes:

[0047] S1: Based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-answering scenario information, determine the vector library to be searched. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-answering index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-answering scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name.

[0048] In this embodiment, the pre-stored knowledge graph structure may include components such as entities, attributes, relationships, ontology, and semantics. The pre-trained vector model can be a model that has been trained to convert words and sentences into vectors. The knowledge graph question-answering scenario information can be scenarios in which different users ask questions in different contexts. This scenario can be obtained based on the context generated during communication with users, or it can be obtained based on the scenario description content input by users.

[0049] In an optional embodiment of this application, the pre-trained vector model can be a word vector model or a sentence-level vector model, such as the Word2Vec word vector model and the GloVe model for representing word vectors in natural speech processing. For example, when the pre-trained vector model is a word vector model, it can transform a sentence containing n words into an n-dimensional vector, where each dimension represents the semantic information of a word, and the value of the vector represents the weight of that word in the sentence. When the pre-trained vector model is a sentence-level vector model, it can encode the entire sentence as a whole, instead of splitting each sentence into words.

[0050] In an optional embodiment of the application, the pre-stored knowledge graph structure includes entities, entity attributes, relations, entity types, entity attribute names, relation types, relation names, starting entities, ending entities, and relation attributes corresponding to the relations. The knowledge graph question-answering scenario information includes the corresponding information. Step S1 includes:

[0051] S101: Store a type of entity and its attributes in the pre-stored knowledge graph structure as a first knowledge point, and use a pre-trained vector model to vectorize each first knowledge point to obtain a first vectorized knowledge point.

[0052] S102: Store a type of relation in the pre-stored knowledge graph structure, along with the corresponding starting entity, ending entity, and relation attributes, as a second knowledge point. Then, use a pre-trained vector model to vectorize each second knowledge point to obtain a second vectorized knowledge point.

[0053] S103: Store all first and second vectorized knowledge points as vectorized graph indexes.

[0054] In this embodiment, each type of entity in the pre-stored knowledge graph structure and its corresponding entity attributes are stored as a first knowledge point. A type of relation in the pre-stored knowledge graph structure and its corresponding starting entity, ending entity, and relation attributes are stored as a second knowledge point. Each knowledge point is stored and vectorized separately. This allows for subsequent user queries to be searched based on vectors to find the top n types of entities or relations that meet the relevance requirements of the user's question. This also includes the attribute names corresponding to each type of entity. For example, an entity can be a person's name, a place name, or an organization. A relation describes the connection or interaction between entities. For example, if the entities include Zhang San, City A, Unit A, and City B, then the relation between Zhang San and City A can be "place of birth," the relation between Zhang San and Unit A can be "name of work unit," and the relation between Unit A and City B can be "place of registration." Here, Zhang San can be considered a person's name as an entity, City A and City B can be considered place names as entities, and Unit A can be considered an organization as an entity. In this embodiment, the vectorization process has already been described in step S1, so it will not be repeated here.

[0055] S104: Based on the question-and-answer scenario information of each knowledge graph, initialize a batch of reference questions and corresponding graph query statements to obtain the question-and-answer index to be stored, and use a pre-trained vector model to vectorize the question-and-answer index to obtain the vectorized question-and-answer index.

[0056] In this embodiment, the scenario questions are mainly used as sample few shots of the question-answering model, serving as a reference to assist in writing graph query statements for the question-answering model. Each question and its corresponding graph query statement are stored and vectorized separately. The vectorization process has already been described in step S1 in this embodiment, so it will not be repeated here.

[0057] In an optional embodiment of this application, the reference question and the corresponding graph query statement are either automatically generated from a large model or generated based on manual writing.

[0058] S105: Store the entities and entity attributes in the pre-stored knowledge graph structure as an entity index, and use a pre-trained vector model to vectorize the entity index to obtain a vectorized entity index.

[0059] In this embodiment, entity attributes refer to the specific characteristics of an entity or a description of the entity. Each entity can have multiple attributes. For example, for a movie entity, it can have the following attributes: movie name, director, release year, main actors, and genre. In this embodiment, the vectorization process has been described in step S1, so it will not be repeated here.

[0060] In an optional embodiment of this application, after storing the entities and entity attributes in the pre-stored knowledge graph structure as an entity index, the method further includes: storing word fields that are synonyms of the entities in the entity index.

[0061] In this embodiment, the word field synonymous with an entity can include aliases, synonyms, and near-synonyms. For example, for the entity "potato," its corresponding aliases "malingshu," "shanyaodan," and "yangyu" can also be stored together as an entity index. This is to better adapt to new entity expressions that may appear in user queries and improve the accuracy of the generated answers.

[0062] S2: Obtain user questions and use a pre-trained vector model to vectorize the user questions to obtain sentence-level search question vectors.

[0063] In this embodiment, the user question can be obtained based on the user's operation, for example, the user enters "How old is Wang Wu?" in the input window of the intelligent question-answering system. The process of vectorizing the user question is similar to the vectorization process in step S1, so it will not be described again here in this embodiment.

[0064] S3: Perform a vector search in the vector library for the question vector to be searched to obtain relevant information about the user's question, and determine the graph structure information based on the pre-stored knowledge graph structure.

[0065] In this embodiment, vector search can be performed using an existing vector algebra-based search model. This involves calculating the similarity between a given vector to be searched and vectors in a vector library, then sorting vectors with similarity exceeding a pre-set threshold according to their similarity to obtain the most relevant user question information. Graph structure information refers to the descriptive information within the knowledge graph structure. For example, a graph structure might be defined as ["Entity Label": "Person", "Attribute 1": "Personal Unique Identifier", "Attribute 2": "Age", "Attribute 3": "Gender", "Attribute 4": "Occupation", "Attribute 5": "Personal Alias"]. This graph structure information can be extracted from a pre-stored knowledge graph structure.

[0066] Specifically, in an optional embodiment of this application, step S3 involves performing a vector search in a search vector library for the question vector to be searched, obtaining user question-related information, including:

[0067] S301: For the user's question vector, use vector search to find the vectorized graph index in the search vector library to obtain the most relevant multi-class entities, entity attributes or relationships, and relationship attributes as the first relevant information.

[0068] In this embodiment, "most relevant" refers to calculating the similarity between a given search vector and a vector in the vectorized graph index, and then sorting the vectors with similarity exceeding a certain preset threshold according to their similarity, resulting in the top n types of entities, where n is a natural number greater than 0.

[0069] S302: For the user's question vector, use vector search to find the vectorized question and answer index in the search vector library to obtain multiple reference questions most relevant to the user's question and their corresponding graph query statements as the second relevant information.

[0070] In this embodiment, "most relevant" refers to calculating the similarity between a given search vector and a vector in the vectorized question-answering index, and then sorting the vectors with similarity exceeding a certain preset threshold according to their similarity, resulting in the top n reference questions and their corresponding graph query statements, where n is a natural number greater than 0.

[0071] In an optional embodiment of this application, n can be adjusted according to the needs of the knowledge graph question-answering scenario, where n is a natural number greater than 0. To save the answer generation time of the intelligent question-answering system, n is generally less than or equal to 3.

[0072] S303: For the user's question vector, use vector search to find the vectorized entity index in the search vector library to obtain multiple entities most relevant to the user's question. Based on the multiple entities and the query preset value degree relationship used to query the entity, query the pre-stored knowledge graph structure to obtain the query preset value degree relationship and the full attribute information of each entity.

[0073] In this embodiment, the most relevant n entities refer to the top n entities obtained by calculating the similarity between a given search vector and a vectorized entity index, and then sorting the vectors whose similarity exceeds a certain preset threshold according to their similarity. The entity query preset value can be a default preset query value; for example, an n-degree relationship can default to a 2-degree relationship. That is, if a user's question involves a certain entity, the system can query a 2-degree relationship and the entity's full attribute information based on that entity. This information can be used as prompts for the large model. For example, if the question involves a person's name, the system can query the entity information and full attribute information related to that name in the pre-stored knowledge graph structure. The default graph query statement starts from the g-th node in the pre-stored knowledge graph structure, filters out nodes whose name attribute value is "Wang Wu," and traverses all incoming and outgoing edges of each "Wang Wu" node to its adjacent nodes. It then continues to traverse the adjacent nodes of each adjacent node, and so on, finally returning the complete path from the query start node to the last traversed node. This information can be used as input for the large model.

[0074] In an optional embodiment of this application, steps S301, S302, and S303 are executed simultaneously.

[0075] In this embodiment, executing steps S301, S302, and S303 simultaneously can improve the efficiency of generating the target answer.

[0076] S4: Combine the graph structure information, user question information, and user question to obtain the input information, and input the input information into the pre-stored question-and-answer model to obtain the target answer.

[0077] In this embodiment, the splicing process refers to the process of converting the user question into a graph query statement that can be input into a pre-stored question-and-answer model by combining graph structure information and user question-related information. The pre-stored question-and-answer model can be an intelligent question-and-answer system, such as an AI robot or a large AI model. The target answer refers to the output item of the pre-stored question-and-answer model.

[0078] Based on the above embodiments, the answer generation method provided in an optional embodiment of this application further includes:

[0079] Step A: When it is detected that the target answer does not meet the user's requirements, the question update vector information is obtained in response to the manual maintenance operation of the user question corresponding to the target answer.

[0080] Step B: Store the updated problem vector information into the search vector library.

[0081] In this embodiment, "the target answer does not meet the user's requirements" refers to a user continuously entering a fixed number of user questions within a fixed time period, or a user entering negative feedback on the target answer after receiving it. Manual maintenance refers to the process of manually breaking down user questions where the target answer does not meet the user's requirements and writing corresponding graph query statements.

[0082] In summary, the answer generation method provided in this application first vectorizes and stores pre-stored knowledge graph structures, pre-trained vector models, and multiple knowledge graph question-answering scenario information to obtain a search vector library. Then, it vectorizes the acquired user questions to obtain sentence-level search question vectors. Next, it performs a vector search within the search vector library to obtain user question-related information and determines the graph structure information based on the pre-stored knowledge graph structure. Finally, it concatenates the graph structure information, user question-related information, and the user question to obtain the input information, which is then input into the pre-stored question-answering model to obtain the target answer. The answer generation method provided in this application, based on vector search and sentence-level vectors, better captures the contextual information and semantic relationships of user questions, searches for input information from the pre-stored question-answering model that better matches the user's desired answer, improves the generalization ability of the pre-stored question-answering model, and thus improves the quality and flexibility of the generated target answer, as well as its accuracy.

[0083] Furthermore, by adjusting the input information of the pre-stored question-answering model according to different knowledge graph question-answering scenarios, the accuracy of the target answer is further improved.

[0084] Meanwhile, by storing synonymous word fields in the entity index, it can better adapt to new entity expressions that may appear in user questions. The vectorized storage of entities can map user questions to entities and attributes in the knowledge graph, fill the subject in the graph query statement, and further improve the accuracy and generation efficiency of the target answer.

[0085] Furthermore, when the target answer is detected as not meeting the user's requirements, a manual maintenance operation is performed on the user question corresponding to the target answer to obtain the question update vector information. This question update vector information is then stored in the search vector library to provide more accurate search information for future answer generation, thereby further improving the accuracy of the target answer.

[0086] Figure 3 This is a schematic diagram of the structure of the answer generation device provided in the embodiments of this application, such as... Figure 3 As shown, the answer generation device includes: an information vectorization storage module 31, an acquisition module 32, a vector search module 33, and an answer generation module 34.

[0087] The information vectorization storage module 31 is used to determine the vector library to be searched based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-and-answer scenario information. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-and-answer index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-and-answer scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name.

[0088] The acquisition module 32 is used to acquire user questions and use a pre-trained vector model to vectorize the user questions to obtain sentence-level search question vectors.

[0089] The vector search module 33 is used to perform a vector search in the vector library for the question vector to be searched, obtain relevant information about the user's question, and determine the graph structure information based on the pre-stored knowledge graph structure.

[0090] The answer generation module 34 is used to concatenate graph structure information, user question-related information and user question to obtain the input information, and input the input information into the pre-stored question-and-answer model to obtain the target answer.

[0091] In an optional embodiment of this application, the information vectorization storage module 31 is specifically used for: storing a type of entity and entity attributes in a pre-stored knowledge graph structure as a first knowledge point, and using a pre-trained vector model to vectorize each first knowledge point to obtain a first vectorized knowledge point; storing a type of relation in a pre-stored knowledge graph structure and the corresponding starting entity, ending entity, and relation attributes as a second knowledge point, and using a pre-trained vector model to vectorize each second knowledge point to obtain a second vectorized knowledge point; storing all the first and second vectorized knowledge points as a vectorized graph index; initializing a batch of reference questions and corresponding graph query statements according to the question-and-answer scenario information of each knowledge graph to obtain a question-and-answer index to be stored, and using a pre-trained vector model to vectorize the question-and-answer index to be stored to obtain a vectorized question-and-answer index; storing entities and entity attributes in a pre-stored knowledge graph structure as an entity index, and using a pre-trained vector model to vectorize the entity index to obtain a vectorized entity index.

[0092] In an optional embodiment of this application, after storing entities and entity attributes in a pre-stored knowledge graph structure as an entity index, the information vectorization storage module 31 is further used to: store word fields that are synonyms with entities in the entity index.

[0093] In an optional embodiment of this application, the information vectorization storage module 31 is used to initialize a batch of reference questions and corresponding graph query statements, so that the reference questions and corresponding graph query statements in the question-and-answer index to be stored are automatically generated by the pre-stored question-and-answer large model or generated based on manual writing.

[0094] In an optional embodiment of this application, the pre-trained vector model used by the information vectorization storage module 31 is a word vector model or a sentence-level vector model.

[0095] In an optional embodiment of this application, the vector search module 33 is specifically used for: using a vector search in the vectorized graph index of the vector library to obtain multiple entities, entity attributes or relationships, and relationship attributes most relevant to the user's question vector as first relevant information; using a vector search in the vectorized question-and-answer index of the vector library to obtain multiple reference questions and corresponding graph query statements most relevant to the user's question as second relevant information; using a vector search in the vectorized entity index of the vector library to obtain multiple entities most relevant to the user's question, and querying a pre-stored knowledge graph structure based on the multiple entities and the query preset value degree relationship used to query the entities to obtain the query preset value degree relationship and the full attribute information of each entity.

[0096] In an optional embodiment of this application, the vector search module 33 performs the following steps simultaneously: first, it uses a vector search to obtain multiple entities, entity attributes or relationships, and relationship attributes most relevant to the user's question vector, based on the vectorized graph index in the search vector library; second, it uses a vector search to obtain multiple reference questions and corresponding graph query statements most relevant to the user's question vector, based on the vectorized entity index in the search vector library, based on the user's question vector, to obtain multiple entities most relevant to the user's question; and third, it uses a vector search to obtain multiple entities most relevant to the user's question, and queries a pre-stored knowledge graph structure based on the multiple entities and the preset value degree relationship used to query the entities, to obtain the preset value degree relationship and full attribute information of each entity.

[0097] In an optional embodiment of this application, the information vectorization storage module 31 is used to initialize a batch of reference questions and corresponding graph query statements, and the number of reference questions in the question-and-answer index to be stored is adjusted according to the needs of the knowledge graph question-and-answer scenario.

[0098] In an optional embodiment of this application, the information vectorization storage module 31 is further configured to: when it is detected that the target answer does not meet the user's requirements, in response to the manual maintenance operation of the user question corresponding to the target answer, obtain the question update vector information; and store the question update vector information into the search vector library.

[0099] The answer generation device provided in this application embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.

[0100] Figure 4 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application, such as... Figure 4 As shown, the device includes at least one processor 41 and a memory 42.

[0101] Among them, memory 42 is used to store computer execution instructions.

[0102] The processor 41 is configured to execute computer execution instructions stored in the memory 42 to implement the various steps involved in the above method embodiments. For details, please refer to the relevant descriptions in the foregoing method embodiments.

[0103] Optionally, the memory 42 can be either standalone or integrated with the processor 41.

[0104] When the memory 412 is set up independently, the device also includes a bus 43 for connecting the memory 42 and the processor 41.

[0105] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described answer generation method.

[0106] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described answer generation method.

[0107] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0108] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0109] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0110] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0111] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0112] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0113] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as these combinations of technical features do not contradict each other, they should be considered within the scope of this specification.

[0114] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0115] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for generating answers, characterized in that, include: Based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-answering scenario information, a vector library to be searched is determined. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-answering index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-answering scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name. The user questions are obtained and vectorized using a pre-trained vector model to obtain sentence-level search question vectors. The process involves performing a vector search on the target question vector in the target vector library to obtain user question-related information, including: using a vector search on the target question vector in the vectorized graph index of the target vector library to obtain multiple entities, entity attributes or relationships, and relationship attributes most relevant to the user question as first relevant information; using a vector search on the target question vector in the vectorized question-answer index of the target vector library to obtain multiple reference questions most relevant to the user question and their corresponding graph query statements as second relevant information; and using a vector search on the target question vector in the vectorized entity index of the target vector library to obtain multiple entities most relevant to the user question, and querying the pre-stored knowledge graph structure based on the multiple entities and the preset query value degree relationship used to query the entities to obtain the preset query value degree relationship for each entity and the full attribute information of the entity. Based on the pre-stored knowledge graph structure, determine the graph structure information; The graph structure information, the user question information, and the user question are concatenated to obtain the input information, which is then input into a pre-stored question-and-answer model to obtain the target answer.

2. The method according to claim 1, characterized in that, The step involves determining a vector library to be searched based on pre-stored knowledge graph structures, pre-trained vector models, and multiple knowledge graph question-answering scenario information. This vector library includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-answering index containing a batch of reference questions and corresponding graph query statements for each knowledge graph question-answering scenario, and a vectorized entity index storing entity types, entity attribute names, relation types, and relation attribute names. Store a type of entity and its attributes in the pre-stored knowledge graph structure as a first knowledge point, and use a pre-trained vector model to vectorize each first knowledge point to obtain a first vectorized knowledge point. A second knowledge point is stored as a type of relation in a pre-stored knowledge graph structure, along with the corresponding starting entity, ending entity, and relation attributes. Each second knowledge point is then vectorized using a pre-trained vector model to obtain a second vectorized knowledge point. All first and second vectorized knowledge points are stored as vectorized graph indexes; Based on the question-and-answer scenario information of each knowledge graph, a batch of reference questions and corresponding graph query statements are initialized to obtain the question-and-answer index to be stored. The question-and-answer index to be stored is then vectorized using a pre-trained vector model to obtain the vectorized question-and-answer index. The entities and entity attributes in the pre-stored knowledge graph structure are stored as an entity index, and the entity index is vectorized using a pre-trained vector model to obtain a vectorized entity index.

3. The method according to claim 2, characterized in that, After storing the entities and entity attributes in the pre-stored knowledge graph structure as an entity index, the method further includes storing word fields that are synonyms of the entity in the entity index.

4. The method according to claim 2, characterized in that, The reference questions and corresponding graph query statements are either automatically generated from the pre-stored question-and-answer model or generated based on manual writing.

5. The method according to claim 2, characterized in that, The pre-trained vector model is either a word vector model or a sentence-level vector model.

6. The method according to claim 1, characterized in that, The steps of using vector search to obtain the most relevant entities, entity attributes or relationships, and relationship attributes as the first relevant information, the steps of using vector search to obtain the most relevant reference questions and corresponding graph query statements as the second relevant information, and the steps of using vector search to obtain the most relevant entities and corresponding graph query statements as the pre-stored knowledge graph structure based on the multiple entities and the preset query value degree relationship for querying the entities, and obtaining the preset query value degree relationship for each entity and the full attribute information of the entity are performed simultaneously.

7. The method according to claim 1, characterized in that, The number of reference questions is adjusted according to the needs of the knowledge graph question-answering scenario.

8. The method according to any one of claims 1 to 7, characterized in that, Also includes: When it is detected that the target answer does not meet the user's requirements, the question update vector information is obtained in response to the manual maintenance operation of the user question corresponding to the target answer; The updated vector information of the problem is stored in the vector library to be searched.

9. An answer generation device, characterized in that, include: The information vectorization storage module is used to determine the vector library to be searched based on the pre-stored knowledge graph structure, pre-trained vector model, and multiple knowledge graph question-and-answer scenario information. The vector library to be searched includes a vectorized graph index storing knowledge graph entities and entity attributes, a vectorized question-and-answer index storing a batch of reference questions and corresponding graph query statements under each knowledge graph question-and-answer scenario, and a vectorized entity index storing entity type, entity attribute name, relation type, and relation attribute name. The acquisition module is used to acquire user questions and use a pre-trained vector model to vectorize the user questions to obtain sentence-level search question vectors; The vector search module is used to perform a vector search in the vector library for the question vector to be searched, and obtain user question-related information, including: using a vector search in the vectorized graph index of the vector library for the question vector to be searched, and obtaining the most relevant multi-class entities, entity attributes or relationships, and relationship attributes as the first relevant information; For the question vector to be searched, a vector search is used to search the vectorized question-answer index in the question vector library to obtain multiple reference questions most relevant to the user question and their corresponding graph query statements as the second relevant information; For the question vector to be searched, a vector search is used to search the vectorized entity index in the vector library to obtain multiple entities most relevant to the user question. Based on the multiple entities and the preset value degree relationship for querying the entities, the pre-stored knowledge graph structure is queried to obtain the preset value degree relationship for each entity and the full attribute information of the entity. Based on the pre-stored knowledge graph structure, the graph structure information is determined. The answer generation module is used to concatenate the graph structure information, the user question-related information, and the user question to obtain the input information, and then input the input information into a pre-stored question-and-answer model to obtain the target answer.

10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 8.

12. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 8.

Citation Information

Patent Citations

  • Question and answer knowledge retrieval method, device and equipment based on graph embedding

    CN113947084A

  • Question and answer method and system based on knowledge graph and large language model

    CN116775847A