Question and answer data generation method, question and answer method, computer device and storage medium

By constructing a target knowledge graph and generating questions and answers with complex logic, the problem of simple existing question-and-answer data is solved, and the quality of question-and-answer data and the ability of large language models to handle complex problems are improved.

CN121434370BActive Publication Date: 2026-05-15RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
Filing Date
2025-12-29
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing question-and-answer data generation methods produce relatively simple question-and-answer data, which causes large language models to fail to provide expected answers when dealing with complex questions.

Method used

By constructing a target knowledge graph, complex logical questions and answers are generated using multi-step search and binary relation decomposition. This includes obtaining target documents related to the target domain, constructing the knowledge graph, extracting entity relationships, and generating question-and-answer data.

Benefits of technology

It improves the complexity and accuracy of question-answering data, enabling the generation of questions and answers that require multiple steps of reasoning to arrive at a conclusion, and enhances the reasoning ability of large language models in specific domains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121434370B_ABST
    Figure CN121434370B_ABST
Patent Text Reader

Abstract

The application discloses a question and answer data generation method, a question and answer method, a computer device and a storage medium, and belongs to the technical field of large language models. The method comprises the following steps: taking any first entity in a target knowledge graph constructed based on a target document as a starting point, performing multi-step searching, and obtaining a second entity; querying a plurality of candidate entities having a direct entity relationship with the second entity from the target knowledge graph, and determining an entity having the same entity relationship type between the second entity as a third entity; decomposing an indirect entity relationship between the first entity and the second entity into a plurality of binary relationships, obtaining a target text block based on the plurality of binary relationships; and generating first question and answer data based on the first entity, the second entity, the third entity, the plurality of binary relationships, the target text block and a target question paradigm. In this way, a question and an answer with complex logic can be accurately generated, and the quality of question and answer data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of large language model technology, and in particular to a question-and-answer data generation method, a question-and-answer method, a computer device, and a storage medium. Background Technology

[0002] Large Language Models (LLMs) are typically trained using question-and-answer data to improve their problem-solving capabilities. Question-and-answer data consists of a set of data containing questions and answers, and effective question-and-answer data can significantly enhance the reasoning ability of large language models.

[0003] For problem-solving in a specific domain, question-and-answer data specific to that domain can be used to train a large language model, enabling the model to solve problems in that domain, i.e., to have reasoning ability in that domain, so that the large language model can meet the needs of real-world scenarios.

[0004] However, the question-and-answer data generated by current data generation methods is relatively simple. Large language models trained with this question-and-answer data can reason about simple questions, but they lack reasoning ability for complex questions, so the large language models cannot give the expected answers. Summary of the Invention

[0005] This application provides a question-and-answer data generation method, a question-and-answer method, a computer device, and a storage medium, which can accurately generate questions with complex logic, thereby improving the data quality of question-and-answer data in the field. The technical solution includes the following:

[0006] Firstly, a question-and-answer data generation method is provided, which includes:

[0007] Retrieve target documents related to the target domain;

[0008] Based on the target document, a target knowledge graph is constructed, which includes multiple entities and the entity relationships between the multiple entities.

[0009] For any first entity in the target knowledge graph, a multi-step search is performed starting from the first entity to obtain the second entity, and the indirect entity relationship between the first entity and the second entity is extracted from the target knowledge graph.

[0010] From the target knowledge graph, query multiple candidate entities that have a direct entity relationship with the second entity, and determine the candidate entities among the multiple candidate entities that have the same entity relationship type as the second entity as the third entity;

[0011] The indirect entity relationship is decomposed into multiple binary relations. Based on the multiple binary relations, a target text block is obtained. The target text block is the text content in the target document that describes the indirect entity relationship.

[0012] Based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm, the first question-and-answer data is generated.

[0013] In this application, a target knowledge graph is first constructed based on target documents associated with the target domain. Then, starting from any first entity in the target knowledge graph, a multi-step search is performed to obtain a second entity. The entity relationship between the found second entity and the first entity is an indirect entity relationship, meaning that multiple steps of reasoning are required to obtain the second entity from the first entity. Next, candidate entities with a direct entity relationship and the same entity relationship type as the second entity are queried from the target knowledge graph and identified as the third entity. The indirect entity relationship between the first and second entities is then decomposed into multiple binary relations. Based on these binary relations, target text blocks describing the indirect entity relationship are obtained from the target documents. Finally, based on the first entity, second entity, third entity, these multiple binary relations, and the target question paradigm, first question-answer data is generated. By performing multi-step searches within the target knowledge graph, and subsequently generating questions based on two entities with indirect entity relationships, the generated questions also require multiple steps of reasoning to arrive at an answer. Since the answer to the question may be an entity related to the second entity, identifying a third entity provides a basis for answer generation. Furthermore, by extracting target text blocks describing this indirect entity relationship from the target document, the accuracy of the first question-and-answer data is ensured. In this way, questions with complex logic and corresponding answers can be accurately generated, thereby increasing the complexity of question-and-answer data generation in the target domain and ultimately improving the quality of the question-and-answer data.

[0014] In conjunction with the first aspect, in some implementations of the first aspect, the construction of the target knowledge graph based on the target document includes:

[0015] The target document is segmented into multiple text blocks;

[0016] Entity extraction and entity relation extraction are performed on each of the multiple text blocks to obtain multiple reference entities and entity relations between the multiple reference entities.

[0017] The target knowledge graph is obtained by integrating the multiple reference entities and the entity relationships between them.

[0018] In the above method, by segmenting the target document into multiple text blocks, multiple reference entities and the entity relationships between these entities are extracted. This transforms the task of extracting entities from the target document into extracting entities from each text block, thereby reducing computational burden and improving the efficiency of constructing the target knowledge graph. Subsequently, these multiple reference entities and their relationships are integrated, allowing for the simplification of the knowledge relationships formed by the multiple reference entities, resulting in a more concise target knowledge graph.

[0019] In combination with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the integration of the plurality of reference entities and the relationships between the plurality of reference entities to obtain the target knowledge graph includes:

[0020] An initial knowledge graph is obtained by representing the multiple reference entities and the entity relationships between the multiple reference entities using multiple triples.

[0021] The initial knowledge graph is subjected to hierarchical clustering to obtain the target knowledge graph.

[0022] Combining the first aspect and the above implementation methods, in some implementation methods of the first aspect, the step of performing a multi-step search starting from any first entity in the target knowledge graph to obtain a second entity includes:

[0023] For any first entity in the target knowledge graph, search twice starting from the first entity to obtain the query entity;

[0024] When the entity relationship between the queried entity and the first entity is an indirect entity relationship, the queried entity is determined as the second entity;

[0025] If the entity relationship between the queried entity and the first entity is a direct entity relationship, the search continues until the queried entity and the first entity have an indirect entity relationship.

[0026] In the above method, by performing two searches to determine whether the searched entity has an indirect entity relationship with the first entity, and since searching downwards twice is equivalent to traversing two entities, the final searched entity may have other entities in existence with the first entity, thus indicating that the second entity has been found. Therefore, by performing two searches to determine whether there is an indirect entity relationship between the two entities, and ending the search when an indirect entity relationship exists, the efficiency of finding the second entity can be improved.

[0027] Combining the first aspect and the above implementation methods, in some implementation methods of the first aspect, first question-and-answer data is generated based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm, including:

[0028] Based on the first entity, the second entity, and the third entity, the first question-and-answer data is generated according to the target question paradigm;

[0029] Based on the multiple binary relations and the target text block, the questions and answers in the first question-and-answer data are verified for consistency, and the first question-and-answer data is retained if the consistency verification passes.

[0030] In the above method, the target document contains a complete knowledge structure. The target text block obtained from the target document can realize accurate reasoning for the corresponding question, thereby obtaining an accurate answer. By verifying the consistency of the questions and answers in the first question and answer data based on the multiple binary relations and the target text block, it can be ensured that the generated questions and answers have logical consistency, thereby improving the data accuracy of the first question and answer data.

[0031] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the step of generating the first question-and-answer data based on the first entity, the second entity, and the third entity according to the target question paradigm includes:

[0032] Based on the target question paradigm, a first prompt word is determined, which includes question-and-answer data generation rules.

[0033] The first entity, the second entity, and the third entity are input into the first model. The first prompt word prompts the first model to generate the first question-and-answer data based on the first entity, the second entity, and the third entity.

[0034] In the above method, the first prompt word is a prompt word corresponding to the target question paradigm. The first prompt word guides the first model, enabling the first model to generate question-and-answer data of the target type. Furthermore, the first prompt word provides the question generation rules, so the first model can quickly and accurately generate the first question-and-answer data.

[0035] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the first question-and-answer data includes a question and a first reference answer. The consistency verification of the questions and answers in the first question-and-answer data based on the multiple binary relations and the target text block includes:

[0036] Based on the multiple binary relations and the target text block, the question is reasoned and answered to obtain a second reference answer;

[0037] If the first reference answer is consistent with the second reference answer, the consistency verification of the first question and answer data is determined to be successful.

[0038] In the above method, by reasoning and answering the questions in the first question-and-answer data based on the multiple binary relations and the target text block, a relatively accurate answer to the question (second reference answer) can be obtained, which is equivalent to providing the standard answer to the question. If the first reference answer and the second reference answer are consistent, it means that the answer generated by the first model corresponds to the question and can accurately answer the question, which also indicates that the first question-and-answer data is accurate. Then the first question-and-answer data can be used for the training of the target model.

