Answer sentence selection method and device based on hierarchical capsule and multi-view information fusion

Through the hierarchical capsule network and multi-view information fusion method, the problem of existing models in capturing the fine-grained semantic relationship between questions and candidate answers is solved, achieving more accurate and efficient answer selection and being able to stably predict multiple labels.

CN115455162BActive Publication Date: 2025-10-03SOUTHEAST UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211113668.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-14
Publication Date
2025-10-03
Estimated Expiration
2042-09-14

AI Technical Summary

Technical Problem

Existing answer selection models are insufficient in capturing the fine-grained semantic relationship between questions and candidate answers, and the final output of the pre-trained model can only predict a single label, resulting in inaccurate answer selection and instability in the fine-tuning step.

Method used

A hierarchical capsule network (HCN) and multi-view information fusion method are adopted. The information aggregation capsule network, sentence aggregation capsule network and category aggregation capsule network share learning feature parameters. Combined with the multi-view information fusion layer, the learning of the middle layer of the encoder is enhanced, multiple labels are output and information loss is reduced.

Benefits of technology

It effectively aggregates the length and semantic features of sentences, solves the problems of information loss and mismatch, improves the accuracy and efficiency of answer sentence selection, and can stably predict multiple labels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115455162B_ABST
    Figure CN115455162B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for answer sentence selection by fusing hierarchical capsules with multi-view information. First, question texts containing multiple answers on the Internet are collected and preprocessed; then, a hierarchical capsule network is used to perform information aggregation and word aggregation on the representation of the encoded output through its progressive aggregation feature, thereby ensuring the accurate transmission of effective information and being able to use the same feature for parameter transmission; then, in order to solve the problem of instability in the fine-tuning step and the problem that the final output of the pre-trained model can only predict a single label, the weight of the entire BERT encoding intermediate layer output is calculated using a multi-view information fusion method to weight the learning information. The present invention can improve the problems in previous answer sentence selection methods, such as ignoring the influence of the multiple layers of intermediate output within the model on the answer sentence selection and being able to only predict a single result, thereby improving the accuracy and efficiency of answer sentence selection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for selecting an answer sentence by fusing hierarchical capsules with multi-view information, and belongs to the technical field of Internet and artificial intelligence. Background Art

[0002] With the rapid development of Internet technology, answer sentence selection has become an important subtask in the fields of information retrieval and natural language processing, and has been applied to many functional areas, among which Community Question Answering (CQA) is the most widely used. The goal of the answer selection task is to select the accurate or top-ranked answer based on its relevance to the given question and regard it as the correct answer given a question and a corresponding list of candidate answers. However, a question usually has many answers, which contain a large amount of irrelevant information. Finding the desired core information from the long list of answers of varying quality can be very time-consuming and difficult. Therefore, in community question answering, comprehensively analyzing the sentences in the answers according to the question and effectively capturing the complex semantic relationship between the question and the answer can effectively help manage the community or obtain valuable information.

[0003] Traditional answer selection models rely primarily on feature engineering, linguistic tools, or lexical methods. These methods primarily rely on manually extracting high-quality features to calculate similarity between questions. This requires extensive human expertise and manual work, is time-consuming, and lacks generalizability. Therefore, to reduce the workload of feature engineering, deep learning models have gradually become the mainstream approach for answer selection. They automatically learn features from both questions and answers to select answers. However, these models generally only consider the contextual and semantic information of each sentence in the question and answer, lacking information interaction. To address this, the introduction of attention mechanisms into deep neural networks has attracted research interest. This mechanism effectively increases the weight of information in similar parts of sentence representations, thereby updating the contextual representations of question and answer. Despite this, attention-based models also have limitations. Most models coarsely collect useful information from the network's hidden states and compress it into a single attention vector, but they are insufficient in capturing the various fine-grained differences between the question and candidate answers. Furthermore, a single attention vector may not adequately capture diverse aspects of the question, leading to inaccurate answers. With the emergence of pre-trained models, they have attracted widespread attention from researchers due to their ability to encode rich common sense into model parameters, thereby capturing the semantic relationship between words and context, and providing better semantic features for various downstream tasks. However, most pre-trained models use the model's final output and add corresponding response strategies based on different tasks. This approach ignores the influence of the intermediate outputs of multiple layers within the model on the selection of answer sentences. Summary of the Invention

