Named entity based text question answering method, device and readable storage medium
By combining named entity recognition and encoding with a deep learning question-answering model, the problems of high computational cost and poor timeliness in question-answering systems are solved, and efficient question-answering responses are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2020-05-20
- Publication Date
- 2026-04-21
AI Technical Summary
Existing question-answering systems are not very timely when computationally intensive, especially when multiple users are using them simultaneously.
We adopt a named entity-based text question answering method, which reduces the amount of data by identifying and segmenting named entities, and encodes the question and answer corpus and inputs it into a pre-trained deep learning question answering model, which is trained and predicted using a long short-term memory network.
It improves the computational efficiency and response speed of the question-and-answer system, ensuring timely responses in multi-user scenarios.
Smart Images

Figure CN111695354B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device, and readable storage medium for text question answering based on named entities. Background Technology
[0002] With the popularization and development of big data and artificial intelligence technologies in various industries in recent years, intelligent scenarios are emerging in various industries, among which question-answering systems are the main representatives of intelligent scenarios.
[0003] Currently, question-answering systems mainly fall into two categories: 1. Those based on word vector transformation, which first convert user input text into word vectors, calculate the spatial distance between the word vectors and those in a vocabulary, and select the vocabulary text with the smallest spatial distance to complete the question-answering process; 2. Those based on deep learning models. The first type, based on word vector transformation, often provides irrelevant answers due to its simplicity, failing to meet the requirements of the current scenario. While the second type, based on deep learning models, can meet the requirements of the current scenario, the high computational demands of deep learning models mean that when multiple users use the system simultaneously, the high computational load often leads to delayed responses and poor timeliness. Summary of the Invention
[0004] This invention provides a text question-answering method, apparatus, electronic device, and computer-readable storage medium based on named entities, with the main purpose of solving the problems of high computational load and poor answering effect in the text answering process.
[0005] To achieve the above objectives, the present invention provides a text question-answering method based on named entities, comprising:
[0006] Receive user-inputted consultation text, and perform named entity recognition on the consultation text to obtain an entity text set;
[0007] Obtain a question-and-answer corpus, and perform named entity recognition and named entity segmentation on the question-and-answer corpus to obtain multiple question-and-answer corpus subsets;
[0008] Extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form an answer text set, and perform segmentation and encoding operations on the answer text set to obtain a question-and-answer encoding set;
[0009] The question-and-answer encoding set is input into a pre-trained deep learning question-and-answer model to obtain the answer text to the inquiry text.
[0010] Optionally, the answer text set is segmented and encoded to obtain a question-and-answer encoding set, including:
[0011] Based on the pre-built segmentation dictionary, the answer text set is segmented to obtain a question-answer word set;
[0012] The encoding operation is performed on the question-answer term set to obtain the question-answer encoding set.
[0013] Optionally, based on a pre-built segmentation dictionary, the answer text set is segmented to obtain a question-and-answer word set, including:
[0014] Step 1: Extract each answer text from the answer text set;
[0015] Step II: Segment the response text according to the preset segmentation rules to obtain response segmentation words;
[0016] Step III: Determine whether the answer segmentation word appears in the segmentation dictionary. If the answer segmentation word does not appear in the segmentation dictionary, return to Step II.
[0017] Step IV: If the answer segmentation word appears in the segmentation dictionary, continue to segment the answer text until the answer text set is extracted to obtain the question and answer word set.
[0018] Optionally, the method further includes training the deep learning question-answering model, wherein the training includes:
[0019] Step A: According to the pre-set network combination weight function, combine multiple groups of long short-term memory networks to obtain the deep learning question answering model to be trained, and obtain the question answering training set and question answering label set, and input the question answering training set into the deep learning question answering model to be trained;
[0020] Step B: Calculate the association weights between each group of long short-term memory networks to obtain the association weight set;
[0021] Step C: Perform weighted summation and activation processing on the associated weight set to obtain the question-answer prediction set;
[0022] Step D: Calculate the error value between the question-answer prediction set and the question-answer tag set. If the error value is greater than the preset error threshold, recalculate the association weights between each group of long short-term memory networks according to the pre-constructed optimization function to obtain the association weight set, and return to step C.
[0023] Step E: If the error value is less than or equal to the error threshold, the trained deep learning question answering model is obtained.
[0024] Optionally, the step of performing named entity recognition and named entity segmentation on the question-and-answer corpus to obtain multiple question-and-answer corpus subsets includes:
[0025] Named entity recognition is performed on the question-and-answer corpus to obtain the question-and-answer entity set;
[0026] Based on the question-and-answer entities included in the question-and-answer entity set, the question-and-answer corpus is divided into multiple question-and-answer corpus subsets.
[0027] To address the aforementioned problems, the present invention also provides a text-based question-answering device based on named entities, the device comprising:
[0028] The entity text calculation module is used to receive the consultation text input by the user, perform named entity recognition on the consultation text, and obtain an entity text set;
[0029] The question-and-answer corpus calculation module is used to acquire a question-and-answer corpus set and perform named entity recognition and named entity segmentation on the question-and-answer corpus set to obtain multiple question-and-answer corpus subsets;
[0030] The encoding module is used to extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets, form an answer text set, and perform segmentation and encoding operations on the answer text set to obtain a question-and-answer encoding set.
[0031] The answer text calculation module is used to input the question-answer encoding set into a pre-trained deep learning question-answering model to obtain the answer text of the inquiry text.
[0032] According to the pre-set network combination weight function, multiple groups of long short-term memory networks are combined to obtain a deep learning question answering model to be trained, and a question answering training set and a question answering label set are obtained. The question answering training set is then input into the deep learning question answering model to be trained.
[0033] Calculate the association weights between each group of long short-term memory networks to obtain the association weight set;
[0034] The question-answer prediction set is obtained by weighted summation and activation processing of the associated weight set;
[0035] Calculate the error value between the question-answer prediction set and the question-answer tag set;
[0036] When the error value is less than or equal to a preset error threshold, a trained deep learning question-answering model is obtained.
[0037] Optionally, the encoding module device is specifically used for:
[0038] Extract each answer text from the answer text set;
[0039] The answer text is segmented according to preset segmentation rules to obtain answer segmentation words;
[0040] When the answer segmentation word appears in the pre-built segmentation dictionary, the answer text is segmented until the answer text set is extracted to obtain the question-and-answer word set.
[0041] To address the above problems, the present invention also provides an electronic device, the electronic device comprising:
[0042] Memory, storing at least one instruction; and
[0043] The processor executes the instructions stored in the memory to implement the named entity-based text question-answering method described above.
[0044] To address the aforementioned problems, the present invention also provides a computer-readable storage medium storing at least one instruction, which is executed by a processor in an electronic device to implement the aforementioned named entity-based text question-answering method.
[0045] In this embodiment of the invention, the received consultation text is first subjected to named entity recognition to obtain an entity text set. The named entity recognition operation can transform the consultation text into an entity text set including names of people, places, organizations, proper nouns, etc., thus reducing the data volume for the first time. At the same time, the obtained question-and-answer corpus is subjected to named entity recognition operation to reduce the data volume for the second time. In addition, the answer text set obtained after named entity recognition is encoded and input into a deep learning question-and-answer model. Since the deep learning question-and-answer model calculates more accurate answer texts than traditional word vector transformation methods, this invention solves the problems of high computational load and poor timeliness in the text answering process. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating a text question-answering method based on named entities provided in an embodiment of the present invention.
[0047] Figure 2 This is a detailed flowchart of step S3 in a named entity-based text question answering method provided in an embodiment of the present invention.
[0048] Figure 3 This is a schematic diagram of a named entity-based text question-answering device according to an embodiment of the present invention;
[0049] Figure 4 This is a schematic diagram of the internal structure of an electronic device that implements a named entity-based text question answering method according to an embodiment of the present invention.
[0050] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0051] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0052] This invention provides a text-based question-answering method based on named entities. (See also...) Figure 1 The diagram shown is a flowchart illustrating a named entity-based text question-answering method according to an embodiment of the present invention. This method can be executed by a device, which can be implemented in software and / or hardware.
[0053] In this embodiment, the named entity-based text question-answering method includes:
[0054] S1. Receive the consultation text input by the user, perform named entity recognition on the consultation text, and obtain an entity text set.
[0055] Named Entity Recognition (NER), also known as proper name recognition, refers to the identification of entities with specific meanings in text, mainly including personal names, place names, organization names, and proper nouns. In this embodiment of the invention, the publicly available Stanford Named Entity Recognizer (SNER) can be used to perform named entity recognition on the consultation text data. The Stanford Recognition Model is a named entity recognition program implemented in the Java programming language.
[0056] For example, if the user inputs a consultation text A as: "I have had diabetes for many years and recently went to a hospital in location A, but the treatment was not very effective. So I would like to know if there are better treatment options for diabetes in hospitals in location B", then using the Stanford recognition model mentioned above, named entity recognition is performed on the consultation text A to obtain a set of entity texts such as "diabetes", "location A", "hospital", and "location B".
[0057] S2. Obtain the question-and-answer corpus set, and perform named entity recognition and named entity segmentation on the question-and-answer corpus set to obtain multiple question-and-answer corpus subsets.
[0058] The embodiments of the present invention can obtain the question-and-answer corpus in various ways, such as using web crawlers to crawl relevant text data from the Internet and organizing it to obtain the question-and-answer corpus, or using currently available and downloadable public corpus sets, such as the National Language Commission's Modern Chinese Corpus and the Modern Chinese Marked Corpus.
[0059] Since the question-and-answer corpus is generally large in size, if the question-and-answer corpus is used directly for text question-and-answer, it is necessary to traverse and search for the answer text corresponding to the user's input inquiry text. Therefore, it will consume a lot of computing resources and it is difficult to achieve the expected requirements. Therefore, the embodiments of the present invention perform named entity recognition and named entity segmentation processing on the obtained question-and-answer corpus.
[0060] Further, S2 includes: performing named entity recognition on the question-and-answer corpus to obtain a question-and-answer entity set; and dividing the question-and-answer corpus into multiple question-and-answer corpus subsets based on the question-and-answer entities included in the question-and-answer entity set.
[0061] In detail, the named entity recognition model in this step can be the Stanford recognition model described in S1, or other recognition models can be used to recognize the question-and-answer corpus.
[0062] Since the question-and-answer corpus contains multiple sets of data, and the question-and-answer entities included in each set are not entirely the same, for example, if corpus A_1 is: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", then the question-and-answer entities included in corpus A_1 are "diabetes", "location A", and "First People's Hospital of Location A". Similarly, corpus A_2 includes the question-and-answer entities "pneumonia" and "location C", and corpus A_3 includes the question-and-answer entities "location B" and "diabetes", etc. Therefore, it is necessary to perform named entity partitioning based on the question-and-answer entities included in each set of data, so as to obtain multiple question-and-answer corpus subsets with the same question-and-answer entities. For example, the question-and-answer corpus subsets for "diabetes" are corpus A_1 and corpus A_3, and the question-and-answer corpus subset for "pneumonia" is A_2, etc.
[0063] S3. Extract question-and-answer corpus subsets related to the consultation text from the multiple question-and-answer corpus subsets to form an answer text set, and perform segmentation and encoding operations on the answer text set to obtain a question-and-answer encoding set.
[0064] After processing in step S2, the question-and-answer corpus of this invention has been divided into multiple question-and-answer corpus subsets according to different named entities. However, since many question-and-answer corpus subsets do not match the user's input consultation text at all, it is necessary to extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form the answer text set, and at the same time encode the data of the text set to obtain a coding set based on word vectors.
[0065] Further, please refer to S3. Figure 2 A detailed flowchart, including:
[0066] S31. Select a subset of question-and-answer corpus corresponding to the entity text set from multiple subsets of question-and-answer corpus to form an answer text set;
[0067] For example, the question-and-answer corpus subsets for "diabetes" are corpus A_1 and corpus A_3, and the question-and-answer corpus subset for "pneumonia" is A_2, etc. However, since users are concerned about "diabetes" rather than "pneumonia", the question-and-answer corpus subset for "pneumonia" is removed, thereby obtaining the question-and-answer corpus subset corresponding to the entity text set, and then forming the answer text set.
[0068] S32. Based on the pre-built segmentation dictionary, perform segmentation operation on the answer text set to obtain a question-answer word set;
[0069] In order to better encode the text set data into a word vector-based encoding set, the present invention first needs to perform a segmentation operation on the answer text set to facilitate subsequent encoding.
[0070] In detail, S32 includes: extracting each answer text from the answer text set, segmenting the answer text according to a preset segmentation rule to obtain answer segmentation words, determining whether the answer segmentation words appear in the segmentation dictionary, if the answer segmentation words do not appear in the segmentation dictionary, re-segmenting the answer text, if the answer segmentation words appear in the segmentation dictionary, continuing to segment the answer text until the answer text set is extracted to obtain the question and answer word set.
[0071] The segmentation specifications include segmentation order, number of segments, and segmentation tolerance. For example, if corpus A_1 is: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and the preset segmentation order is reverse segmentation, the number of segments is 2 characters, and the segmentation tolerance is 2, then the first segmentation of corpus A_1 yields "hospital". It is then checked whether "hospital" exists in the pre-built segmentation dictionary. If "hospital" exists, corpus A_1 becomes: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and a second segmentation yields "people". If "hospital" does not exist in the pre-built segmentation dictionary, corpus A_1 remains: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and "People's Hospital" is obtained according to the segmentation tolerance of 2. This process is repeated to obtain several phrases, which are then summarized to form a question-and-answer phrase set.
[0072] S33. Perform encoding operations on the question-and-answer word set to obtain a question-and-answer encoding set.
[0073] In this embodiment of the invention, the encoding operation can be performed on the question-and-answer word set using Google's Word2vec tool or the Huffman coding method to obtain a question-and-answer encoding set. The question-and-answer encoding set is generally a vector set, as vectors have good semantic properties and can be used to represent the features of each text.
[0074] S4. Input the question-answering encoding set into the pre-trained deep learning question-answering model to obtain the answer text of the inquiry text.
[0075] Specifically, the method further includes training the deep learning question-answering model, wherein the training includes:
[0076] Step A: According to the pre-set network combination weight function, combine multiple groups of long short-term memory networks to obtain the deep learning question answering model to be trained, and obtain the question answering training set and question answering label set, and input the question answering training set into the deep learning question answering model to be trained;
[0077] Step B: Calculate the association weights between each group of long short-term memory networks to obtain the association weight set;
[0078] Step C: Perform weighted summation and activation processing on the associated weight set to obtain the question-answer prediction set;
[0079] Step D: Calculate the error value between the question-answer prediction set and the question-answer tag set. If the error value is greater than the preset error threshold, recalculate the association weights between each group of long short-term memory networks according to the pre-constructed optimization function to obtain the association weight set, and return to step C.
[0080] Step E: If the error value is less than or equal to the error threshold, the trained deep learning question answering model is obtained.
[0081] In this embodiment of the invention, the Long Short-Term Memory (LSTM) network is a type of neural network that can remember event information over time to perform classification and prediction. The LSTM network includes an input processing state, a forgetting processing state, and an output processing state.
[0082] Preferably, the network combined weight function is as follows:
[0083]
[0084] In the above function, Represents the Long Short-Term Memory network. Number each group of long short-term memory networks. The corresponding time t is the first The combined weights of the long short-term memory network.
[0085] Furthermore, the calculation of the association weights between each group of long short-term memory networks to obtain the association weight set is performed using the following formula:
[0086]
[0087] in, Indicates the first The association weights of a long short-term memory network, , These represent the internal parameters of the deep learning question-answering model. This indicates the corresponding time t. The data processing status of a long short-term memory network.
[0088] Before performing weighted summation and activation processing on the associated weight set to obtain the question-answer prediction set, the method further includes normalizing the associated weight set. The normalization process uses the following formula:
[0089]
[0090] In the above formula, This represents the total number of the associated weight sets. Indicates the first The association weights of a long short-term memory network, Represents the normalized i-th Association weights of a long short-term memory network.
[0091] Furthermore, the formula for calculating the weighted sum is:
[0092]
[0093] The activation process includes:
[0094]
[0095] in, For pre-built activation functions, This represents the value after weighted summation. This represents the first time step at time t-1. The data processing status of a long short-term memory network. This represents the predicted text for the question and answer at time t-1. The question-and-answer prediction text is given at time t.
[0096] In a preferred embodiment of the present invention, the error value of calculating the question-answer prediction set and the question-answer tag set can be achieved using currently disclosed exponential loss functions or squared loss functions, etc.
[0097] In this embodiment of the invention, after the deep learning question-answering model is trained, it can directly accept question-answering encoding sets for intelligent responses. For example, if the user inputs a consultation text A: "I have had diabetes for many years and recently sought treatment at a hospital in location A, but the results were not very good. Therefore, I would like to know if hospitals in location B have better treatment options for diabetes," after the encoded text is processed through S1 to S3 and input into the trained deep learning question-answering model, an answer similar to "Compared to all hospitals in locations A and B, the most authoritative treatment for diabetes is Peking Union Medical College Hospital in location B" can be obtained.
[0098] In this embodiment of the invention, the received consultation text is first subjected to named entity recognition to obtain an entity text set. The named entity recognition operation can transform the consultation text into an entity text set including names of people, places, organizations, proper nouns, etc., thus reducing the data volume for the first time. At the same time, the obtained question-and-answer corpus is subjected to named entity recognition operation to reduce the data volume for the second time. In addition, the answer text set obtained after named entity recognition is encoded and input into a deep learning question-and-answer model. Since the deep learning question-and-answer model calculates more accurate answer texts than traditional word vector transformation methods, this invention solves the problems of high computational load and poor timeliness in the text answering process.
[0099] like Figure 3 The diagram shown is a functional block diagram of the named entity-based text question-answering device of the present invention.
[0100] The named entity-based text question-answering device 100 of this invention can be installed in an electronic device. Depending on the functions implemented, the named entity-based text question-answering device may include an entity text calculation module 101, a question-answer corpus calculation module 102, an encoding module 103, and an answer text calculation module 104. The modules described in this invention can also be referred to as units, which are a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and are stored in the memory of the electronic device.
[0101] In this embodiment, the functions of each module / unit are as follows:
[0102] The entity text calculation module 101 is used to receive the consultation text input by the user, perform named entity recognition on the consultation text, and obtain an entity text set.
[0103] Named Entity Recognition (NER), also known as proper name recognition, refers to the identification of entities with specific meanings in text, mainly including personal names, place names, organization names, and proper nouns. In this embodiment of the invention, the entity text calculation module 101 can use the publicly available Stanford Named Entity Recognizer (SNER) to perform named entity recognition on the consultation text data. The Stanford Recognition Model is a named entity recognition program implemented in the Java programming language.
[0104] For example, if the user inputs a consultation text A as: "I have had diabetes for many years and recently went to a hospital in location A, but the treatment was not very effective. So I would like to know if there are better treatment options for diabetes in hospitals in location B", then using the Stanford recognition model mentioned above, named entity recognition is performed on the consultation text A to obtain a set of entity texts such as "diabetes", "location A", "hospital", and "location B".
[0105] The question-and-answer corpus calculation module 102 is used to obtain a question-and-answer corpus set and perform named entity recognition and named entity segmentation on the question-and-answer corpus set to obtain multiple question-and-answer corpus subsets.
[0106] The question-and-answer corpus calculation module 102 described in this embodiment of the invention can obtain the question-and-answer corpus in various ways, such as using web crawlers to crawl relevant text data from the network and organize it to obtain the question-and-answer corpus, or using currently available and downloadable public corpus sets, such as the National Language Commission's Modern Chinese Corpus and the Modern Chinese Marked Corpus.
[0107] Since the question-and-answer corpus is generally large in size, if the question-and-answer corpus is used directly for text question-and-answer, it is necessary to traverse and search for the answer text corresponding to the user's input inquiry text. Therefore, it will consume a lot of computing resources and it is difficult to achieve the expected requirements. Therefore, in this embodiment of the invention, the question-and-answer corpus calculation module 102 is used to perform named entity recognition and named entity segmentation processing on the acquired question-and-answer corpus.
[0108] Specifically, the question-and-answer corpus calculation module 102 is used to: perform named entity recognition on the question-and-answer corpus set to obtain a question-and-answer entity set; and perform text segmentation on the question-and-answer corpus set according to the question-and-answer entities included in the question-and-answer entity set to obtain multiple question-and-answer corpus subsets.
[0109] Preferably, the named entity recognition model used in the question-and-answer corpus calculation module 102 can be the Stanford recognition model described above. Alternatively, other recognition models can be used to recognize the question-and-answer corpus.
[0110] Since the question-and-answer corpus includes multiple sets of corpora, and the question-and-answer entities included in each set of corpora are not entirely the same, for example, if corpus A_1 is: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", then the question-and-answer entities included in corpus A_1 are "diabetes", "location A", and "First People's Hospital of Location A", and so on, we can obtain the question-and-answer entities included in corpus A_2, such as "pneumonia" and "location C", and the question-and-answer entities included in corpus A_3, such as "location B" and "diabetes", the question-and-answer corpus calculation module 102 needs to perform named entity partitioning based on the question-and-answer entities included in each set of corpora, so as to obtain multiple question-and-answer corpus subsets with the same question-and-answer entities, such as the question-and-answer corpus subsets for "diabetes" being corpus A_1 and corpus A_3, and the question-and-answer corpus subset for "pneumonia" being A_2, etc.
[0111] The encoding module 103 is used to extract a subset of question-and-answer corpora related to the consultation text from the plurality of question-and-answer corpora subsets, form an answer text set, and perform segmentation and encoding operations on the answer text set to obtain a question-and-answer encoding set.
[0112] In this embodiment of the invention, the question-and-answer corpus has been divided into multiple question-and-answer corpus subsets according to different named entities. However, since many question-and-answer corpus subsets do not match the user's input consultation text, it is necessary to use the encoding module 103 to extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form a response text set, and at the same time encode the data of the text set to obtain an encoding set based on word vectors.
[0113] Specifically, the encoding module 103 is used to: select a subset of question-and-answer corpora corresponding to the entity text set from multiple subsets of question-and-answer corpora to form an answer text set; perform a segmentation operation on the answer text set according to a pre-built segmentation dictionary to obtain a question-and-answer word set; and perform an encoding operation on the question-and-answer word set to obtain a question-and-answer encoding set.
[0114] For example, the question-and-answer corpus subsets for "diabetes" are corpus A_1 and corpus A_3, and the question-and-answer corpus subset for "pneumonia" is A_2, etc. However, since users are concerned about "diabetes" rather than "pneumonia", the question-and-answer corpus subset for "pneumonia" is removed, thereby obtaining the question-and-answer corpus subset corresponding to the entity text set, and then forming the answer text set.
[0115] In order to better encode the text set data into a word vector-based encoding set, the present invention first needs to perform a segmentation operation on the answer text set to facilitate subsequent encoding.
[0116] In detail, the segmentation operation specifically includes: extracting each answer text from the answer text set; segmenting the answer text according to a preset segmentation rule to obtain answer segmentation words; determining whether the answer segmentation words appear in the segmentation dictionary; if the answer segmentation words do not appear in the segmentation dictionary, re-segmenting the answer text; if the answer segmentation words appear in the segmentation dictionary, continuing to segment the answer text until the answer text set is completely extracted to obtain the question-and-answer word set.
[0117] The segmentation specifications include segmentation order, number of segments, and segmentation tolerance. For example, if corpus A_1 is: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and the preset segmentation order is reverse segmentation, the number of segments is 2 characters, and the segmentation tolerance is 2, then the first segmentation of corpus A_1 yields "hospital". It is then checked whether "hospital" exists in the pre-built segmentation dictionary. If "hospital" exists, corpus A_1 becomes: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and a second segmentation yields "people". If "hospital" does not exist in the pre-built segmentation dictionary, corpus A_1 remains: "Among all hospitals in location A, the most authoritative hospital for diabetes treatment is the First People's Hospital of Location A", and "People's Hospital" is obtained according to the segmentation tolerance of 2. This process is repeated to obtain several phrases, which are then summarized to form a question-and-answer phrase set.
[0118] In this embodiment of the invention, the encoding operation can be performed on the question-and-answer word set using Google's Word2vec tool or the Huffman coding method to obtain a question-and-answer encoding set. The question-and-answer encoding set is generally a vector set, as vectors have good semantic properties and can be used to represent the features of each text.
[0119] The answer text calculation module 104 is used to input the question-answer encoding set into a pre-trained deep learning question-answering model to obtain the answer text of the inquiry text.
[0120] Furthermore, the named entity-based text question answering device 100 of the present invention also includes a model training module 105, used for:
[0121] According to the pre-set network combination weight function, multiple groups of long short-term memory networks are combined to obtain the deep learning question answering model to be trained, and the question answering training set and question answering label set are obtained. The question answering training set is then input into the deep learning question answering model to be trained.
[0122] Calculate the association weights between each group of long short-term memory networks to obtain the association weight set;
[0123] The question-answer prediction set is obtained by weighted summation and activation processing of the associated weight set;
[0124] Calculate the error value between the question-answer prediction set and the question-answer tag set;
[0125] When the error value is less than or equal to a preset error threshold, a trained deep learning question-answering model is obtained.
[0126] In this embodiment of the invention, the Long Short-Term Memory (LSTM) network is a type of neural network that can remember event information over time to perform classification and prediction. The LSTM network includes an input processing state, a forgetting processing state, and an output processing state.
[0127] Preferably, the network combined weight function is as follows:
[0128]
[0129] In the above function, Represents the Long Short-Term Memory network. Number each group of long short-term memory networks. The corresponding time t is the first The combined weights of the long short-term memory network.
[0130] Furthermore, the calculation of the association weights between each group of long short-term memory networks to obtain the association weight set is performed using the following formula:
[0131]
[0132] in, Indicates the first The association weights of a long short-term memory network, , These represent the internal parameters of the deep learning question-answering model. This indicates the corresponding time t. The data processing status of a long short-term memory network.
[0133] Before performing weighted summation and activation processing on the associated weight set to obtain the question-answer prediction set, the method further includes normalizing the associated weight set. The normalization process uses the following formula:
[0134]
[0135] In the above formula, This represents the total number of the associated weight sets. Indicates the first The association weights of a long short-term memory network, Represents the normalized i-th Association weights of a long short-term memory network.
[0136] Furthermore, the formula for calculating the weighted sum is:
[0137]
[0138] The activation process includes:
[0139]
[0140] in, For pre-built activation functions, This represents the value after weighted summation. This represents the first time step at time t-1. The data processing status of a long short-term memory network. This represents the predicted text for the question and answer at time t-1. The question-and-answer prediction text is given at time t.
[0141] In a preferred embodiment of the present invention, the error value of calculating the question-answer prediction set and the question-answer tag set can be achieved using currently disclosed exponential loss functions or squared loss functions, etc.
[0142] In this embodiment of the invention, after the deep learning question-answering model is trained, it can directly accept question-answering encoding sets for intelligent responses. For example, if the user inputs a consultation text A: "I have had diabetes for many years and recently sought treatment at a hospital in location A, but the results were not very good. Therefore, I would like to know if hospitals in location B have better treatment options for diabetes," after the encoded text is processed through S1 to S3 and input into the trained deep learning question-answering model, an answer similar to "Compared to all hospitals in locations A and B, the most authoritative treatment for diabetes is Peking Union Medical College Hospital in location B" can be obtained.
[0143] In this embodiment of the invention, the received consultation text is first subjected to named entity recognition to obtain an entity text set. The named entity recognition operation can transform the consultation text into an entity text set including names of people, places, organizations, proper nouns, etc., thus reducing the data volume for the first time. At the same time, the obtained question-and-answer corpus is subjected to named entity recognition operation to reduce the data volume for the second time. In addition, the answer text set obtained after named entity recognition is encoded and input into a deep learning question-and-answer model. Since the deep learning question-and-answer model calculates more accurate answer texts than traditional word vector transformation methods, this invention solves the problems of high computational load and poor timeliness in the text answering process.
[0144] like Figure 4 The diagram shown is a structural schematic of an electronic device that implements the named entity-based text question answering method of the present invention.
[0145] The electronic device 1 may include a processor 10, a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a named entity-based text question-and-answer program 12.
[0146] The memory 11 includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device 1, such as a plug-in portable hard drive, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 1. Furthermore, the memory 11 can include both internal and external storage units of the electronic device 1. The memory 11 can be used not only to store application software and various types of data installed on the electronic device 1, such as the code of a named entity-based text question-and-answer program, but also to temporarily store data that has been output or will be output.
[0147] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., executing named entity-based text question-and-answer programs) and calls data stored in the memory 11 to perform various functions of the electronic device 1 and process data.
[0148] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable communication between the memory 11 and at least one processor 10, etc.
[0149] Figure 4 Only electronic devices with components are shown; those skilled in the art will understand that... Figure 4 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0150] For example, although not shown, the electronic device 1 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0151] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, a Bluetooth interface, etc.), which is typically used to establish communication connections between the electronic device 1 and other electronic devices.
[0152] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), and optionally, a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device 1 and to display a visual user interface.
[0153] It should be understood that the embodiments described are for illustrative purposes only and are not limited to this structure in the scope of the patent application.
[0154] The named entity-based text question-and-answer program 12 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions, which, when run in the processor 10, can achieve the following:
[0155] Receive user-inputted consultation text, and perform named entity recognition on the consultation text to obtain an entity text set;
[0156] Obtain a question-and-answer corpus, and perform named entity recognition and named entity segmentation on the question-and-answer corpus to obtain multiple question-and-answer corpus subsets;
[0157] Extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form an answer text set, and perform segmentation and encoding operations on the answer text set to obtain a question-and-answer encoding set;
[0158] The question-and-answer encoding set is input into a pre-trained deep learning question-and-answer model to obtain the answer text to the inquiry text.
[0159] Specifically, the processor 10's implementation method for the above instructions can be found in [reference needed]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0160] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0161] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0162] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0163] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0164] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0165] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within the invention. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0166] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices recited in a system claim may also be implemented by a single unit or device through software or hardware. The term "second class" is used to indicate names and does not indicate any specific order.
[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A text-based question-answering method based on named entities, characterized in that, The method includes: Receive user-inputted consultation text, perform named entity recognition on the consultation text, and obtain an entity text set; Obtain a question-and-answer corpus, and perform named entity recognition and named entity segmentation on the question-and-answer corpus to obtain multiple question-and-answer corpus subsets; Extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form an answer text set. Based on a pre-constructed segmentation dictionary, perform at least one round of segmentation operation on the answer text set according to a preset segmentation order, segmentation quantity, and segmentation tolerance to obtain multiple segmentation words until all of the multiple segmentation words appear in the segmentation dictionary. Then, summarize them to obtain a question-and-answer word group set. Perform vector encoding operation on the question-and-answer word group set to obtain a question-and-answer encoding set. The question-and-answer encoding set is input into a pre-trained deep learning question-and-answer model to obtain the answer text to the inquiry text. Specifically, the step involves performing at least one round of segmentation on the answer text set according to a pre-constructed segmentation dictionary, following a preset segmentation order, segmentation quantity, and segmentation tolerance, to obtain multiple segmented words until all of the multiple segmented words appear in the segmentation dictionary. These segmented words are then aggregated to obtain a question-and-answer word set, including: Step 1: Extract each answer text from the answer text set; Step II: Segment the response text according to the preset segmentation rules to obtain response segmentation words; Step III: Determine whether the answer segmentation word appears in the segmentation dictionary. If the answer segmentation word does not appear in the segmentation dictionary, return to Step II. Step IV: If the answer segmentation word appears in the segmentation dictionary, continue to segment the answer text until the answer text set is extracted to obtain the question-and-answer word set; The training of the deep learning question answering model includes: Step A: According to the pre-set network combination weight function, combine multiple groups of long short-term memory networks to obtain the deep learning question answering model to be trained, and obtain the question answering training set and question answering label set, and input the question answering training set into the deep learning question answering model to be trained; Step B: Calculate the association weights between each group of long short-term memory networks to obtain the association weight set; Step C: Perform weighted summation and activation processing on the associated weight set to obtain the question-answer prediction set; Step D: Calculate the error value between the question-answer prediction set and the question-answer tag set. If the error value is greater than the preset error threshold, recalculate the association weights between each group of long short-term memory networks according to the pre-constructed optimization function to obtain the association weight set, and return to step C. Step E: If the error value is less than or equal to the error threshold, the trained deep learning question answering model is obtained.
2. The text question-answering method based on named entities as described in claim 1, characterized in that, The process of performing named entity recognition and named entity segmentation on the question-and-answer corpus yields multiple question-and-answer corpus subsets, including: Named entity recognition is performed on the question-and-answer corpus to obtain the question-and-answer entity set; Based on the question-and-answer entities included in the question-and-answer entity set, the question-and-answer corpus is divided into multiple question-and-answer corpus subsets.
3. A text-based question-answering device based on named entities, characterized in that, The device includes: The entity text calculation module is used to receive the consultation text input by the user, perform named entity recognition on the consultation text, and obtain an entity text set; The question-and-answer corpus calculation module is used to acquire a question-and-answer corpus set and perform named entity recognition and named entity segmentation on the question-and-answer corpus set to obtain multiple question-and-answer corpus subsets; The encoding module is used to extract question-and-answer corpus subsets related to the consultation text from multiple question-and-answer corpus subsets to form an answer text set. Based on a pre-constructed segmentation dictionary, the module performs at least one round of segmentation operations on the answer text set according to a preset segmentation order, number of segments, and segmentation tolerance to obtain multiple segmentation words until all of the multiple segmentation words appear in the segmentation dictionary. These segmentation words are then aggregated to obtain a question-and-answer word set. Vector encoding operations are then performed on the question-and-answer word set to obtain a question-and-answer encoding set. Specifically, the step of performing at least one round of segmentation operations on the answer text set according to the pre-constructed segmentation dictionary and a preset segmentation order, number of segments, and segmentation tolerance is described above. The process involves several steps: Step 1: Extracting each answer text from the answer text set; Step 2: Segmenting the answer text according to a preset segmentation rule to obtain answer segmentation words; Step 3: Determining whether the answer segmentation words appear in the segmentation dictionary. If the answer segmentation words do not appear in the segmentation dictionary, returning to Step 2; Step 4: If the answer segmentation words appear in the segmentation dictionary, continuing to segment the answer text until the answer text set is extracted and the question-and-answer word set is obtained. The response text calculation module is used to input the question-and-answer encoding set into a pre-trained deep learning question-and-answer model to obtain the response text of the consultation text. The training of the deep learning question-and-answer model includes: Step A: Combining multiple groups of long short-term memory networks according to a pre-set network combination weight function to obtain the deep learning question-and-answer model to be trained, and obtaining a question-and-answer training set and a question-and-answer label set, inputting the question-and-answer training set into the deep learning question-and-answer model to be trained; Step B: Calculating the association weights between each group of long short-term memory networks to obtain an association weight set; Step C: Performing weighted summation and activation processing on the association weight set to obtain a question-and-answer prediction set; Step D: Calculating the error value between the question-and-answer prediction set and the question-and-answer label set. If the error value is greater than a preset error threshold, recalculating the association weights between each group of long short-term memory networks according to a pre-constructed optimization function to obtain an association weight set, and returning to Step C; Step E: If the error value is less than or equal to the error threshold, the trained deep learning question-and-answer model is obtained.
4. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the named entity-based text question-answering method as described in any one of claims 1 to 2.
5. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the named entity-based text question-answering method as described in any one of claims 1 to 2.
Citation Information
Patent Citations
Intelligent dialogue method, robot dialogue system, server and storage medium
CN109885664A
Multi-round intelligent question-answering method, system, controller and medium
CN110717027A