[0039] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, after generating the first question-and-answer data based on the first entity, the second entity, and the third entity according to the target question paradigm, it further includes:

[0040] Based on the first question and answer data, multiple data fields are generated;

[0041] If the multiple data fields meet the preset conditions, the first question and answer data is converted into the second question and answer data.

[0042] In the above method, by determining multiple data fields and converting the first question-and-answer data into the second question-and-answer data when the multiple data fields meet the preset conditions, question-and-answer data combined with specific data values ​​can be obtained, thereby generating question-and-answer data that fits the actual application. Subsequently, the target model can be trained based on this data, which can improve the target model's ability to solve practical problems.

[0043] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the question-and-answer data generation method further includes:

[0044] If there are formula calculation rules among the multiple data fields, determine that the multiple data fields satisfy the preset conditions; or,

[0045] When the multiple data fields are data fields used in a preset scenario, it is determined that the multiple data fields satisfy the preset conditions.

[0046] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the step of converting the first question-and-answer data into second question-and-answer data when the plurality of data fields satisfy preset conditions includes:

[0047] For any one of the multiple data fields, query the index name corresponding to the reference field that is related to the data field from the target data table;

[0048] Based on the index name, query the data value of the reference field that is related to the data field;

[0049] Based on the data value of the reference field associated with each of the plurality of data fields, the first question and answer data is converted into second question and answer data.

[0050] The above method first retrieves all data values ​​related to each data field, and then combines these values ​​to convert the first question-and-answer data into second question-and-answer data. This allows for the acquisition of more comprehensive data values, resulting in second question-and-answer data that is more relevant to practical applications, thus improving the data quality of the second question-and-answer data.

[0051] In conjunction with the first aspect and the above implementation methods, in some implementation methods of the first aspect, the step of converting the first question-and-answer data into second question-and-answer data based on the data value of the reference field associated with each of the plurality of data fields includes:

[0052] The first question-and-answer data and the data values ​​of the reference fields associated with each of the plurality of data fields are input into the second model. The second prompt word prompts the second model to convert the first question-and-answer data into the second question-and-answer data based on data value reasoning.

[0053] Secondly, a question-and-answer data generation device is provided, the device comprising:

[0054] The acquisition module is used to acquire target documents related to the target domain;

[0055] The graph construction module is used to construct a target knowledge graph based on the target document. The target knowledge graph includes multiple entities and the entity relationships between the multiple entities.

[0056] The entity lookup module is used to perform a multi-step search for any first entity in the target knowledge graph, starting from the first entity, to obtain a second entity, and to extract the indirect entity relationship between the first entity and the second entity from the target knowledge graph; to query multiple candidate entities that have a direct entity relationship with the second entity from the target knowledge graph, and to determine the candidate entities among the multiple candidate entities that have the same entity relationship type as the second entity as the third entity;

[0057] The acquisition module is also used to decompose the indirect entity relationship into multiple binary relations, and based on the multiple binary relations, acquire a target text block, wherein the target text block is the text content in the target document that describes the indirect entity relationship;

[0058] The generation module is used to generate first question-and-answer data based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm.

[0059] In conjunction with the second aspect, in some implementations of the second aspect, the graph construction module is specifically used for:

[0060] The target document is segmented into multiple text blocks;

[0061] Entity extraction and entity relation extraction are performed on each of the multiple text blocks to obtain multiple reference entities and entity relations between the multiple reference entities.

[0062] The target knowledge graph is obtained by integrating the multiple reference entities and the entity relationships between them.

[0063] Combining the second aspect and the above implementation methods, in some implementations of the second aspect, the graph construction module is specifically used for:

[0064] An initial knowledge graph is obtained by representing the multiple reference entities and the entity relationships between the multiple reference entities using multiple triples.

[0065] The initial knowledge graph is subjected to hierarchical clustering to obtain the target knowledge graph.

[0066] Combining the second aspect and the above implementation methods, in some implementations of the second aspect, the entity lookup module is specifically used for:

[0067] For any first entity in the target knowledge graph, search twice starting from the first entity to obtain the query entity;

[0068] When the entity relationship between the queried entity and the first entity is an indirect entity relationship, the queried entity is determined as the second entity;

[0069] If the entity relationship between the queried entity and the first entity is a direct entity relationship, the search continues until the queried entity and the first entity have an indirect entity relationship.

[0070] Combining the second aspect and the above implementation methods, in some implementations of the second aspect, the generation module is used for:

[0071] Based on the first entity, the second entity, and the third entity, the first question-and-answer data is generated according to the target question paradigm;

[0072] Based on the multiple binary relations and the target text block, the questions and answers in the first question-and-answer data are verified for consistency, and the first question-and-answer data is retained if the consistency verification passes.

[0073] Combining the second aspect and the above implementation methods, in some implementations of the second aspect, the generation module is specifically used for:

[0074] Based on the target question paradigm, a first prompt word is determined, which includes question-and-answer data generation rules.

[0075] The first entity, the second entity, and the third entity are input into the first model. The first prompt word prompts the first model to generate the first question-and-answer data based on the first entity, the second entity, and the third entity.

[0076] In conjunction with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the first question-and-answer data includes a question and a first reference answer, and the generation module is specifically used for:

[0077] Based on the multiple binary relations and the target text block, the question is reasoned and answered to obtain a second reference answer;

[0078] If the first reference answer is consistent with the second reference answer, the consistency verification of the first question and answer data is determined to be successful.

[0079] In conjunction with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the generation module is further used to: generate multiple data fields based on the first question and answer data;

[0080] The question-and-answer data generation device also includes:

[0081] The conversion module is used to convert the first question-and-answer data into second question-and-answer data when the multiple data fields meet preset conditions.

[0082] In conjunction with the second aspect and the above-described implementations, in some implementations of the second aspect, the question-and-answer data generation device further includes:

[0083] The determining module is used to determine whether the multiple data fields satisfy the preset conditions when there are formula calculation rules among the multiple data fields; or, when the multiple data fields are data fields used in a preset scenario, to determine whether the multiple data fields satisfy the preset conditions.

[0084] In conjunction with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the conversion module is specifically used for:

[0085] For any one of the multiple data fields, query the index name corresponding to the reference field that is related to the data field from the target data table;

[0086] Based on the index name, query the data value of the reference field that is related to the data field;

[0087] Based on the data value of the reference field associated with each of the plurality of data fields, the first question and answer data is converted into second question and answer data.

[0088] In conjunction with the second aspect and the above implementation methods, in some implementation methods of the second aspect, the conversion module is specifically used for:

[0089] The first question-and-answer data and the data values ​​of the reference fields associated with each of the plurality of data fields are input into the second model. The second prompt word prompts the second model to convert the first question-and-answer data into the second question-and-answer data based on data value reasoning.

[0090] Thirdly, a question-and-answer method is provided, which includes:

[0091] In response to an input operation on the target problem, the target problem is obtained;

[0092] The system receives and displays the target answer, which is the answer to the target question output by the target model after the target question is input into the target model. The target model is trained based on the question and answer data generated by the question and answer data generation method.

[0093] In this application, since the question-and-answer data generated by the question-and-answer data generation method has complex logic, a target model is trained using the generated data. This target model is then capable of handling complex problems within the target domain. In this case, in response to the input operation of the target question, the target question is obtained and input into the target model. The target model can then perform accurate reasoning on the target question, thereby outputting a relatively accurate target answer. As a result, users can obtain the answers they expect, thus improving the user experience.

[0094] Fourthly, a question-and-answer device is provided, the device comprising:

[0095] The acquisition module is used to acquire the target question in response to an input operation on the target question;

[0096] The receiving module is used to receive and display the target answer, which is the answer to the target question output by the target model after the target question is input into the target model. The target model is trained based on the question and answer data generated by the question and answer data generation method.

[0097] Fifthly, a computer device is provided, the computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the above-described question-and-answer data generation method.

[0098] Sixthly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described question-and-answer data generation method.

[0099] In a seventh aspect, a computer program product containing instructions is provided, which, when run on a computer, causes the computer to perform the steps of the question-and-answer data generation method described above.

[0100] It is understood that the beneficial effects of the second aspect can be found in the relevant descriptions of the first aspect, the beneficial effects of the fourth aspect can be found in the relevant descriptions of the third aspect, and the beneficial effects of the fifth, sixth, and seventh aspects can be found in the relevant descriptions of the first or third aspect, and will not be repeated here. Attached Figure Description

[0101] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0102] Figure 1 This is a schematic diagram of the implementation environment of a question-and-answer data generation method provided in an embodiment of this application;

[0103] Figure 2 This is a flowchart of a question-and-answer data generation method provided in an embodiment of this application;

[0104] Figure 3 This is a flowchart of a question-and-answer method provided in an embodiment of this application;

[0105] Figure 4 This is a schematic diagram of the structure of a question-and-answer data generation device provided in an embodiment of this application;

[0106] Figure 5 This is a schematic diagram of the structure of a question-and-answer device provided in an embodiment of this application;

[0107] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0108] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0109] It should be understood that "multiple" as mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, " / " indicates "or," for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist, for example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first," "second," etc., do not limit the quantity or execution order, and that "first," "second," etc., do not necessarily imply differences.

[0110] The application scenarios of the embodiments of this application will be explained first.