[0004] In response to the problems and shortcomings in the prior art, the present invention attempts to solve the problem of discarding effective information due to pooling operations in deep network models through capsule networks. In order to avoid the problem of information loss due to excessive stride when sentence information is dispersed and the number of categories is small, which is not conducive to aggregation, a hierarchical capsule network (HCN) method is proposed. This method can aggregate the length and semantic features of the entire sentence, and will not cause information loss and mismatch due to a large aggregation span. Based on this, the present invention proposes an answer sentence selection method that integrates hierarchical capsule networks and multi-view information. The hierarchical capsule network is used to aggregate the length and semantic features of the entire sentence, avoiding information loss and mismatch due to a large aggregation span; and the multi-view information fusion method is used to stabilize the fine-tuning step and the final output can predict multiple labels, which can effectively solve the instability of the fine-tuning step and the problem that the final output of the pre-trained model can only predict a single label.

[0005] To achieve the above-mentioned purpose, the present invention is implemented through the following technical solutions:

[0006] The answer sentence selection method based on the fusion of hierarchical capsule and multi-view information includes the following steps:

[0007] Step 1: Question-Answer Text Collection

[0008] Collect question texts and answer texts containing multiple answers from the Internet to accumulate a sample data set; each sample in the data set includes a question and an answer in the online text; split the data set into a training set, a validation set, and a test set;

[0009] Step 2: Data Preprocessing

[0010] Preprocess each sample in the dataset and construct triple data. A triple data includes question text, answer text and the label corresponding to the answer text.

[0011] Step 3: Model training

[0012] First, the question and answer are processed into sentences, and the BERT bidirectional language model is used to generate context embedding vectors, in which the BERT model is fine-tuned and optimized using the large-scale answer selection corpus ASNQ; then, in the encoding layer, the BERT encoder is used to encode the bidirectional contextual semantic information to further obtain the information dependency between words; then in the hierarchical capsule network (HCN), the information aggregation capsule network (InforCaps), the sentence aggregation capsule network (SegCaps) and the category aggregation capsule network (CateCaps) share the learning of the same type of feature parameters; the dynamic routing mechanism of the information aggregation capsule layer aggregates the high-dimensional sparse semantics of each word to obtain the preliminary clustering features between words; in the sentence aggregation capsule layer, the rich vocabulary features after clustering are further clustered, and the number of capsules is gradually reduced. A shorter sentence length is obtained, but rich information is obtained. Finally, the capsule layer is input into the category capsule layer for classification, thereby ensuring the clustering performance of specific objects; at the same time, in the multi-view information fusion layer, the weights of all the encoding intermediate layer outputs in the entire BERT encoder are calculated in the first step and normalized. In the second step, the information output by each encoding layer is weightedly fused using the weights to obtain the final information table. In the third step, the weighted information representation obtained by the multi-view information fusion layer is processed using the activation function ReLU and added as "correction information" to the final semantic representation of the hierarchical capsule network for classification, thereby enhancing the learning of the encoder intermediate layer information; finally, the output layer is composed of the outputs of the hierarchical capsule network layer and the multi-view information fusion layer, and the model is trained using a joint loss function of marginal loss and cross entropy loss;

[0013] Step 4: Model testing and answer sentence selection

[0014] Based on the best model obtained through training, answer sentences are selected for questions with multiple answers.

[0015] Furthermore, in step 1, when obtaining the data set, a large number of question texts containing multiple answers and corresponding answer texts are first captured from the social networking platform, and the standard answers to the questions are selected according to manual rules; when splitting the data set, the ratio of the training set, validation set and test set is 8:1:1.

[0016] Furthermore, the preprocessing process in step 2 is: cleaning the data, retaining data containing only questions, answers and answer labels, using the nltk library to sentence-process the questions and answers, and eliminating data groups containing less than two sentences.

[0017] Furthermore, step 3 includes the following sub-steps:

[0018] Sub-step 3-1, build the data layer

