CN112163405A - Question generation method and device - Google Patents

Question generation method and device Download PDF

Info

Publication number
CN112163405A
CN112163405A CN202010937089.XA CN202010937089A CN112163405A CN 112163405 A CN112163405 A CN 112163405A CN 202010937089 A CN202010937089 A CN 202010937089A CN 112163405 A CN112163405 A CN 112163405A
Authority
CN
China
Prior art keywords
keyword
candidate
sample
keywords
vector
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
CN202010937089.XA
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.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology 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 Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202010937089.XA priority Critical patent/CN112163405A/en
Publication of CN112163405A publication Critical patent/CN112163405A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • 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/3332Query translation
    • G06F16/3334Selection or weighting of terms from queries, including natural language queries
    • 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/3346Query execution using probabilistic model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates

Abstract

The application discloses a question generation method and device, and relates to the technical field of Natural Language Processing (NLP), the technical field of intelligent search and the technical field of deep learning. The specific implementation scheme is as follows: extracting a plurality of candidate keywords in the target text; calculating and generating an attention vector of each candidate keyword according to a preset algorithm; extracting a word vector of each candidate keyword, and acquiring the confidence coefficient of each candidate keyword according to the word vector and the attention vector; and determining a target keyword in the candidate keywords according to the confidence degree, and generating a problem corresponding to the target text according to the target keyword. Therefore, the corresponding question is generated according to the soft attention to the keywords in the text, the matching of the question and the text is ensured, and the support is provided for the retrieval accuracy.

Description

