A question and answer library construction method and related apparatus
By constructing a question-answering library using neural network models and predefined template libraries, the problem of difficulty in identifying descriptive objects and scenes in question-answering pairs is solved, thereby improving the quality of question-answering pairs and the robustness of the model.
Patent Information
- Application Number
- CN202010492385.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-02
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2040-06-02
AI Technical Summary
Existing technologies cannot effectively extract question-answer pairs containing descriptions of objects, conditions, and scenarios from text, resulting in poor performance of question-answer databases.
By predicting sentence categories and word characteristics using a trained neural network model, matching question templates with a predefined template library, constructing a question-and-answer library, and combining remote supervision and administrator instructions to correct sentence categories and word characteristics, the representational capabilities of traditional relation extraction methods are alleviated.
It improves the accuracy and quality of question-answer pair identification, solves the data pressure problem of question-answer pairs in the cold start stage, and enhances the robustness and controllability of the model.
Smart Images

Figure CN113761109B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of natural language analysis, and particularly relate to a question and answer library construction method and related device. BACKGROUND
[0002] With the development of computer technology, artificial intelligence (AI) is becoming more and more mature, and many intelligent assistants capable of human-computer dialogue have appeared on the market, such as mobile phone voice assistants, automatic question and answer robots, etc. When a user asks a question to an intelligent assistant, the intelligent assistant can analyze the question raised by the user, then find the corresponding answer in the constructed question and answer library, and finally reply to the user with the found answer. Therefore, it is extremely important to construct a high-quality and content-rich question and answer library.
[0003] At present, the scheme for constructing a question and answer library is to extract question and answer pairs from text to form a question and answer library. However, how to extract question and answer pairs from text is still a technical difficulty. Question and answer pair information contains a large amount of information, such as description object, description condition, description scene, etc., which is difficult to express simply using the existing subject-predicate-object triple structure, so the effect of using traditional relation extraction method to obtain question and answer pairs from text is poor. SUMMARY
[0004] Embodiments of the present application provide a question and answer library construction method and related device, to solve the technical problem that the above-mentioned method of extracting question and answer library based on triple cannot recognize description object, description condition, and description scene, resulting in poor effect of extracted question and answer pairs.
[0005] In a first aspect, the embodiments of the present application provide a question and answer library construction method, including: obtaining text information; obtaining, according to the text information, a sentence category corresponding to a sentence in the text information and a word feature corresponding to a word in the text information by a trained neural network model, the sentence category being used to represent a category to which the sentence in the text information belongs, and the word feature being used to represent a feature of the word in the text information; determining a question template matched by the sentence category and the word feature through a pre-defined template library, filling the word into a position corresponding to the question template, obtaining a question and answer pair, and constructing a question and answer library containing the question and answer pair, the template library including a matching relationship between the sentence category, the word feature, and the question template. The embodiments of the present application predict the sentence category of a sentence and the word feature of a word through a neural network model, match a corresponding question template, obtain a question and answer pair, and then construct a question and answer library. The embodiments of the present application can recognize the meaning of a sentence and a word through the sentence category and the word feature, effectively alleviate the problem of insufficient representation ability of traditional relation extraction in complex multi-relation extraction, and make the obtained question and answer pair good in effect.
[0006] With reference to the first aspect, in a possible implementation manner, before the obtaining the text information, the obtaining the text information, and the obtaining, according to the text information, the sentence category corresponding to each sentence in the text information and the word feature corresponding to each word in the text information by using the trained neural network model, the method further includes: segmenting the text information into sentences and words to obtain text information composed of segmented sentences.
[0007] With reference to the first aspect, in a possible implementation manner, the obtaining the text information includes: obtaining one or more of a portable document format document, a presentation document, and a Word document; and extracting the text information in the portable document format document, the presentation document, or the Word document to obtain the text information in a pure text format.
[0008] With reference to the first aspect, in a possible implementation manner, before the obtaining, according to the text information, the sentence category corresponding to each sentence in the text information and the word feature corresponding to each word in the text information by using the trained neural network model, the method further includes: obtaining training text information; determining, by using a predefined template library, a training sentence category corresponding to each sentence in the training text information and a training word feature corresponding to each word in the training text information; and training the neural network model according to the training text information, the training sentence category, and the training word feature to obtain the trained neural network model.
[0009] In the cold start stage, the embodiment of the present application determines the training sentence category corresponding to each sentence in the training text information and the training word feature corresponding to each word in the training text information by using the predefined template library, which greatly relieves various data pressures faced by the question and answer pair library in the cold start stage.
[0010] With reference to the first aspect, in a possible implementation manner, after the obtaining, according to the text information, the sentence category corresponding to each sentence in the text information and the word feature corresponding to each word in the text information by using the trained neural network model, the method further includes: modifying the sentence category corresponding to each sentence in the text information and the word feature corresponding to each word in the text information according to an administrator instruction; and retraining the trained neural network model according to the text information, the modified sentence category, and the modified word feature.
[0011] The embodiment of the present application modifies the sentence category corresponding to each sentence and the word feature corresponding to each word by using the administrator instruction, further controls the quality of the knowledge base in the operation stage of the question and answer pair library, and avoids the semantic drift problem possibly caused by the model. Moreover, the neural network model can be continuously trained to improve the robustness of the model.
[0012] With reference to the first aspect, in a possible implementation manner, the neural network model comprises a bidirectional encoder representation transformer (BERT), a full connection layer, a bidirectional long short-term memory network (BiLSTM), and a conditional random field (CRF), and the obtaining, by the trained neural network model, of the sentence category corresponding to a sentence in the text information and the word feature corresponding to a word in the text information according to the text information comprises: receiving, by the BERT, the text information and a first identifier, the first identifier being used for predicting the sentence category corresponding to a sentence in the text information; obtaining, by the full connection layer, a word vector sequence corresponding to the text information and a second identifier corresponding to the first identifier; determining, according to the second identifier, the sentence category corresponding to a sentence in the text information; obtaining, by the BiLSTM and the CRF, a label corresponding to the word vector sequence; and determining, according to the label, the word feature corresponding to a word in the text information.
[0013] With reference to the first aspect, in a possible implementation manner, the sentence category comprises one or more of a position category, a usage category, an explanation category, an imperative category, and a purpose category.
[0014] With reference to the first aspect, in a possible implementation manner, the word feature comprises one or more of a description object, position information, usage information, description information, action information, reference condition information, result information, and purpose information.
[0015] In a second aspect, an embodiment of the present application provides a question and answer library construction system, comprising: an obtaining module configured to obtain text information; a processing module configured to obtain, according to the text information, a sentence category corresponding to a sentence in the text information and a word feature corresponding to a word in the text information by using a trained neural network model, the sentence category being used for representing a category to which a sentence in the text information belongs, and the word feature being used for representing a feature of a word in the text information; and the processing module is further configured to determine, by using a pre-defined template library, a question template matched with the sentence category and the word feature, fill the word into a position corresponding to the question template, and construct a question and answer library after obtaining a question and answer pair, the question and answer library comprising the question and answer pair, and the template library comprising a matching relationship between the sentence category, the word feature, and the question template.
[0016] With reference to the second aspect, in a possible implementation manner, the system further comprises a word segmentation module configured to segment the text information into sentences and words to obtain text information composed of segmented sentences.
[0017] With reference to the second aspect, in a possible implementation manner, the obtaining module comprises: an obtaining unit, configured to obtain one or more of a portable document format document, a presentation document and a Word document; and a format conversion unit, configured to extract the text information in the portable document format document, the presentation document or the Word document to obtain the text information in a pure text format.
[0018] With reference to the second aspect, in a possible implementation manner, the system further comprises: a training module, configured to obtain training text information; the training module is further configured to determine, by using a predefined template library, a training sentence category corresponding to a sentence in the training text information and a training word feature corresponding to a word in the training text information; and the training module is further configured to train the neural network model according to the training text information, the training sentence category and the training word feature to obtain a trained neural network model.
[0019] With reference to the second aspect, in a possible implementation manner, the system further comprises: a cycle training module, configured to modify, according to an administrator instruction, a sentence category corresponding to a sentence in the text information and a word feature corresponding to a word in the text information; and the cycle training module is further configured to retrain the trained neural network model according to the text information, the modified sentence category and the modified word feature.
[0020] With reference to the second aspect, in a possible implementation manner, the neural network model comprises a bidirectional encoder representation transformer (BERT), a full connection layer, a bidirectional long short-term memory network (BiLSTM) and a conditional random field (CRF); the processing module is further configured to receive, by using the BERT, the text information and a first identifier, the first identifier being used for predicting a sentence category corresponding to a sentence in the text information; the processing module is further configured to obtain, by using the full connection layer, a word vector sequence corresponding to the text information and a second identifier corresponding to the first identifier; the processing module is further configured to determine, according to the second identifier, the sentence category corresponding to the sentence in the text information; the processing module is further configured to obtain, by using the BiLSTM and the CRF, a label corresponding to the word vector sequence; and the processing module is further configured to determine, according to the label, a word feature corresponding to a word in the text information.
[0021] With reference to the second aspect, in a possible implementation manner, the sentence category comprises one or more of a position category, a usage category, an explanation category, an imperative category and a purpose category.
[0022] With reference to the second aspect, in a possible implementation manner, the word feature comprises one or more of a description object, position information, usage information, description information, action information, reference condition information, result information and purpose information.
[0023] In a third aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores instructions, and when the instructions are run on a computer, the computer is caused to execute the method according to the first aspect.
[0024] In a fourth aspect, an embodiment of the present application provides a server, comprising one or more central processing units, a memory, an input / output interface, a wired or wireless network interface, and a power supply; the memory is a volatile memory or a persistent memory; the central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the method according to the first aspect.
[0025] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, and when the instructions are run on a computer, the computer is caused to execute the method according to the first aspect.
[0026] In a sixth aspect, an embodiment of the present application provides a question and answer library construction device, comprising one or more central processing units and a memory.
[0027] The memory is configured to store programs.
[0028] The processor is configured to execute the programs in the memory, so that the question and answer library construction device executes the method according to the first aspect.
[0029] From the above technical solutions, it can be seen that the embodiments of the present application have the following advantages:
[0030] The embodiments of the present application provide a question and answer library construction method, which predicts the sentence category of a sentence and the word characteristics of a word through a neural network model, matches a corresponding question template to obtain a question and answer pair, and then constructs a question and answer library. The present application can identify the meaning of a sentence and a word through the sentence category and the word characteristics, effectively alleviating the problem of insufficient representation ability of traditional relation extraction in complex multi-relation extraction, and obtaining a good question and answer pair. The embodiments of the present application also provide a question and answer library construction device, system, server, computer program product, and computer readable storage medium. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 The flowchart of the question and answer library construction method in the embodiments of the present application is shown.
[0032] Figure 2 The system architecture diagram of the question and answer library construction method in the embodiments of the present application is shown.
[0033] Figure 3 The schematic diagram of the heuristic rule supervision in the embodiments of the present application is shown.
[0034] Figure 4A schematic diagram of a neural network model in an embodiment of the present application;
[0035] Figure 5 A schematic diagram of a hot operation stage in an embodiment of the present application;
[0036] Figure 6 A schematic diagram of a question and answer corpus construction system provided in an embodiment of the present application;
[0037] Figure 7 Another schematic diagram of a question and answer corpus construction system in an embodiment of the present application;
[0038] Figure 8 A schematic diagram of a server structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] The embodiments of the present application provide a question and answer corpus construction method and related apparatus, and are used for solving the technical problem that the question and answer pair extracted by the above-mentioned question and answer corpus construction method based on triple extraction cannot recognize a described object, a described condition and a described scene, and thus the extracted question and answer pair has a poor effect.
[0040] The terms "first", "second", "third", "fourth" and the like in the description and claims of the present application and in the above-mentioned drawings (if any) are used to distinguish similar objects, and do not necessarily have to be used to describe a particular sequential or chronological order. It should be understood that the data thus used can be interchanged, where appropriate, so that the embodiments of the present application described herein can be carried out in a different order than the one illustrated or described herein. In addition, the terms "comprising" and "corresponding to" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a list of steps or units is not necessarily limited to those steps or units that are clearly listed, but can include other steps or units that are not clearly listed or inherent to such processes, methods, products or devices.
[0041] In the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any embodiment or design presented as "exemplary" or "for example" in the embodiments of the present application is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the words "exemplary" or "for example" is intended to present concepts in a concrete manner.
[0042] The technical problems solved by the embodiments of the present application are described below first:
[0043] The main technical difficulties of extracting question-answer pairs from text are: 1) The question-answer pair information contains a large amount of information, such as description objects, description conditions, description scenes, etc., which is difficult to express simply using existing triple structure, so traditional relationship extraction methods cannot be used to obtain question-answer pairs from text. 2) The question-answer pair itself is not completely structured information, but is still a highly abstracted text. 3) The form of the question-answer pair changes constantly depending on its type, and if not limited, it is difficult to generate a coherent, reliable, and context-related question-answer pair.
[0044] Existing solutions can be broadly divided into two categories: 1) Relationship extraction-based question-answer pair generation. This method is based on information extraction, using heuristic rules or deep learning methods to extract triple information from natural language descriptions, and then using pre-constructed question-answer pair templates to generate corresponding question-answer pair corpora. However, this method is severely limited by the representation ability of triples. 2) Natural language generation-based question-answer pair generation. This method is based on natural language generation, using deep learning models to learn generation models from a large amount of question-answer pair corpora, but because the generated form is difficult to constrain, the generated question-answer pairs often have problems such as incoherent description, context irrelevance, and question-answer mismatch.
[0045] The first category is to generate question-answer pairs based on relationship extraction and build a question-answer library. Relationship extraction aims to extract structured triples from a large amount of unstructured text, and triples usually describe two entities and their corresponding relationships, or an entity and its corresponding attributes and attribute values. Based on relationship extraction, this method designs corresponding question-answer pair templates for each type of relationship, thereby constructing question-answer pairs. However, question-answer pairs are not simply triples. A question often contains multiple information such as description objects, description conditions, and description scenes, which cannot be covered by a triple. At the same time, question-answer pairs are often a highly abstracted context, such as "What should I do?" and "What do you think?" These questions often require a solution or suggestion from the text, so they may lack corresponding description objects. When facing these types of question-answer pairs, the relationship extraction-based question-answer pair generation method does not have a good solution.
[0046] The second category is based on natural language generation question and answer pairs, and a question and answer library is constructed. Natural language generation aims to generate a task-related natural language description under the condition of a certain known information. This method is widely used in text summarization, description generation and other scenarios. In the question generation task, the existing technology usually generates a corresponding question under the condition of a given context and a corresponding answer. The specific implementation of this technology is usually a method based on a deep learning model, so a large amount of training corpus is needed to learn the description form of the language. When only the context is given, the method based on natural language generation also needs to design a corresponding answer extraction module, which is responsible for extracting the content that can be asked from the context, and then using the generation model to obtain the corresponding question to form a complete question and answer pair.
[0047] A major problem faced by the natural language generation technology in solving the question and answer pair generation is the uncontrollability of the generation process, which greatly reduces the readability of the question and answer pair. Because there is no mature technology to control the specific format of the text generation when generating text, which makes the model generate some sentences that are not smooth, which greatly reduces the usability of the system. The method based on natural language generation is also limited by the training corpus. The quality of the training corpus determines the effect of the model training. In the English field, researchers usually conduct experiments on public datasets such as SQuAD, while in the Chinese field, there is no high-quality question and answer corpus. Therefore, it is difficult to develop a corresponding corpus for this problem, which is a problem of reversing the end and the beginning. At the same time, the use of natural language generation to construct the question and answer pair also needs a corresponding answer extraction model. The combination of multiple models will cause the error propagation between the models, further reducing the quality of the generated question and answer pair.
[0048] To sum up, the question and answer pair extraction based on relation extraction is limited by the expression ability of the triple, and cannot well model the question and answer pair which is a kind of tuple with rich information. The question and answer pair extraction based on natural language generation is limited by supervised data, generation mode and error propagation. In the absence of training corpus, the generation model is difficult to effectively learn the expression form of natural language and the relationship between the question and the context, which leads to the difficulty of this method in the cold start stage. At the same time, the uncontrolled generation mode leads to large and small grammatical errors between the generated sentences, which seriously affects the system performance, and the error of the previous leading answer extraction model is further propagated to the generation model, so the generation model cannot complete the question and answer pair extraction.
[0049] Embodiments of the present application aim at the problems of sparse data in the cold start stage, high labeling cost, weak expression ability of the model in the training stage, and poor generation effect, and propose a question and answer library construction method and system.
[0050] Figure 1 The flowchart of the question and answer library construction method in the embodiments of the present application is shown.Figure 2 A system architecture diagram of the question and answer library construction method in the embodiments of the present application. As shown in the figure, the question and answer library construction method can include the following steps: Figure 1
[0051] 101. The server acquires text information.
[0052] In the embodiments of the present application, the subject performing the construction of the question and answer library is not limited. In some embodiments, the server constructs the question and answer library and then sends the question and answer library to the terminal, so that the terminal can reply to the user according to the question and answer library. In other embodiments, the server constructs the question and answer library and then receives the question sent by the terminal, finds the corresponding answer in the question and answer library, and sends the answer to the terminal, so that the terminal can reply to the user with the answer. In other embodiments, the terminal constructs the question and answer library according to the text information from the server and the local text information, and replies to the user according to the question and answer library. In other embodiments, the terminal can construct the question and answer library according to the text information, so as to quickly understand the text information through the question and answer library. The terminal described above can be a computer, a tablet, a mobile phone, a smart robot, etc. The embodiments of the present application do not limit the subject performing the construction of the question and answer library. For the sake of clear and convenient description, the embodiments of the present application will be described with the server as the subject, and the same applies to other subjects, which will not be described herein again.
[0053] In the embodiments of the present application, the application scenarios of the construction of the question and answer library are not limited. In some application scenarios, the server constructs the question and answer library and then sends the question and answer library to the terminal. When the user asks the intelligent assistant on the terminal, the intelligent assistant replies to the user according to the question and answer library. In some application scenarios, the server constructs the question and answer library, and the user can send a message to the intelligent customer robot on the server to ask a question, and then the intelligent customer robot can reply to the user with a message according to the question and answer library. In some application scenarios, the server can construct a frequently asked question library (FAQ) corresponding to the user manual according to the user manual corresponding to the product. The user can directly view the frequently asked question library to find the corresponding question.
[0054] In the embodiments of the present application, the source of the text information is not limited. In some embodiments, the text information can come from the network, can come from the user manual, can come from the literature, and can also come from the speech conversion, which is not limited in the embodiments of the present application. The speech conversion refers to that a piece of recording is converted into text information after speech recognition, and such text information can also be used as the source of the construction of the question and answer library.
[0055] In the embodiments of the present application, the language of the text information is not limited. In some embodiments, the text information is Chinese. In other embodiments, the text information is English. In other embodiments, the text information is Japanese. The embodiments of the present application do not limit this.
[0056] In the embodiments of the present application, the server can receive text information input in multiple formats. In some embodiments, the server receives text information in portable document format (PDF), and the server can convert the text information in PDF format into text information in pure text format. For example, the server can convert the text information in PDF format into text information in pure text format through optical character recognition (OCR) identification. In other embodiments, the server receives a presentation document (PPT document), and the server can extract text information in the PPT document to obtain text information in pure text format. In other embodiments, the server receives a Word document, and the server can extract text information in the Word document to obtain text information in pure text format. In other embodiments, the server directly obtains text information in pure text format, such as text information in txt format. In other embodiments, the server receives text information in picture format, and the server can convert the text information in picture format into text information in pure text format through image recognition. In other embodiments, the server receives a segment of voice, and the server can convert the segment of voice into text information in pure text format through voice recognition. The process of converting text information in various formats into text information in pure text format (txt document) by the server described above can be referred to as data preprocessing.
[0057] 102. The server divides the obtained text information into sentences to obtain candidate sentence pairs in units of sentences.
[0058] Figure 3 An illustrative diagram of heuristic rule supervision in the embodiments of the present application is shown in FIG. 1. As shown in FIG. 1, in the embodiments of the present application, the server first performs paragraph analysis on the text information. The paragraph analysis includes paragraph division and sentence splicing. Figure 3
[0059] The paragraph division refers to dividing the text information into multiple paragraphs. For example, the server can divide the paragraphs according to paragraph delimiters in the text information. The paragraph delimiters can be reserved when other formats are converted into pure text format, can be self-provided in pure text information, or can be added by manual reading of pure text information. In actual applications, the paragraph delimiters can also be provided through other ways, which are not limited in the embodiments of the present application. In other embodiments, the server can also divide the text information into multiple paragraphs through other algorithms, which are not limited in the embodiments of the present application.
[0060] The sentence splicing refers to re-splicing the broken sentences in a paragraph block of the text information. In the embodiment of the present application, since the incorrect segmentation of sentences may be caused during the conversion of different format files, the module re-splices the broken sentences in the same paragraph block after the paragraph division, to obtain the paragraph blocks divided according to the paragraphs. For example, the server can re-splice the sentences according to the full stop. In actual application, the server can also splice according to other algorithms, which are not limited in the embodiment of the present application.
[0061] As shown in Figure 3 , the server performs sentence analysis on the text information after the paragraph analysis, to obtain candidate sentence pairs. The sentence analysis includes sentence division, word segmentation and part-of-speech tagging.
[0062] The sentence division refers to that the server divides each paragraph into one sentence. For example, for the text information divided into multiple paragraphs, the server can divide the sentences by using the division punctuation. For example, the full stop and the full stop are a sentence, the full stop and the comma are a short sentence, and the semicolon and the full stop are a sentence. In actual application, there can be other ways and algorithms for dividing the sentences, which are not limited in the embodiment of the present application.
[0063] The word segmentation and the part-of-speech tagging refer to that the server performs word segmentation and part-of-speech tagging through a word segmentation module. The word segmentation module can execute a word segmentation algorithm, that is, extract and divide multiple words from the text information. For example, the sentence "close the storage box" can be divided into "close" and "storage box". The word segmentation algorithm is not limited in the embodiment of the present application. The part-of-speech tagging refers to tagging the corresponding words with the corresponding intent roles. For example, the intent role of "storage box" is Object. For details, refer to the description of the intent role in the subsequent embodiments, which are not described herein.
[0064] 103. The server remotely supervises the candidate sentence pairs to obtain supervision data.
[0065] In the cold start stage, the server can receive the instructions of the administrator to realize the remote supervision of the candidate sentence pairs, or can design a special cold start algorithm to realize the remote supervision, which are not limited in the embodiment of the present application. The step 103 will be described by taking the server receiving the instructions of the administrator as an example, and other modes can be implemented by referring to the embodiment, which are not described herein.
[0066] As shown in Figure 3 , the server can remotely supervise the candidate sentence pairs by using a predefined template library. The server can divide the specific question intent according to the instructions of the administrator by matching the heuristic rules, and extract the intent roles to obtain the remote supervision data. As shown in Figure 3 , the predefined template library is used as the question and answer pair library to construct the supervision information in the cold start stage, including the question intent library, the intent role library and the heuristic rule library.
[0067] The question intent library defines question intent categories that the context can contain, such as describing location information of an object, describing usage information of an object, and the like, which cover different information and are mutually exclusive. Exemplarily, the question intent categories include a location category (describing object location), a usage category (describing object usage information), an explanation category (describing object meaning), an imperative category (containing specific imperatives and negative imperatives), and a purpose category (describing purpose and means information). In actual applications, the question intent categories can also include other cases, which are not limited by embodiments of the present application. In embodiments of the present application, the question intent categories are mainly used to represent categories corresponding to sentences, and therefore the question intent categories can also be referred to as sentence categories.
[0068] The intent role library contains all intent roles that are needed to describe information of different categories. Exemplarily, Object is used to refer to describing an object, Position is used to refer to location information, Usage is used to refer to usage information, Description is used to refer to description information, Action is used to refer to action information, Condition is used to refer to condition information, Result is used to refer to result information, and Purpose is used to refer to purpose information. In actual applications, the intent roles can also include other cases, which are not limited by embodiments of the present application. In embodiments of the present application, the intent roles are mainly used to represent characteristics corresponding to words, and therefore the intent roles can also be referred to as word characteristics.
[0069] The heuristic rule library assigns an intent role corresponding to each question intent, and defines a representation form thereof, which is used for remote supervision and question-answer pair generation. Exemplarily, one of the heuristic rules can be: containing intent roles: Object, Position; question template: question (Q): Where is the Object located? answer (A): Position. conversation (C): The Object is located at the Position. In actual applications, the server can also establish other heuristic rules, which are not limited by embodiments of the present application.
[0070] Based on the above pre-defined template library, the server can perform remote supervision on the candidate sentence pairs. First, the server can divide the candidate sentence pairs into specific question intent categories according to administrator instructions by matching the heuristic rules. Exemplarily, the sentence "Touchscreens are used to control many functions that on traditional cars are controlled by physical buttons (e.g., adjusting the rearview mirror)" can be divided into a usage category question intent category.
[0071] Also, the server determines, according to the administrator's instruction, that the intent role of "touch screen" in the sentence "Touch screen is used to control many functions that are controlled by physical buttons on traditional cars (e.g., adjusting the rearview mirror)" is Object, and the intent role of "used to control many functions" is Usage. Thus, the server can extract the intent roles in the sentence as Object: touch screen, and Usage: used to control many functions.
[0072] In some embodiments, the server can display the text information on a window, and the administrator selects a sentence in the window and right-clicks (or types) a question intent category, which is equivalent to inputting an instruction to the server, and the server can determine, according to the instruction, the question intent category corresponding to the sentence. The administrator can also select a word in the window and right-click (or type) an intent role, which is equivalent to inputting an instruction to the server, and the server can determine, according to the instruction, the intent role corresponding to the word.
[0073] In some embodiments, according to the heuristic rule, the server can match to one or more question templates according to the question intent of the usage category and the intent roles of Object and Usage, where one question template is: Q: What is Object used for? A: Usage, C: Object is used for Usage. Thus, the server can generate the question and answer pair data as: Q: What is the touch screen used for? A: used to control many functions, C: the touch screen is used to control many functions. For another example, the sentence "Before opening or closing the trunk lid, it is essential to check for obstacles (people and objects) around the trunk lid" can be divided into a condition category question intent, and the server can determine, according to the administrator's instruction, that the sentence contains the intent roles of Condition (before opening or closing the trunk lid) and Action (checking for obstacles around the trunk lid). Thus, the server can extract the intent roles in the sentence as Condition: before opening or closing the trunk lid, and Action: checking for obstacles around the trunk lid. According to the heuristic rule, the server can determine that the question and answer pair data is: Q: What is the condition for checking for obstacles around the trunk lid? A: before opening or closing the trunk lid, C: before opening or closing the trunk lid, the condition for checking for obstacles around the trunk lid.
[0074] In the process of supervision of the heuristic rules, the server can obtain remote supervision data, i.e., the question intent category corresponding to the sentence, the intent role corresponding to the word in the sentence, and the corresponding question-answer pair. Compared with the original text data, the remote supervision data already contains a large number of positive samples, and the preliminary role extraction is completed, which can be used to train the neural network model. In some embodiments, if the supervision data is used to train the neural network model, the supervision data can specifically only include the question intent category corresponding to the sentence and the intent role corresponding to the word, and the neural network model is trained by the text information, the question intent category corresponding to the sentence, and the intent role corresponding to the word. For details, refer to step 104.
[0075] 104. The server trains the neural network model by using the supervision data to obtain a trained neural network model.
[0076] In the embodiments of the present application, the input of the neural network model is the word in the candidate sentence pair and the identifier “[CLS]” used to predict the question intent category, and the output of the neural network model is the intent role corresponding to the word in the candidate sentence pair and the question intent category corresponding to the identifier “[CLS]”. In the training process, the server can use the supervision data as the training data, use the word in the candidate sentence pair in the training data as the input for training, use the intent role corresponding to the candidate sentence pair and the question intent category corresponding to the candidate sentence pair in the training data as the output for training, and optimize and adjust the parameters in the neural network model according to the training algorithm until the training reaches a good effect. In the application process, the server can obtain the candidate sentence pair after processing the text information through a process similar to step 102, then input the word in the candidate sentence pair and the identifier “[CLS]” used to predict the question intent category into the neural network model to obtain the corresponding intent role and question intent category, and then generate the question-answer pair through the question template in the template library according to the intent role and question intent category. Finally, according to the intent role and question intent category and the question-answer pair, the supervision is performed through the heuristic rules, the question-answer pair is extracted from the supervision data after obtaining the supervision data, and the question-answer library is constructed.
[0077] In actual application, the server can use various neural network models capable of realizing word labeling, such as recurrent neural networks (RNN), long short term memory (LSTM) model, bidirectional LSTM model, and gated recurrent uni (GRU), etc., which are not limited in the embodiments of the present application.
[0078] In order to clearly describe the technical solutions of the present application and provide a feasible implementation scheme, the present application provides a neural network model such as Figure 4As shown. Figure 4 This is a schematic diagram of the neural network model in an embodiment of this application. For example... Figure 4 As shown, the neural network model includes a BERT pre-trained model, a bidirectional long short-term memory network (BiLSTM model), and a conditional random field (CRF) layer.
[0079] The BERT pre-trained model, also known as the BERT sequence labeling model, can be built upon the bidirectional encoder representation from transformers (BERT) model by adding a softmax fully connected layer. For example... Figure 4 As shown, the server uses the words in the candidate sentence pairs as input to the BERT pre-trained model, i.e., Token1, Token2, ..., TokenN. Furthermore, the server sets an additional identifier "[CLS]" as input to the BERT pre-trained model to predict the question intent. Figure 4 As shown, the server obtains the output of the fully connected layer through the BERT pre-trained model as: C, T1, T2…T N Here, the identifier C is used to represent the question intent category. For example, if the value of identifier C is 1, it indicates that the question intent category of the candidate sentence pair is location-based; if the value of identifier C is 2, it indicates that the question intent category of the candidate sentence pair is usage-based. In practical applications, the correspondence between identifier C and question intent category can be specifically set according to the training situation and the BERT pre-trained model. This application embodiment does not limit this. T1, T2…T N These are word vector sequences, containing semantic information corresponding to the words in the text. In this embodiment, the BERT pre-trained model is used as a skeleton to encode the text to obtain sufficient semantic information.
[0080] BiLSTM models generally consist of a forward LSTM network and a backward LSTM network. They capture past (through the forward network) and future (through the backward network) feature information and concatenate them to obtain context encoding information. This context information is further fed into a Conditional Random Field (CRF). A CRF layer is a Markov chain that considers only linear one-sided relationships, effectively capturing the transition probabilities between different labels. Figure 4As shown, the server receives the following CRF layer output (labels): o, object-B, object-I…o. It is evident that the first label, o, represents any other label and has no meaning. The second label, object-B, indicates that the intent role of the first word in the candidate sentence pair is "object," and the third label, object-I, indicates that the intent role of the second word in the candidate sentence pair is "object."
[0081] Similarly, the server can obtain the question intent category corresponding to the candidate sentence pair and the intent role corresponding to each word, i.e., the prediction result, based on the BERT pre-trained model, BiLSTM model, and CRF layer mentioned above. For example, if the server inputs "To close the storage box, please press the lid down slowly" into the neural network model, it can obtain the output "Question intent category is purpose class" and "Purpose: To close the storage box, Action: Press the lid down slowly".
[0082] In training, such as Figure 4 When using the neural network model shown, the server can use the supervision data obtained in step 103 as training data. Based on the sentence words, the question intent category corresponding to the sentence, the intent role corresponding to the sentence words, and the identifier [CLS] in the supervision data, the server trains the neural network model using a neural network training algorithm to optimize the parameters in the neural network model, enabling the neural network model to initially identify the question intent category corresponding to the sentence and the intent role corresponding to the sentence words. The neural network training algorithm can employ backpropagation, etc., and this embodiment does not limit the specific algorithm used.
[0083] 105. The server obtains new text information and uses the trained neural network model to obtain the prediction result corresponding to the new text information.
[0084] In this embodiment, the server can segment the new text information to obtain segmented text information. The specific process is similar to steps 101 and 102 described above, and will not be repeated here.
[0085] The server processes the segmented text information using a trained neural network model to obtain the prediction result corresponding to that text information. In this embodiment, as... Figure 4 As shown, after processing by the trained neural network model, the server can obtain the question intent category corresponding to the sentence, the intent role corresponding to the words in the sentence, and thus the prediction result. The processing procedure of the neural network model is similar to the description corresponding to step 104 above, and will not be repeated here.
[0086] For example, the text information obtained by the server after word segmentation is the sentence "If you want to close the storage box, press the cover plate slowly downward". The server processes the sentence through the trained neural network model, and obtains that the problem intent category corresponding to the sentence is the purpose class, and the intent role corresponding to the word "If you want to close the storage box" is Purpose, and the intent role corresponding to the word "press the cover plate slowly downward" is Action.
[0087] 106. The server performs heuristic rule supervision on the prediction result to obtain supervised data.
[0088] In the embodiments of the present application, after the server obtains the problem intent category of each sentence and the intent role of each word corresponding to the new text information, the server can find the corresponding question template from the template library, generate the corresponding question and answer pair, and obtain the supervised data. It can be understood that the supervised data generally includes the problem intent category of each sentence, the intent role of each word, and the question and answer pair.
[0089] In some embodiments, the server determines one or more question templates corresponding to the problem intent category of the sentence and the intent role of the word through heuristic rules, thereby generating a question and answer pair. For example, the problem intent category of the sentence "Do not adjust the seat during driving" is the condition class, the word "during driving" is Condition, the word "do not" is Not (used to represent negative information), and the word "adjust the seat" is Action. The server matches three templates through heuristic rules according to the above conditions, which are "Question: Condition, can Action? Answer: No." "Question: Under what conditions, can not Action? Answer: Condition." "Question: Condition, what is the suggestion? Answer: Do not Action." Then three question and answer pairs can be generated respectively: "Question: Can you adjust the seat during driving? Answer: No." "Question: Under what conditions, can not adjust the seat? Answer: During driving." "Question: What is the suggestion during driving? Answer: Do not adjust the seat."
[0090] In some embodiments, the supervised data still has unlabeled intent roles, or has incorrectly labeled intent roles, or has incorrectly labeled question intent categories, or has obviously incorrect question-answer pairs. At this time, human intervention (Human in the loop) can be used to manually correct or complete the above situations. After manual annotation, the server can obtain high-quality supervised data. In the embodiments of the present application, each time the server performs step 106, the server can train the neural network model according to the manually corrected supervised data, continuously improve the robustness of the model, and enable the model to generate more accurate prediction results.
[0091] 107. Extract question-answer pairs from the supervised data to construct a question-answer library.
[0092] In the embodiments of the present application, as can be known from the description of step 106, the supervised data contains a large number of question-answer pairs. The server can extract these question-answer pairs to construct a question-answer library.
[0093] In the above process, steps 101 to 104 are the cold start phase, and steps 105 to 107 are the hot operation phase.
[0094] In the cold start phase, before the method is implemented, the neural network model has not been trained and cannot directly predict text information. Therefore, the server first obtains text information for training, and performs word segmentation on the text information. Then, the server can determine the question intent category of each sentence in the text information and the intent role corresponding to the words in the sentence according to the administrator's instructions, to obtain supervised data. Then the server trains the neural network model according to the sentence words, the identifier [CLS], the question intent category of each sentence, and the intent role corresponding to the words in the sentence in the supervised data, to obtain a trained neural network model.
[0095] Figure 5 The above is a schematic diagram of the hot operation phase in the embodiments of the present application. In the hot operation phase, the server can obtain new text information (i.e. text information that needs to generate a question-answer library, Figure 5The server can perform word segmentation on the text information (e.g., in a txt document). Then, the server can obtain, according to the segmented text information, the question intent category corresponding to the sentence in the text information and the intent role corresponding to the word in the sentence by using the trained neural network model. Then, the server can find one or more question templates corresponding to the question intent category corresponding to the sentence and the intent role corresponding to the word in the sentence according to the heuristic rules in the template library and the question intent category corresponding to the sentence and the intent role corresponding to the word in the sentence, and generate question and answer pairs. These question and answer pairs can constitute a question and answer library. For example, after the server obtains the text information "To close an application, click the X in the middle of the top window", the server can generate the question and answer pair "Question: What can be done to close an application? Answer: Click the x in the middle of the top window." in the hot operation stage. In another example, after the server obtains the text information "Before adjusting the front seat, make sure that there are no obstacles (people and objects) around the seat", the server finally generates the question and answer pair "Question: What can be done or suggested before adjusting the front seat? Answer: Make sure that there are no obstacles (people and objects) around the seat."
[0096] In some embodiments, the server can also correct the question intent category, the intent role, and the question and answer pair according to the instructions of the administrator to improve the quality of the question and answer library. In some embodiments, the question intent category and the intent role corrected by the human being can be further used to train the neural network model, so as to improve the robustness of the neural network model and improve the prediction accuracy of the neural network model.
[0097] It can be understood that the hot operation stage can be repeated, that is, steps 105 to 107 are repeatedly executed in a loop, and the question and answer library is continuously constructed according to the text information. In some embodiments, the neural network model is continuously trained according to the question intent category and the intent role corrected by the human being, so as to improve the robustness of the neural network model and improve the prediction accuracy of the neural network model.
[0098] The question and answer library construction method provided by the embodiments of the present application can identify different intent roles in the context through the intent role flag, and realize more rich type definition than relationship extraction. The embodiments of the present application also avoid the uncertainty caused by the generation model through the pre-defined template library and the heuristic rules.
[0099] The application also provides an application example of establishing a common question library according to a user manual document. The process includes: first, according to the user manual document, analyzing the possible problem intentions, designing the corresponding intention roles, and constructing the problem intention library and the intention role library. Based on the problem intention library and the intention role library, the corresponding question and answer pair templates are designed for each type of problem intention, the intention roles are classified, and the heuristic rule library is formed. The problem intention library, the intention role library and the heuristic rule library constitute the template library.
[0100] Then, the server receives and stores the template library, and obtains training data by training the input user manual through heuristic rule supervision and a small amount of manual supervision, and inputs the training data into the model to obtain a problem intention classification and intention role labeling model (i.e. the neural network model trained in the above embodiment).
[0101] Then, the server can structure the new document by using the trained model, extract the corresponding intention roles to form structured data, and obtain the problem intention category corresponding to each sentence and the intention role corresponding to the word. Exemplary:
[0102] The input context is: The touchscreen is used to control many functions that are controlled by physical buttons on traditional cars (for example, adjusting the rearview mirror). The intention role extraction obtains the structured data as: Object: touchscreen; Usage: used to control many functions.
[0103] The input context is: Before opening or closing the trunk lid, it is essential to check the trunk lid area for obstacles (people and objects). The intention role extraction obtains the structured data as: Condition: before opening or closing the trunk lid; Action: check the trunk lid area for obstacles.
[0104] The input context is: To close the storage box, press the cover plate slowly downward. The intention role extraction obtains the structured data as: Purpose: to close the storage box; Action: press the cover plate slowly downward.
[0105] Finally, the server finds the corresponding question and answer templates according to the problem intention category corresponding to each sentence and the intention role corresponding to the word by heuristic rule supervision and manual supervision, fills in the corresponding positions, and can also revise errors by manual revision to obtain question and answer pairs and construct a question and answer library (FAQ library). Exemplary:
[0106] The input context is: To close an application, click the X in the middle of the top of the window. The question and answer pair obtained is: Question: What can be done to close an application; Answer: Please click the x in the middle of the top of the window.
[0107] The input context is: During driving, do not adjust the seat. The obtained question and answer pair is: 1, Question: Can the seat be adjusted during driving? Answer: No. 2, Question: Under what conditions can the seat not be adjusted? Answer: During driving. 3, Question: What is the suggestion during driving? Answer: Do not adjust the seat.
[0108] The input context is: Before adjusting the front row seat, please ensure that there are no obstacles (persons and objects) around the seat. The obtained question and answer pair is: Question: Before adjusting the front row seat, what can be done or what is the suggestion? Answer: Please ensure that there are no obstacles (persons and objects) around the seat.
[0109] The question and answer library construction method provided in the embodiments of the present application generates a corresponding FAQ library by using pre-defined heuristic rules on the basis of question intention classification and intention role labeling, effectively avoiding the problem that the generated format cannot be controlled by using a generation model. At the same time, the method guarantees the accuracy of the knowledge in the knowledge base during the cold start stage of the knowledge base construction, and avoids semantic drift caused in the process of knowledge base construction. By using the method, the FAQ generation can be controlled by only expanding the heuristic rule library, and the problem of retraining of the generation model is avoided.
[0110] The question and answer library construction method provided in the embodiments of the present application is based on an information extraction scheme of intention labeling, effectively alleviating the problem of insufficient representation ability of traditional relation extraction in complex multi-relation extraction. In the embodiments of the present application, the pre-defined template library greatly alleviates various data pressures faced by the question and answer pair library during the cold start stage, and the idea of remote supervision can be used to partially structure the text. The idea of human-in-the-loop further controls the quality of the knowledge base during the operation stage of the question and answer pair library, and avoids the semantic drift problem possibly caused by the model.
[0111] The embodiments of the present application use intention labeling to realize the process of constructing a question and answer pair knowledge base from text. The process realizes the effective combination of the cold start and hot operation of the knowledge base construction by combining a small pre-defined template library and introducing the idea of human-in-the-loop.
[0112] Figure 6 A schematic diagram of a question and answer library construction system provided in the embodiments of the present application is shown in FIG. 1. Figure 6 As shown in FIG. 1, the question and answer library construction system includes:
[0113] The acquisition module 601 is configured to acquire text information.
[0114] The processing module 602 is configured to obtain, according to the text information, a sentence category corresponding to a sentence in the text information and a word feature corresponding to a word in the text information by using the trained neural network model, wherein the sentence category is used to represent a category to which the sentence in the text information belongs, and the word feature is used to represent a feature of the word in the text information.
[0115] The processing module 602 is further configured to determine a question template matched with the sentence category and the word feature by using a predefined template library, fill the word into a position corresponding to the question template, and obtain a question and answer pair to construct a question and answer library, wherein the question and answer library includes the question and answer pair, and the template library includes a matching relationship between the sentence category, the word feature and the question template.
[0116] Specifically, in some embodiments, the obtaining module 601 is configured to perform the above Figure 1 The processing module 602 is configured to perform the above Figure 1 The processing module 602 is configured to perform the above
[0117] In some embodiments, the question and answer library construction system further includes a word segmentation module configured to segment a sentence and perform word segmentation on the text information to obtain text information composed of segmented sentences.
[0118] In some embodiments, the obtaining module includes an obtaining unit configured to obtain one or more of a portable document format document, a presentation document and a Word document; and a format conversion unit configured to extract the text information in the portable document format document, the presentation document or the Word document to obtain the text information in a pure text format. Figure 7 Another schematic diagram of the question and answer library construction system in the embodiments of the present application is shown in FIG. 6B. Figure 7 As shown in FIG. 6B, in some embodiments, the question and answer library construction system further includes a training module 603 configured to obtain training text information; the training module 603 is further configured to determine a training sentence category corresponding to a sentence in the training text information and a training word feature corresponding to a word in the training text information by using a predefined template library; and the training module 603 is further configured to train the neural network model according to the training text information, the training sentence category and the training word feature to obtain the trained neural network model.
[0119] Specifically, in some embodiments, the training module 603 is configured to perform the above Figure 1 The training module 603 is configured to perform the above
[0120] In some embodiments, the question and answer library construction system further comprises a cycle training module configured to modify sentence categories corresponding to sentences and word features corresponding to words in the text information according to administrator instructions; and the cycle training module is further configured to retrain the trained neural network model according to the text information, the modified sentence categories, and the modified word features.
[0121] In some embodiments, the neural network model comprises a bidirectional encoder representation transformer (BERT), a full connection layer, a bidirectional long short-term memory network (BiLSTM), and a conditional random field (CRF); the processing module 602 is further configured to receive the text information and a first identifier for predicting sentence categories corresponding to sentences in the text information via the BERT; the processing module 602 is further configured to obtain a word vector sequence corresponding to the text information and a second identifier corresponding to the first identifier via the full connection layer; the processing module 602 is further configured to determine the sentence categories corresponding to the sentences in the text information according to the second identifier; the processing module 602 is further configured to obtain labels corresponding to the word vector sequence via the BiLSTM and the CRF; and the processing module 602 is further configured to determine word features corresponding to words in the text information according to the labels.
[0122] In some embodiments, the question intent category comprises one or more of a location category, a usage category, an explanation category, an imperative category, and a purpose category.
[0123] In some embodiments, the intent role comprises one or more of an object description, location information, usage information, description information, action information, reference condition information, result information, and purpose information.
[0124] The embodiments of the present application also provide a computer readable storage medium, which stores instructions, when the instructions are executed on a computer, causing the computer to perform the method of the corresponding embodiments. Figure 1 The method of the corresponding embodiments.
[0125] Figure 8A server structure diagram is provided in the embodiments of the present application. The server 800 can have great differences due to different configurations or performances, and can include one or more central processing units (CPUs) 822 (for example, one or more processors) and a memory 832, one or more storage media 830 (for example, one or more mass storage devices) storing application programs 842 or data 844. The memory 832 and the storage media 830 can be temporary storage or persistent storage. The programs stored in the storage media 830 can include one or more modules (not shown in the figure), and each module can include a series of instruction operations in the server. Further, the central processing unit 822 can be configured to communicate with the storage media 830 and execute the series of instruction operations in the storage media 830 on the server 800.
[0126] The server 800 can further include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, and / or one or more operating systems 841, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM , and the like.
[0127] The steps performed by the server in the above embodiments can be based on the server structure shown in the above Figure 8 . Specifically, the CPU 822 can perform all the steps in the above Figure 1 corresponding embodiments. In some embodiments, the modules in the CPU 822 can include the obtaining module 601, the processing module 602, and the like in the above Figure 6 corresponding embodiments, and the training module 603, the loop training module, and the like in the above Figure 7 corresponding embodiments, which will not be described herein again.
[0128] In the embodiments of the present application, the CPU 822 is specifically configured to: obtain text information; obtain, according to the text information, a sentence category corresponding to a sentence in the text information and a word feature corresponding to a word in the text information by using a trained neural network model, the sentence category being used to represent a category to which the sentence in the text information belongs, and the word feature being used to represent a feature of the word in the text information; determine a question template matched with the sentence category and the word feature by using a predefined template library, fill the word into a position corresponding to the question template, and obtain a question and answer pair to construct a question and answer library, the question and answer library containing the question and answer pair, and the template library including a matching relationship between the sentence category, the word feature and the question template.
[0129] In some embodiments, the CPU 822 is further configured to: divide the text information into sentences and words to obtain text information composed of the divided sentences.
[0130] In some embodiments, the CPU 822 is further configured to: obtain one or more of a portable document format document, a presentation document and a Word document; and extract the text information in the portable document format document, the presentation document or the Word document to obtain the text information in a pure text format.
[0131] In some embodiments, the CPU 822 is further configured to: obtain training text information; determine a training sentence category corresponding to a sentence in the training text information and a training word feature corresponding to a word in the training text information by using a predefined template library; and train the neural network model according to the training text information, the training sentence category and the training word feature to obtain the trained neural network model.
[0132] In some embodiments, the CPU 822 is further configured to: modify the sentence category corresponding to a sentence in the text information and the word feature corresponding to a word in the text information according to an administrator instruction; and retrain the trained neural network model according to the text information, the modified sentence category and the modified word feature.
[0133] In some embodiments, the CPU 822 is further configured to: receive the text information and a first identifier by using the BERT, the first identifier being used to predict a sentence category corresponding to a sentence in the text information; obtain a word vector sequence corresponding to the text information and a second identifier corresponding to the first identifier by using the full connection layer; determine the sentence category corresponding to the sentence in the text information according to the second identifier; obtain a label corresponding to the word vector sequence by using the BiLSTM and the CRF; and determine the word feature corresponding to the word in the text information according to the label.
[0134] In some embodiments, the question intent category includes one or more of a location category, a usage category, an explanation category, an imperative category, and a purpose category.
[0135] In some embodiments, the intent role includes one or more of a describing object, location information, usage information, describing information, action information, referring condition information, result information, and purpose information.
[0136] Embodiments of the present application also provide a computer program product containing instructions, which, when executed on a computer, cause the computer to perform the method of any of the above Figure 1 Embodiments of the corresponding method.
[0137] Embodiments of the present application also provide a question and answer library construction device, comprising one or more central processing units and a memory;
[0138] The memory is configured to store a program;
[0139] The processor is configured to execute the program in the memory, so that the question and answer library construction device performs the method of any of the above Figure 1 Embodiments of the corresponding method. Specifically, the processor can perform all the steps in Figure 1
[0140] In actual application, the question and answer library construction device can further comprise other modules, such as a power module, etc., and embodiments of the present application do not limit this.
[0141] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0142] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented by other ways. For example, the above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0143] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiments of the present application.
[0144] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0145] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in part, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk, and various media that can store program codes.
Claims
1. A method for constructing a question-and-answer database, characterized in that, include: Retrieve text information; Based on the text information, the sentence category corresponding to the sentence in the text information and the word characteristics corresponding to the words in the text information are obtained through the trained neural network model. The sentence category is used to indicate the category to which the sentence in the text information belongs, and the word characteristics are used to indicate the characteristics of the words in the text information. At least one question template matching the sentence category and word characteristics is determined by a predefined template library. The words are filled into the corresponding positions of the question templates to obtain question-answer pairs and then a question-answer library is constructed. The question-answer library contains the question-answer pairs. The template library includes the matching relationship between the sentence category, word characteristics and question templates. The question template includes a question part and an answer part. After obtaining the sentence category corresponding to the sentence in the text information and the word characteristics corresponding to the words in the text information through a trained neural network model based on the text information, the method further includes: Modify the sentence category and word characteristics of the sentences and words in the text information according to the administrator's instructions; The trained neural network model is retrained based on the text information, the modified sentence category, and the modified word characteristics.
2. The method according to claim 1, characterized in that, After acquiring the text information, and before obtaining the sentence category corresponding to the sentence in the text information and the word characteristics corresponding to the words in the text information through a trained neural network model based on the text information, the method further includes: The text information is segmented into sentences and words to obtain text information composed of sentences after word segmentation.
3. The method according to claim 1 or 2, characterized in that, The acquisition of text information includes: Get one or more of the following: Portable Document Format (PDO) documents, presentation documents, and Word documents; The text information is extracted from the portable document format document, presentation document, or Word document to obtain the text information in plain text format.
4. The method according to any one of claims 1 to 2, characterized in that, Before obtaining the sentence category corresponding to the sentence in the text information and the word characteristics corresponding to the words in the text information through the trained neural network model based on the text information, the method further includes: Obtain training text information; The training sentence category corresponding to the sentence in the training text information and the training word characteristics corresponding to the word in the training text information are determined by a predefined template library. The neural network model is trained based on the training text information, the training sentence category, and the characteristics of the training words to obtain the trained neural network model.
5. The method according to any one of claims 1 to 2, characterized in that, The neural network model includes a bidirectional encoder-transformer (BERT), a fully connected layer, a bidirectional long short-term memory network (BiLSTM), and a conditional random field (CRF). The step of obtaining the sentence category corresponding to a sentence in the text and the word characteristics corresponding to a word in the text through the trained neural network model based on the text information includes: The BERT receives the text information and a first identifier, the first identifier being used to predict the sentence category corresponding to the sentence in the text information. The word vector sequence corresponding to the text information and the second identifier corresponding to the first identifier are obtained through the fully connected layer. The sentence category corresponding to the sentence in the text information is determined based on the second identifier; The labels corresponding to the word vector sequence are obtained through the BiLSTM and the CRF; The word characteristics corresponding to the words in the text information are determined based on the labels.
6. The method according to any one of claims 1 to 2, characterized in that, The sentence categories include one or more of the following: position, usage, explanation, imperative, and purpose.
7. The method according to any one of claims 1 to 2, characterized in that, The word characteristics include one or more of the following: object of description, location information, usage information, descriptive information, action information, referential condition information, result information, and purpose information.
8. A question-and-answer database construction system, characterized in that, include: The acquisition module is used to acquire text information; The processing module is used to obtain the sentence category corresponding to the sentence in the text information and the word characteristics corresponding to the words in the text information through a trained neural network model based on the text information. The sentence category is used to indicate the category to which the sentence in the text information belongs, and the word characteristics are used to indicate the characteristics of the words in the text information. The processing module is further configured to determine at least one question template that matches the sentence category and the word characteristics through a predefined template library, fill the word into the position corresponding to the question template, and construct a question-answer library after obtaining a question-answer pair. The question-answer library contains the question-answer pair. The template library includes the matching relationship between the sentence category, the word characteristics and the question template. The question template includes a question part and an answer part. The loop training module is used to modify the sentence category and word characteristics of sentences and words in the text information according to administrator instructions. The loop training module is also used to retrain the trained neural network model based on the text information, the modified sentence category, and the modified word characteristics.
9. The system according to claim 8, characterized in that, Also includes: The word segmentation module is used to segment the text information into sentences and words to obtain text information composed of segmented sentences.
10. The system according to claim 8 or 9, characterized in that, The acquisition module includes: The acquisition unit is used to acquire one or more of portable document format documents, presentation documents, and Word documents; The format conversion unit is used to extract the text information from the portable document format document, presentation document, or Word document to obtain the text information in plain text format.
11. The system according to any one of claims 8 to 9, characterized in that, Also includes: The training module is used to acquire training text information; The training module is also used to determine the training sentence category corresponding to the sentence in the training text information and the training word characteristics corresponding to the word in the training text information through a predefined template library; The training module is also used to train the neural network model based on the training text information, the training sentence category, and the characteristics of the training words, to obtain the trained neural network model.
12. The system according to any one of claims 8 to 9, characterized in that, The neural network model includes a bidirectional encoded representation transformer BERT, a fully connected layer, a bidirectional long short-term memory network BiLSTM, and a conditional random field CRF; The processing module is further configured to receive the text information and a first identifier through the BERT, wherein the first identifier is used to predict the sentence category corresponding to the sentence in the text information; The processing module is further configured to obtain the word vector sequence corresponding to the text information and the second identifier corresponding to the first identifier through the fully connected layer; The processing module is further configured to determine the sentence category corresponding to the sentence in the text information based on the second identifier; The processing module is also used to obtain the labels corresponding to the word vector sequence through the BiLSTM and the CRF; The processing module is further configured to determine the word characteristics corresponding to the words in the text information based on the tags.
13. The system according to any one of claims 8 to 9, characterized in that, The sentence categories include one or more of the following: position, usage, explanation, imperative, and purpose.
14. The system according to any one of claims 8 to 9, characterized in that, The word characteristics include one or more of the following: object of description, location information, usage information, descriptive information, action information, referential condition information, result information, and purpose information.
15. A computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 7.
16. A computer program product comprising instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 7.
17. A server, characterized in that, Includes one or more central processing units, memory, input / output interfaces, wired or wireless network interfaces, and power supply; The memory is either a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory on the server to perform the method according to any one of claims 1 to 7.
18. A question-and-answer database construction apparatus, characterized in that, Includes one or more central processing units and memory; The memory is used to store programs; The processor is used to execute the program in the memory, causing the question-and-answer database construction apparatus to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Intelligent question-answering system generated based on questions
CN110321420A
Patent retrieval method and device based on multiple rounds of conversations
CN110442676A