[0019] First, the BERT model is fine-tuned and optimized on the large answer selection corpus ASNQ to make the fine-tuned model parameters more suitable for downstream tasks. Then, the fine-tuned BERT model is used to extract the vocabulary and convert each word sequence of the question and answer in the triple into a word vector representation. In the BERT model, the input sentence pairs are combined into a sequence, and the sentences are separated by a special separator [SEP]. The [CLS] tag is manually added at the beginning of the sentence, which means the aggregate representation of the sequence. Throughout the MPT-HCN model experiment, the data is preprocessed to keep all types consistent. Therefore, the input form of all datasets is [[CLS], A, [SEP], B, [SEP]], where A and B represent the question and a candidate answer in the corresponding candidate set, respectively.

[0020] Sub-step 3-2, build text embedding layer

[0021] Given a question q and its tokens At the same time, a candidate answer a corresponding to the question is given i and its lexical elements Where s and m represent the length of the question and answer respectively. Each word is initialized using the BERT model. The formula for the contextual embedding representation E is as follows:

[0022]

[0023] in represents the representation of the entire input, k = s + m + 3 is the total length of the input question, answer and special word, d e is the dimension of the context embedding representation;

[0024] Sub-step 3-3, build text encoding layer

[0025] The BERT encoder is used to encode bidirectional context information. The encoder consists of N identical layers, each of which consists of two parts: a multi-head attention mechanism and a position-based fully connected feedforward neural network. Residual connections are used to avoid the loss of original information caused by excessive depth of the network layer. By calculating the matching relationship between the question vector Q and the key vector K, the weighted matrix Attention(Q,K,V) is obtained, and then the head corresponding to each value matrix V is output. i The weighted value of:

[0026]

[0027]

[0028] At the same time, multi-head attention is composed of multiple attention layers connected in series. The vector information obtained by the different parameter matrices of each attention layer is superimposed to obtain the n-th layer context depth representation of the encoder:

[0029] M n =MultiHead(Q,K,V)=Concat(head1,…,head h )W O

[0030] in, W O is a learnable parameter, d k is a constant parameter; and the implementation of the multi-head attention mechanism requires a fully connected forward neural network consisting of two linear layers and a Relu() activation function; finally, residual connections and layer normalization are performed to ensure that information can be fully transmitted to the n+1th layer;

[0031]

[0032] H n =LayerNormM n +F n

[0033] in, is a learnable parameter;

[0034] Sub-steps 3-4: Constructing a hierarchical capsule network layer

[0035] The hierarchical capsule network layer contains three types of capsules: information aggregation capsule network, sentence aggregation capsule network, and category aggregation capsule network. They learn the same type of feature parameters by sharing to ensure the clustering performance of specific objects;

[0036] In the information aggregation capsule network, the implicit information of fixed words is first clustered; the network uses H NAs input, and set the number of capsules to k and the number of neurons in each capsule to d model ; Then, the output state of the encoder As the input layer of the capsule network, and get the prediction vector:

[0037]

[0038] W ij is a learnable parameter;

[0039] Secondly, the prediction vector u j|i is input into the dynamic routing protocol and determines the coupling coefficient c ij , which indicates the probability that information is passed to the next layer:

[0040]

[0041] Next, perform a weighted summation of all input information:

[0042]

[0043] Total input j A nonlinear transformation is performed in the squeeze function to ensure that the direction of the vector remains unchanged:

[0044]

[0045] Finally, according to the vector output v of capsule j j , learning weight b ij is updated and passed to the next iteration of the dynamic route:

[0046] b ij =b ij +u j|i v j

[0047] After the information aggregation capsule network, the output can be obtained It keeps the number of words fixed and shortens the information represented by each word dimension, where

[0048] In the sentence aggregation capsule network, by keeping the neurons in each capsule fixed and gradually reducing the number of capsules instead of merging operations, better category output is promoted; the output H of the information aggregation capsule network is converted to I As the input of the network, n I is the number of capsules, d I For the number of neurons in each capsule, we can get the prediction vector:

[0049]

[0050] W jt is a learnable parameter;

[0051] The same dynamic routing mechanism is used for this network:

[0052] v t =Dynamic Routing(u t|j ,iter S )

[0053] v t is the vector output of capsule t;

[0054] Finally, the output of the sentence aggregation capsule network can be obtained in

[0055] In the category aggregation capsule network, H is used S As input, the specific calculation method is the same as that of the sentence aggregation capsule network, and the final output is The paradigm of the final result is:

[0056] H HCN =||H C ||

[0057] in