[0111] Currently, to enable large language models to possess general reasoning capabilities and domain-specific question-answering capabilities, they can be trained using general datasets and domain datasets. General datasets are typically open-source question-answering data from different domains. Training the large language model on a general dataset allows it to acquire general question-answering capabilities across various domains, i.e., general reasoning capabilities. Domain datasets typically include question-answering data related to a specific domain (such as the food and beverage industry). Training the large language model on a domain dataset enables it to acquire domain-specific question-answering capabilities. The data quality of the domain dataset directly impacts the large language model's reasoning ability.

[0112] In related technologies, text data is input into a large language model, which segments the text data into simple texts. Then, corresponding questions are generated based on the simple texts. Since the meanings expressed by the simple texts are relatively simple (for example, "entering the store" means the number of people entering the store), the questions generated directly based on the simple texts are also relatively simple (for example, "what is the number of people entering the store"). Therefore, the question-and-answer data logic generated in this way is relatively simple.

[0113] Therefore, if a large language model is trained using question-and-answer data generated in this way, the resulting large language model will only be able to answer simple questions. It will not be able to make accurate inferences for complex questions raised by users, and thus the large language model will not be able to output answers that meet the user's expectations.

[0114] Therefore, this application provides a question-and-answer data generation method that can be applied to scenarios where domain datasets are constructed.

[0115] Specifically, a target knowledge graph is first constructed based on target documents associated with the target domain. Then, starting from any first entity in the target knowledge graph, a multi-step search is performed to obtain a second entity, and the indirect entity relationship between the first and second entities is extracted—that is, multiple steps of reasoning are required to obtain the second entity from the first entity. Next, multiple candidate entities with direct entity relationships to the second entity are queried from the target knowledge graph. Then, candidate entities with the same entity relationship type as the second entity are identified as third entities. This indirect entity relationship is then decomposed into multiple binary relations, and target text blocks describing these indirect entity relationships are obtained from the target documents based on these binary relations. Finally, the first question-and-answer data is generated based on the first entity, second entity, third entity, these binary relations, target text blocks, and the target question paradigm.

[0116] In this scenario, by performing multi-step searches within the target knowledge graph, and subsequently generating questions based on the two entities with indirect entity relationships found, the generated questions also require multiple steps of reasoning to arrive at an answer. Since the answer to the question may be an entity related to the second entity, identifying the third entity provides a basis for answer generation. Furthermore, by retrieving target text blocks describing this indirect entity relationship from the target document, a basis for the consistency and accuracy of the first question-and-answer data is provided. Thus, based on the first entity, second entity, third entity, multiple binary relationships, target text blocks, and the target question paradigm, questions with complex logic and corresponding answers can be accurately generated, thereby increasing the complexity of question-and-answer data in the target domain and ultimately improving the quality of the question-and-answer data.

[0117] The implementation environment involved in the embodiments of this application will be further described.

[0118] For example, Figure 1 This is a schematic diagram illustrating the implementation environment of a question-and-answer data generation method provided in an embodiment of this application. See also... Figure 1 , Figure 1 It includes client 101 and server 102.

[0119] In this system, client 101 and server 102 establish a connection via a network. Client 101 can interact with server 102 through the network to receive or send messages, etc. The network provides a communication link between client 101 and server 102, and the network can include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0120] Client 101 can be a smartphone, tablet, laptop, desktop computer, in-vehicle device, smart wearable device, or Internet of Things (IoT) device, etc.

[0121] Server 102 can be a distributed server cluster composed of multiple servers, or it can be implemented as a single server. The server can also be a server in a distributed system, or a server combined with blockchain. The server can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0122] In some embodiments, server 102 may be deployed with a pre-trained target model, which is a model with dialogue capabilities (such as the large language model described above). One possible approach is to execute the question-and-answer data generation method provided in this application embodiment on server 102 to generate question-and-answer data in a specific domain and train the target model accordingly, enabling server 102 to run the target model.

[0123] After the target model is trained, the client 101 can receive the question information input by the user and send the question information to the server 102; the server 102 inputs the question information into the target model and outputs the answer information; the server 102 returns the answer information to the client 101.

[0124] The specific implementation of the client, server, and interaction process between them provided in this application embodiment can be found in the corresponding contents of the following embodiments, and will not be repeated here.

[0125] Before describing the question-and-answer data generation method provided in the embodiments of this application, the terms involved in the embodiments of this application will be explained.

[0126] 1. Knowledge Graph

[0127] Knowledge graphs are used to structure knowledge using entities, relationships, and attributes. They clearly represent real-world entities, concepts, and their relationships using nodes and edges. The basic unit of a knowledge graph is the triple, and all complex knowledge networks are composed of countless triples. In other words, a complete knowledge graph is formed by combining multiple triples.

[0128] A triple consists of three parts: head entity, relation, and tail entity. A triple is like a complete subject-verb-object phrase, which can clearly express a specific knowledge fact. For example, a triple (Einstein, proposed, relativity) can express the content of "Einstein proposed the theory of relativity".

[0129] 2. Resource Description Framework (RDF)

[0130] The Resource Description Framework (RDF) is a standard data model for describing network resources and their relationships. It consists of three parts: subject, predicate, and object. The subject is the object being described, which in this embodiment is represented as an entity. The predicate describes the attributes or relationships of the subject and defines the association type between the subject and the object. The object is the value or object that the predicate points to, which in this embodiment is represented as another entity.

[0131] For example, an RDF triple is (Street Dance Crew, Leader is, Xiaoming), where the subject is "Street Dance Crew", the predicate is "Leader is", and "Xiaoming" is the object.

[0132] 3. Entity Relationship

[0133] In knowledge graphs, entity relationships are the core "bridge" connecting different entities and conveying semantic information. They define "what kind of relationship exists between entities" and are a key element in constructing structured knowledge (corresponding to the "relation" part in a triple). Without entity relationships, isolated entities are just meaningless data points, while entity relationships enable logical connections between these data, forming "knowledge" that can be understood by machines.

[0134] Entity relationships can be divided into direct entity relationships and indirect entity relationships. Two entities in a triple have a direct entity relationship, while two entities that need to be represented by at least two triples have an indirect entity relationship. That is, for a direct entity relationship, there are no other entities acting as a bridge between the two entities, while for an indirect entity relationship, there are other entities acting as a bridge between the two entities.

[0135] For example, given a triple (Zhang San, works at, Company A), the relationship between Zhang San and Company A is a direct relationship. Given two triples (Zhang San, works at, Company A) and (Company A, employs, Li Si), the relationship between Zhang San and Li Si is an indirect relationship.

[0136] 4. Problem Paradigm

[0137] A problem paradigm refers to a standard framework formed by a class of problems with similar structures, core contradictions, or solution logic. Simply put, a problem paradigm is like a "general template for similar problems," but it is not a template; rather, it represents a way of thinking. In the embodiments of this application, the problem paradigm is mainly used to provide a framework for generating a certain type of question-and-answer data.

[0138] The question-and-answer data generation method provided in the embodiments of this application will be explained in detail below.

[0139] Figure 2 This is a flowchart illustrating a question-and-answer data generation method provided in an embodiment of this application. This method can be executed via a server. See also... Figure 2 The method includes the following steps.

[0140] Step 201: Obtain the target documents associated with the target domain.

[0141] The target domain refers to the domain related to the question and answer data. In this embodiment of the application, the target domain can be the catering domain, which can be further subdivided into the store management domain under the catering domain. Therefore, in step 201, the target documents related to the catering domain are first obtained.

[0142] A target document is used to provide relevant knowledge within a target domain. For example, a target document may include a knowledge system within the target domain. For instance, if the target document is a "Traffic Conversion Guide," it may include knowledge on "how to improve traffic conversion rates." In this embodiment, the target document can be a knowledge document accumulated daily within the target domain, an industry analysis report, a store analysis report, etc. This embodiment does not limit this; any document containing relevant knowledge within the target domain can be used as a target document. Furthermore, in this embodiment, the target document is not limited to a single document; it can also be multiple documents containing relevant knowledge within the target domain.

[0143] Step 202: Based on the target document, construct a target knowledge graph, which includes multiple entities and the entity relationships between these entities.

[0144] These multiple entities refer to entities related to the relevant knowledge system within the target domain, which can be extracted from the target document. For example, these multiple entities can represent knowledge subjects, attributes, etc., within the target domain.

[0145] Since the target document can contain a knowledge system in the target domain, which can be composed of relationships between different entities, a knowledge graph in the target domain can be constructed based on the target document. This allows the relationships between different entities in the knowledge system of the target domain to be effectively represented, making the relationships between related entities in the target domain more intuitive.

[0146] One possible approach is to perform the following steps in step 202: segment the target document into multiple text blocks; extract entities and entity relationships from each of the multiple text blocks to obtain multiple reference entities and entity relationships between them; and integrate the multiple reference entities and entity relationships to obtain the target knowledge graph.

[0147] Any one of the multiple text blocks can be a paragraph, a sentence, a logical unit, etc. in the target document. The embodiments of this application do not limit the granularity of the target document segmentation.

[0148] These multiple reference entities originate from multiple text blocks after the target document has been segmented, which is equivalent to a subdivision of multiple entities in the aforementioned target knowledge graph.

[0149] It should be understood that the target knowledge graph should be a comprehensive knowledge graph without duplicate semantic relationships. In the above method, the target document is first segmented into multiple smallest processing units (text blocks), and entity extraction and entity relation extraction are performed on each text block. This allows for the acquisition of multiple reference entities and entity relations between multiple reference entities with comprehensive knowledge relations. Then, these multiple reference entities and entity relations are integrated to simplify the knowledge relations formed by multiple reference entities, thereby obtaining a comprehensive knowledge graph without duplicate semantic relationships.