Question generation method and device
Technical Field
The application relates to the technical field of NLP, intelligent search and deep learning, in particular to a problem generation method and device.
Background
The problem generation technique refers to: given a paragraph of text, a corresponding question is generated using a machine learning approach. Thus, a relational pair of question and paragraph text is constructed to facilitate providing an intelligent search service for users based on the relational pair.
In the related art, the problem of paragraph text is constructed in a manual mode, the construction mode of the problem consumes manpower, and due to subjectivity influence of manual understanding, the accuracy of the constructed problem is low, and the matching degree of the problem and the paragraph text is low.
Disclosure of Invention
The application provides a generation method and a device for solving the technical problem that the matching degree between problem generation and a text is not high.
According to a first aspect, there is provided a question generation method, comprising: extracting a plurality of candidate keywords in the target text; calculating and generating an attention vector of each candidate keyword according to a preset algorithm; extracting a word vector of each candidate keyword, and acquiring a confidence coefficient of each candidate keyword according to the word vector and the attention vector; determining target keywords in the candidate keywords according to the confidence degrees, and generating the problems corresponding to the target texts according to the target keywords.
According to a second aspect, there is provided an apparatus for generating a question, comprising: the first extraction module is used for extracting a plurality of candidate keywords in the target text; the first generation module is used for calculating and generating an attention vector of each candidate keyword according to a preset algorithm; the acquisition module is used for extracting a word vector of each candidate keyword and acquiring the confidence coefficient of each candidate keyword according to the word vector and the attention vector; and the second generation module is used for determining a target keyword in the candidate keywords according to the confidence degrees and generating a problem corresponding to the target text according to the target keyword.
According to a third aspect, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of generating the problem described in the above embodiments.
According to a fourth aspect, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of generating the problem described in the above embodiments.
The embodiments in the above application have at least the following advantages or benefits:
extracting a plurality of candidate keywords in a target text, further calculating and generating an attention vector of each candidate keyword according to a preset algorithm, extracting a word vector of each candidate keyword, obtaining the confidence coefficient of each candidate keyword according to the word vector and the attention vector, finally determining the target keyword in the candidate keywords according to the confidence coefficient, and generating a problem corresponding to the target text according to the target keyword. Therefore, the corresponding question is generated according to the soft attention to the keywords in the text, the matching of the question and the text is ensured, and the support is provided for the retrieval accuracy.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
fig. 1 is a schematic flow chart of a method of generating a question according to a first embodiment of the present application;
FIG. 2 is a flow chart diagram of a method of generating a question according to a second embodiment of the present application;
FIG. 3 is a flow chart diagram of a method of generating a question according to a third embodiment of the present application;
FIG. 4 is a schematic diagram of a scenario of a problem generation method according to a fourth embodiment of the present application;
fig. 5 is a schematic structural diagram of a problem generation apparatus according to a fifth embodiment of the present application;
fig. 6 is a schematic structural diagram of a problem generation apparatus according to a sixth embodiment of the present application;
fig. 7 is a schematic configuration diagram of a problem generation apparatus according to a seventh embodiment of the present application;
FIG. 8 is a block diagram of an electronic device to implement a method of generation of a problem of an embodiment of the present application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application for the understanding of the same, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In order to solve the problem that the matching degree between the problem generation and the text is not high in the prior art, the scheme for generating the problem by combining the keywords in the text is provided, so that the generated problem has important practical application value by enhancing the perception capability of the key information.
A problem generation method and apparatus of an embodiment of the present application are described below with reference to the drawings.
Fig. 1 is a flowchart of a method of generating a question according to an embodiment of the present application, as shown in fig. 1, the method including:
step 101, extracting a plurality of candidate keywords in a target text.
The target text may be understood as one paragraph or a plurality of paragraphs in the article, or may be a whole news, and the like, which is not limited herein.
In this embodiment, in order to make the generated target text correspond to a problem, keywords in the target text may be perceived, and a plurality of candidate keywords in the target text are extracted.
It should be noted that, in different application scenarios, the manner of extracting multiple candidate keywords in the target text is different, and the following is exemplified:
example one:
in this example, a word segmentation process is performed on a target text to obtain a plurality of segmented words, for example, the target text is subjected to the word segmentation process according to noun attributes to obtain a plurality of segmented words, and further, in order to improve the problem generation efficiency, a stop word in the plurality of segmented words is identified, the stop word may be a word such as "yes" or the like for the purpose of making a sentence smooth but not including a specific meaning, and further, other segmented words except the stop word are used as candidate keywords, so that the noise influence of the stop word is removed, and the efficiency of generating a subsequent problem is improved.
Example two:
in this example, a word segmentation process is performed on a target text to obtain a plurality of segmented words, for example, the target text is subjected to the word segmentation process according to noun attributes to obtain a plurality of segmented words, and further, the occurrence frequency of each segmented word is obtained, and the segmented words with the frequency greater than a certain value are determined as candidate keywords.
Example three:
in the example, the subject semantics of the target text are recognized according to a pre-trained semantic recognition model, then word segmentation processing is performed on the target text to obtain a plurality of participles, the participle semantics of each participle are recognized according to the pre-trained semantic recognition model, the participle semantics are matched with the subject semantics, and the participle with the matching degree larger than a certain value is determined as a candidate keyword.
And 102, calculating and generating the attention vector of each candidate keyword according to a preset algorithm.
In this embodiment, the attention vector for each candidate keyword is computed and generated according to a preset algorithm, and the attention vector directs the question generation to consider the candidate keyword.
And 103, extracting a word vector of each candidate keyword, and acquiring the confidence coefficient of each candidate keyword according to the word vector and the attention vector.
The word vector of each candidate word may be obtained based on word2vec, glove, ELMo, BERT models, and the like in the natural language processing technology, and is not described herein again.
In the embodiment, a single word vector is not used purely as a feature of a keyword, but an attention vector is introduced, and the confidence of each candidate keyword is determined based on the attention vector and the word vector together, wherein the confidence can be understood as the probability that the corresponding candidate keyword can be generated into a target problem.
And 104, determining target keywords in the candidate keywords according to the confidence degrees, and generating a problem corresponding to the target text according to the target keywords.
In this embodiment, a target keyword is determined among a plurality of candidate keywords according to the confidence level, and a problem corresponding to the target text is generated according to the target keyword, for example, a candidate keyword whose confidence level is greater than a preset confidence level threshold is determined as the target keyword, and then a problem corresponding to the target text is generated according to the target keyword.
In some possible examples, a problem generation model may be trained in advance, and the problem generation model may be obtained by training based on a deep learning model, for example, training a problem generation model based on a sample keyword, comparing a sample problem output by the problem generation model with a labeled problem corresponding to the sample keyword, calculating a problem loss value according to a comparison result, where the loss value may be obtained by calculating semantic features of the labeled problem and semantic features of the sample problem according to a loss function, or may be obtained by calculating a feature vector corresponding to the sample problem, calculating a vector corresponding to a standard problem, and calculating a vector distance between the sample problem and the standard problem to determine a corresponding loss value.
And when the loss value is larger than a certain value, adjusting model parameters of the problem generation model until the loss value is smaller than the certain value.
In other possible examples, the part-of-speech of the target keyword is analyzed, a part-of-speech sequence structure of the question sentence is constructed in advance, for example, the part-of-speech sequence structure of the question sentence is "subject", "predicate", "object", and the like, and the target keyword is recombined to generate a corresponding question according to the part-of-speech and the part-of-speech sequence structure of the target keyword.
In this example, when the number of target keywords of the same part of speech is greater than the number of corresponding parts of speech in the part of speech sequence structure, the target keywords of the same part of speech may be screened out from the plurality of target keywords of the same part of speech, and the target keywords of the same part of speech as the number of corresponding parts of speech in the part of speech sequence structure may be subjected to problem composition.
Furthermore, after a question corresponding to the target text is generated, the question text input by the user in the search engine can be received, the semantic matching is carried out on the question text and the text corresponding to the target text, and when the semantic matching degree is greater than a certain value, the corresponding target text is used as an answer and provided for the user, so that the method has important progress in the NLP field and the intelligent search technical field.
In summary, in the method for generating a problem according to the embodiment of the application, a plurality of candidate keywords in a target text are extracted, an attention vector of each candidate keyword is calculated and generated according to a preset algorithm, a word vector of each candidate keyword is extracted, a confidence level of each candidate keyword is obtained according to the word vector and the attention vector, and finally, the target keyword is determined among the candidate keywords according to the confidence levels, and the problem corresponding to the target text is generated according to the target keyword. Therefore, the corresponding question is generated according to the soft attention to the keywords in the text, the matching of the question and the text is ensured, and the support is provided for the retrieval accuracy.
In the actual implementation process, the attention vector of each candidate keyword is actually used to guide the attention degree of the corresponding keyword during the generation of the problem, and therefore, any algorithm capable of calculating the attention degree can be regarded as a preset algorithm for calculating the attention vector in the present application. Examples are illustrated below:
example one:
in this example, as shown in fig. 2, the calculation of the attention vector for generating each candidate keyword according to a preset algorithm includes:
step 201, inputting each candidate keyword into a preset depth model, and obtaining the keyword probability of each candidate keyword.
It can be understood that the preset depth model is trained in advance to obtain the corresponding relation between the candidate keywords and the keyword probability, so that each candidate keyword is input into the preset depth model to obtain the keyword probability of each candidate keyword. Keyword probability herein is understood to be the probability that a candidate keyword may be a keyword in a question.
In an embodiment of the present application, the preset depth model may be an ERNIE model, and in this embodiment, a large amount of sample data is used for training to obtain a corresponding preset depth model according to a deep learning technique.
Step 202, calculating the probability of the keywords according to a preset algorithm, and generating the attention vector of each candidate keyword.
In this embodiment, the probability of the keyword is calculated according to a preset algorithm, and an attention vector of each candidate keyword is generated.
For example, the probability calculation of the keyword is performed according to a vector formula, and an attention vector of each candidate keyword is generated, wherein the vector formula is the following formula (1):
ei=Pkey(i).ekey+(1-Pkey(i)).enon-keyformula (1)
Wherein i represents the ith candidate keyword, eiAttention vector for the ith candidate keyword, Pkey(i) Probability of keyword as ith candidate keyword, ekeyFor a predetermined keyword vector, enon-keyThe method includes the steps that a preset non-keyword vector is adopted, wherein the preset keyword vector and the preset non-keyword vector of different candidate keywords can be the same or different, when the preset keyword vector and the preset non-keyword vector of different candidate keywords are different, the preset keyword vector and the preset non-keyword vector corresponding to different parts of speech can be set according to the parts of speech of the candidate keywords, and the preset keyword vector and the preset non-keyword vector corresponding to different parts of speech are different.
For another example, keyword probability ranges corresponding to different standard vectors are preset, the keyword probability range to which the current keyword probability belongs is queried, and then, according to a target standard vector corresponding to the keyword probability range to which the current keyword probability belongs, the product of the target standard vector and the keyword probability to which the current keyword belongs is determined as the attention vector.
Example two:
in this example, the semantic similarity of the subject semantics of each candidate keyword and the target text is calculated according to a preset deep learning model, and further, the occurrence frequency of each candidate keyword in the target text is calculated, the product value of the frequency and the semantic similarity is calculated, and the product value is multiplied by a preset matrix vector to obtain a corresponding attention vector. The preset semantic vector can be obtained by extracting according to the text features of the target text.
In summary, the problem generation method of the embodiment of the application can flexibly adopt different modes to calculate the attention vector of each candidate keyword, so as to guide the keywords in the attention target text when generating the problem, and improve the value of generating the problem.
Based on the above embodiment, in different application scenarios, the way of obtaining the confidence level of each candidate keyword according to the word vector and the attention vector is different, which is exemplified as follows:
example one:
in this example, as shown in fig. 3, extracting a word vector of each candidate keyword, and obtaining a confidence of each candidate keyword according to the word vector and the attention vector includes:
step 301, each candidate keyword and the corresponding attention vector are spliced to generate an input value.
In this embodiment, each candidate keyword and the corresponding attention vector are concatenated to generate an input value. For example, after or before each candidate keyword, etc.
Step 302, inputting a plurality of input values corresponding to a plurality of candidate keywords into a preset keyword extraction model, and generating a confidence of each candidate keyword.
In this embodiment, a plurality of input values corresponding to a plurality of candidate keywords are input into a preset keyword extraction model, and a confidence level of each candidate keyword is generated.
Before inputting a plurality of input values corresponding to a plurality of candidate keywords into a preset keyword extraction model, training the keyword extraction model is also needed.
When the keyword extraction model is trained, a plurality of sample keywords of a sample text and sample attention vectors corresponding to the sample keywords are extracted, each sample keyword and the corresponding sample attention vector are used for generating a sample input value, then the plurality of sample input values corresponding to the sample text are input into the initial keyword extraction model, and a sample confidence coefficient corresponding to each sample keyword is generated.
Further, a target sample keyword is determined among the plurality of sample keywords according to the sample confidence, for example, a sample keyword with a confidence greater than a preset value is determined as the target sample keyword.
Calculating a loss value of the target keyword and a labeled sample keyword of the sample text, for example, calculating a semantic difference value between the semantic information of the target keyword and the semantic information of the labeled sample keyword, and taking the semantic difference value as the loss value, and for example, calculating a repetition probability between the target keyword and the labeled sample keyword, where the overlap probability may be a ratio of the number of the keywords same as the labeled sample keyword to the total number of the labeled sample keywords, or a ratio of the number of the words same as the target keyword contained in the labeled sample keyword to the total number of the words contained in the labeled sample keyword, and further taking a difference value between 1 and the ratio as the loss value.
And when the loss value is greater than a preset threshold value, adjusting model parameters of the initial keyword extraction model, wherein the model parameters can be the number of convolution kernels of the initial keyword extraction model and the like, and completing training of the initial keyword extraction model to obtain the keyword extraction model when the loss value is less than the preset threshold value.
For example, as shown in fig. 4, when the target text is "small and bright called", the identified candidate keywords are "he", "called", "small" and "bright", so that the attention vector of each candidate keyword is calculated and generated according to a preset algorithm, and after the "he", "called", "small" and "bright" are spliced with the corresponding attention vector to generate corresponding input values, the input values are input into a keyword extraction model, where the keyword extraction model may be understood as a model with a coding layer for extracting word vectors of the candidate keywords, and at this time, in order to avoid blurring the attention vectors, the coding layer is provided with masks for the attention vectors. Thus, the confidence of the candidate keyword is determined from the output of the keyword extraction model, and the target keyword is determined from the confidence.
In this embodiment, in order to further improve the value of problem generation, a keyword extraction model and a problem generation model may be trained jointly, that is, a [ start symbol ] sample target keyword [ separator ] sample text [ separator ] "is used as input data, where the sample target keyword is generated by the problem generation model according to a target keyword generated by the sample text, the input data is input to the keyword extraction model, a problem and label problem calculation loss value output by the keyword extraction model is calculated, and model parameters of the keyword extraction model and the problem generation model are adjusted according to the loss value.
Example two:
in this example, after the word vector of each candidate keyword is extracted, the product vector of the word vector and the attention vector is directly calculated, and the product vector is input into a pre-trained deep learning model to obtain a corresponding confidence level, wherein the product vector integrates the attention vector, so that a certain weight is reflected, and the corresponding confidence level is led by attention.
In summary, the problem generation method of the embodiment of the application determines the confidence level of each candidate keyword together with the word vector of each candidate keyword and the attention vector representing the contribution degree in the problem generation scene, so that the follow-up confidence level is guided by attention, and the problem generation value is improved.
In order to implement the above embodiments, the present application also provides a problem generation apparatus. Fig. 5 is a schematic structural diagram of a problem generation apparatus according to the present application, and as shown in fig. 5, the problem generation apparatus includes: the system comprises a first extraction module 510, a first generation module 520, an acquisition module 530 and a second generation module 540, wherein the first extraction module 510 is used for extracting a plurality of candidate keywords in a target text;
a first generating module 520, configured to calculate and generate an attention vector of each candidate keyword according to a preset algorithm;
an obtaining module 530, configured to extract a word vector of each candidate keyword, and obtain a confidence level of each candidate keyword according to the word vector and the attention vector;
and the second generating module 540 is configured to determine a target keyword from the multiple candidate keywords according to the confidence, and generate a question corresponding to the target text according to the target keyword.
In an embodiment of the present application, the first extracting module 510 is specifically configured to:
performing word segmentation processing on the target text to obtain a plurality of word segments;
and identifying a stop word in the plurality of segmented words, and determining the segmented words except the stop word as a plurality of candidate keywords.
It should be noted that the explanation of the problem generation method described above is also applicable to the problem generation apparatus according to the embodiment of the present invention, and the implementation principle is similar, and is not described herein again.
To sum up, the problem generation apparatus according to the embodiment of the present application extracts a plurality of candidate keywords in a target text, further calculates and generates an attention vector of each candidate keyword according to a preset algorithm, extracts a word vector of each candidate keyword, obtains a confidence of each candidate keyword according to the word vector and the attention vector, and finally determines a target keyword among the plurality of candidate keywords according to the confidence and generates a problem corresponding to the target text according to the target keyword. Therefore, the corresponding question is generated according to the soft attention to the keywords in the text, the matching of the question and the text is ensured, and the support is provided for the retrieval accuracy.
In the actual implementation process, the attention vector of each candidate keyword is actually used to guide the attention degree of the corresponding keyword during the generation of the problem, and therefore, any algorithm capable of calculating the attention degree can be regarded as a preset algorithm for calculating the attention vector in the present application. Examples are illustrated below:
in one embodiment of the present application, as shown in fig. 6, on the basis of fig. 5, the first generating module 520 includes: an obtaining unit 521 and a generating unit 522, wherein the obtaining unit 521 is configured to input each candidate keyword into a preset depth model, and obtain a keyword probability of each candidate keyword;
the generating unit 522 is configured to calculate the probability of the keyword according to a preset algorithm, and generate an attention vector of each candidate keyword.
In this embodiment, the generating unit 522 is specifically configured to:
calculating the probability of the keywords according to a vector formula to generate the attention vector of each candidate keyword, wherein the vector formula is as follows:
ei=Pkey(i).ekey+(1-Pkey(i)).enon-key
wherein i represents the ith candidate keyword, eiAttention vector for the ith candidate keyword, Pkey(i) Probability of keyword as ith candidate keyword, ekeyFor a predetermined keyword vector, enon-keyIs a predetermined non-keyword vector.
It should be noted that the explanation of the problem generation method described above is also applicable to the problem generation apparatus according to the embodiment of the present invention, and the implementation principle is similar, and is not described herein again.
In summary, the problem generation device according to the embodiment of the present application can flexibly adopt different ways to calculate the attention vector of each candidate keyword, so as to guide the keywords in the attention target text when generating the problem, thereby improving the value of generating the problem.
Based on the above embodiment, in different application scenarios, the way of obtaining the confidence level of each candidate keyword according to the word vector and the attention vector is different, which is exemplified as follows:
in an embodiment of the present application, the obtaining module 530 is specifically configured to:
splicing each candidate keyword and the corresponding attention vector to generate an input value;
and inputting a plurality of input values corresponding to the candidate keywords into a preset keyword extraction model, and generating the confidence coefficient of each candidate keyword.
In this embodiment, as shown in fig. 7, the problem generation apparatus further includes, based on the problem shown in fig. 5: a second extraction module 550, a third generation module 560, a fourth generation module 570, a determination module 580, a calculation module 590, a training module 5100, wherein,
a second extraction module 550, configured to extract a plurality of sample keywords of the sample text and sample attention vectors corresponding to the sample keywords;
a third generating module 560, configured to splice each sample keyword and the corresponding sample attention vector to generate a sample input value;
a fourth generating module 570, configured to input a plurality of sample input values corresponding to the sample text into the initial keyword extraction model, and generate a sample confidence corresponding to each sample keyword;
a determining module 580 for determining a target sample keyword among the plurality of sample keywords according to the sample confidence;
the calculating module 590 is configured to calculate a loss value of the target keyword and a labeled sample keyword of the sample text;
the training module 5100 is configured to, when the loss value is greater than the preset threshold, adjust model parameters of the initial keyword extraction model until the loss value is less than the preset threshold, complete training of the initial keyword extraction model, and acquire the keyword extraction model.
It should be noted that the explanation of the problem generation method described above is also applicable to the problem generation apparatus according to the embodiment of the present invention, and the implementation principle is similar, and is not described herein again.
In summary, the problem generation apparatus according to the embodiment of the present application determines the confidence level of each candidate keyword together with the word vector of each candidate keyword and the attention vector representing the contribution degree in the problem generation scenario, so as to ensure that the subsequent confidence level is guided by attention, thereby improving the problem generation value.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
As shown in fig. 8, is a block diagram of an electronic device according to a method of problem generation of an embodiment of the present application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application that are described and/or claimed herein.
As shown in fig. 8, the electronic apparatus includes: one or more processors 801, memory 802, and interfaces for connecting the various components, including a high speed interface and a low speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). Fig. 8 illustrates an example of a processor 801.
The memory 802 is a non-transitory computer readable storage medium as provided herein. Wherein the memory stores instructions executable by at least one processor to cause the at least one processor to perform a method of generation of a problem provided herein. The non-transitory computer readable storage medium of the present application stores computer instructions for causing a computer to perform a method of generation of a problem provided by the present application.
The memory 802, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the method of problem generation in the embodiments of the present application (e.g., the first extraction module 510, the first generation module 520, the acquisition module 530, and the second generation module 540 shown in fig. 5). The processor 801 executes various functional applications of the server and data processing, i.e., a method of realizing generation of the problem in the above-described method embodiment, by running non-transitory software programs, instructions, and modules stored in the memory 802.
The memory 802 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created from use of the electronic device according to generation of the question, and the like. Further, the memory 802 may include high speed random access memory and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 802 optionally includes memory located remotely from the processor 801, which may be connected to the electronic device of the generation of the question over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the method of generating a question may further include: an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803, and the output device 804 may be connected by a bus or other means, and are exemplified by a bus in fig. 8.
The input device 803 may receive input numeric or character information, and key signal inputs, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, a pointing stick, one or more mouse buttons, a track ball, a joystick, etc., that result in user settings and function controls of the electronic device associated with the generation of the problem. The output devices 804 may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibrating motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme of the embodiment of the application, a plurality of candidate keywords in the target text are extracted, then the attention vector of each candidate keyword is calculated and generated according to a preset algorithm, the word vector of each candidate keyword is extracted, the confidence coefficient of each candidate keyword is obtained according to the word vector and the attention vector, finally, the target keyword is determined in the candidate keywords according to the confidence coefficient, and the problem corresponding to the target text is generated according to the target keyword. Therefore, the corresponding question is generated according to the soft attention to the keywords in the text, the matching of the question and the text is ensured, and the support is provided for the retrieval accuracy.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present application may be executed in parallel, sequentially, or in different orders, and the present invention is not limited thereto as long as the desired results of the technical solutions disclosed in the present application can be achieved.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (14)