[0058] Sub-steps 3-5: Constructing a multi-view information fusion layer

[0059] Since BERT can effectively learn bidirectional semantic information, the cls position vector in the n-th layer encoding represents Aggregated through nth th The information learned by the entire sequence in the layer; for the nth th The coded information obtained in the layer and Thus, the encoding information set of each layer encoder at the [CLS] position is obtained:

[0060]

[0061] Where [,] is a concatenation operation;

[0062] Use average pooling to obtain the information weights of different encoding layers, and apply the Softmax function to normalize the weights to obtain ω:

[0063] ω=Softmax(Average(H cls ))

[0064] Next, a linear layer is used to perform multi-view information mapping, and the general information representation is mapped to a specific encoder layer representation:

[0065] C cls =tanh(W cls H cls +b cls )

[0066] in

[0067]

[0068] Finally, the information weight of each layer of the encoder is weighted and fused with the specific information to obtain the information representation It ultimately contains the outputs of all layers in the BERT encoder;

[0069] When information fusion is performed, the ReLU activation function is used to process This is then added as “corrective information” to the final semantic representation of the hierarchical capsule network:

[0070]

[0071] Substeps 3-6, joint training loss

[0072] All parameters are initialized randomly in the range of [-0.1, 0.1]. The Adam optimizer is used for gradient backpropagation to update the model parameters. The initial learning rate is set to 2e-5, the initial dropout value is 0.1, and the gradient is clipped with a maximum gradient norm of 1. When the training loss no longer decreases or the number of training rounds exceeds a certain number, the model training ends and the model with the best performance on the validation set is saved.

[0073] Furthermore, the step 4 specifically includes the following process:

[0074] First, perform data processing in step 2 on the data, build the input form of the model, and input it into the trained model in step 3 to select the answer sentence.

[0075] Furthermore, step 4 also includes the following process:

[0076] The mean precision (MPR) and mean reciprocal rank (MRR) of the answers selected by the model are calculated with the standard answers to test the performance of answer sentence selection. The specific calculation method is:

[0077]

[0078]

[0079] Among them, rank i refers to the ranking position of the first correct candidate answer to the i-th question, is a list of the top K relevant candidate answers.

[0080] A device for selecting an answer sentence by fusing hierarchical capsules with multi-view information, the device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the method for selecting an answer sentence by fusing hierarchical capsules with multi-view information is implemented.

[0081] Compared with the prior art, the advantages of the present invention are as follows:

[0082] 1. This paper adopts an answer sentence selection technology based on a hierarchical capsule network and multi-view information fusion to construct a hierarchical capsule network, aggregate the length and semantic features of the entire sentence, thereby avoiding information loss and mismatch caused by a large aggregation span, ensuring the accurate transmission of effective information, and can use the same features for parameter transfer, achieving better clustering performance.

[0083] 2. This paper proposes a multi-view fusion method that effectively addresses the instability of the fine-tuning step. Furthermore, by learning from the encoder's intermediate layers, this method breaks the previous practice of using a pre-trained model's final output to predict only a single label. It effectively predicts multi-label answer sentence selection, improving the accuracy and efficiency of answer sentence selection. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] Figure 1 Flowchart of a method according to an embodiment of the present invention.

[0085] Figure 2 This is an overall model diagram of an embodiment of the present invention.

[0086] Figure 3 This is an example diagram of answer sentence selection involved in an embodiment of the present invention. DETAILED DESCRIPTION

[0087] The technical solutions provided by the present invention will be described in detail below with reference to specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.

[0088] The specific model for realizing the present invention is as follows Figure 2 According to the model diagram, the present invention provides an answer sentence selection method that integrates hierarchical capsules and multi-view information. The detailed implementation steps are as follows:

[0089] Step 1: Collection of question and answer texts. To ensure data diversity and universality, this implementation first crawls a large number of question texts containing multiple answers and corresponding answer texts from social networking platforms, and selects standard answers to the questions based on manual rules. Questions, answers, and answer labels together constitute the sample dataset D. Each sample in the dataset includes questions and answers in online texts. Sample examples are as follows: Figure 3 Finally, all the obtained data are split into training set, validation set and test set according to 8:1:1.