[0150] In the above method, multiple reference entities and entity relationships between multiple reference entities are extracted by dividing the target document into multiple text blocks. This transforms the task of extracting entities from the target document into extracting entities from each text block, thereby reducing computational pressure and improving the construction efficiency of the target knowledge graph.

[0151] The operation of extracting entities and entity relations for each of the multiple text blocks to obtain multiple reference entities and entity relations between the multiple reference entities can be as follows: For any one of the multiple text blocks, input the text block into the entity relation extraction model, extract the entities and entity relations contained in the text block through the entity relation extraction model, and output at least one reference entity and entity relations between different reference entities.

[0152] The entity relation extraction model is used to extract entities and entity relations contained in text. In this embodiment, the entity relation extraction model can be a large language model. Since the large language model is usually a trained model with natural language processing capabilities, in specific implementation, entities and entity relations can be extracted through instruction engineering. Specifically, corresponding entity extraction instructions are constructed, and the large language model is instructed to extract entities and entity relations from text blocks, thereby obtaining the entities and entity relations contained in the text blocks.

[0153] The operation of integrating the multiple reference entities and the entity relationships between them to obtain the target knowledge graph can be as follows: representing multiple reference entities and the entity relationships between them through multiple triples to obtain an initial knowledge graph; performing hierarchical clustering on the initial knowledge graph to obtain the target knowledge graph.

[0154] In this embodiment, multiple RDF triples can be used to represent multiple reference entities and the entity relationships between them. Since RDF triples mainly reflect the relationship between subjects and objects, using multiple RDF triples to represent multiple reference entities and the entity relationships between them can make the subject relationship between the head entity and the tail entity clearer, thereby making the entity relationships between reference entities in the initial knowledge graph clearer.

[0155] Hierarchical clustering is used to integrate semantically repetitive reference entities and entity relationships in the initial knowledge graph, eliminating semantically repetitive entities and resulting in a more concise target knowledge graph. In other words, the multiple entities and entity relationships in the target knowledge graph are obtained by simplifying and integrating multiple reference entities and entity relationships in the initial knowledge graph. One possible approach is to use the Leiden algorithm to perform hierarchical clustering on the initial knowledge graph to obtain the target knowledge graph. It should be understood that this application's embodiments are not limited to the Leiden algorithm; other hierarchical clustering algorithms can also be used to perform hierarchical clustering on the initial knowledge graph to merge semantically repetitive reference entities and entity relationships, thereby obtaining the target knowledge graph.

[0156] In some embodiments, for any two reference entities among a plurality of reference entities, if the type of the entity relationship does not belong to the target relationship type, the two reference entities and the entity relationship between the two reference entities are represented by a triple.

[0157] The types of entity relationships are entity relationships between two entities such as "contains", "is", "affects", "measures", etc.

[0158] A target relation type refers to a relatively simple relation type between two entities. Target relation types can be pre-defined by technical personnel. For example, a simple entity relation type like "is" simply means that one entity is another entity. Because the entities and relationships involved in a target relation type are relatively simple, the questions generated based on it are also relatively simple. Therefore, when the entity relation type between two reference entities is a target relation type, triples are not needed to represent the entity relation between the two reference entities; that is, this type of entity relation does not need to be reflected in the knowledge graph.

[0159] In the above method, only when the type of the entity relationship does not belong to the target relationship type is the two reference entities and the entity relationship between the two reference entities represented by triples. This makes the entity relationship between the entities contained in the target knowledge graph that is subsequently constructed a specific type of entity, and thus high-quality question-and-answer data can be generated based on the target knowledge graph.

[0160] The following example illustrates the process of constructing a target knowledge graph based on the target document.

[0161] Given a target document, including how to improve "order conversion rate," improving order conversion rate is like dating—in short, a good user experience! First, it starts with appearance. Aesthetics matter, and the store's decor is key. When consumers enter, seeing the store sign, in-store posters, window displays, and attractive food photos greatly increases their positive impression. Second, it relies on design. The menu must be carefully designed; product positioning, dish descriptions, and specialty categories / sorting should align with consumers' ordering habits, encouraging quick decisions. Additionally, good store reviews, brand stories, and a professional photo album also boost conversion rates. Third, it depends on integrity. Reasonable store promotions and menu pricing, where customers pay after ordering, meet their expectations, significantly increasing the order success rate.

[0162] By segmenting the target document into text, multiple text blocks can be obtained. Then, entities and entity relationships are extracted from each text block to obtain multiple reference entities and entity relationships between them. These multiple reference entities and entity relationships can be constructed using the following triples.

[0163] (1) Influencing relationships: (User experience, impact, order conversion rate), (Store decoration, impact, user experience), (Menu, impact, user experience), (Store activities, impact, user experience), (Dish prices, impact, user experience).

[0164] (2) Inclusion relationship: (Shop decoration, includes, shop sign), (Shop decoration, includes, in-store poster), (Shop decoration, includes, shop window), (Shop decoration, includes, beautiful pictures of dishes), (Menu, includes, product positioning), (Menu, includes, dish description), (Menu, includes, special category), (Menu, includes, sorting).

[0165] (3) Functional relationship: (store evaluation, promotion, order conversion rate), (brand story, promotion, order conversion rate), (merchant album, promotion, order conversion rate), (meeting consumer expectations, improvement, order conversion rate).

[0166] (4) Matching relationships: (sorting, matching, ordering habits), (dish price, matching, order success rate).

[0167] Then, the initial knowledge graph is formed by the above triples, and the target knowledge graph can be obtained by hierarchical clustering of the initial knowledge graph.

[0168] Step 203: For any first entity in the target knowledge graph, perform a multi-step search starting from the first entity to obtain the second entity, and extract the indirect entity relationship between the first entity and the second entity from the target knowledge graph.

[0169] The first entity is any entity in the target knowledge graph. Furthermore, there is an indirect entity relationship between the first entity and the second entity.

[0170] In step 203, starting with a first entity, a multi-step search is performed. By progressively searching for related entities, a second entity with an indirect entity relationship with the first entity is found. That is, until there are other entities between the found entity (the second entity) and the first entity that can be associated with the first entity and the second entity.

[0171] After finding the second entity, the indirect entity relationship between the first and second entities is extracted from the target knowledge graph to provide a richer theoretical basis for the subsequent generation of the first question-and-answer data.

[0172] It should be understood that the purpose of the question-and-answer data generation method provided in this application embodiment is to generate relatively complex question-and-answer data in order to train a model with complex logical reasoning capabilities. Therefore, in order to generate logically complex questions, the entities found from the target knowledge graph cannot be entities with direct entity relationships. If the question is generated based on two entities with direct entity relationships, the generated question can be answered through one-step reasoning, so the generated question is still relatively simple.

[0173] In the above method, by performing a multi-step search in the target knowledge graph, the found second entity has an indirect entity relationship with the first entity. That is, the second entity cannot be obtained by reasoning from the first entity in one step, but requires multiple steps of reasoning. In this case, the questions generated based on the first and second entities have logical complexity, thereby improving the data quality of the question-and-answer data.

[0174] One possible approach is that step 203 can be performed as follows: for any first entity in the target knowledge graph, search twice starting from the first entity to obtain the query entity; when the entity relationship between the query entity and the first entity is an indirect entity relationship, determine the query entity as the second entity; when the entity relationship between the query entity and the first entity is a direct entity relationship, continue searching until the entity found has an indirect entity relationship with the first entity.

[0175] Specifically, for a given first entity, starting from this first entity, a search can be performed twice, level by level, to obtain the query entity. Then, it is determined whether the entity relationship between the query entity and the first entity is an indirect entity relationship. It should be understood that if the query entity can be found after two level-down searches, then the query entity and the first entity have an indirect entity relationship. However, if two level-down searches are not possible, i.e., there are no entities with two or more levels of relationship below the first entity, the two level-down searches will fail. In this case, the first entity is used as the starting point, and a search is performed once level by level downwards, then once more at the same level to obtain the query entity. Next, it is determined whether the query entity and the first entity have an indirect entity relationship. If they do not, the search continues once more from the query entity, and it is determined whether the searched entity has an indirect entity relationship with the first entity. If the searched entity has an indirect entity relationship with the first entity, the search ends.

[0176] As an example, suppose the first entity selected from the target knowledge graph is "order conversion rate". Then, starting from "order conversion rate", we search downwards twice, layer by layer. In the case of sequential search, for example, the first search will find the entity "user experience", and the second search will find "store decoration". Then we determine whether there is an indirect entity relationship between "store decoration" and "order conversion rate". Since there is an intermediate entity "user experience" between "store decoration" and "order conversion rate", there is an indirect entity relationship between "store decoration" and "order conversion rate". Therefore, "store decoration" can be identified as the second entity.

[0177] Step 204: Query multiple candidate entities that have a direct entity relationship with the second entity from the target knowledge graph, and identify the candidate entities among these multiple candidate entities that have the same entity relationship type as the second entity as the third entity.

[0178] It should be noted that multiple candidate entities refer to entities in the target knowledge graph that have a direct entity relationship with the second entity but not with the first entity. For example, multiple candidate entities refer to multiple entities at the lower level of the second entity in the target knowledge graph.

[0179] The entity relationship type is the type of entity relationship between two entities, such as "contains", "affected by", "promotes", etc.