1. A method of generating a question, comprising:
extracting a plurality of candidate keywords in the target text;
calculating and generating an attention vector of each candidate keyword according to a preset algorithm;
extracting a word vector of each candidate keyword, and acquiring a confidence coefficient of each candidate keyword according to the word vector and the attention vector;
determining target keywords in the candidate keywords according to the confidence degrees, and generating the problems corresponding to the target texts according to the target keywords.
2. The method of claim 1, wherein the extracting the plurality of candidate keywords in the target text comprises:
performing word segmentation processing on the target text to obtain a plurality of word segments;
and identifying a stop word in the plurality of segmented words, and determining segmented words except the stop word as the plurality of candidate keywords.
3. The method of claim 1, wherein said generating an attention vector for each of said candidate keywords according to a predetermined algorithm comprises:
inputting each candidate keyword into a preset depth model, and acquiring the keyword probability of each candidate keyword;
and calculating the probability of the keywords according to a preset algorithm to generate the attention vector of each candidate keyword.
4. The method of claim 3, wherein said calculating probability of said keyword according to a preset algorithm to generate an attention vector for each of said candidate keywords comprises:
calculating the probability of the keywords according to a vector formula to generate the attention vector of each candidate keyword, wherein the vector formula is as follows:
ei=Pkey(i).ekey+(1-Pkey(i)).enon-key
wherein i represents the ith candidate keyword, eiAttention vector, P, for the ith said candidate keywordkey(i) Probability of the i-th candidate keyword, ekeyFor a predetermined keyword vector, enon-keyIs a predetermined non-keyword vector.
5. The method of claim 1, wherein said extracting a word vector for each of said candidate keywords and obtaining a confidence level for said each of said candidate keywords based on said word vector and said attention vector comprises:
splicing each candidate keyword and the corresponding attention vector to generate an input value;
and inputting a plurality of input values corresponding to the candidate keywords into a preset keyword extraction model, and generating the confidence coefficient of each candidate keyword.
6. The method of claim 5, wherein before the inputting the plurality of input values corresponding to the plurality of candidate keywords into the preset keyword extraction model, further comprising:
extracting a plurality of sample keywords of a sample text and a sample attention vector corresponding to each sample keyword;
splicing each sample keyword and the corresponding sample attention vector to generate a sample input value;
inputting a plurality of sample input values corresponding to the sample text into an initial keyword extraction model, and generating a sample confidence coefficient of each sample keyword;
determining target sample keywords in the plurality of sample keywords according to the sample confidence degrees, and calculating loss values of the target keywords and labeled sample keywords of the sample text;
and when the loss value is greater than a preset threshold value, adjusting model parameters of the initial keyword extraction model until the loss value is less than the preset threshold value, and finishing training the initial keyword extraction model to obtain the keyword extraction model.
7. An apparatus for generating a question, comprising:
the first extraction module is used for extracting a plurality of candidate keywords in the target text;
the first generation module is used for calculating and generating an attention vector of each candidate keyword according to a preset algorithm;
the acquisition module is used for extracting a word vector of each candidate keyword and acquiring the confidence coefficient of each candidate keyword according to the word vector and the attention vector;
and the second generation module is used for determining a target keyword in the candidate keywords according to the confidence degrees and generating a problem corresponding to the target text according to the target keyword.
8. The apparatus of claim 7, wherein the first extraction module is specifically configured to:
performing word segmentation processing on the target text to obtain a plurality of word segments;
and identifying a stop word in the plurality of segmented words, and determining segmented words except the stop word as the plurality of candidate keywords.
9. The apparatus of claim 7, wherein the first generating means comprises:
the acquisition unit is used for inputting each candidate keyword into a preset depth model and acquiring the keyword probability of each candidate keyword;
and the generating unit is used for calculating the probability of the keywords according to a preset algorithm and generating the attention vector of each candidate keyword.
10. The apparatus of claim 9, wherein the generating unit is specifically configured to:
calculating the probability of the keywords according to a vector formula to generate the attention vector of each candidate keyword, wherein the vector formula is as follows:
ei=Pkey(i).ekey+(1-Pkey(i)).enon-key
wherein i represents the ith candidate keyword, eiAttention vector, P, for the ith said candidate keywordkey(i) Probability of the i-th candidate keyword, ekeyFor a predetermined keyword vector, enon-keyIs a predetermined non-keyword vector.
11. The apparatus of claim 7, wherein the obtaining module is specifically configured to:
splicing each candidate keyword and the corresponding attention vector to generate an input value;
and inputting a plurality of input values corresponding to the candidate keywords into a preset keyword extraction model, and generating the confidence coefficient of each candidate keyword.
12. The apparatus of claim 11, further comprising:
the second extraction module is used for extracting a plurality of sample keywords of the sample text and a sample attention vector corresponding to each sample keyword;
a third generation module, configured to splice each sample keyword and a corresponding sample attention vector to generate a sample input value;
a fourth generation module, configured to input a plurality of sample input values corresponding to the sample text into an initial keyword extraction model, and generate a sample confidence for each sample keyword;
a determining module, configured to determine a target sample keyword among the plurality of sample keywords according to the sample confidence;
the calculation module is used for calculating loss values of the target keywords and the labeled sample keywords of the sample text;
and the training module is used for adjusting the model parameters of the initial keyword extraction model when the loss value is greater than a preset threshold value, and finishing the training of the initial keyword extraction model to obtain the keyword extraction model until the loss value is less than the preset threshold value.
13. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of generating a question of any one of claims 1-6.
14. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of generating a question according to any one of claims 1 to 6.
CN202010937089.XA 2020-09-08 2020-09-08 Question generation method and device Pending CN112163405A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010937089.XA CN112163405A (en) 2020-09-08 2020-09-08 Question generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010937089.XA CN112163405A (en) 2020-09-08 2020-09-08 Question generation method and device

