CN110781274A - Question-answer pair generation method and device - Google Patents

Question-answer pair generation method and device Download PDF

Info

Publication number
CN110781274A
CN110781274A CN201910880193.7A CN201910880193A CN110781274A CN 110781274 A CN110781274 A CN 110781274A CN 201910880193 A CN201910880193 A CN 201910880193A CN 110781274 A CN110781274 A CN 110781274A
Authority
CN
China
Prior art keywords
information
question
answer pair
answer
text
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910880193.7A
Other languages
Chinese (zh)
Inventor
王励
陈咨尧
钟黎
刘黎春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910880193.7A priority Critical patent/CN110781274A/en
Publication of CN110781274A publication Critical patent/CN110781274A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a question-answer pair generation method, which can improve the matching degree between questions and answers of the question-answer pair. After obtaining a text to be analyzed, generating a candidate question-answer pair according to the text to be analyzed, wherein the text to be analyzed comprises n layers of information, n is greater than or equal to 2, the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information. And finally, determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.

Description

Question-answer pair generation method and device
Technical Field
The present application relates to the field of network technologies, and in particular, to a method and an apparatus for generating a question-answer pair.
Background
With the rapid development of artificial intelligence technology, the demand of users for intelligent question answering is increasing day by day, specifically, the intelligent question answering accurately positions the questions of the users in a question-answer mode, and provides personalized information service for the users through interaction with the users.
One of the core points of the intelligent question answering is a corpus stored with basic data. The important component of the corpus is Frequently used question-answer pair (FAQ) composed of a standard question and a corresponding standard answer sentence. The FAQ is usually created by manual maintenance and entry, for example, question sentences and answer sentences with question-answer relationships are manually extracted from the document contents to generate question-answer pairs.
However, in the above manual entry process, the matching degree between the extracted partial question sentences and answer sentences is not high enough due to the uneven levels of the languages or professional qualities of the entered personnel.
Disclosure of Invention
The embodiment of the application provides a question-answer pair generation method and device, which can improve the matching degree between questions and answers of the question-answer pair.
A first aspect of an embodiment of the present application provides an object control method, including:
acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score corresponding to the candidate question-answer pair through a target classification model;
and determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
A second aspect of the embodiments of the present application provides an apparatus for generating a question-answer pair, including:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a text to be analyzed, the text to be analyzed comprises n layers of information, and n is greater than or equal to 2;
a generating module, configured to generate a candidate question-answer pair according to the text to be analyzed, where the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, a question of the candidate question-answer pair is generated based on upper layer information in the two adjacent layers of information, an answer of the candidate question-answer pair is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
the second acquisition module is used for acquiring the relevance score corresponding to the candidate question-answer pair through a target classification model;
and the determining module is used for determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
Based on the second aspect, in a first implementation manner of the second aspect in this embodiment of the application, the generating module is further configured to:
acquiring adjacent two layers of information from the n layers of information of the text to be analyzed;
acquiring keywords from upper layer information in the two adjacent layers of information and each layer of information to which the upper layer information belongs;
generating a question according to the keyword;
generating an answer according to lower layer information in the two adjacent layers of information;
and generating the candidate question-answer pairs according to the questions and the answers.
Based on the first implementation manner of the second aspect, in a second implementation manner of the second aspect in this embodiment of the application, the generating module is further configured to obtain, through a statement generation model, a question corresponding to the keyword.
Based on the second aspect, in a third implementation manner of the second aspect in this embodiment of the application, the determining module is further configured to determine the candidate question-answer pair with the relevance score greater than or equal to a relevance threshold as a target question-answer pair.
Based on the second aspect, or any one of the first implementation manner to the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect in this embodiment of the application, layer 1 information to layer n-1 information of the n layers of information are level 1 headings to level n-1 headings in the text to be parsed, and layer n information of the n layers of information is a paragraph under the level n-1 headings of the text to be parsed.
In a third aspect of the embodiments of the present application, a method for model training includes:
acquiring a question-answer pair to be trained, wherein the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, the question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, the answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score of the question-answer pair to be trained through a classification model to be trained;
and training the classification model to be trained through a target loss function according to the relevance score and the real score to obtain a target classification model.
A fourth aspect of the embodiments of the present application provides an apparatus for model training, including:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a question-answer pair to be trained, the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, a question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, an answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information;
the second acquisition module is used for acquiring the relevance score of the question-answer pair to be trained through the classification model to be trained;
and the training module is used for training the classification model to be trained through a target loss function according to the relevance value and the real value to obtain a target classification model.
A fifth aspect of an embodiment of the present application provides a terminal device, including: a memory, a transceiver, a processor, and a bus system;
wherein the memory is used for storing programs;
the processor is used for executing the program in the memory and comprises the following steps:
acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score corresponding to the candidate question-answer pair through a target classification model;
determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair;
the bus system is used for connecting the memory and the processor so as to enable the memory and the processor to communicate.
A sixth aspect of embodiments of the present application is a computer-readable storage medium, comprising instructions that, when executed on a computer, cause the computer to perform the method according to the first or third aspect.
According to the technical scheme, the embodiment of the application has the following advantages:
the embodiment of the application provides a question-answer pair generation method, which is used for generating a candidate question-answer pair according to a text to be analyzed after the text to be analyzed is obtained, wherein the text to be analyzed comprises n layers of information, n is greater than or equal to 2, the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information. And finally, determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair. In the process, because the content information of the text to be analyzed has a hierarchical relationship, the question and the answer of the candidate question-answer pair generated based on the two adjacent layers of information have a certain matching relationship, and the candidate question-answer pair is screened based on the degree of correlation (namely the degree of the correlation score) between the question and the answer through the target classification model, so that the finally determined question and answer of the target question-answer pair can have a higher matching degree.
Drawings
Fig. 1 is a schematic flow chart of a method for generating question-answer pairs in an embodiment of the present application;
FIG. 2 is a schematic diagram of a tree structure in an embodiment of the present application;
FIG. 3 is a schematic diagram of an application of an end-to-end model in an embodiment of the present application;
FIG. 4 is a schematic flow chart of a method of model training in an embodiment of the present application;
fig. 5 is a schematic structural diagram of a device for generating question-answer pairs in the embodiment of the present application;
FIG. 6 is a schematic structural diagram of an apparatus for model training in an embodiment of the present application;
fig. 7 is a schematic structural diagram of a terminal device in the embodiment of the present application.
Detailed Description
The embodiment of the application provides a question-answer pair generation method and device, which can improve the matching degree between questions and answers of the question-answer pair.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "corresponding" and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be appreciated that as artificial intelligence technology is researched and developed, artificial intelligence technology has been developed and applied in a variety of fields. The method adopts a Natural Language Processing (NLP) technology to generate the question and answer pair, wherein the natural Language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, intelligent question answering, knowledge mapping, and the like.
The question-answer pair (composed of a standard question and a corresponding standard answer) generated by the application can be applied to an intelligent question-answer scene. The intelligent question-answer method accurately positions the questions of the user in a question-answer mode, and provides personalized information service for the user through interaction with the user. It can be understood that, after the user inputs a question through the terminal device, the terminal device determines that the question of the user is similar to the question in a question-answer pair, and then the answer in the question-answer pair can be returned as the question result of the user for the user to use.
Therefore, in order to satisfy the question requirement of the user, the questions and the answers in the question-answer pair must keep a certain matching degree.
In order to improve the matching degree between the questions and the answers in the question-answer pair, the following describes a method for generating the question-answer pair provided in the embodiment of the present application from the perspective of the terminal device. Fig. 1 is a schematic flow chart of a method for generating a question-answer pair in an embodiment of the present application, and referring to fig. 1, an embodiment of the method for generating a question-answer pair in an embodiment of the present application includes:
101. acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
in this embodiment, when the entry staff needs to generate question-answer pairs on the terminal device for entering the corpus, the text to be analyzed for extracting information may be selected and input to the terminal device. It should be noted that the text to be parsed may be a text having a certain hierarchical relationship, where the hierarchical relationship generally means that content information of the text is presented in a progressive format layer by layer, and specifically, the text to be parsed may be a product description, an instruction manual, and the like, where the text includes n layers of information, where a first layer of information includes a second layer of information, a second layer of information includes a third layer of information, and the like, until the nth layer of information, and n is greater than or equal to 2. For example, the first layer of information may be social contact, the second layer of information may be social-dependent WeChats and microblogs, the third layer of information may be payment and shake of WeChats dependent on WeChats, hot searches and topics dependent on microblogs, and so on.
102. Generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, the question of the candidate question-answer pair is generated based on upper layer information in the two adjacent layers of information, the answer of the candidate question-answer pair is generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information;
after the terminal equipment acquires the text to be analyzed, candidate question-answer pairs can be generated according to the text to be analyzed. The candidate question-answer pairs are generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pairs are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pairs are generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information.
Specifically, the terminal device may analyze the text to be analyzed to obtain n layers of information in the text, and select a part of information from the n layers of information to generate candidate question-answer pairs. It should be noted that the number of question-answer pairs is at least one, and one question-answer pair is usually generated based on two adjacent layers of information in n layers of information, for example, a pair of candidate question-answer pairs may be formed by first layer information and second layer information having an affiliation, where the information at the upper layer may be used to generate questions and the information at the lower layer may be used to generate answers, for example, when the first layer information is social contact and the second layer information is micro-letter and micro-blog, the questions in the candidate question-answer pair may be generated based on social contact, and the answers in the candidate question-answer pair may be generated based on micro-letter and micro-blog, so that the questions and answers of the candidate question-answer pair generated based on the two adjacent layers of information have a certain matching degree.
103. Obtaining a relevance score corresponding to the candidate question-answer pair through a target classification model;
after the candidate question-answer pairs are obtained, the relevance of the candidate question-answer pairs can be judged through the target classification model, and the relevance scores of the candidate question-answer pairs are obtained. It is understood that the target classification model is used to determine whether the questions and answers in the candidate question-answer pairs have a certain correlation, i.e., whether the questions and answers can constitute a question-answer relationship. Because the question-answer pairs generated in step 102 are not in exact question-answer relationship, there may be a case where the question and answer pairs are not matched, that is, "question-not-answer", and this case is usually caused by the fact that when the multi-layer information of the text is automatically extracted, except for the fact that the information is extracted by mistake or the content of the text itself is written with errors.
Therefore, through the target classification model, the relevance judgment can be carried out on the candidate question-answer pairs one by one to obtain the relevance score of each candidate question-answer pair so as to determine whether the question and the answer of each candidate question-answer pair have question-answer relationship,
104. And determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
After obtaining the relevance scores of all candidate question-answer pairs, it is possible to determine which part of the candidate question-answer pairs meets the requirement (i.e., the question and the answer have a question-answer relationship) based on the relevance scores, and determine the part of the candidate question-answer pairs as the target question-answer pairs.
In this embodiment, because the content information of the text to be analyzed has a hierarchical relationship, the question and the answer of the candidate question-answer pair generated based on the two adjacent layers of information have a certain matching relationship, and the candidate question-answer pair is further subjected to screening based on the degree of correlation (i.e., the degree of the correlation score) between the question and the answer through the target classification model, so that the question and the answer of the finally determined target question-answer pair can have a higher matching degree.
Optionally, based on the embodiment corresponding to fig. 1, in an optional embodiment of the method for generating a question-answer pair in the embodiment of the present application, layer 1 information to layer n-1 information of the n layers of information are level 1 titles to level n-1 titles in a text to be analyzed, and layer n information of the n layers of information is a paragraph under level n-1 titles of the text to be analyzed.
In this embodiment, the content information in the text to be parsed has a certain hierarchical relationship, where each layer of information may be presented in the form of a title, for example, a first-level title, a second-level title subordinate to the first-level title, a third-level title subordinate to the second-level title, and the like. It is understood that n layers of information are extracted from the text, i.e. the level 1 to level n-1 headings in the text are extracted as the level 1 to level n-1 information, and the paragraphs under the level n-1 heading are extracted as the nth layer information, so that complete n layers of information can be obtained. It should be noted that, the n-1 level title here refers to the first level title to the n-1 level title of the content information in the text to be analyzed, the n-1 level title is the lowest level title in the text, and the corresponding paragraph under the lowest level title can be used as the nth level information.
Furthermore, the extracted n layers of information can be presented in a tree structure, so that the information can be managed and called in a centralized manner.
For ease of understanding, the tree structure is specifically described below in conjunction with fig. 2. Fig. 2 is a schematic diagram of a tree structure in an embodiment of the present application, please refer to fig. 2, where a null node is used as a root node of the tree structure, and extends outward from the root node to connect with a plurality of primary nodes, each of the primary nodes may connect with a plurality of secondary nodes, and so on until reaching n-level nodes. The information set by the first-level node is a first-level title in the text, the information set by the second-level node is a second-level title in the text, and the like, and the information set by the nth-level node is a paragraph under the (n-1) th-level title of the text. As shown in fig. 2, the contents described in the text are an introduction of an XX area bank card, which is first-level titled "an introduction of an XX area credit card" and "an introduction of an XX area savings card", second-level titled "an introduction of an XX area credit card" is an introduction, a preferential policy, an application condition, an administration condition, and the like, third-level titled "an application condition" is a class a condition and a class B condition, fourth-level titled "a class condition" is a condition that three basic conditions should be provided, and paragraphs "a condition that three basic conditions should be provided" are a condition 1, a condition 2, and a condition 3, respectively.
Optionally, based on each embodiment corresponding to fig. 1, in an optional embodiment of the method for generating question-answer pairs in the embodiment of the present application, the generating candidate question-answer pairs according to the text to be parsed includes:
acquiring adjacent two layers of information from n layers of information of a text to be analyzed;
acquiring keywords from upper layer information in two adjacent layers of information and each layer of information to which the upper layer information belongs;
generating a question according to the keyword;
generating an answer according to lower layer information in two adjacent layers of information;
and generating candidate question-answer pairs according to the questions and the answers.
In this embodiment, after the text to be analyzed is obtained, n layers of information of the text to be analyzed can be obtained through analysis, and then two adjacent layers of information are selected from the n layers of information and used for generating a pair of candidate question-answer pairs. For example, for the branch of the XX region credit card introduction, the lowest nodes (i.e. paragraphs) of "condition 1", "condition 2" and "condition 3" extend upwards to the level node of "class a condition", and at this time, the fifth-level node to the third-level node form a subtree, and in the subtree, the fifth-level node and the fourth-level node are adjacent two-layer information (i.e. paragraphs information of "condition 1", "condition 2", "condition 3" and items of "four-level with three basic conditions" and have the label of adjacent two-layer information), the fourth level node and the third level node are two adjacent layers of information (namely, a fourth level title of 'three basic conditions should be provided' and a third level title of 'type A condition' are two adjacent layers of information). Similarly, the same operations can be performed for the branch described for the XX zone savings card, which is not described herein.
After the two adjacent layers of information are obtained from the n layers of information, the questions and answers of the candidate question-answer pairs can be respectively generated. Specifically, keywords are obtained from upper layer information in two adjacent layers of information and each layer of information to which the upper layer information belongs, a question is generated based on the keywords, and an answer is generated according to lower layer information in two adjacent layers of information.
For example, in two adjacent layers of information composed of four-level headings of "condition 1", "condition 2", "condition 3", and "should have three basic conditions", the upper layer of information is "should have three basic conditions", the subordinate layers of information are "type a conditions", "application conditions", and "XX regional credit card introduction", the extracted keyword may be the XX region, the credit card, the application conditions, the type a conditions, and the three conditions, and based on the keyword, the problem that can be generated is: asking for the credit card in the XX area, three conditions which the A-type conditions should have are what, and the condition 1, the condition 2 and the condition 3 in the lower layer information are answers to the questions, so that a candidate question-answer pair is generated.
For another example, in two adjacent layers of information composed of a four-level title, which is "three basic conditions" and a three-level title, which is "a-type condition", the upper layer of information is "a-type condition", the subordinate layers of information are sequentially "application condition" and "introduction of XX area credit card", the extracted keywords may be XX area, credit card, application condition, and a-type condition, and based on the extracted keywords, the problem may be generated as follows: asking for the credit card in the XX area, what the A-type condition is, and the answer to the question is provided with three basic conditions in the lower layer information, so that another candidate question-answer pair is generated.
Optionally, the method for generating the question according to the keyword detection may be: and obtaining the problems corresponding to the keywords through the statement generation model. Specifically, the statement generation model may be an end-to-end model, fig. 3 is an application diagram of the end-to-end model in the embodiment of the present application, please refer to fig. 3, in the end-to-end model, a plurality of keywords may be input, and after an operation inside the model, the keywords may be combined into a question statement that is approximately applied daily. It should be noted that the end-to-end model here is a trained model for generating a statement representing a question for a specific keyword.
Optionally, based on each embodiment corresponding to fig. 1, in an optional embodiment of the method for generating question-answer pairs in the embodiment of the present application, determining a target question-answer pair from the candidate question-answer pairs according to the relevance score corresponding to the candidate question-answer pair includes:
and determining the candidate question-answer pairs with the relevance scores larger than or equal to the relevance threshold value as target question-answer pairs.
In this embodiment, a correlation threshold is set for determining whether the candidate question-answer pair meets the requirement, that is, the question and the answer have a question-answer relationship. And if the relevance score of a certain candidate question-answer pair is greater than or equal to the relevance threshold, determining the candidate question-answer pair as a target question-answer pair meeting the requirement, and otherwise, deleting the candidate question-answer pair. Still as in the above example, in the candidate question-answer pair consisting of the question "ask for what the three conditions of the class a condition should be in the application conditions for the credit card in the region XX" and the answer "condition 1, condition 2 and condition 3", the question is "ask for what the class a condition is in the application conditions for the credit card in the region XX" and the answer "should be in the three basic conditions", the question and the answer obviously do not have a question-answer relationship, that is, the relevance score is smaller than the relevance threshold value, and the candidate question-answer pair is deleted.
An embodiment of the present application further provides a method for model training, fig. 4 is a schematic flowchart of the method for model training in the embodiment of the present application, please refer to fig. 4, and an embodiment of the method for model training in the embodiment of the present application includes:
401. acquiring a question-answer pair to be trained, wherein the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, the question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, the answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
in this embodiment, a to-be-analyzed text that is prepared in advance and used for training a model may be obtained, and a to-be-trained question-and-answer pair may be generated according to the to-be-analyzed text, it should be noted that the to-be-analyzed text used for training the model may be similar to the text in the above embodiments, and a process of generating the to-be-trained question-and-answer pair may refer to a relevant description of generating a candidate question-and-answer pair in each of the above embodiments, which is not described herein in detail.
402. Obtaining the relevance score of the question-answer pair to be trained through the classification model to be trained;
the step 402 may refer to the related description of step 103 in the above embodiment, and is not described herein again.
403. And training the classification model to be trained through a target loss function according to the relevance value and the real value to obtain a target classification model.
And calculating the deviation between the relevance score and the real score through a target loss function after the relevance score of the question-answer pair to be trained is measured by the model to be trained, if the deviation is overlarge, adjusting the parameters of the classification model to be trained, and training again until the deviation is within an allowable range, so that the target classification model can be obtained.
The above is a specific description of the method in the embodiments of the present application, and the apparatus for generating the question and the apparatus for training the model in the embodiments of the present application will be described below. Fig. 5 is a schematic structural diagram of a device for generating a question-answer pair in an embodiment of the present application, referring to fig. 5, an embodiment of the device for generating a question-answer pair in the embodiment of the present application includes:
a first obtaining module 501, configured to obtain a text to be parsed, where the text to be parsed includes n layers of information, and n is greater than or equal to 2;
a generating module 502, configured to generate a candidate question-answer pair according to the text to be analyzed, where the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, a question of the candidate question-answer pair is generated based on upper layer information in the two adjacent layers of information, an answer of the candidate question-answer pair is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
a second obtaining module 503, configured to obtain, through the target classification model, a relevance score corresponding to the candidate question-answer pair;
a determining module 504, configured to determine a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
Optionally, in an optional embodiment of the apparatus for generating a question-answer pair in the embodiment of the present application, the generating module 502 is further configured to:
acquiring adjacent two layers of information from n layers of information of a text to be analyzed;
acquiring keywords from upper layer information in two adjacent layers of information and each layer of information to which the upper layer information belongs;
generating a question according to the keyword;
generating an answer according to lower layer information in two adjacent layers of information;
and generating candidate question-answer pairs according to the questions and the answers.
Optionally, in an optional embodiment of the apparatus for generating a question-answer pair in the embodiment of the present application, the generating module 502 is further configured to obtain a question corresponding to the keyword through the sentence generation model.
Optionally, in an optional embodiment of the apparatus for generating question-answer pairs in the embodiment of the present application, the determining module 504 is further configured to determine, as the target question-answer pair, a candidate question-answer pair whose relevance score is greater than or equal to a relevance threshold.
Optionally, in an optional embodiment of the apparatus for generating a question-answer pair in the embodiment of the present application, the layer 1 information to the layer n-1 information of the n layers of information are the level 1 title to the level n-1 title in the text to be analyzed, and the layer n information of the n layers of information is a paragraph under the level n-1 title of the text to be analyzed.
An embodiment of the present application further provides a device for model training, fig. 6 is a schematic structural diagram of the device for model training in the embodiment of the present application, please refer to fig. 6, and an embodiment of the device for model training in the embodiment of the present application includes:
a first obtaining module 601, configured to obtain a question-answer pair to be trained, where the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, a question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, an answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information;
a second obtaining module 602, configured to obtain, through a to-be-trained classification model, a relevance score of the to-be-trained question-answer pair;
and the training module 603 is configured to train the classification model to be trained through a target loss function according to the relevance score and the real score, so as to obtain a target classification model.
It should be noted that, because the contents of information interaction, execution process, and the like between the modules/units of the apparatus are based on the same concept as the method embodiment of the present application, the technical effect brought by the contents is the same as the method embodiment of the present application, and specific contents may refer to the description in the foregoing method embodiment of the present application, and are not described herein again.
As shown in fig. 7, for convenience of description, only the portions related to the embodiments of the present application are shown, and details of the specific technology are not disclosed, please refer to the method portion of the embodiments of the present application. The terminal may be any terminal device including a mobile phone, a tablet computer, a Personal Digital Assistant (PDA), a point of sale (POS), a vehicle-mounted computer, and the like, taking the terminal as the mobile phone as an example:
fig. 7 is a schematic structural diagram of a terminal device in the embodiment of the present application. Referring to fig. 7, the handset includes: radio Frequency (RF) circuitry 710, memory 720, input unit 730, display unit 740, sensor 750, audio circuitry 760, wireless fidelity (WiFi) module 770, processor 780, and power supply 790. Those skilled in the art will appreciate that the handset configuration shown in fig. 7 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 7:
the RF circuit 710 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information of a base station and then processes the received downlink information to the processor 780; in addition, the data for designing uplink is transmitted to the base station. In general, the RF circuitry 710 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuit 710 may also communicate with networks and other devices via wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to global system for mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), etc.
The memory 720 may be used to store software programs and modules, and the processor 780 may execute various functional applications and data processing of the cellular phone by operating the software programs and modules stored in the memory 720. The memory 720 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 720 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 730 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone. Specifically, the input unit 730 may include a touch panel 731 and other input devices 732. The touch panel 731, also referred to as a touch screen, can collect touch operations of a user (e.g. operations of the user on or near the touch panel 731 by using any suitable object or accessory such as a finger, a stylus, etc.) and drive the corresponding connection device according to a preset program. Alternatively, the touch panel 731 may include two portions of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts it to touch point coordinates, and sends the touch point coordinates to the processor 780, and can receive and execute commands from the processor 780. In addition, the touch panel 731 may be implemented by various types, such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit 730 may include other input devices 732 in addition to the touch panel 731. In particular, other input devices 732 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 740 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 740 may include a display panel 741, and optionally, the display panel 741 may be configured in the form of a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 731 can cover the display panel 741, and when the touch panel 731 detects a touch operation on or near the touch panel 731, the touch operation is transmitted to the processor 780 to determine the type of the touch event, and then the processor 780 provides a corresponding visual output on the display panel 741 according to the type of the touch event. Although the touch panel 731 and the display panel 741 are two independent components in fig. 7 to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 731 and the display panel 741 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 750, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 741 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 741 and/or a backlight when the mobile phone is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
Audio circuitry 760, speaker 761, and microphone 762 may provide an audio interface between a user and a cell phone. The audio circuit 760 can transmit the electrical signal converted from the received audio data to the speaker 761, and the electrical signal is converted into a sound signal by the speaker 761 and output; on the other hand, the microphone 762 converts the collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 760, and then processes the audio data output processor 780, and then transmits the audio data to, for example, another cellular phone through the RF circuit 710, or outputs the audio data to the memory 720 for further processing.
WiFi belongs to short-distance wireless transmission technology, and the mobile phone can help a user to receive and send e-mails, browse webpages, access streaming media and the like through the WiFi module 770, and provides wireless broadband Internet access for the user. Although fig. 7 shows the WiFi module 770, it is understood that it does not belong to the essential constitution of the handset, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 780 is a control center of the mobile phone, connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 720 and calling data stored in the memory 720, thereby integrally monitoring the mobile phone. Optionally, processor 780 may include one or more processing units; optionally, processor 780 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 780.
The handset also includes a power supply 790 (e.g., a battery) for providing power to the various components, optionally, the power supply may be logically connected to the processor 780 via a power management system, so as to implement functions such as managing charging, discharging, and power consumption via the power management system.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which are not described herein.
In the embodiment of the present application, the processor 780 included in the terminal further has the following functions:
acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, the question of the candidate question-answer pair is generated based on upper layer information in the two adjacent layers of information, the answer of the candidate question-answer pair is generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information;
obtaining a relevance score corresponding to the candidate question-answer pair through a target classification model;
and determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
Embodiments of the present application also relate to a computer-readable storage medium, which includes instructions that, when executed on a computer, cause the computer to perform the method for question-answer pair generation or the method for model training as described above.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.