[0180] Since the answer to a question generated based on the first entity and the second entity should be related to both entities, and the first entity is the subject of the question, if the answer has a direct entity relationship with the first entity, it means that the question generated based on the first entity and the second entity can be obtained through simple reasoning. In other words, the question-and-answer data generated based on the first entity and the second entity is relatively simple, which does not conform to the purpose of this application's embodiments. Therefore, the answer to a question generated based on the first entity and the second entity can be related to the second entity.

[0181] Furthermore, candidate entities with the same entity relationship type are used to describe the same attribute of the second entity, and the answer to the question generated based on the first and second entities should also be a description under one dimension. Therefore, the candidate entity with the same entity relationship type as the second entity among the multiple candidate entities can be identified as the third entity.

[0182] In the above method, by querying multiple candidate entities that have a direct entity relationship with the second entity from the target knowledge graph, and identifying the candidate entities among the multiple candidate entities that have the same entity relationship type as the second entity as the third entity, an accurate basis is provided for generating answers to subsequent questions, so that questions with complex logic can be answered more accurately.

[0183] For example, the first entity is "order conversion rate" and the second entity is "store decoration". For instance, if multiple candidate entities with direct entity relationships to the second entity are found from the target knowledge graph, including "store sign", "in-store poster", "store window", and "beautiful food pictures", and the entity relationship type between the multiple candidate entities "store sign", "in-store poster", "store window", and "beautiful food pictures" and the second entity "store decoration" is "inclusion", then all of these multiple candidate entities can be identified as the third entity.

[0184] Step 205: Decompose the indirect entity relationship into multiple binary relations. Based on these multiple binary relations, obtain the target text block, which is the text content in the target document that describes the indirect entity relationship.

[0185] A binary relation is a relationship between two entities. Multiple binary relations can be represented by multiple triples, which is equivalent to restoring the indirect entity relationship between the first entity and the second entity into multiple triples. Through these multiple triples, the flow information of the relationship between the first entity and the second entity can be accurately displayed.

[0186] The target text block can be the text content in the target document that describes the indirect entity relationship.

[0187] As described in step 203 above, after querying the second entity in the target knowledge graph, starting with the first entity, the indirect entity relationship between the first and second entities is extracted from the target knowledge graph. This indirect entity relationship is decomposed into multiple binary relations, and based on these binary relations, target text blocks are obtained, allowing the tracing of the indirect entity relationship's origin in the target document. It should be understood that the target document contains a complete knowledge structure, and accurate reasoning about the corresponding question can be achieved through the target text blocks, thus obtaining an accurate answer.

[0188] In this case, by obtaining multiple tuples and target text blocks, the reasoning basis for the problem can be found, and then these multiple tuples and target text blocks can provide a valid basis for the accurate generation of the answer.

[0189] In some embodiments, when extracting the indirect entity relationship between the first entity and the second entity in the target knowledge graph, the direct entity relationship between the second entity and the third entity can also be extracted, that is, the entire relationship chain from the first entity to the third entity can be extracted. Then, the indirect entity relationship between the first entity and the second entity, as well as the direct entity relationship between the second entity and the third entity, can be decomposed into multiple binary relations, and the target text block can be obtained based on these multiple binary relations.

[0190] In this case, the multiple tuples and target text blocks obtained contain relational flow information and text content from the entire relational link from question to answer, which provides an accurate basis for judging the consistency of subsequent questions and answers.

[0191] Step 206: Generate the first question-and-answer data based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm.

[0192] The target problem paradigm refers to the problem paradigm of the target type. In the embodiments of this application, a problem paradigm library can be pre-built. This problem paradigm library stores various types of problem paradigms to represent the generation ideas of various types of problems, which can guide the generation of various types of problems.

[0193] For example, the question paradigm library may include multiple question paradigms as shown in Table 1 below. Table 1 includes various types of question paradigms, and each question paradigm includes a question description, an answer description, and a question example.

[0194] Table 1

[0195]

[0196] The aforementioned preset type entity refers to an entity with a specific type name. For example, preset type entities may include entities of types such as person names and place names.

[0197] This application embodiment uses Table 1 above as an example to illustrate various types of problem paradigms. The specific problem paradigms are defined by technical personnel. Table 1 above does not constitute a limitation on this application embodiment.

[0198] One possible approach is that the operation in step 206 can be achieved through the following steps (a)-(b).

[0199] a. Generate the first question-and-answer data based on the first entity, the second entity, and the third entity, according to the target question paradigm.

[0200] The second entity is an entity that has an indirect entity relationship with the first entity, and the third entity is an entity that has a direct entity relationship with the second entity and the same entity relationship type. The second entity can provide a basis for generating complex questions, and the third entity can provide a basis for generating question answers. In this case, preliminary first question and answer data can be generated based on the first entity, the second entity, and the third entity, according to the target question paradigm.

[0201] One possible approach is to perform step a as follows: determine the first prompt word based on the target question paradigm; input the first entity, the second entity, and the third entity into the first model, and prompt the first model to generate the first question-and-answer data based on the first entity, the second entity, and the third entity using the first prompt word.

[0202] The first prompt word includes the question-and-answer data generation rules. It should be understood that the target question paradigm provides a framework for generating a certain type of question; therefore, based on the target question paradigm, corresponding prompt words for generating this type of question can be determined. In one possible implementation, different types of question paradigms can correspond to specific prompt words, with the first prompt word being the prompt word corresponding to the target type of question paradigm.

[0203] For example, assuming the target question paradigm is the same as the question paradigm corresponding to the reasoning question, the first prompt could be: Based on the information provided below, design a question that requires multi-step reasoning to answer, where "start" and "end" are the relational subjects in your question, "target" is the final answer to your question, and there is a relationship of the same type between "end" and "target". For example, {question: From end to start, which entities does end need to have the corresponding entity relationship with; answer: "target"}. Note: Do not force the generation of illogical questions. If the provided information cannot generate a reasoning-intensive, logically rigorous question and answer according to the above requirements, please write empty strings for "question" and "answer".

[0204] In the example above, "start" corresponds to the first entity, "end" corresponds to the second entity, and "target" corresponds to the third entity. That is, the first prompt word provides guidance on how to generate the corresponding question based on the first and second entities, and how to generate the corresponding answer based on the third entity.

[0205] The first model is used to generate question-and-answer data, which can generate questions and answers expressed in natural language. In the embodiments of this application, the first model can be a Large Language Model (LLM).

[0206] In the above method, the first prompt word is a prompt word corresponding to the target question paradigm. The first prompt word guides the first model, enabling the first model to generate question-and-answer data of the target type. Furthermore, the first prompt word provides the question generation rules, so the first model can quickly and accurately generate the first question-and-answer data.

[0207] b. Based on the multiple binary relations and the target text block, perform consistency verification on the questions and answers in the first question-and-answer data, and retain the first question-and-answer data if the consistency verification passes.

[0208] To ensure logical consistency between the generated questions and answers, that is, to ensure that the questions and answers correspond, consistency verification of the questions and answers in the first question-and-answer data can improve the accuracy of the question-and-answer data.

[0209] One possible approach is to perform step b as follows: based on the multiple binary relations and the target text block, reason about the questions in the first question-and-answer data to obtain a second reference answer; if the first reference answer and the second reference answer are consistent, determine that the consistency verification of the first question-and-answer data has passed.

[0210] In some embodiments, these multiple binary relations are used to represent the relationship flow information between the first entity and the second or third entity throughout the entire relationship chain. Therefore, the relationship transmission process throughout the entire relationship chain can be known through these multiple binary relations. Furthermore, the target text block contains the source text of this relationship chain. This relationship chain can be inferred from the target text block. In this case, the answer to the question generated based on this relationship chain can be accurately inferred.

[0211] Therefore, in the above method, by reasoning and answering the questions in the first question-and-answer data based on the multiple binary relations and the target text block, a relatively accurate answer to the question (second reference answer) can be obtained, which is equivalent to providing the standard answer to the question. If the first reference answer and the second reference answer are consistent, it means that the answer generated by the first model corresponds to the question and can accurately answer the question, which also indicates that the first question-and-answer data is accurate. Then the first question-and-answer data can be used for the training of the target model.

[0212] In some embodiments, a target document may also be obtained, and based on the multiple binary relations, target text blocks, and target document, inferences are made to answer the questions in the first question-and-answer data to obtain a second reference answer.

[0213] It should be understood that the target document contains a more complete knowledge system. Since there may be connections between knowledge, the knowledge described in the target text block may also be related to other knowledge in the target document. In this case, by using these multiple binary relations, the target text block and the target document, more comprehensive and accurate reasoning can be achieved, thereby obtaining a more accurate and complete second reference answer.

[0214] Optionally, if the second reference answer is inconsistent with the first reference answer, the questions and answers in the first question-and-answer data can be adjusted to obtain updated first question-and-answer data. Then, consistency verification is performed on the updated first question-and-answer data until the final first question-and-answer data passes consistency verification.

[0215] One possible approach is that the specific operations described above for verifying the consistency of the first question-and-answer data can be implemented using the first model.

[0216] Specifically, when inputting the first entity, the second entity, and the third entity, the multiple binary relations, target text blocks, and target documents are input together into the first model. After the first model generates the first question-and-answer data based on the first entity, the second entity, and the third entity, the first model can be guided by the third prompt word to perform consistency verification on the first question-and-answer data based on the multiple binary relations, target text blocks, and target documents.

[0217] The third prompt is used to provide task hints for consistency verification, as well as specific guidance on how to perform the verification. For example, the third prompt could be: After the question-and-answer data is generated, based on the provided reference information (multiple binary relations, target text blocks, and target documents), reason step by step to answer the "question," obtain a reasoning result, and determine whether your generated answer is consistent with this reasoning result. If they are inconsistent, please further adjust your "question" and "answer" until your generated answer matches the reasoning result. Finally, return the adjusted "question" and "answer" in JSON format.

[0218] Steps 201-206 above describe the process of generating the first question-and-answer data based on the target document in the target domain. It should be understood that the target document is a document containing various knowledge in the target domain. Therefore, the first question-and-answer data generated based on the target document is more inclined to the question-and-answer data in the guidance and suggestion scenario in the target domain. This kind of question-and-answer data can obtain the corresponding answer without combining specific data analysis information. It is question-and-answer data based purely on the knowledge system.

[0219] However, in real-world scenarios, tasks are not limited to guidance and suggestions; they may also include tasks such as store data analysis and business analysis. For example, users might ask questions like, "Please compare the order conversion rate this month with the order conversion rate last month—has it increased or decreased?" Answering such questions requires specific data values ​​to complete the corresponding reasoning process and arrive at the correct answer. Therefore, to improve the target model's reasoning ability in these scenarios, the first question-and-answer data can be converted into second question-and-answer data.

[0220] The second question-and-answer data is obtained by combining specific data values ​​with the first question-and-answer data. In other words, the second question-and-answer data is based on the first question-and-answer data and combined with specific data values ​​to obtain question-and-answer data that can solve data analysis problems in practical applications.

[0221] One possible approach is to first generate multiple data fields based on the first question-and-answer data; and then, if these multiple data fields meet preset conditions, convert the first question-and-answer data into second question-and-answer data.

[0222] These multiple data fields can be multiple entities included in the first question and answer data. Since technicians can set various data fields to obtain and save corresponding data in specific application scenarios, and these data fields may be some entities, in the above method, by generating multiple data fields based on the first question and answer data, it can be known whether the generated question and answer data can be mapped to a specific application scenario. By obtaining the corresponding data values, the second question and answer data can be obtained. This ensures that the first question and answer data is converted into the second question and answer data only when it can be mapped to the actual application scenario and the corresponding data values ​​are obtained.

[0223] Specifically, when there are formula calculation rules among the multiple data fields, it is determined that the multiple data fields meet the preset conditions; or, when the multiple data fields are data fields used in a preset scenario, it is determined that the multiple data fields meet the preset conditions.

[0224] The first method described above involves determining whether the multiple data fields include the conditions of a calculation formula. For example, if the formula is: Store Conversion Rate = Number of People Entering the Store / Number of People Being Viewed, then if the multiple data fields include "Store Conversion Rate," "Number of People Entering the Store," and "Number of People Being Viewed," then the multiple data fields meet the preset conditions. Since the presence of formula calculation rules in multiple data fields indicates a high likelihood of receiving data calculation-related questions in practical applications, in such cases, the first question-and-answer data can be converted into a second question-and-answer data incorporating specific data values.

[0225] The second method described above involves determining whether the multiple data fields are used in a specific scenario. Since some specific scenarios involve data analysis tasks, these scenarios require second question-and-answer data to support the training of the target model. Therefore, if the multiple data fields are those specific to this scenario, it means that the first question-and-answer data can be converted into second question-and-answer data combined with specific data values. It should be understood that preset scenarios can be pre-set by technical personnel according to actual needs.

[0226] In the above method, by determining multiple data fields and converting the first question-and-answer data into the second question-and-answer data when the multiple data fields meet the preset conditions, question-and-answer data combined with specific data values ​​can be obtained, thereby generating question-and-answer data that fits the actual application. Subsequently, the target model can be trained based on this data, which can improve the target model's ability to solve practical problems.

[0227] The following describes how to convert the first question and answer data into the second question and answer data. The specific operation of converting the first question and answer data into the second question and answer data can include the following steps (1)-(3).

[0228] (1) For any one of the multiple data fields, query the index name of the reference field that is related to this data field from the target data table.

[0229] The target data table is a data index table set up based on the data function tables in the actual application scenario. The target data table includes a table function description, data format, field identifiers and descriptions of the multiple fields involved, and the index name corresponding to each field. The index name of a field can be obtained by combining the table function description and the field description.

[0230] Since a data field is a relatively broad expression, such as order conversion rate, there may be more granular fields related to this data field, such as "average daily order conversion rate in the past 7 days" and "order conversion rate in the past 7 days". By setting a unique index name for these more granular fields, it becomes easier to query data values ​​related to the data field in the future.

[0231] One possible approach is to identify the reference field if the description of a field in the target data table contains the data field itself. This indicates that the field represents a more granular division of the data field, and the corresponding index name can then be obtained.

[0232] In the above method, the reference field that is related to this data field should be a more granular field division of this data field. Then, by querying the index name corresponding to the reference field that is related to this data field from the target data table, all data values ​​that are related to this data field can be obtained in the future, so as to obtain more comprehensive data. This makes the second question and answer data generated later more accurate.

[0233] (2) Based on the index name, query the data value of the reference field that is related to this data field.

[0234] After obtaining the index names of all reference fields that are related to this data field, the data value corresponding to each reference field can be obtained based on the index name of each reference field. Therefore, by obtaining the corresponding data value based on the index name of each reference field associated with each of the multiple data fields, it is possible to obtain the data values ​​corresponding to all reference fields associated with each of the multiple data fields.

[0235] It is worth noting that, in order to increase the amount of question and answer data generated, different stores can be switched to obtain the data values ​​of the reference fields associated with each of the multiple data fields from different stores, thereby obtaining multiple sets of data values, which can then be used to convert and obtain multiple second question and answer data.

[0236] It is worth noting that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0237] (3) Based on the data value of the reference field associated with each of the multiple data fields, the first question and answer data is converted into the second question and answer data.

[0238] One possible approach is to input the first question-and-answer data and the data values ​​of the reference fields associated with each of the multiple data fields into the second model, and then use a second prompt word to guide the second model to convert the first question-and-answer data into second question-and-answer data based on data value inference.

[0239] The second prompt word is used to provide the conversion rules for transforming the first question-and-answer data into the second question-and-answer data. For example, the second prompt word could be: "Based on the provided data, modify the original plain text question into a question that incorporates specific data values, and replace the answer with the corresponding data values. The modified question does not change the logical basis of the question, and the derivation of the answer also needs to rely on the same theoretical method. The final output format is: {data_question: ...; data_answer: ...}."

[0240] The second model is used to convert the first question-and-answer data into the second question-and-answer data. In other words, it is used to generate the second question-and-answer data containing specific data based on the first question-and-answer data and add specific data requirements to meet the needs of practical applications.

[0241] For example, the first question-and-answer data is {question: Given the number of exposures, what parameters are needed to calculate the store conversion rate; answer: Number of people entering the store}. The reference field values ​​associated with each of these data fields include: "Average daily store conversion rate in the last 7 days": "0.1", "Average daily store conversion rate in the last 7 days": "0.7", "Average daily exposures in the last 7 days": "5000", and "Average daily store visitors in the last 7 days": "500". Therefore, the second question-and-answer data that can be obtained based on this data value is: {data_question: Given 5000 exposures and a store conversion rate of 0.1, how many people entered the store; data_answer: 500}.

[0242] It is worth noting that after converting the first question-and-answer data into the second question-and-answer data, consistency verification can also be performed on the second question-and-answer data.

[0243] Specifically, multiple binary relations, target text blocks, and target documents can be input into the second model, and the second model can be guided by a third prompt word to perform consistency verification on the second question-and-answer data based on these multiple binary relations, target text blocks, and target documents.

[0244] It should be understood that guiding the second model to perform consistency verification on the second question-and-answer data based on the multiple binary relations, target text blocks, and target documents through the third prompt word is similar to guiding the first model to perform consistency verification on the first question-and-answer data based on the multiple binary relations, target text blocks, and target documents through the third prompt word, and will not be elaborated here.

[0245] In steps (1) to (3) above, all data values ​​related to each data field are first obtained, and then the first question-and-answer data is converted into second question-and-answer data by combining the various data values ​​related to each data field. In this way, more comprehensive data values ​​can be obtained, thereby generating second question-and-answer data that is more in line with actual applications, which means that the data quality of the second question-and-answer data can be improved.

[0246] It should be understood that the embodiments of this application are used to illustrate the question-and-answer data generation method by taking the generation of one question-and-answer data as an example. In this solution, multiple first question-and-answer data and multiple second question-and-answer data can be generated by combining multiple entities in the target knowledge graph, so that a domain dataset under the target domain can be constructed in the future.

[0247] In some embodiments, after generating multiple first question-and-answer data and multiple second question-and-answer data, similar questions can be deduplicated to ensure that there are no semantically duplicated question-and-answer data among the generated multiple question-and-answer data.

[0248] In some embodiments, after generating multiple first question-and-answer data and multiple second question-and-answer data, sentence transformation can be performed on the multiple first question-and-answer data and multiple second question-and-answer data to obtain sentence-transformed first question-and-answer data and second question-and-answer data.

[0249] By transforming the sentence structure, the subject of the question in the question-and-answer data may change, and thus the answer will also change, similar to "one question with multiple questions". In this way, the diversity of question-and-answer data can be improved.

[0250] This application also provides a quality assessment mechanism for question-and-answer data, which includes an assessment based on rule compliance and an assessment based on reasoning complexity. The rule compliance assessment determines whether the question-and-answer data is generated according to the question generation rules. It should be understood that if question-and-answer data is generated according to the generation rules, the quality score can be increased accordingly. The reasoning complexity assessment determines the reasoning complexity of the question-and-answer data, that is, whether the reasoning process for answering the question implicitly involves multiple steps of reasoning or knowledge integration. If the question-and-answer data conforms to this assessment mechanism, the quality score can be increased accordingly.

[0251] By evaluating the generated question-and-answer data based on the aforementioned quality assessment mechanism, a corresponding quality score can be obtained. It should be understood that when the quality score meets a certain requirement, the corresponding question-and-answer data can be used for subsequent model training; conversely, when the quality score does not meet the requirement, the corresponding question-and-answer data cannot be used for subsequent model training.

[0252] In this way, by evaluating the question-and-answer data through the above quality assessment mechanism, the question-and-answer data can be used for subsequent model training only when the quality score meets the requirements. This can improve the data quality of the question-and-answer data and make the reasoning ability of the target model trained later stronger.

[0253] It is worth noting that the question-and-answer data generation method provided in this application can extract and synthesize question information with controllable complexity based on entity-relationship links in a knowledge graph, forming vertical knowledge reasoning-intensive question-and-answer data with rigorous reasoning logic and clear answers. Furthermore, by generating first and second question-and-answer data in this application, corresponding question-and-answer data can be constructed for scenarios such as data analysis, problem insight, and suggestion guidance in the business operation field. Thus, it is possible to generate question-and-answer data across all scenarios in the target domain.

[0254] In this embodiment, the server first constructs a target knowledge graph based on target documents associated with the target domain. Then, starting from any first entity in the target knowledge graph, a multi-step search is performed to obtain a second entity. The entity relationship between the found second entity and the first entity is an indirect entity relationship, meaning that multiple steps of reasoning are required to obtain the second entity from the first entity. Next, candidate entities with a direct entity relationship and the same entity relationship type as the second entity are queried from the target knowledge graph and identified as the third entity. The indirect entity relationship between the first and second entities is then decomposed into multiple binary relations. Based on these binary relations, target text blocks describing the indirect entity relationship are obtained from the target documents. Finally, first question-and-answer data is generated based on the first entity, the second entity, the third entity, the multiple binary relations, and the target question paradigm. By performing multi-step searches within the target knowledge graph, and subsequently generating questions based on two entities with indirect entity relationships, the generated questions also require multiple steps of reasoning to arrive at an answer. Since the answer to the question may be an entity related to the second entity, identifying a third entity provides a basis for answer generation. Furthermore, by extracting target text blocks describing this indirect entity relationship from the target document, the accuracy of the first question-and-answer data is ensured. In this way, questions with complex logic and corresponding answers can be accurately generated, thereby increasing the complexity of question-and-answer data generation in the target domain and ultimately improving the quality of the question-and-answer data.

[0255] This application provides a question-and-answer method. Figure 3 This is a flowchart illustrating a question-and-answer method provided in an embodiment of this application. This question-and-answer method can be applied to a client-side application; see [link / reference]. Figure 3 The method includes the following steps.

[0256] Step 301: In response to the input operation on the target question, obtain the target question.

[0257] The target question can be a question raised by a user. In one possible way, the client can deploy a dialogue system that can answer the user's question. In this embodiment, the user can refer to a merchant.

[0258] For example, a dialogue system may have a dialogue interface where users can input a target question. The client can obtain the target question input by the user and send it to the server, so that the server can deduce the target answer based on the target question.

[0259] Step 302: Receive and display the target answer. The target answer is the answer to the target question output by the target model after inputting the target question. The target model is trained based on the question-and-answer data generated by the question-and-answer data generation method.

[0260] In this embodiment, a target model can be deployed on the server. This target model can be pre-trained based on question-and-answer data generated by the question-and-answer data generation method provided in the above embodiments. By inputting a target question into the target model, the target model can reason about and answer the target question, obtaining the corresponding target answer. The server can then send the target answer output by the target model to the client, allowing the client to receive and display the answer, thus providing the user with the answer to the target question.

[0261] One possible approach is to pre-train the target model based on a dataset from the target domain.

[0262] The target domain dataset includes multiple question-and-answer data, which can be question-and-answer data generated by the question-and-answer data generation method provided in the above embodiments (including first question-and-answer data and second question-and-answer data).

[0263] It should be understood that a pre-trained base model can be obtained, and then the base model can be supervised fine-tuned and trained using reinforcement learning through multiple question-and-answer data in the target domain dataset. The model after training is the target model.

[0264] In this embodiment, since the question-and-answer data generated by the question-and-answer data generation method has complex logic, a target model is trained based on the generated data. This target model then possesses the ability to handle complex problems within the target domain. In this case, the client responds to the input operation of the target question, obtains the target question, inputs it into the target model, and the target model can accurately reason about the target question, thereby outputting a relatively accurate target answer. Subsequently, the client displays the target answer, allowing the user to obtain an answer that meets their expectations, thus improving the user experience.

[0265] Figure 4 This is a schematic diagram of a question-and-answer data generation device provided in an embodiment of this application. The question-and-answer data generation device can be implemented as part or all of a computer device by software, hardware, or a combination of both. This computer device can be as described below. Figure 6 The computer equipment shown. See also Figure 4 The device includes: an acquisition module 401, a map construction module 402, an entity lookup module 403, and a generation module 404.

[0266] Module 401 is used to acquire target documents associated with the target domain;

[0267] The graph construction module 402 is used to construct a target knowledge graph based on the target document. The target knowledge graph includes multiple entities and the entity relationships between the multiple entities.

[0268] The entity lookup module 403 is used to perform a multi-step search for any first entity in the target knowledge graph, starting from the first entity, to obtain the second entity, and to extract the indirect entity relationship between the first entity and the second entity from the target knowledge graph; to query multiple candidate entities that have a direct entity relationship with the second entity from the target knowledge graph, and to determine the candidate entities with the same entity relationship type as the second entity among the multiple candidate entities as the third entity;

[0269] The acquisition module 401 is also used to decompose the indirect entity relationship into multiple binary relations, and based on the multiple binary relations, to acquire the target text block, which is the text content in the target document that describes the indirect entity relationship;

[0270] The generation module 404 is used to generate the first question and answer data based on the first entity, the second entity, the third entity, multiple binary relations, the target text block, and the target question paradigm.

[0271] In one possible implementation, the graph construction module 402 is specifically used for:

[0272] The target document is segmented into multiple text blocks;

[0273] Entity extraction and entity relation extraction are performed on each text block in multiple text blocks to obtain multiple reference entities and entity relations between multiple reference entities.

[0274] The target knowledge graph is obtained by integrating multiple reference entities and the entity relationships between them.

[0275] In one possible implementation, the graph construction module 402 is specifically used for:

[0276] An initial knowledge graph is obtained by representing multiple reference entities and the entity relationships between them using multiple triples.

[0277] The initial knowledge graph is hierarchically clustered to obtain the target knowledge graph.

[0278] In one possible implementation, the entity lookup module 403 is specifically used for:

[0279] For any first entity in the target knowledge graph, search twice starting from the first entity to obtain the query entity;

[0280] When the entity relationship between the query entity and the first entity is an indirect entity relationship, the query entity will be identified as the second entity.

[0281] If the entity being searched has a direct relationship with the first entity, continue searching until the entity being searched has an indirect relationship with the first entity.

[0282] In one possible implementation, the generation module 404 is used for:

[0283] Based on the first entity, the second entity, and the third entity, generate the first question-and-answer data according to the target question paradigm;

[0284] Based on multiple binary relations and target text blocks, consistency verification is performed on the questions and answers in the first question-and-answer data, and the first question-and-answer data is retained if the consistency verification passes.

[0285] In one possible implementation, the generation module 404 is specifically used for:

[0286] Based on the target question paradigm, the first prompt word is determined, which includes the question-and-answer data generation rules.

[0287] The first entity, the second entity, and the third entity are input into the first model. The first prompt word prompts the first model to generate the first question-and-answer data based on the first entity, the second entity, and the third entity.

[0288] In one possible implementation, the first question-and-answer data includes a question and a first reference answer, and the generation module 404 is specifically used for:

[0289] Based on multiple binary relations and target text blocks, the question is reasoned to obtain a second reference answer;

[0290] If the first reference answer and the second reference answer are consistent, the consistency verification of the first question and answer data is confirmed to be successful.

[0291] In one possible implementation, the generation module 404 is further configured to: generate multiple data fields based on the first question-and-answer data;

[0292] The question-and-answer data generation device also includes:

[0293] The conversion module is used to convert the first question and answer data into the second question and answer data when multiple data fields meet preset conditions.

[0294] In one possible implementation, the question-and-answer data generation device further includes:

[0295] The determination module is used to determine whether multiple data fields meet preset conditions when there are formula calculation rules among them; or, when multiple data fields are data fields used in a preset scenario, to determine whether multiple data fields meet preset conditions.

[0296] In one possible implementation, the conversion module is specifically used for:

[0297] For any one of the multiple data fields, retrieve the index name of the reference field that is related to the data field from the target data table;

[0298] Based on the index name, retrieve the data value of the reference field that is related to the data field;

[0299] Based on the data values ​​of the reference fields associated with each of the multiple data fields, the first question and answer data is converted into the second question and answer data.

[0300] In one possible implementation, the conversion module is specifically used for:

[0301] The first question-and-answer data and the data values ​​of the reference fields associated with each of the multiple data fields are input into the second model. The second prompt word prompts the second model to convert the first question-and-answer data into second question-and-answer data based on data value reasoning.

[0302] In this embodiment, a target knowledge graph is first constructed based on target documents associated with the target domain. Then, starting from any first entity in the target knowledge graph, a multi-step search is performed to obtain a second entity. The entity relationship between the found second entity and the first entity is an indirect entity relationship, meaning that multiple steps of reasoning are required to obtain the second entity from the first entity. Next, candidate entities with a direct entity relationship and the same entity relationship type as the second entity are queried from the target knowledge graph and identified as the third entity. The indirect entity relationship between the first and second entities is then decomposed into multiple binary relations. Based on these binary relations, target text blocks describing the indirect entity relationship are obtained from the target documents. Finally, based on the first entity, the second entity, the third entity, the multiple binary relations, and the target question paradigm, first question-answer data is generated. By performing multi-step searches within the target knowledge graph, and subsequently generating questions based on two entities with indirect entity relationships, the generated questions also require multiple steps of reasoning to arrive at an answer. Since the answer to the question may be an entity related to the second entity, identifying a third entity provides a basis for answer generation. Furthermore, by extracting target text blocks describing this indirect entity relationship from the target document, the accuracy of the first question-and-answer data is ensured. In this way, questions with complex logic and corresponding answers can be accurately generated, thereby increasing the complexity of question-and-answer data generation in the target domain and ultimately improving the quality of the question-and-answer data.

[0303] It should be noted that the question-and-answer data generation device provided in the above embodiments is only illustrated by the division of the above functional modules when generating question-and-answer data. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0304] The question-and-answer data generation device and question-and-answer data generation method provided in the above embodiments belong to the same concept. The specific working process and technical effects of the units and modules in the above embodiments can be found in the method embodiments section, and will not be repeated here.

[0305] Figure 5 This is a schematic diagram of a question-and-answer device provided in an embodiment of this application. The question-and-answer device can be implemented as part or all of a computer device by software, hardware, or a combination of both. This computer device can be as described below. Figure 6 The computer equipment shown. See also Figure 5 The device includes: an acquisition module 501 and a receiving module 502.

[0306] The acquisition module 501 is used to acquire the target question in response to an input operation on the target question;

[0307] The receiving module 502 is used to receive and display the target answer. The target answer is the answer to the target question output by the target model after the target question is input into the target model. The target model is trained based on the question and answer data generated by the question and answer data generation method.

[0308] In this embodiment, since the question-and-answer data generated by the question-and-answer data generation method has complex logic, a target model is trained based on the generated data. This target model then possesses the ability to handle complex problems within the target domain. In this case, in response to an input operation on the target question, the target question is obtained. After the target question is input into the target model, the model can perform accurate reasoning on the target question, thereby outputting a relatively accurate target answer. Thus, users can obtain answers that meet their expectations, thereby improving the user experience.

[0309] It should be noted that the question-and-answer device provided in the above embodiments is only illustrated by the division of the above functional modules when answering questions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0310] The functional units and modules in the above embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of the embodiments of this application.

[0311] The question-answering device and question-answering method embodiments provided in the above embodiments belong to the same concept. The specific working process and technical effects of the units and modules in the above embodiments can be found in the method embodiment section, and will not be repeated here.

[0312] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 6 As shown, the computer device 600 includes: a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60. When the processor 60 executes the computer program 62, it implements the steps in the question-and-answer data generation method or question-and-answer method in the above embodiments.

[0313] The computer device 600 can be a general-purpose computer device or a special-purpose computer device. In specific implementations, the computer device 600 can be a desktop computer, a portable computer, a handheld computer, a mobile phone, a tablet computer, or a network server. This application embodiment does not limit the type of computer device 600. Those skilled in the art will understand that... Figure 6 The computer device 600 is merely an example and does not constitute a limitation on the computer device 600. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.

[0314] Processor 60 can be a Central Processing Unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0315] In some embodiments, memory 61 may be an internal storage unit of computer device 600, such as a hard disk or memory of computer device 600. In other embodiments, memory 61 may be an external storage device of computer device 600, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on computer device 600. Furthermore, memory 61 may include both internal and external storage units of computer device 600. Memory 61 is used to store operating system, application programs, boot loader, data, and other programs. Memory 61 may also be used to temporarily store data that has been output or will be output.

[0316] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps in the various method embodiments described above.

[0317] This application provides a computer program product that, when run on a computer, causes the computer to perform the steps described in the various method embodiments above.

[0318] If the integrated unit is implemented as 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, all or part of the processes in the above method embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a photographing device / terminal device, a recording medium, a computer memory, ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage devices. The computer-readable storage medium mentioned in this application can be a non-volatile storage medium; in other words, it can be a non-transient storage medium.

[0319] It should be understood that all or part of the steps of the above embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented in whole or in part as a computer program product. The computer program product includes one or more computer instructions. The computer instructions can be stored in the above-described computer-readable storage medium.

[0320] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0321] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0322] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0323] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0324] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for generating question-and-answer data, characterized in that, The method includes: Retrieve target documents related to the target domain; Based on the target document, a target knowledge graph is constructed, which includes multiple entities and the entity relationships between the multiple entities. For any first entity in the target knowledge graph, a multi-step search is performed starting from the first entity to obtain the second entity, and the indirect entity relationship between the first entity and the second entity is extracted from the target knowledge graph. From the target knowledge graph, query multiple candidate entities that have a direct entity relationship with the second entity, and determine the candidate entities among the multiple candidate entities that have the same entity relationship type as the second entity as the third entity; The indirect entity relationship is decomposed into multiple binary relations. Based on the multiple binary relations, a target text block is obtained. The target text block is the text content in the target document that describes the indirect entity relationship. Based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm, generate the first question-and-answer data; The process of generating first question-and-answer data based on the first entity, the second entity, the third entity, the multiple binary relations, the target text block, and the target question paradigm includes: Based on the target question paradigm, a first prompt word is determined, which includes question-and-answer data generation rules. The first entity, the second entity, and the third entity are input into the first model, and the first prompt word prompts the first model to generate the first question-and-answer data based on the first entity, the second entity, and the third entity; Based on the multiple binary relations and the target text block, the questions and answers in the first question-and-answer data are verified for consistency, and the first question-and-answer data is retained if the consistency verification passes.

2. The method according to claim 1, characterized in that, The construction of the target knowledge graph based on the target document includes: The target document is segmented into multiple text blocks; Entity extraction and entity relation extraction are performed on each of the multiple text blocks to obtain multiple reference entities and entity relations between the multiple reference entities. The target knowledge graph is obtained by integrating the multiple reference entities and the entity relationships between them.

3. The method according to claim 2, characterized in that, The process of integrating the multiple reference entities and their relationships to obtain the target knowledge graph includes: An initial knowledge graph is obtained by representing the multiple reference entities and the entity relationships between the multiple reference entities using multiple triples. The initial knowledge graph is subjected to hierarchical clustering to obtain the target knowledge graph.

4. The method according to claim 1, characterized in that, The step of performing a multi-step search starting from any first entity in the target knowledge graph to obtain a second entity includes: For any first entity in the target knowledge graph, search twice starting from the first entity to obtain the query entity; When the entity relationship between the queried entity and the first entity is an indirect entity relationship, the queried entity is determined as the second entity; If the entity relationship between the queried entity and the first entity is a direct entity relationship, the search continues until the queried entity and the first entity have an indirect entity relationship.

5. The method according to claim 1, characterized in that, The first question-and-answer data includes questions and a first reference answer. The consistency verification of the questions and answers in the first question-and-answer data based on the multiple binary relations and the target text block includes: Based on the multiple binary relations and the target text block, the question is reasoned and answered to obtain a second reference answer; If the first reference answer is consistent with the second reference answer, the consistency verification of the first question and answer data is determined to be successful.

6. The method according to any one of claims 1-5, characterized in that, After generating the first question-and-answer data based on the first entity, the second entity, and the third entity according to the target question paradigm, the process further includes: Based on the first question and answer data, multiple data fields are generated; If the multiple data fields meet the preset conditions, the first question and answer data is converted into the second question and answer data.

7. The method according to claim 6, characterized in that, The method further includes: If there are formula calculation rules among the multiple data fields, determine that the multiple data fields satisfy the preset conditions; or, When the multiple data fields are data fields used in a preset scenario, it is determined that the multiple data fields satisfy the preset conditions.

8. The method according to claim 6, characterized in that, The step of converting the first question-and-answer data into second question-and-answer data when the multiple data fields meet preset conditions includes: For any one of the multiple data fields, query the index name corresponding to the reference field that is related to the data field from the target data table; Based on the index name, query the data value of the reference field that is related to the data field; Based on the data value of the reference field associated with each of the plurality of data fields, the first question and answer data is converted into second question and answer data.

9. The method according to claim 8, characterized in that, The process of converting the first question-and-answer data into second question-and-answer data based on the data value of a reference field associated with each of the plurality of data fields includes: The first question-and-answer data and the data values ​​of the reference fields associated with each of the plurality of data fields are input into the second model. The second prompt word prompts the second model to convert the first question-and-answer data into the second question-and-answer data based on data value reasoning.

10. A question-and-answer method, characterized in that, The method includes: In response to an input operation on the target problem, the target problem is obtained; Receive and display the target answer, wherein the target answer is the answer to the target question output by the target model after the target question is input into the target model, and the target model is trained based on the question and answer data generated by the question and answer data generation method according to any one of claims 1-9.

11. A computer device, characterized in that, The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the method as described in any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 10.