[0090] Step 2: Data preprocessing. To ensure the data is more suitable for training the designed model, we first clean the data, retaining only the questions, answers, and answer labels. We then use the NLTK library to break the questions and answers into sentences, and remove data sets containing two or fewer sentences to facilitate subsequent ablation experiments. Finally, we process the dataset into triples for application in subsequent steps. A triple consists of the question text, the answer text, and the corresponding label.

[0091] Step 3: Model training. The dataset processed in step 2 is used to train the answer sentence selection model based on hierarchical capsule network and multi-view information fusion proposed in this invention. The implementation of this step can be divided into the following sub-steps:

[0092] Sub-step 3-1, construct the data layer. First, the BERT model is fine-tuned and optimized on the large answer selection corpus ASNQ, so that the fine-tuned model parameters are more suitable for downstream tasks. Then the fine-tuned BERT model is used to extract the vocabulary and convert each word sequence of the question and answer in the triple into a word vector representation. In the BERT model, the input sentence pairs are combined into a sequence, and the sentences are separated by a special separator [SEP]. The [CLS] tag needs to be manually added at the beginning of the sentence, which means the aggregated representation of the sequence. Throughout the MPT-HCN model experiment, the data needs to be preprocessed to keep all types consistent. Therefore, the input form of all datasets is [[CLS], A, [SEP], B, [SEP]], where A and B represent the question and a candidate answer in the corresponding candidate set, respectively.

[0093] Sub-step 3-2, build the text embedding layer. Given a question q and its word At the same time, a candidate answer a corresponding to the question is given i and its lexical elements Where s and m represent the length of the question and answer respectively. Each word is initialized using the BERT model. The formula for the contextual embedding representation E is as follows:

[0094]

[0095] in represents the representation of the entire input, k = s + m + 3 is the total length of the input question, answer and special word, d e is the dimension of the context embedding representation.

[0096] Sub-step 3-3, construct the text encoding layer. This embodiment requires the use of a BERT encoder to encode bidirectional context information. The encoder consists of N identical layers. Each layer consists of two parts: a multi-head attention mechanism and a position-based fully connected feedforward neural network, and a residual connection is used to avoid the loss of original information caused by the network layer being too deep. By calculating the matching relationship between the question vector Q and the key vector K, the weighted matrix Attention (Q, K, V) is obtained, and then the head corresponding to each value matrix V is output. i The weighted value of:

[0097]

[0098]

[0099] At the same time, multi-head attention is composed of multiple attention layers connected in series. The vector information obtained by the different parameter matrices of each attention layer is superimposed to obtain the n-th layer context depth representation of the encoder:

[0100] M n =MultiHead(Q,K,V)=Concat(head1,…,head h )W o

[0101] in W O are learnable parameters. The multi-head attention mechanism is implemented through a fully connected feed-forward neural network consisting of two linear layers and a Relu() activation function. Finally, residual connections and layer normalization are performed to ensure that information is fully transmitted to the n+1th layer.

[0102]

[0103] H n =LayerNormM n +F n

[0104] Substeps 3-4 construct the hierarchical capsule network layer. The hierarchical capsule network layer mainly contains three types of capsules: information aggregation capsule network, sentence aggregation capsule network, and category aggregation capsule network. They share the same type of feature parameters to ensure clustering performance for specific objects.

[0105] In the information aggregation capsule network, the implicit information of fixed words needs to be clustered first. The network uses H N As input, and set the number of capsules to k and the number of neurons in each capsule to d model Then, the output state of the encoder is As the input layer of the capsule network, and get the prediction vector:

[0106]

[0107] Secondly, the prediction vector u j|i is input into the dynamic routing protocol and determines the coupling coefficient c ij This coefficient can indicate the probability of information being passed to the next layer.

[0108]

[0109] Next, perform a weighted summation of all input information:

[0110]

[0111] Total input j A non-linear transformation is performed in the squeeze function to ensure that the direction of the vector remains unchanged.

[0112]

[0113] Finally, according to the vector output v of capsule j j , learning weight b ij Is updated and passed to the next iteration of the dynamic route.

[0114] b ij =b ij +u j|i v j

[0115] After the information aggregation capsule network, the output can be obtained It keeps the number of words fixed and shortens the information represented by each word dimension, where

[0116] In the sentence aggregation capsule network, by keeping the neurons in each capsule fixed and gradually reducing the number of capsules instead of merging operations, better category output is promoted. I As the input of the network, n I is the number of capsules, d I For the number of neurons in each capsule, we can get the prediction vector:

[0117]

[0118] The same dynamic routing mechanism is used for this network:

[0119] v t =Dynamic Routing(u t|j ,iter S )

[0120] Finally, the output of the sentence aggregation capsule network can be obtained in

[0121] In the category aggregation capsule network, H is used S As input, the specific calculation method is the same as that of the sentence aggregation capsule network, and the final output is The paradigm of the final result is:

[0122] H HCN =||H C ||

[0123] in

[0124] Sub-steps 3-5, build a multi-view information fusion layer. Since BERT can effectively learn bidirectional semantic information, Aggregated through nth th The information learned by the entire sequence in the layer. th The coded information obtained in the layer and Thus, the encoding information set of each layer encoder at the [CLS] position can be obtained:

[0125]

[0126] Where [,] is a concatenation operation.

[0127] In order to enable the encoder to learn semantic information more efficiently, this implementation uses average pooling to obtain the information weights of different encoding layers and applies the Softmax function to normalize the weights to obtain ω:

[0128] ω=Softmax(Average(H cls ))

[0129] Next, a linear layer is used to perform multi-view information mapping, and the general information representation is mapped to a specific encoder layer representation:

[0130] C cls =tanh(W cls H cls +b cls )

[0131] in d label is the dimension size of the vector.

[0132]

[0133] Finally, the information weight of each layer of the encoder is weighted and fused with the specific information to obtain the information representation It ultimately contains the outputs of all layers in the BERT encoder.

[0134] When information fusion is performed, the ReLU activation function is used to process This is then added as “corrective information” to the final semantic representation of the hierarchical capsule network:

[0135]

[0136] Substeps 3-6: Joint training loss. This example uses random initialization to initialize all parameters in the range [-0.1, 0.1]. The Adam optimizer is used for gradient backpropagation to update model parameters. The initial learning rate is set to 2e-5, the initial dropout value is 0.1, and gradient clipping is performed with a maximum gradient norm of 1. Model training ends when the training loss stops decreasing or the number of training epochs exceeds 30, and the best performing model on the validation set is saved.

[0137] Step 4: Model testing and answer sentence selection. Based on the best validation model obtained in step 3, answer sentence selection is performed on the dataset used. First, the data is processed in step 2 and the model input form is constructed. This is input into the trained model to select the answer sentence. The mean average precision (MPR) and mean reciprocal ranking (MRR) of the answers selected by the model are calculated against the standard answers to test the performance of the answer sentence selection. The specific calculation method is as follows:

[0138]

[0139]

[0140] Among them, rank i refers to the ranking position of the first correct candidate answer to the i-th question, is a list of the top K relevant candidate answers.

[0141] Based on the same inventive concept, the present invention provides an answer sentence selection device that integrates hierarchical capsules and multi-view information, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the device implements the above-mentioned answer sentence selection method that integrates hierarchical capsules and multi-view information.

[0142] The technical means disclosed in the solutions of the present invention are not limited to those disclosed in the above-mentioned embodiments, but also include technical solutions composed of any combination of the above-mentioned technical features. It should be noted that those skilled in the art may make various improvements and modifications without departing from the principles of the present invention, and such improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. The answer sentence selection method based on the fusion of hierarchical capsule and multi-view information is characterized by: The following steps are involved: Step 1: Question-Answer Text Collection Collect question texts and answer texts containing multiple answers from the Internet to accumulate a sample data set; each sample in the data set includes a question and an answer in the online text; Split the dataset into training, validation, and test sets; Step 2: Data Preprocessing Preprocess each sample in the dataset and construct triple data. A triple data includes question text, answer text and the label corresponding to the answer text. Step 3: Model training First, the question and answer are separated into sentences, and the contextual embedding vector is generated using the BERT bidirectional language model. The BERT model is fine-tuned and optimized using the large-scale answer selection corpus ASNQ. Then, at the encoding layer, the BERT encoder is used to encode bidirectional contextual semantic information to further obtain the information dependencies between words. Then, in the hierarchical capsule network HCN, the information aggregation capsule network InforCaps, the sentence aggregation capsule network SegCaps, and the category aggregation capsule network CateCaps share the same type of feature parameters. The dynamic routing mechanism of the information aggregation capsule layer aggregates the high-dimensional sparse semantics of each word to obtain preliminary clustering features between words. In the sentence aggregation capsule layer, the clustered rich lexical features are further clustered twice, gradually reducing the number of capsules to obtain a shorter sentence length but richer information. Finally, the capsule layer is input into the category capsule layer for classification, thereby ensuring the clustering performance of specific objects. At the same time, in the multi-view information fusion layer, the weights of the outputs of all encoding intermediate layers in the entire BERT encoder are calculated in the first step and normalized. In the second step, the information output from each encoding layer is weightedly fused using the weights to obtain the final information table. In the third step, the weighted information representation obtained by the multi-view information fusion layer is processed using the activation function ReLU and added as "correction information" to the final semantic representation of the hierarchical capsule network for classification, thereby enhancing the learning of the information in the encoder intermediate layer. Finally, the output layer is composed of the outputs of the hierarchical capsule network layer and the multi-view information fusion layer. The model is trained using a joint loss function of marginal loss and cross entropy loss. Step 4: Model testing and answer sentence selection Based on the best model obtained through training, answer sentences are selected for questions with multiple answers.

2. The answer sentence selection method based on hierarchical capsule and multi-view information fusion according to claim 1 is characterized in that: In step 1, when obtaining the data set, a large number of question texts containing multiple answers and corresponding answer texts are first captured from the social networking platform, and the standard answers to the questions are selected according to manual rules; when splitting the data set, the ratio of the training set, validation set and test set is 8:1:

1.

3. The answer sentence selection method based on hierarchical capsule and multi-view information fusion according to claim 1 is characterized in that: The preprocessing process in step 2 is as follows: clean the data, retain the data containing only questions, answers and answer labels, use the nltk library to sentence-process the questions and answers, and eliminate the data groups containing less than two sentences.

4. The answer sentence selection method based on hierarchical capsule and multi-view information fusion according to claim 1, characterized in that: The step 3 includes the following sub-steps: Sub-step 3-1, build the data layer First, the BERT model is fine-tuned and optimized on the large answer selection corpus ASNQ to make the fine-tuned model parameters more suitable for downstream tasks; then the fine-tuned BERT model is used to extract the vocabulary and convert each word sequence of the question and answer in the triple into a word vector representation; in the BERT model, the input sentence pairs are combined into a sequence, and the sentences are separated by a special separator [SEP]; the [CLS] tag is manually added at the beginning of the sentence, which means the aggregate representation of the sequence; throughout the MPT-HCN model experiment, the data is preprocessed to keep all types consistent; therefore, the input form of all datasets is [[CLS], A, [SEP], B, [SEP]], where A and B represent the question and a candidate answer in the corresponding candidate set, respectively; Sub-step 3-2, build text embedding layer Given a question q and its tokens At the same time, a candidate answer a corresponding to the question is given i and its lexical elements Where s and m represent the length of the question and answer respectively. Each word is initialized using the BERT model. The formula for the contextual embedding representation E is as follows: in represents the representation of the entire input, k = s + m + 3 is the total length of the input question, answer and special word, d e is the dimension of the context embedding representation; Sub-step 3-3, build text encoding layer The BERT encoder is used to encode bidirectional context information. The encoder consists of N identical layers, each of which consists of two parts: a multi-head attention mechanism and a position-based fully connected feedforward neural network. Residual connections are used to avoid the loss of original information caused by excessive depth of the network layer. By calculating the matching relationship between the question vector Q and the key vector K, the weighted matrix Attention (Q, K, V) is obtained, and then the head corresponding to each value matrix V is output. i The weighted value of: At the same time, multi-head attention is composed of multiple attention layers connected in series. The vector information obtained by the different parameter matrices of each attention layer is superimposed to obtain the n-th layer context depth representation of the encoder: M n =MultiHead(Q,K,V)=Concat(head1,...,head h )W O in, W O is a learnable parameter, d k is a constant parameter; and the implementation of the multi-head attention mechanism requires a fully connected forward neural network consisting of two linear layers and a Relu() activation function; finally, residual connections and layer normalization are performed to ensure that information can be fully transmitted to the n+1th layer; H n =LayerNormM n +F n in, is a learnable parameter; Sub-steps 3-4: Constructing a hierarchical capsule network layer The hierarchical capsule network layer contains three types of capsules: information aggregation capsule network, sentence aggregation capsule network, and category aggregation capsule network. They learn the same type of feature parameters by sharing to ensure the clustering performance of specific objects; In the information aggregation capsule network, the implicit information of fixed words is first clustered; the network uses H N As input, and set the number of capsules to k and the number of neurons in each capsule to d model ; Then, the output state of the encoder As the input layer of the capsule network, and get the prediction vector: W ij is a learnable parameter; Secondly, the prediction vector u j|i is input into the dynamic routing protocol and determines the coupling coefficient c ij , which indicates the probability that information is passed to the next layer: Next, perform a weighted summation of all input information: Total input j A nonlinear transformation is performed in the squeeze function to ensure that the direction of the vector remains unchanged: Finally, according to the vector output v of capsule j j , learn the weight b ij is updated and passed to the next iteration of the dynamic route: b ij =b ij +u j|i v j After the information aggregation capsule network, the output can be obtained It keeps the number of words fixed and shortens the information represented by each word dimension, where In the sentence aggregation capsule network, by keeping the neurons in each capsule fixed and gradually reducing the number of capsules instead of merging operations, better category output is promoted; the output H of the information aggregation capsule network is converted to I As the input of the network, n I is the number of capsules, d I For the number of neurons in each capsule, we can get the prediction vector: W jt is a learnable parameter; The same dynamic routing mechanism is used for this network: v t =Dynamic Routing(u t|j ,iter S ) v t is the vector output of capsule t; Finally, the output of the sentence aggregation capsule network can be obtained in In the category aggregation capsule network, H is used S As input, the specific calculation method is the same as that of the sentence aggregation capsule network, and the final output is The paradigm of the final result is: H HCN =||H C || in n C =2; Sub-steps 3-5: Constructing a multi-view information fusion layer Since BERT can effectively learn bidirectional semantic information, the cls position vector in the n-th layer encoding represents Aggregated through nth th The information learned by the entire sequence in the layer; for the nth th The coded information obtained in the layer and Thus, the encoding information set of each layer encoder at the [CLS] position is obtained: Where [,] is a series operation; Use average pooling to obtain the information weights of different encoding layers, and apply the Softmax function to normalize the weights to obtain ω: ω=Softmax(Average(H cls )) Next, a linear layer is used to perform multi-view information mapping, and the general information representation is mapped to a specific encoder layer representation: C cls =tanh(W cls H cls +b cls ) in Finally, the information weight of each layer of the encoder is weighted and fused with the specific information to obtain the information representation It ultimately contains the outputs of all layers in the BERT encoder; When information fusion is performed, the ReLU activation function is used to process This is then added as “corrective information” to the final semantic representation of the hierarchical capsule network: Substeps 3-6, joint training loss All parameters are initialized randomly in the range of [-0.1, 0.1]. The Adam optimizer is used for gradient backpropagation to update the model parameters. The initial learning rate is set to 2e-5, the initial dropout value is 0.1, and the gradient is clipped with a maximum gradient norm of 1. When the training loss no longer decreases or the number of training rounds exceeds a certain number, the model training ends and the model with the best performance on the validation set is saved.

5. The answer sentence selection method based on hierarchical capsule and multi-view information fusion according to claim 1, characterized in that: The step 4 specifically includes the following process: First, perform data processing in step 2 on the data, build the input form of the model, and input it into the trained model in step 3 to select the answer sentence.

6. The answer sentence selection method based on hierarchical capsule and multi-view information fusion according to claim 5, characterized in that: The step 4 also includes the following process: The answers selected by the model are compared with the standard answers to calculate the class mean precision (MPR) and mean reciprocal ranking (MRR) to test the performance of answer sentence selection. The specific calculation method is: Among them, rank i refers to the ranking position of the first correct candidate answer to the i-th question, is a list of the top K relevant candidate answers.

7. A device for selecting an answer sentence by fusing hierarchical capsules with multi-view information, the device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when loaded into the processor, implements the method for selecting an answer sentence by fusing hierarchical capsules with multi-view information as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multi-view fused answer selection method for reading understanding choice questions

    CN111339281A

  • Question-answer matching method based on BERT model and comparison aggregation framework

    CN112328767A