Claims (10)

1. A method for question-answer pair generation, comprising:
acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score corresponding to the candidate question-answer pair through a target classification model;
and determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
2. The method of claim 1, wherein generating candidate question-answer pairs from the text to be parsed comprises:
acquiring adjacent two layers of information from the n layers of information of the text to be analyzed;
acquiring keywords from upper layer information in the two adjacent layers of information and each layer of information to which the upper layer information belongs;
generating a question according to the keyword;
generating an answer according to lower layer information in the two adjacent layers of information;
and generating the candidate question-answer pairs according to the questions and the answers.
3. The method of question-answer pair generation according to claim 2, wherein said generating questions from said keywords comprises:
and obtaining the question corresponding to the keyword through a statement generation model.
4. The method of generating question-answer pairs according to claim 1, wherein the determining a target question-answer pair from the candidate question-answer pairs according to the relevance scores corresponding to the candidate question-answer pairs comprises:
and determining the candidate question-answer pairs with the relevance scores larger than or equal to a relevance threshold value as target question-answer pairs.
5. The method according to any one of claims 1 to 4, wherein layer 1 information to layer n-1 information of the n layers of information are level 1 headings to level n-1 headings in the text to be parsed, and layer n information of the n layers of information is a paragraph under the level n-1 headings of the text to be parsed.
6. A method of model training, comprising:
acquiring a question-answer pair to be trained, wherein the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, the question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, the answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score of the question-answer pair to be trained through a classification model to be trained;
and training the classification model to be trained through a target loss function according to the relevance score and the real score to obtain a target classification model.
7. A question-answer pair generating apparatus, comprising:
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a text to be analyzed, the text to be analyzed comprises n layers of information, and n is greater than or equal to 2;
a generating module, configured to generate a candidate question-answer pair according to the text to be analyzed, where the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, a question of the candidate question-answer pair is generated based on upper layer information in the two adjacent layers of information, an answer of the candidate question-answer pair is generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
the second acquisition module is used for acquiring the relevance score corresponding to the candidate question-answer pair through a target classification model;
and the determining module is used for determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair.
8. An apparatus for model training, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a question-answer pair to be trained, the question-answer pair to be trained is generated based on two adjacent layers of information in n layers of information of a text to be analyzed, a question of the question-answer pair to be trained is generated based on upper layer information in the two adjacent layers of information, an answer of the question-answer pair to be trained is generated based on lower layer information in the two adjacent layers of information, and the lower layer information belongs to the upper layer information;
the second acquisition module is used for acquiring the relevance score of the question-answer pair to be trained through the classification model to be trained;
and the training module is used for training the classification model to be trained through a target loss function according to the relevance value and the real value to obtain a target classification model.
9. A terminal device, comprising: a memory, a transceiver, a processor, and a bus system;
wherein the memory is used for storing programs;
the processor is used for executing the program in the memory and comprises the following steps:
acquiring a text to be analyzed, wherein the text to be analyzed comprises n layers of information, and n is more than or equal to 2;
generating a candidate question-answer pair according to the text to be analyzed, wherein the candidate question-answer pair is generated based on two adjacent layers of information in the n layers of information, questions of the candidate question-answer pair are generated based on upper layer information in the two adjacent layers of information, answers of the candidate question-answer pair are generated based on lower layer information in the two adjacent layers of information, and the lower layer information is subordinate to the upper layer information;
obtaining the relevance score corresponding to the candidate question-answer pair through a target classification model;
determining a target question-answer pair from the candidate question-answer pair according to the relevance score corresponding to the candidate question-answer pair;
the bus system is used for connecting the memory and the processor so as to enable the memory and the processor to communicate.
10. A computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the method of any of claims 1 to 6.
CN201910880193.7A 2019-09-16 2019-09-16 Question-answer pair generation method and device Pending CN110781274A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910880193.7A CN110781274A (en) 2019-09-16 2019-09-16 Question-answer pair generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910880193.7A CN110781274A (en) 2019-09-16 2019-09-16 Question-answer pair generation method and device