Publications (1)

Publication Number Publication Date
CN112163405A true CN112163405A (en) 2021-01-01

Family

ID=73858374

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010937089.XA Pending CN112163405A (en) 2020-09-08 2020-09-08 Question generation method and device

Country Status (1)

Country Link
CN (1) CN112163405A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113220888A (en) * 2021-06-01 2021-08-06 上海交通大学 Case clue element extraction method and system based on Ernie model
CN113240562A (en) * 2021-05-27 2021-08-10 南通大学 Method and system for recommending and matching obstetrical and academic research projects based on nlp
CN113239273A (en) * 2021-05-14 2021-08-10 北京百度网讯科技有限公司 Method, device, equipment and storage medium for generating text
CN115033774A (en) * 2022-06-16 2022-09-09 北京百度网讯科技有限公司 Method, device, equipment and medium for generating search text to be recommended
CN115600587A (en) * 2022-12-16 2023-01-13 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室)(Cn) Mathematics application question generation system and method, intelligent terminal and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180225568A1 (en) * 2017-02-07 2018-08-09 Fmr Llc Domain-specific stopword removal from unstructured computer text using a neural network
CN109933806A (en) * 2019-04-01 2019-06-25 长沙理工大学 A kind of repetition generation method, system, equipment and computer readable storage medium
CN110119765A (en) * 2019-04-18 2019-08-13 浙江工业大学 A kind of keyword extracting method based on Seq2seq frame
CN110232183A (en) * 2018-12-07 2019-09-13 腾讯科技(深圳)有限公司 Keyword extraction model training method, keyword extracting method, device and storage medium
CN110263122A (en) * 2019-05-08 2019-09-20 北京奇艺世纪科技有限公司 A kind of keyword acquisition methods, device and computer readable storage medium
CN111078865A (en) * 2019-12-24 2020-04-28 北京百度网讯科技有限公司 Text title generation method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180225568A1 (en) * 2017-02-07 2018-08-09 Fmr Llc Domain-specific stopword removal from unstructured computer text using a neural network
CN110232183A (en) * 2018-12-07 2019-09-13 腾讯科技(深圳)有限公司 Keyword extraction model training method, keyword extracting method, device and storage medium
CN109933806A (en) * 2019-04-01 2019-06-25 长沙理工大学 A kind of repetition generation method, system, equipment and computer readable storage medium
CN110119765A (en) * 2019-04-18 2019-08-13 浙江工业大学 A kind of keyword extracting method based on Seq2seq frame
CN110263122A (en) * 2019-05-08 2019-09-20 北京奇艺世纪科技有限公司 A kind of keyword acquisition methods, device and computer readable storage medium
CN111078865A (en) * 2019-12-24 2020-04-28 北京百度网讯科技有限公司 Text title generation method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杨丹浩;吴岳辛;范春晓;: "一种基于注意力机制的中文短文本关键词提取模型", 计算机科学, no. 01 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239273A (en) * 2021-05-14 2021-08-10 北京百度网讯科技有限公司 Method, device, equipment and storage medium for generating text
CN113239273B (en) * 2021-05-14 2023-07-28 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for generating text
CN113240562A (en) * 2021-05-27 2021-08-10 南通大学 Method and system for recommending and matching obstetrical and academic research projects based on nlp
CN113220888A (en) * 2021-06-01 2021-08-06 上海交通大学 Case clue element extraction method and system based on Ernie model
CN115033774A (en) * 2022-06-16 2022-09-09 北京百度网讯科技有限公司 Method, device, equipment and medium for generating search text to be recommended
CN115600587A (en) * 2022-12-16 2023-01-13 合肥综合性国家科学中心人工智能研究院(安徽省人工智能实验室)(Cn) Mathematics application question generation system and method, intelligent terminal and readable storage medium

Similar Documents

Publication Publication Date Title
CN112560912B (en) Classification model training method and device, electronic equipment and storage medium
US20220383190A1 (en) Method of training classification model, method of classifying sample, and device
CN112163405A (en) Question generation method and device
CN111625635A (en) Question-answer processing method, language model training method, device, equipment and storage medium
CN112560479B (en) Abstract extraction model training method, abstract extraction device and electronic equipment
CN111241819B (en) Word vector generation method and device and electronic equipment
CN111967262A (en) Method and device for determining entity tag
CN111078865B (en) Text title generation method and device
CN111259671B (en) Semantic description processing method, device and equipment for text entity
CN111177355B (en) Man-machine conversation interaction method and device based on search data and electronic equipment
US11907671B2 (en) Role labeling method, electronic device and storage medium
JP2022050379A (en) Semantic retrieval method, apparatus, electronic device, storage medium, and computer program product
CN112541076B (en) Method and device for generating expanded corpus in target field and electronic equipment
CN113553414B (en) Intelligent dialogue method, intelligent dialogue device, electronic equipment and storage medium
CN111079945B (en) End-to-end model training method and device
KR20220029384A (en) Entity linking method and device, electronic equipment and storage medium
CN111950291A (en) Semantic representation model generation method and device, electronic equipment and storage medium
CN111967569A (en) Neural network structure generation method and device, storage medium and electronic equipment
CN111126061B (en) Antithetical couplet information generation method and device
CN111859997A (en) Model training method and device in machine translation, electronic equipment and storage medium
CN110674260A (en) Training method and device of semantic similarity model, electronic equipment and storage medium
CN114444462B (en) Model training method and man-machine interaction method and device
CN111984774A (en) Search method, device, equipment and storage medium
CN113360751A (en) Intention recognition method, apparatus, device and medium
CN114120166A (en) Video question and answer method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination