Method, storage medium and electronic device for automatically generating test questions based on case text
By preprocessing and model training of case text information, a variety of types of test questions were generated, which solved the problems of low efficiency of test questions generation and high repetition rate in the existing technology, and achieved efficient mastery of knowledge points and improved safety awareness.
Patent Information
- Application Number
- CN202210561195.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-23
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2042-05-23
AI Technical Summary
The prior art safety accident case text test questions in the field of fire safety are inefficient in the generation of safety test questions and the repetition rate of questions is high, making it difficult to fully master the knowledge points.
By obtaining case text information, data preprocessing and building training sets, using the BERT-FLAT-CRF model to generate key-value pairs of test questions and answers, forming a case knowledge base, including multiple-choice questions, multiple-choice questions and answer questions, and based on user geography, Push relevant test questions for location and answer historical data.
It significantly improves the efficiency of test questions generation, avoids duplication of questions, helps the questioners to fully grasp the relevant case knowledge points, and improves the safety awareness and safety education effect of practitioners.
Smart Images

Figure CN114969337B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of case informatization, and in particular to a method, storage medium and electronic device for automatically generating test questions based on case text. Background Art
[0002] With the continuous improvement of social and economic levels, the importance attached to production safety has also shown a continuous upward trend. Strengthening the training and management of enterprise production safety has become the focus of work units at all levels. Taking fire safety as an example, the most basic thing to do a good job in fire safety is to fully master the relevant laws, regulations and policies, and be familiar with the production and management characteristics of various industries. In recent years, due to the various factors of economic and social development and information technology, how to quickly familiarize yourself with these policies, regulations and safety accident cases and be able to use them skillfully has become the primary problem faced by every fire safety worker.
[0003] At present, relatively mature computer semantic understanding technology in China has been applied to fields such as fire safety, but there are relatively few studies on test question generation systems applied to safety accident case texts. If test question information related to safety accident cases is to be compiled, the test maker is required to read the entire case text in advance, and then combine his or her own understanding of the text content to come up with corresponding test questions. Not only is the whole process time-consuming and labor-intensive, but due to the inertia of thinking, the test question information generated each time based on the same accident case text is often the same, which is not conducive to the test taker's ability to fully grasp the knowledge points. Summary of the invention
[0004] Therefore, it is necessary to provide a technical solution for automatically generating test questions based on case texts, so as to solve the problems of low efficiency and high question repetition rate in the method of generating test question information based on cases.
[0005] In a first aspect, the present invention provides a method for automatically generating test questions based on case text, comprising the following steps:
[0006] Get case text information;
[0007] Performing data preprocessing on the case text information to construct a training set;
[0008] Input the training set into the training model for training to obtain key-value pairs of test questions and test answers;
[0009] Based on the multiple key-value pairs, questions related to the text information of each case are generated to obtain a case knowledge base.
[0010] As an optional embodiment, performing data preprocessing on the case text information includes:
[0011] Symbols other than text content in the case text information are removed, the extracted text content is divided into sentences, and each sentence is marked using the BIOES encoding method; among them, "B" represents the beginning of the entity, "I" represents the middle of the entity, "O" represents non-entity and is used to mark irrelevant characters, "E" represents the end of the entity, and "S" represents a single word or word marker.
[0012] As an optional embodiment, the training model includes a BERT layer, a FLAT layer and a CRF layer;
[0013] The BERT layer is used to enhance the semantic representation of the sentence and obtain serialized text input;
[0014] The FLAT layer is used to construct two position codes for each character or vocabulary information, and convert the character or vocabulary information into a position code;
[0015] The CRF layer is used to model the label sequence based on the dependency relationship between label information, so as to obtain the optimal sequence.
[0016] As an optional embodiment, the FLAT layer includes a Transformer structure; the FLAT layer is used to construct two position codes for each character or vocabulary information, and converting the character or vocabulary information into the position code specifically includes:
[0017] Head[i] and tail[2] are used to represent the head and tail of a character or vocabulary information respectively, and four relative position distances are used to represent the relative relationship between two words. The calculation methods of the four relative position distances are as follows:
[0018]
[0019]
[0020]
[0021]
[0022] in, Represents x i head to x j Head distance; Represents x i head to x j The tail distance; Represents x i tail to x j Head distance; Represents x i tail to xj The tail distance;
[0023] The relative position encoding is calculated based on the above four relative position distances according to the following formula:
[0024]
[0025] Among them, W r are the parameters that need to be trained. Represents the concatenation operator;
[0026] The calculation method is as follows:
[0027]
[0028]
[0029] Where d is the dimension of the position encoding;
[0030] The calculation results can then be input into the self-attention mechanism layer, and the calculation method is as follows:
[0031]
[0032] Among them, W q , W k,R , W k,E , u and v are the parameters that need to be trained, and E represents the word embedding lookup table or the output of the last layer of Transformer.
[0033] As an optional embodiment, the CRF layer is used to model the label sequence based on the dependency relationship between label information, so as to obtain the optimal sequence including:
[0034] The CRF layer is trained using maximum likelihood estimation and introduces the transformation matrix W as a parameter; for sentence X, the probability that the model labels the sequence Y = (y1, y2, ..., yn) is:
[0035]
[0036]
[0037] Where X represents the input sentence x1, x2, ..., xn, Y is the label sequence y1, y2, ..., yn, P i,yj represents the probability value of the i-th character being classified as the j-th label, W i,yj represents the state transition value from the i-th label to the j-th label, and exp represents the exponential function of the natural constant e;
[0038] The optimal sequence is the sequence with the largest probability value.
[0039] As an optional embodiment, the case text information includes event cause information; and the generating of topics related to each case text information according to the plurality of key-value pairs includes:
[0040] Using regular expressions to obtain direct cause entries leading to the occurrence of the event from the case text information, storing the obtained direct cause entries leading to the occurrence of the event in a first database, and matching them based on rules;
[0041] And / or the case text information includes event response information; the topics related to each case text information generated according to the multiple key-value pairs include:
[0042] The event response measure entries are obtained from the case text information using regular expressions, the obtained event response measure entries are stored in a second database, and matching is performed based on rules.
[0043] As an optional embodiment, matching the event cause information in a rule-based manner includes:
[0044] When the direct cause entry is greater than 0 and less than 3, generate two random integers random_index and random_index1 between [0, 1]; if random_index is equal to 0, generate an error judgment question; if random_index1 is equal to 0, randomly select a cause R that does not belong to the event from the first database O , generate test information;
[0045] And / or matching based on rules for incident response information including:
[0046] When the event response measure entry is greater than 0 and less than 3, generate two random integers random_index and random_index1 between [0, 1]; if random_index is equal to 0, generate an error judgment question; if random_index1 is equal to 0, randomly select a response measure C that does not belong to the event from the second database O , generate test question information.
[0047] As an optional embodiment, the case knowledge base includes multiple different types of test question information, and the types of the test question information include multiple-choice questions, true-false questions and answer questions;
[0048] The method further comprises:
[0049] Receive a question answering request from a user terminal, and record geographic location information of the user terminal and timestamp information of initiating the question answering request;
[0050] According to the geographical location information of the user terminal and the timestamp information of the question answering request, the historical question answering data of all user terminals within a preset area within a preset time period are obtained, and the type of the question information with the highest answer error rate is used as the push question type; the preset time period is a certain length of time before the timestamp information of the question answering request; the preset area range is an area within a preset radius with the geographical location information of the user terminal as the center;
[0051] The answer information corresponding to the pushed question type is pushed to the user terminal that currently initiates the answer request.
[0052] In a second aspect, the present invention further provides a storage medium storing a computer program, which implements the method steps of the first aspect of the present invention when executed by a processor.
[0053] In a third aspect, the present invention further provides an electronic device, including a processor and a storage medium, wherein the storage medium is the storage medium of the second aspect;
[0054] The processor is used to execute the computer program stored in the storage medium to implement the method steps of the first aspect.
[0055] Different from the prior art, the present invention provides a method, storage medium and electronic device for automatically generating test questions based on case texts, the method comprising the following steps: obtaining case text information; performing data preprocessing on the case text information to construct a training set; inputting the training set into a training model for training to obtain key-value pairs of test questions and test answers; generating questions related to each case text information based on a plurality of key-value pairs to obtain a case knowledge base. Since the test question information is obtained by inputting the preprocessed data of the case text information into the training model for training, the training model can combine a variety of different types of test question information for different case texts, which greatly improves the question setting efficiency compared to the manual question setting method, and at the same time avoids the occurrence of repeated questions to the greatest extent, which is conducive to the test taker to more comprehensively grasp the knowledge points of the relevant cases when answering questions. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 A flowchart of a method for automatically generating test questions based on case texts according to a first embodiment of the present invention;
[0057] Figure 2 A flowchart of a method for automatically generating test questions based on case texts according to a second embodiment of the present invention;
[0058] Figure 3 A flowchart of a method for automatically generating test questions based on case texts according to a third embodiment of the present invention;
[0059] Figure 4 This is a diagram of the BERT-FLAT-CRF model architecture involved in one embodiment of the present invention;
[0060] Figure 5 Schematic diagram of the structure of a BERT model involved in one embodiment of the present invention;
[0061] Figure 6 A schematic diagram of a module of an electronic device according to an embodiment of the present invention;
[0062] Reference numerals:
[0063] 10. Electronic equipment;
[0064] 101. Processor;
[0065] 102. Storage medium. DETAILED DESCRIPTION
[0066] In order to explain in detail the possible application scenarios, technical principles, specific schemes that can be implemented, and the purposes and effects that can be achieved, the following is a detailed description of the specific embodiments listed in conjunction with the accompanying drawings. The embodiments described herein are only used to more clearly illustrate the technical solutions of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.
[0067] Reference to "embodiment" herein means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The term "embodiment" appearing in various places in the specification does not necessarily refer to the same embodiment, nor does it particularly limit its independence or association with other embodiments. In principle, in the present application, as long as there is no technical contradiction or conflict, the various technical features mentioned in the embodiments can be combined in any way to form a corresponding implementable technical solution.
[0068] Unless otherwise defined, the technical terms used in this document have the same meanings as those generally understood by those skilled in the art to which this application belongs; the use of relevant terms in this document is only for describing specific embodiments and is not intended to limit this application.
[0069] In the description of this application, the term "and / or" is an expression used to describe the logical relationship between objects, indicating that three relationships may exist, for example, A and / or B, which means: A exists, B exists, and A and B exist at the same time. In addition, the character " / " in this article generally indicates that the objects before and after are in an "or" logical relationship.
[0070] In the present application, terms such as “first” and “second” are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship of quantity, priority or sequence between these entities or operations.
[0071] Without further limitations, in this application, the words "include", "comprises", "has" or other similar expressions used in sentences are intended to cover non-exclusive inclusion. These expressions do not exclude the presence of additional elements in the process, method or product including the elements, so that the process, method or product including a series of elements may include not only those limited elements, but also other elements not explicitly listed, or also include elements inherent to such process, method or product.
[0072] Similar to the understanding in the Examination Guidelines, in this application, expressions such as "greater than", "less than", "exceed" and the like are understood to exclude the number itself; expressions such as "above", "below", "within" and the like are understood to include the number itself. In addition, in the description of the embodiments of this application, "multiple" means more than two (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups", "multiple times", etc., unless otherwise clearly and specifically limited.
[0073] Natural Language Processing (NLP) is a field that studies various theories and methods for understanding and generating natural language with computers. It is an important or even core branch in the field of artificial intelligence and an interdisciplinary subject between computer science and linguistics. In today's era of ever-expanding data, text information is growing exponentially, providing a wide range of practical application scenarios for natural language processing technology. The early application of NLP technology was slightly difficult, but after the field of natural language processing entered the era of deep training, NLP began to emerge at the application level. Popular application tasks in recent years include information extraction, named entity recognition, text summarization, sentiment analysis, question-and-answer systems, machine translation, and dialogue systems, etc. They all have certain social significance and allow people to see the actual capabilities of natural language processing. Pre-trained models represented by BERT have successively demonstrated their capabilities, even exceeding the level of humans in some tasks. Models born in recent years are also mostly based on pre-trained models, including many in the Chinese field. It is also the powerful capabilities of pre-trained models that have made the application of NLP increasingly popular.
[0074] The main purpose of the present invention is to propose a question generation method based on a safety accident case text. For any input accident case text, the method can automatically generate test questions related to the text content according to the text content. The test questions can be used to test the degree of mastery of the text content by the person reading the text, thereby achieving the purpose of safety education for the staff, improving the safety awareness of the practitioners, and reducing the occurrence of safety accidents.
[0075] Specifically in the present invention, the generated test questions may include a variety of different types. For example, when constructing multiple-choice questions, the legal time, place or number in the sentence can be extracted as the answer to the correct option, and the remaining part of the sentence can be used as the question stem; the main cause of the safety accident case can also be extracted as the answer to the question; or the content of the preventive measures and corrective measures in the accident case can be extracted to generate related questions as the answers to multiple-choice questions or judgment questions.
[0076] like Figure 1 As shown, in a first aspect, the present invention provides a method for automatically generating test questions based on case text, comprising the following steps:
[0077] First, go to step S101 to obtain case text information;
[0078] Then, step S102 is performed to pre-process the case text information to construct a training set;
[0079] Then, step S103 is entered to input the training set into the training model for training, and key-value pairs of test questions and test answers are obtained;
[0080] Then, the process proceeds to step S104 to generate questions related to each case text information according to the plurality of key-value pairs to obtain a case knowledge base.
[0081] In this embodiment, the case text information records the basic information of the event, the cause information of the event, and the event response information. The basic information of the event includes the time point and location of the event. The cause information of the event refers to the cause of the event, and the event response information refers to the response measures for the event. The basic information of the event, the cause information of the event, and the event response information are usually recorded in the case text information in the form of text or characters. The event may refer to a safety accident, such as a fire safety accident, an electricity safety accident, etc.
[0082] In this embodiment, the key-value pair refers to the pairing information corresponding to the test question title and the test question answer, and the pairing information can be stored in the form of a key-value pair for subsequent indexing. The test question title and the test question answer can be generated in real time based on the training model to avoid duplication of the generated test question information. A variety of different types of test question information can be stored in the case knowledge base so that it can be called in real time when receiving a question answer request from a user terminal.
[0083] After adopting the above scheme, since the test information involved in the present invention is obtained by inputting pre-processed data based on the case text information into the training model for training, the training model can combine a variety of different types of test information for different case texts. Compared with the manual question-setting method, the question-setting efficiency is greatly improved, and at the same time, the occurrence of repeated questions is avoided to the greatest extent, which is conducive to the test taker to more comprehensively grasp the knowledge points of related cases when answering questions.
[0084] In some embodiments, data preprocessing of the case text information includes: removing symbols other than text content in the case text information, dividing the extracted text content into sentences, and marking each sentence using the BIOES encoding method; wherein "B" represents the beginning of an entity, "I" represents the middle of an entity, "O" represents a non-entity and is used to mark irrelevant characters, "E" represents the end of an entity, and "S" represents a single character or word marker.
[0085] Furthermore, symbols other than text content include extra spaces in the case text information, special symbols such as addition, subtraction, multiplication and division. After the extracted text content is divided into sentences, the blanks at the beginning and end of the sentences can be removed before marking, and punctuation marks can be removed if there are any at the end of the sentence.
[0086] After preprocessing the case text information in the above manner, a training set can be constructed. The training set contains sentences that have undergone preliminary filtering symbols, so that the subsequent training model can process the data more conveniently and generate corresponding test question information.
[0087] In some embodiments, the training model includes a BERT layer, a FLAT layer, and a CRF layer;
[0088] The BERT layer is used to enhance the semantic representation of the sentence and obtain serialized text input;
[0089] The FLAT layer is used to construct two position codes for each character or vocabulary information, and convert the character or vocabulary information into a position code;
[0090] The CRF layer is used to model the label sequence based on the dependency relationship between label information, so as to obtain the optimal sequence.
[0091] Preferably, the training model is a BERT-FLAT-CRF named entity recognition model, which can segment and recognize sentences in the training set, identify corresponding named entities such as time, place or numbers, etc., and organize them; then split the recognized labels through regular matching, such as splitting according to time, place, main reason, secondary reason, etc., and store the split results in the database.
[0092] The BERT layer (the first layer of the model) is the BERT word embedding layer, which uses the Chinese BERT pre-trained model. The BERT model is built on the basis of the Transformer model. It contains two layers of bidirectional Transformer models, but slightly different in that the BERT model only contains the Encoder part. In the BERT model, a multi-head attention layer is used as its core processing layer. BERT models of different sizes contain different numbers of multi-head attention mechanism layers (such as 12 or 24 layers), and each multi-head attention layer contains different numbers of attention heads (such as 12 or 16). Since there is no weight sharing between the layers of the BERT model, a BERT model can effectively contain up to 384 (24x16) different attention mechanism results. The BERT model is only a model in the pre-training stage. When solving specific NLP tasks, it is necessary to add other processing models after the BERT model to complete the Encoder-Decoder configuration. The structure of the BERT model is as follows: Figure 5 shown.
[0093] In some embodiments, the FLAT layer includes a Transformer structure; the FLAT layer is used to construct two position codes for each character or vocabulary information, and converting the character or vocabulary information into the position code specifically includes:
[0094] Head[i] and tail[i] are used to represent the head and tail of a character or vocabulary information respectively, and four relative position distances are used to represent the relative relationship between two words. The calculation methods of the four relative position distances are as follows:
[0095]
[0096]
[0097]
[0098]
[0099] in, Represents x i head to xj Head distance; Represents x i head to x j The tail distance; Represents x i tail to x j Head distance; Represents x i tail to x j The tail distance;
[0100] The relative position encoding is calculated based on the above four relative position distances according to the following formula:
[0101]
[0102] Among them, W r are the parameters that need to be trained. Represents the connection operator; W r It can be a weight parameter of a neural network, and the connection operator can be AND, NAND (not AND), OR or other exclusive OR operations.
[0103] The calculation method is as follows:
[0104]
[0105]
[0106] Where d is the dimension of the position encoding;
[0107] The calculation results can then be input into the self-attention mechanism layer, and the calculation method is as follows:
[0108]
[0109] Among them, W q , W k,R , W k,E , u and v are the parameters that need to be trained, and E represents the word embedding lookup table or the output of the last layer of Transformer.
[0110] Preferably, Figure 4As shown in the figure, the FLAT layer adopts the classic Transformer structure on the left and bottom sides, and the FLAT structure has only one Transformer structure. The four matrices on the right are the flattening of the Lattice structure. Usually in the Transformer structure, there will be a representation of position information. The original Transformer structure is absolute position, while in later structures, the position relationship is mostly represented by relative position. The representation of relative position is diverse.
[0111] The FLAT layer structure design solves the problem of mining the vocabulary information of the input text itself, and the structure can also capture long-distance dependencies. In addition, since the position information representation in the FLAT structure solves the parallelization problem, the time efficiency is greatly improved.
[0112] In some embodiments, the CRF layer is used to model the tag sequence based on the dependency relationship between tag information, so as to obtain the optimal sequence including:
[0113] The CRF layer is trained using maximum likelihood estimation and introduces the transformation matrix W as a parameter; for sentence X, the probability that the model labels the sequence Y = (y1, y2, ..., yn) is:
[0114]
[0115]
[0116] Where X represents the input sentence x1, x2, ..., xn, Y is the label sequence y1, y2, ..., yn, P i,yj represents the probability value of the i-th character being classified as the j-th label, W i,yj represents the state transition value from the i-th label to the j-th label, exp represents the exponential function of the natural constant e; the optimal sequence is the sequence with the largest probability value.
[0117] Different from the Softmax function used in common deep learning models, CRF can learn the dependencies between labels. For example, in the industry type label, B-TIME cannot appear after M-TIME.
[0118] In some embodiments, the case text information includes event cause information; the generating of topics related to each case text information based on the multiple key-value pairs includes: using regular expressions to obtain direct cause entries that caused the event to occur from the case text information, storing the obtained direct cause entries that caused the event to occur into a first database, and matching them based on rules.
[0119] And / or, the case text information includes event response information; the generating of topics related to each case text information based on the multiple key-value pairs includes: using regular expressions to obtain event response entries from the case text information, storing the obtained event response entries in a second database, and matching them based on rules.
[0120] Preferably, matching the event cause information in a rule-based manner includes: when the direct cause entry is greater than 0 and less than 3, generating two random integers random_index and random_index1 between [0, 1]; if random_index is equal to 0, generating an error judgment question; if random_index1 is equal to 0, randomly selecting a cause R that does not belong to the event from the first database O , generate test question information.
[0121] And / or, matching the event response information in a rule-based manner includes: when the event response entry is greater than 0 and less than 3, generating two random integers random_index and random_index1 between [0, 1]; if random_index is equal to 0, generating an error judgment question; if random_index1 is equal to 0, randomly selecting a response C that does not belong to the event from the second database O , generate test question information.
[0122] By setting two random numbers to randomly generate different types of test information (such as multiple-choice questions or true-or-false questions), the duplication of test information can be effectively avoided, making it easier for test takers to grasp the knowledge points of related test questions more comprehensively.
[0123] like Figure 2 As shown, the case knowledge base includes multiple different types of test information, and the types of test information include multiple-choice questions, true-false questions and answer questions;
[0124] The method further comprises:
[0125] First, enter step S201 to receive a question answering request from a user terminal, and record the geographical location information of the user terminal and the timestamp information of initiating the question answering request;
[0126] Then, step S202 is entered to obtain historical answer data of all user terminals within a preset area within a preset time period according to the geographical location information of the user terminal and the timestamp information of the answer request, and the type of the test information with the highest answer error rate is used as the push question type; the preset time period is a certain length of time before the timestamp information of the answer request; the preset area range is an area within a preset radius with the geographical location information of the user terminal as the center;
[0127] Then, the process proceeds to step S203 to push the answer information corresponding to the pushed question type to the user terminal that currently initiates the question answering request.
[0128] Taking the preset time period of one month before the timestamp information of the question answering request and the preset radius of 1 kilometer as an example, when the system receives a question answering request from a user terminal, it will retrieve the historical answering data of all user terminals within a 1-kilometer range centered on the geographical location information of the user terminal in the past month, and make statistics on these answering data. For example, the number of wrong answers to judgment questions in this area is much higher than that of multiple-choice questions. The system determines that the judgment questions will push the question type and push the relevant judgment question information to the user terminal that currently initiates the question answering request. Through design, in addition to knowing their own test results, user terminals can also know the answering results of people near their community based on the pushed test questions. For example, after digesting and absorbing the knowledge points that are easy to make mistakes, it is convenient for subsequent lectures in the surrounding area, thereby improving the breadth of popular science of safety knowledge.
[0129] Of course, in order to make the pushed test information more representative and timely, first, the test information generated based on the case with the time information recorded in the case text information close to it can be pushed according to the timestamp information of the question-answering request. Secondly, based on the geographical location information of the current user terminal, the types of events that have occurred recently in the preset area corresponding to the geographical location information can be obtained from the historical database. For example, if there have been two fires in the past year, the system will focus on calling the case text information related to fire to generate relevant test information and push it to the terminal; for example, if there have been multiple traffic accidents near the location of the user terminal in the past year, the system will focus on calling the case text information related to traffic safety to generate relevant test information and push it to the terminal. In this way, the push of test information can be made more targeted and representative.
[0130] like Figure 3 As shown, in some application scenarios, the method provided by the present invention may further include the following steps:
[0131] First, step S1 may be entered to obtain text data corresponding to accident cases from multiple different channels. Specifically, text materials of safety accident related cases may be obtained from different channels such as fire safety policies and regulations, enterprise actual case libraries, and the Internet.
[0132] Then, step S2 is entered to pre-process the text data, and to establish named entity recognition (NER), text summarization, and information extraction models. In this step, the acquired accident case text materials can be pre-processed, annotated, and a training set can be constructed to establish a knowledge base.
[0133] Then, step S3 is entered to generate relevant test questions based on information such as time, place, and numbers, traverse the list in the NER to make judgments, and generate answers corresponding to the test questions.
[0134] Then, step S4 is entered to apply regularization, NER and other technologies to obtain cause entries from the accident case text, and step S5 is entered to apply regularization, NER, summary generation, information extraction and other technologies to obtain accident-related solutions.
[0135] By repeating steps S3-S5, the problems that can be extracted from the input safety accident case text can be described one by one, and the generated accident case text test questions can be summarized to form a knowledge base.
[0136] The present invention fully considers the characteristics of event safety knowledge and provides a method for generating questions based on event case texts to solve the current problems of manual question generation, which requires reading the entire text, and then generating questions based on the text content, which is time-consuming and labor-intensive, and the questions generated for the same accident case text are the same each time. In order to achieve the purpose of semantic understanding and automatic intelligence, the present invention uses a word segmentation algorithm to segment the accident case text information input by the user in natural language, and at the same time pre-processes and annotates the text to form a training sample library based on standardization. The system should also have the function of using its own stored knowledge to judge the input data, generate results and further verify them, so as to build a complete safety accident case knowledge base. Constructing a knowledge base for question generation based on safety accident case texts through knowledge acquisition, representation and reasoning is the key to improving the safety awareness of practitioners and reducing the occurrence of safety accidents.
[0137] For an input arbitrary accident case text, the present invention can automatically generate test questions related to the text content according to the text content, and these test questions can be used to test the degree of mastery of the text content by the person reading the text, thereby achieving the purpose of safety education for the staff, improving the safety awareness of the practitioners, and reducing the occurrence of safety accidents. When the accident case text is input into the system, the system can complete the generation of a set of questions related to the text content according to the text content in a very short time, which greatly improves the efficiency of question generation.
[0138] In a second aspect, the present invention further provides a storage medium storing a computer program, which implements the method steps of the first aspect of the present invention when executed.
[0139] like Figure 6 As shown, in the third aspect, the present invention also provides an electronic device 10, including a processor 101 and a storage medium 102, wherein the storage medium 102 is the storage medium as in the second aspect; the processor 101 is used to execute the computer program stored in the storage medium 102 to implement the method steps as in the first aspect.
[0140] In this embodiment, the electronic device is a computer device, including but not limited to: personal computers, servers, general-purpose computers, special-purpose computers, network devices, embedded devices, programmable devices, smart mobile terminals, smart home devices, wearable smart devices, vehicle-mounted smart devices, etc. Storage media include but are not limited to: RAM, ROM, disks, tapes, optical disks, flash memory, USB flash drives, mobile hard disks, memory cards, memory sticks, network server storage, network cloud storage, etc. Processors include but are not limited to CPU (central processing unit), GPU (graphics processing unit), MCU (microprocessor), etc.
[0141] Those skilled in the art should understand that the above embodiments can be provided as methods, devices, or computer program products. These embodiments can take the form of complete hardware embodiments, complete software embodiments, or embodiments combining software and hardware. All or part of the steps in the methods involved in the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a storage medium readable by a computer device for executing all or part of the steps of the methods of the above embodiments.
[0142] The above embodiments are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a computer device to generate a machine, so that the instructions executed by the processor of the computer device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0143] These computer program instructions may also be stored in a computer device readable memory capable of directing a computer device to operate in a specific manner, so that the instructions stored in the computer device readable memory produce a manufactured product including an instruction device, the instruction device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0144] These computer program instructions can also be loaded onto a computer device so that a series of operating steps are executed on the computer device to produce a computer-implemented process, whereby the instructions executed on the computer device provide for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0145] Although the above embodiments have been described, once those skilled in the art know the basic creative concepts, they can make additional changes and modifications to these embodiments. Therefore, the above are only embodiments of the present invention and do not limit the patent protection scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for automatically generating test questions based on case text, characterized in that: The following steps are involved: Get case text information; Performing data preprocessing on the case text information to construct a training set; Input the training set into the training model for training to obtain key-value pairs of test questions and test answers; Generate questions related to each case text information according to the plurality of key-value pairs to obtain a case knowledge base; The training model includes a BERT layer, a FLAT layer and a CRF layer; The BERT layer is used to enhance the semantic representation of the sentence and obtain serialized text input; The FLAT layer is used to construct two position codes for each character or vocabulary information, and convert the character or vocabulary information into a position code; The CRF layer is used to model the label sequence based on the dependency relationship between label information, so as to obtain the optimal sequence; The FLAT layer includes a Transformer structure; The FLAT layer is used to construct two position codes for each character or vocabulary information. Converting the character or vocabulary information into a position code specifically includes: Head[i] and tail[i] are used to represent the head and tail of a character or vocabulary information respectively, and four relative position distances are used to represent the relative relationship between two words. The calculation methods of the four relative position distances are as follows: in, Represents x i head to x j Head distance; Represents x i head to x j The tail distance; Represents x i tail to x j Head distance; Represents x i tail to x j The tail distance; The relative position encoding is calculated based on the above four relative position distances according to the following formula: Among them, W r are the parameters that need to be trained. Represents the concatenation operator; The calculation method is as follows: Where d is the dimension of the position encoding; The calculation results can then be input into the self-attention mechanism layer, and the calculation method is as follows: Among them, W q , W k,R , W k,E , u and v are parameters that need to be trained, and E represents the word embedding lookup table or the output of the last layer of Transformer; The CRF layer is used to model the label sequence based on the dependency relationship between label information, so as to obtain the optimal sequence including: The CRF layer is trained using maximum likelihood estimation and introduces the transformation matrix W as a parameter; for sentence X, the probability that the model labels the sequence Y = (y1, y2, ..., yn) is: Where X represents the input sentence x1,x2,...,xn, and Y is the label sequence y1,y2,...,yn,P i,yj represents the probability value of the i-th character being classified as the j-th label, W i,yj represents the state transition value from the i-th label to the j-th label, and exp represents the exponential function of the natural constant e; The optimal sequence is the sequence with the largest probability value.
2. The method for automatically generating test questions from case texts as claimed in claim 1, characterized in that: The data preprocessing of the case text information includes: Symbols other than text content in the case text information are removed, the extracted text content is divided into sentences, and each sentence is marked using the BIOES encoding method; among them, "B" represents the beginning of the entity, "I" represents the middle of the entity, "O" represents non-entity and is used to mark irrelevant characters, "E" represents the end of the entity, and "S" represents a single word or word mark.
3. The method for automatically generating test questions from case texts as claimed in claim 1, characterized in that: The case text information includes event cause information; the topics related to each case text information generated according to the multiple key-value pairs include: Using regular expressions to obtain direct cause entries leading to the occurrence of the event from the case text information, storing the obtained direct cause entries leading to the occurrence of the event in a first database, and matching them based on rules; And / or the case text information includes event response information; the topics related to each case text information generated according to the multiple key-value pairs include: The event response measure entries are obtained from the case text information using regular expressions, the obtained event response measure entries are stored in a second database, and matching is performed based on rules.
4. The method for automatically generating test questions from case texts as claimed in claim 3, characterized in that: The rule-based matching of event cause information includes: When the direct cause entry is greater than 0 and less than 3, generate two random integers random_index and random_index1 between [0,1]; if random_index is equal to 0, generate an error judgment question; if random_index1 is equal to 0, randomly select a cause R that does not belong to the event from the first database O , generate test information; And / or matching based on rules for incident response information including: When the event response measure entry is greater than 0 and less than 3, generate two random integers random_index and random_index1 between [0,1]; if random_index is equal to 0, generate an error judgment question; if random_index1 is equal to 0, randomly select a response measure C that does not belong to the event from the second database O , generate test question information.
5. The method for automatically generating test questions from case texts as claimed in claim 1, characterized in that: The case knowledge base includes multiple different types of test information, and the types of test information include multiple-choice questions, true-false questions and answer questions; The method further comprises: Receive a question answering request from a user terminal, and record geographic location information of the user terminal and timestamp information of initiating the question answering request; According to the geographical location information of the user terminal and the timestamp information of the question answering request, the historical question answering data of all user terminals within a preset area within a preset time period are obtained, and the type of the question information with the highest answer error rate is used as the push question type; the preset time period is a certain length of time before the timestamp information of the question answering request; the preset area range is an area within a preset radius with the geographical location information of the user terminal as the center; The answer information corresponding to the pushed question type is pushed to the user terminal that currently initiates the answer request.
6. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 5 is implemented.
7. An electronic device, characterized in that: comprising a processor and a storage medium, wherein the storage medium is the storage medium according to claim 6; The processor is configured to execute the computer program stored in the storage medium to implement the method according to any one of claims 1 to 5.