Publications (1)

Publication Number Publication Date
CN110781274A true CN110781274A (en) 2020-02-11

Family

ID=69383814

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910880193.7A Pending CN110781274A (en) 2019-09-16 2019-09-16 Question-answer pair generation method and device

Country Status (1)

Country Link
CN (1) CN110781274A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111914062A (en) * 2020-07-13 2020-11-10 上海乐言信息科技有限公司 Long text question-answer pair generation system based on keywords

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959559A (en) * 2018-06-29 2018-12-07 北京百度网讯科技有限公司 Question and answer are to generation method and device
CN109299250A (en) * 2018-09-14 2019-02-01 广州神马移动信息科技有限公司 Methods of exhibiting, device, storage medium and the electronic equipment of answer
CN110196929A (en) * 2019-05-20 2019-09-03 北京百度网讯科技有限公司 The generation method and device of question and answer pair

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959559A (en) * 2018-06-29 2018-12-07 北京百度网讯科技有限公司 Question and answer are to generation method and device
CN109299250A (en) * 2018-09-14 2019-02-01 广州神马移动信息科技有限公司 Methods of exhibiting, device, storage medium and the electronic equipment of answer
CN110196929A (en) * 2019-05-20 2019-09-03 北京百度网讯科技有限公司 The generation method and device of question and answer pair

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111914062A (en) * 2020-07-13 2020-11-10 上海乐言信息科技有限公司 Long text question-answer pair generation system based on keywords
CN111914062B (en) * 2020-07-13 2021-04-06 上海乐言科技股份有限公司 Long text question-answer pair generation system based on keywords

Similar Documents

Publication Publication Date Title
CN109145303B (en) Named entity recognition method, device, medium and equipment
TWI684148B (en) Grouping processing method and device of contact person
CN110276075A (en) Model training method, name entity recognition method, device, equipment and medium
CN111177371B (en) Classification method and related device
CN111553162A (en) Intention identification method and related device
CN111931501B (en) Text mining method based on artificial intelligence, related device and equipment
CN111597804B (en) Method and related device for training entity recognition model
CN110795538B (en) Text scoring method and related equipment based on artificial intelligence
CN110852109A (en) Corpus generating method, corpus generating device, and storage medium
CN110704661A (en) Image classification method and device
WO2021159877A1 (en) Question answering method and apparatus
CN109543014B (en) Man-machine conversation method, device, terminal and server
CN110209778A (en) A kind of method and relevant apparatus of dialogue generation
CN114328852A (en) Text processing method, related device and equipment
CN112214605A (en) Text classification method and related device
CN115022098B (en) Artificial intelligence safety target range content recommendation method, device and storage medium
CN110276010A (en) A kind of weight model training method and relevant apparatus
CN111651604A (en) Emotion classification method based on artificial intelligence and related device
CN110597957B (en) Text information retrieval method and related device
CN112749252A (en) Text matching method based on artificial intelligence and related device
CN110825863B (en) Text pair fusion method and device
CN110781274A (en) Question-answer pair generation method and device
CN110019648B (en) Method and device for training data and storage medium
CN116955610A (en) Text data processing method and device and storage medium
CN113569043A (en) Text category determination method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40022072

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination