A method and system for intelligent question answering based on large model
Through the intelligent question and answer method based on large models, using word segmentation and context embedding, clustering and reconstruction technology, combined with attention interaction, the accuracy shortcomings of traditional intelligent question and answer systems are solved, and the accuracy of question and answer is significantly improved.
Patent Information
- Application Number
- CN202410057741.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-12
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-01-12
AI Technical Summary
Existing intelligent question answering methods have shortcomings in accuracy. In particular, the traditional knowledge graph question answering system has difficulty in accurately feeding back the answers to questions in terms of entity relationship extraction and matching, resulting in low accuracy of question answering.
Using an intelligent question and answer method based on a large model, the question text is obtained for word segmentation and context embedding, word context clustering and text reconstruction are performed, and a word embedding matrix of the answer corpus and the target reconstructed text is constructed for attention interaction and similarity calculation. degree to determine the answer.
It improves the accuracy of text vector generation, eliminates the anisotropy of text vectors, comprehensively considers the relevant information between the answer corpus and the target reconstructed text, and significantly improves the accuracy of question and answer.
Smart Images

Figure CN117874202B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent question answering technology, and in particular to an intelligent question answering method and system based on a large model. Background Art
[0002] In recent years, with the rapid development of information technology, the continuous development and advancement of artificial intelligence (AI), big data technology (BDT) and "Internet +" practice, the amount of data in various modes has increased exponentially. Especially with the popularization of various network applications, different types of data such as text, pictures, and videos can be obtained by users from different channels. People's demand for fast and accurate information is becoming more and more urgent, and the question-answering system can obtain information through unstructured data or structured data to answer questions, becoming an important branch and emerging research hotspot in the field of artificial intelligence and information retrieval.
[0003] Existing intelligent question-answering methods include question-answering systems based on knowledge graph embedding. The core idea is to represent each predicate and entity as a low-dimensional vector, and jointly restore the core entity and predicate embedding representation of the question in the KG embedding space. Through joint distance measurement, the closest fact of the obtained vector in the KG is calculated and returned as the answer. However, the amount of calculation is relatively large and the accuracy is also low. It also includes a convolutional network variant based on ConvNet, which infers sentence similarity by integrating the differences between multiple convolutions at different scales. However, the limitations of labeled data limit the performance of the model. Therefore, traditional knowledge graph question-answering has two problems: entity relationships cannot be correctly extracted or entity relationships cannot be matched in the knowledge graph, resulting in the question-answering system being unable to effectively feedback the answer to the question and the accuracy of the question-answering is low. Summary of the invention
[0004] The present invention provides a large-model-based intelligent question-answering method and system, the main purpose of which is to solve the problem of low accuracy of intelligent question-answering.
[0005] To achieve the above object, the present invention provides an intelligent question answering method based on a large model, comprising:
[0006] Obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector of each segmentation context in the segmentation context set;
[0007] Performing word embedding clustering on the word segmentation context set according to the embedding vector to obtain context clustering clusters, calculating the probability distribution of each word segmentation context in the word segmentation context set in the context clustering clusters, and generating a word context vector for each word segmentation context according to the probability distribution;
[0008] The probability distribution of each word segment context in the context cluster is calculated using the following formula:
[0009]
[0010] Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter;
[0011] Constructing a text vector of the question text according to the word context vector, performing anisotropic disambiguation on the text vector to obtain a target vector of the question text, and performing text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text;
[0012] Obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text;
[0013] The similarity between the target reconstructed text and the answer corpus is calculated according to the interaction matrix, and the target answer corpus corresponding to the question text is determined according to the similarity.
[0014] Optionally, calculating the embedding vector of each segmentation context in the segmentation context set includes:
[0015] Convert each segmentation context in the segmentation context set into a context vector;
[0016] The context vector is embedded and encoded using a pre-trained encoding language model to obtain an embedding vector of each segmentation context in the segmentation context set.
[0017] Optionally, constructing a text vector of the question text according to the word context vector includes:
[0018] Calculating the inverse document frequency of the word segmentation context corresponding to each of the word context vectors in the word segmentation context set;
[0019] Multiplying the inverse document frequency by the word context vector to obtain a frequency vector;
[0020] The frequency vectors are vector-concatenated to obtain a text vector of the question text.
[0021] Optionally, performing anisotropic disambiguation on the text vector to obtain a target vector of the question text includes:
[0022] Decomposing the text vector into a word segmentation vector set, and calculating the covariance matrix corresponding to the word segmentation vector set;
[0023] Converting the covariance matrix into a unit matrix to obtain a unit covariance matrix;
[0024] Performing singular value decomposition on the unit covariance matrix to obtain a decomposition matrix;
[0025] Performing a linear transformation on the word segmentation vector set according to the decomposition matrix to obtain a transformation vector;
[0026] The word segmentation vector set is linearly transformed using the following formula to obtain a transformation vector:
[0027]
[0028] in, Represents the transformation vector corresponding to the lth word segmentation vector in the word segmentation vector set, y l represents the lth word segmentation vector in the word segmentation vector set, μ represents the expectation between the word segmentation vector set, Λ represents the positive diagonal matrix in the decomposition matrix, and U represents the orthogonal matrix in the decomposition matrix;
[0029] A target vector of the question text is constructed according to the transformation vector.
[0030] Optionally, the text reconstruction of the question text according to the target vector to obtain a target reconstructed text of the question text includes:
[0031] Using a pre-built semantic encoder to semantically encode the question text to obtain encoding vectors of different encoding layers;
[0032] Performing nonlinear mapping on the encoding vector to obtain a mapping encoding vector;
[0033] Performing vector superposition on the mapping coding vectors to obtain a fused semantic vector of the question text;
[0034] A fully connected activation calculation is performed on the fused semantic vector to obtain a target reconstructed text of the question text.
[0035] Optionally, respectively constructing word embedding matrices corresponding to the answer corpus and the target reconstructed text includes:
[0036] Performing text preprocessing on the answer corpus and the target reconstructed text to obtain a clean text;
[0037] Performing character segmentation and character filling on the clean text to obtain text characters;
[0038] The text characters are mapped into character vectors, and a word embedding matrix corresponding to the answer corpus and the target reconstructed text is generated according to the character vectors.
[0039] Optionally, performing attention interaction on the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text includes:
[0040] Calculate a similarity matrix between the answer corpus and the target reconstructed text according to the word embedding matrix;
[0041] Performing row activation operations and column activation operations on the similarity matrix respectively to obtain an activation matrix;
[0042] The activation matrix is matrix-multiplied by the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text.
[0043] Optionally, calculating the similarity between the target reconstructed text and the answer corpus according to the interaction matrix includes:
[0044] Performing residual connection on the interaction matrix using a pre-built feedforward neural network to obtain residual features;
[0045] Calculate the fusion features of the interaction matrix according to the residual features;
[0046] The fusion feature of the interaction matrix is calculated using the following formula:
[0047] N=[u a ;u b ;u a -u b ;u a *u b ]
[0048] Among them, N represents the fusion feature, u a Represents the residual features corresponding to the answer corpus in the residual features, u b represents the residual feature corresponding to the target reconstructed text in the residual feature, and * represents the vector cross product symbol;
[0049] The fused features are fully connected to obtain the similarity between the target reconstructed text and the answer corpus.
[0050] Optionally, the fully connecting the fused features to obtain the similarity between the target reconstructed text and the answer corpus includes:
[0051] Performing a first full connection on the fused features to obtain a first fully connected vector;
[0052] Performing activation calculation on the first fully connected vector to obtain an activation vector;
[0053] Performing a second full connection on the activation vector to obtain a second fully connected vector;
[0054] The second fully connected vector is normalized to obtain the similarity between the target reconstructed text and the answer corpus.
[0055] In order to solve the above problems, the present invention also provides an intelligent question-answering system based on a large model, the system comprising:
[0056] An embedding vector calculation module is used to obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector for each segmentation context in the segmentation context set;
[0057] A word context vector generation module is used to perform word embedding clustering on the word segmentation context set according to the embedding vector to obtain a context clustering cluster, calculate the probability distribution of each word segmentation context in the word segmentation context set in the context clustering cluster, and generate a word context vector for each word segmentation context according to the probability distribution;
[0058] The probability distribution of each word segment context in the context cluster is calculated using the following formula:
[0059]
[0060] Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter;
[0061] A text reconstruction module, used to construct a text vector of the question text according to the word context vector, perform anisotropic disambiguation on the text vector to obtain a target vector of the question text, and perform text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text;
[0062] A word embedding matrix attention interaction module is used to obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text;
[0063] The target answer corpus determination module is used to calculate the similarity between the target reconstructed text and the answer corpus according to the interaction matrix, and determine the target answer corpus corresponding to the question text according to the similarity.
[0064] The embodiment of the present invention calculates the embedding vector of each segmentation context by searching the segmentation context set corresponding to the text segmentation of the question text, and can calculate the word context vector of each text segmentation in different contexts, so that the text segmentation integrates different contexts and improves the accuracy of text vector generation; constructs a text vector according to the word context vector, performs anisotropic disambiguation on the text vector, and reconstructs the question text to obtain a target reconstructed text, which can eliminate the anisotropy of the text vector and reconstruct a target reconstructed text with more accurate context and semantics; constructs a word embedding matrix corresponding to the answer corpus and the target reconstructed text, and performs attention interaction on the word embedding matrix, which can comprehensively consider the relevant information between the answer corpus and the target reconstructed text, so that the feature information in the interaction matrix is more comprehensive; calculates the similarity between the target reconstructed text and the answer corpus according to the interaction matrix, which can comprehensively consider the relevant information between the answer corpus and the target reconstructed text, and obtains a more accurate target answer corpus. Therefore, the intelligent question answering method and system based on a large model proposed by the present invention can solve the problem of low accuracy of intelligent question answering. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A schematic diagram of a flow chart of an intelligent question-answering method based on a large model provided by an embodiment of the present invention;
[0066] Figure 2 A schematic diagram of a process for constructing a text vector of a question text based on a word context vector provided by an embodiment of the present invention;
[0067] Figure 3 A schematic diagram of a process for constructing a word embedding matrix corresponding to an answer corpus and a target reconstructed text provided in an embodiment of the present invention;
[0068] Figure 4 A functional module diagram of a large-model-based intelligent question-answering system provided in accordance with an embodiment of the present invention.
[0069] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0070] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0071] The embodiment of the present application provides an intelligent question-and-answer method based on a large model. The execution subject of the intelligent question-and-answer method based on a large model includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided in the embodiment of the present application. In other words, the intelligent question-and-answer method based on a large model can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0072] Reference Figure 1 FIG. 1 is a flow chart of an intelligent question-answering method based on a large model provided by an embodiment of the present invention. In this embodiment, the intelligent question-answering method based on a large model includes:
[0073] S1. Obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector of each segmentation context in the segmentation context set.
[0074] In the embodiment of the present invention, the question text is the inquiry text input by the user, and each question text can be divided into multiple text segmentation words, but the text segmentation words may have different contexts in different texts. For example, in "the baggage in this crosstalk is not well shaken" and "the baggage on him is too heavy", "baggage" has different contexts and different meanings. Therefore, the segmentation context that may be included in each text analysis can be found in the pre-constructed corpus. Among them, the corpus includes multiple segmentation contexts corresponding to the preset corpus.
[0075] Specifically, embodiments of the present invention can use text segmentation methods such as stuttering word segmentation, shortest path word segmentation, recurrent neural network word segmentation, and n-gram word segmentation to segment the question text to obtain text segmentations, perform consistency matching in the corpus through the text segmentations, obtain the corpus matched by each text segmentation, and extract the corresponding context set of the corpus as the segmentation context set of each text segmentation.
[0076] In one embodiment, a pre-trained language model (Bidirectional Encoder Representation from Transformers, BERT) may be used to perform embedding vector encoding on each segmentation context to obtain an embedding vector.
[0077] In the embodiment of the present invention, the step of calculating the embedding vector of each segmentation context in the segmentation context set includes:
[0078] Convert each segmentation context in the segmentation context set into a context vector;
[0079] The context vector is embedded and encoded using a pre-trained encoding language model to obtain an embedding vector of each segmentation context in the segmentation context set.
[0080] In detail, by calculating the embedding vector of each word segmentation context, the vector representation of each word segmentation context can be obtained, and then the text vector of the question text can be constructed to perform semantic disambiguation on the question text and improve the accuracy of intelligent question answering.
[0081] S2. Perform word embedding clustering on the word segmentation context set according to the embedding vector to obtain context clustering clusters, calculate the probability distribution of each word segmentation context in the word segmentation context set in the context clustering clusters, and generate a word context vector for each word segmentation context according to the probability distribution.
[0082] In the embodiment of the present invention, word embedding clustering is to obtain a preset number of context clusters after fuzzy clustering of the word segment context set, and use the cluster center of each context cluster as the multi-context representation of each text segment.
[0083] It should be noted that fuzzy clustering belongs to soft clustering. By performing word embedding clustering on the word segment context set through soft clustering, it can be ensured that each word segment context belongs to each context clustering cluster with a certain probability, so that each word segment context has a different probability distribution in the context clustering cluster.
[0084] In the embodiment of the present invention, the probability distribution of each segmentation context in the context cluster is calculated using the following formula:
[0085]
[0086] Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter.
[0087] In the embodiment of the present invention, the probability that each word context belongs to a different context cluster can be calculated through probability distribution, and a plurality of word context vectors in different contexts are generated through probability distribution.
[0088] Specifically, the embodiment of the present invention multiplies the embedding vector corresponding to each segmentation context by the corresponding probability distribution to obtain the word context vector of each segmentation context.
[0089] In detail, a word context vector for each word segmentation context can be generated according to the probability distribution, so that the word context vector representation of each text word segmentation in different contexts can be obtained, so that text word segmentation can integrate different contexts and improve the accuracy of text vector generation.
[0090] S3. Construct a text vector of the question text according to the word context vector, perform anisotropic disambiguation on the text vector to obtain a target vector of the question text, and perform text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text.
[0091] In the embodiment of the present invention, the text vector is a vector that represents the entire question text. Different contexts can be integrated through the word context vector to avoid ambiguity between the upper and lower contexts, thereby improving the accuracy of text vector calculation.
[0092] In the embodiment of the present invention, refer to Figure 2 As shown, the step of constructing the text vector of the question text according to the word context vector includes:
[0093] S21, calculating the inverse document frequency of the word segmentation context corresponding to each of the word context vectors in the word segmentation context set;
[0094] S22, multiplying the inverse document frequency by the word context vector to obtain a frequency vector;
[0095] S23, performing vector concatenation on the frequency vectors to obtain a text vector of the question text.
[0096] In the embodiment of the present invention, the inverse document frequency is the inverse of the frequency of each segment context in the segment context set. The importance of each segment context is reflected by the inverse document frequency. In the segment context set, the importance of the segment context may be proportional to the number of occurrences, but may also be inversely proportional to the frequency of occurrence in the segment context set. Therefore, the importance of each segment context in the question text can be reflected by the inverse document frequency, thereby obtaining a more accurate text vector.
[0097] Specifically, by multiplying the inverse document frequency with the word context vector, the importance of each text word in different word segmentation contexts can be obtained, so that different word segmentation contexts can be comprehensively considered to obtain a text vector with more accurate context.
[0098] In the embodiment of the present invention, since the text vector is calculated using the embedding vector generated by the pre-trained language model, but since the distribution of the embedding vector does not satisfy the Gaussian distribution, the generated text vector will have an anisotropy problem. Therefore, the text vector can be anisotropically disambiguated to obtain a more accurate target vector.
[0099] In the embodiment of the present invention, performing anisotropic disambiguation on the text vector to obtain a target vector of the question text includes:
[0100] Decomposing the text vector into a word segmentation vector set, and calculating the covariance matrix corresponding to the word segmentation vector set;
[0101] Converting the covariance matrix into a unit matrix to obtain a unit covariance matrix;
[0102] Performing singular value decomposition on the unit covariance matrix to obtain a decomposition matrix;
[0103] Performing a linear transformation on the word segmentation vector set according to the decomposition matrix to obtain a transformation vector;
[0104] A target vector of the question text is constructed according to the transformation vector.
[0105] In detail, the word segmentation vector set is composed of the frequency vectors that make up the text vector. The covariance matrix is obtained through the word segmentation vector set, and the covariance matrix can be converted into W T ∑W, and converted into a unit matrix to obtain a unit covariance matrix. Therefore, the unit covariance matrix is a positive definite symmetric matrix. By performing singular value decomposition on the positive definite symmetric matrix, a decomposition matrix W composed of an orthogonal matrix and a positive diagonal matrix is obtained. Then, the word segmentation vector is converted into a target vector that conforms to the Gaussian distribution through the decomposition matrix to eliminate the anisotropy of the text vector.
[0106] In one embodiment, the word segmentation vector set is linearly transformed using the following formula to obtain a transformation vector:
[0107]
[0108] in, Represents the transformation vector corresponding to the lth word segmentation vector in the word segmentation vector set, y l represents the lth word segmentation vector in the word segmentation vector set, μ represents the expectation between the word segmentation vector set, Λ represents the positive diagonal matrix in the decomposition matrix, and U represents the orthogonal matrix in the decomposition matrix.
[0109] In the embodiment of the present invention, text reconstruction is to reconstruct a target reconstructed text with more accurate context and semantics based on the target vector, so as to improve the accuracy of subsequent determination of the target answer corpus.
[0110] In the embodiment of the present invention, the text reconstruction of the question text according to the target vector to obtain the target reconstructed text of the question text includes:
[0111] Using a pre-built semantic encoder to semantically encode the question text to obtain encoding vectors of different encoding layers;
[0112] Performing nonlinear mapping on the encoding vector to obtain a mapping encoding vector;
[0113] Performing vector superposition on the mapping coding vectors to obtain a fused semantic vector of the question text;
[0114] A fully connected activation calculation is performed on the fused semantic vector to obtain a target reconstructed text of the question text.
[0115] Among them, the semantic encoder can be the BERT model preset in the above S1. The semantic encoder contains multiple embedded coding layers in BERT to obtain encoding vectors of different embedded coding layers, and then map the encoding vectors of different dimensions to the vector space of the same dimension through linear mapping to further extract the semantic features in the question text. Specifically, the encoding vectors can be nonlinearly mapped using a nonlinear function.
[0116] In an embodiment of the present invention, vector superposition is to superimpose elements of the same channel of the mapped coding vector to obtain a fused semantic vector that fuses multiple levels of coding features. Therefore, full connection activation is performed through the fully connected layer and the activation function, and the text corresponding to the fused semantic vector is output to obtain the target reconstructed text.
[0117] S4. Obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text.
[0118] In an embodiment of the present invention, the answer corpus is the answer text corresponding to the preset question text. It should be noted that the answer corpus can be the preset answers to multiple existing questions, for example, the corpus corresponding to multiple preset question texts such as questions in professional knowledge, questions in the Internet, hot issues, historical issues, etc.
[0119] Specifically, see Figure 3 As shown, the word embedding matrices corresponding to the answer corpus and the target reconstructed text are respectively constructed, including:
[0120] S31, performing text preprocessing on the answer corpus and the target reconstructed text to obtain a clean text;
[0121] S32, performing character segmentation and character filling on the clean text to obtain text characters;
[0122] S33, mapping the text characters into character vectors, and generating a word embedding matrix corresponding to the answer corpus and the target reconstructed text according to the character vectors.
[0123] Among them, text preprocessing is to remove punctuation marks and meaningless characters to obtain clean text with each character having meaning. Then use the preset character segmentation tool to segment the clean text into characters, for example, the pynlpir tool, and character filling is to use the preset special symbols to fix the segmented characters to the same length to obtain a word embedding matrix for subsequent calculations, wherein the word embedding matrix can be a 1*n row matrix.
[0124] Specifically, a pre-trained model such as word2vec can be used to map each text character into a character vector of fixed length, and the answer corpus and the word embedding matrix of the target reconstructed text can be generated through the character vector.
[0125] In another embodiment of the present invention, attention interaction comprehensively considers the semantic relevance between the answer corpus and the target reconstructed text itself, thereby improving the comprehensiveness of the information in the word embedding matrix.
[0126] In the embodiment of the present invention, the step of performing attention interaction on the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text includes:
[0127] Calculate a similarity matrix between the answer corpus and the target reconstructed text according to the word embedding matrix;
[0128] Performing row activation operations and column activation operations on the similarity matrix respectively to obtain an activation matrix;
[0129] The activation matrix is matrix-multiplied by the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text.
[0130] In an embodiment of the present invention, the similarity matrix contains the cosine similarity between the character vectors in each word embedding matrix. For example, the matrix element in the a-th row and b-th column of the similarity matrix is the similarity between the a-th character vector in the answer corpus and the b-th character vector in the target reconstructed text.
[0131] It should be noted that the activation matrix is matrix multiplied with the word embedding matrix, and the word embedding matrix corresponding to the answer corpus and the target reconstructed text is multiplied with an activation matrix respectively. For example, the word embedding matrix of the answer corpus is multiplied with the activation matrix obtained by the row activation operation, and the word embedding matrix corresponding to the target reconstructed text is multiplied with the activation matrix obtained by the column activation operation.
[0132] In the embodiment of the present invention, the relevant information between the answer corpus and the target reconstructed text can be comprehensively considered by performing attention interaction, so that the feature information in the interaction matrix is more comprehensive, which is conducive to improving the accuracy of subsequent similarity calculation.
[0133] S5. Calculate the similarity between the target reconstructed text and the answer corpus according to the interaction matrix, and determine the target answer corpus corresponding to the question text according to the similarity.
[0134] In the embodiment of the present invention, the similarity is the feature similarity between the target reconstructed text and each answer corpus calculated based on the interaction matrix. The greater the feature similarity, the greater the possibility that the answer corpus is the target answer corpus. Therefore, the target answer corpus corresponding to the question text can be determined based on the similarity.
[0135] In the embodiment of the present invention, the calculating the similarity between the target reconstructed text and the answer corpus according to the interaction matrix includes:
[0136] Performing residual connection on the interaction matrix using a pre-built feedforward neural network to obtain residual features;
[0137] Calculate the fusion features of the interaction matrix according to the residual features;
[0138] The fused features are fully connected to obtain the similarity between the target reconstructed text and the answer corpus.
[0139] In an embodiment of the present invention, the feedforward neural network includes a two-layer feedforward network and a normalization layer. The feedforward neural network is used to perform two linear transformations and activations on the interaction matrix. Finally, residual connections and layer normalization are performed on the results of the linear transformation and the first layer normalization to obtain residual features.
[0140] It should be noted that the residual features include the residual features corresponding to the interaction matrix of the answer corpus and the residual features corresponding to the interaction matrix of the target reconstructed text, that is, the residual features corresponding to the answer corpus and the residual features corresponding to the target reconstructed text
[0141] Specifically, the fusion feature is to fuse the features of the interaction matrix of the answer corpus and the target reconstructed text to obtain the fusion feature of the fused answer corpus and the target reconstructed text.
[0142] In detail, the fusion feature of the interaction matrix is calculated using the following formula:
[0143] N=[u a ;u b ;u a -u b ;u a *u b ]
[0144] Among them, N represents the fusion feature, u a Represents the residual features corresponding to the answer corpus in the residual features, u b represents the residual feature corresponding to the target reconstructed text in the residual feature, and * represents the vector cross product symbol.
[0145] Preferably, before calculating the fusion feature, the residual feature can be firstly transformed into one dimension, so as to perform vector concatenation on the residual feature to obtain the fusion feature.
[0146] In the embodiment of the present invention, the step of fully connecting the fusion features to obtain the similarity between the target reconstructed text and the answer corpus includes:
[0147] Performing a first full connection on the fused features to obtain a first fully connected vector;
[0148] Performing activation calculation on the first fully connected vector to obtain an activation vector;
[0149] Performing a second full connection on the activation vector to obtain a second fully connected vector;
[0150] The second fully connected vector is normalized to obtain the similarity between the target reconstructed text and the answer corpus.
[0151] In the embodiment of the present invention, the fusion features are fully connected through two layers of fully connected networks, wherein the dimensions in each layer of the fully connected network are inconsistent, so as to improve the dimensional scale of the full connection.
[0152] Specifically, different activation algorithms can be used to perform activation calculation on the first fully connected vector and normalize the second fully connected vector, so as to finally output the similarity between the target reconstructed text and the answer corpus.
[0153] In an embodiment of the present invention, by calculating the similarity between the target reconstructed text and the answer corpus through the interaction matrix, the interaction information and semantic information between the target reconstructed text and the answer corpus can be comprehensively considered, thereby more accurately calculating the similarity between the target reconstructed text and the answer corpus.
[0154] In the embodiment of the present invention, the answer corpus with the greatest similarity to the target reconstructed text is selected as the target answer corpus corresponding to the question text, and the target answer corpus is used as the answer text of the question text.
[0155] like Figure 4 , which is a functional module diagram of a large model-based intelligent question-answering system provided in one embodiment of the present invention.
[0156] The intelligent question-answering system 400 based on a large model of the present invention can be installed in an electronic device. According to the functions implemented, the intelligent question-answering system 400 based on a large model can include an embedding vector calculation module 401, a word context vector generation module 402, a text reconstruction module 403, a word embedding matrix attention interaction module 404 and a target answer corpus determination module 405. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0157] In this embodiment, the functions of each module / unit are as follows:
[0158] The embedding vector calculation module 401 is used to obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector for each segmentation context in the segmentation context set;
[0159] The word context vector generating module 402 is used to perform word embedding clustering on the word segmentation context set according to the embedding vector to obtain context clusters, calculate the probability distribution of each word segmentation context in the word segmentation context set in the context clusters, and generate a word context vector for each word segmentation context according to the probability distribution;
[0160] The probability distribution of each word segment context in the context cluster is calculated using the following formula:
[0161]
[0162] Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter;
[0163] The text reconstruction module 403 is used to construct a text vector of the question text according to the word context vector, perform anisotropic disambiguation on the text vector to obtain a target vector of the question text, and perform text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text;
[0164] The word embedding matrix attention interaction module 404 is used to obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text;
[0165] The target answer corpus determination module 405 is used to calculate the similarity between the target reconstructed text and the answer corpus according to the interaction matrix, and determine the target answer corpus corresponding to the question text according to the similarity.
[0166] In detail, each module described in the large model-based intelligent question answering system 400 in the embodiment of the present invention is used in the same manner as described above. Figures 1 to 3 The same technical means are used as the intelligent question answering method based on large models described in the text, and can produce the same technical effects, so I will not go into details here.
[0167] The present invention also provides an electronic device, which may include a processor, a memory, a communication bus and a communication interface, and may also include a computer program stored in the memory and executable on the processor, such as an intelligent question-answering method program based on a large model.
[0168] In some embodiments, the processor may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect the various components of the entire electronic device, and executes or executes the programs or modules stored in the memory (for example, executing the intelligent question-answering method program based on a large model, etc.), and calls the data stored in the memory to execute various functions of the electronic device and process data.
[0169] The memory includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory may be an internal storage unit of an electronic device in some embodiments, such as a mobile hard disk of the electronic device. The memory may also be an external storage device of an electronic device in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory may also include both an internal storage unit of the electronic device and an external storage device. The memory may be used not only to store application software and various types of data installed in the electronic device, such as the code of the intelligent question-answering method program based on a large model, but also to temporarily store data that has been output or is to be output.
[0170] The communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory and at least one processor, etc.
[0171] The communication interface is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user 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 generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0172] The figure only shows an electronic device with components. Those skilled in the art will understand that the structure shown in the figure does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0173] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor through a power management system, so that the power management system can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0174] Specifically, the specific implementation method of the processor for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.
[0175] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or system capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0176] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0177] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0178] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0179] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0180] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0181] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0182] In addition, 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 systems stated in a system claim can also be implemented by one unit or system through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. An intelligent question answering method based on a large model, characterized in that: The method comprises: Obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector of each segmentation context in the segmentation context set; Performing word embedding clustering on the word segmentation context set according to the embedding vector to obtain context clustering clusters, calculating the probability distribution of each word segmentation context in the word segmentation context set in the context clustering clusters, and generating a word context vector for each word segmentation context according to the probability distribution; The probability distribution of each word segment context in the context cluster is calculated using the following formula: Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter; Construct a text vector of the question text according to the word context vector, perform anisotropic disambiguation on the text vector to obtain a target vector of the question text, and perform text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text; performing anisotropic disambiguation on the text vector to obtain the target vector of the question text includes: decomposing the text vector into a word segmentation vector set, calculating a covariance matrix corresponding to the word segmentation vector set; converting the covariance matrix into a unit matrix to obtain a unit covariance matrix; performing singular value decomposition on the unit covariance matrix to obtain a decomposition matrix; performing linear transformation on the word segmentation vector set according to the decomposition matrix to obtain a transformation vector; The word segmentation vector set is linearly transformed using the following formula to obtain a transformation vector: in, Represents the transformation vector corresponding to the lth word segmentation vector in the word segmentation vector set, y l represents the lth word segmentation vector in the word segmentation vector set, μ represents the expectation between the word segmentation vector set, Λ represents the positive diagonal matrix in the decomposition matrix, and U represents the orthogonal matrix in the decomposition matrix; Constructing a target vector of the question text according to the transformation vector; Obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text; The similarity between the target reconstructed text and the answer corpus is calculated according to the interaction matrix, and the target answer corpus corresponding to the question text is determined according to the similarity.
2. The intelligent question-answering method based on a large model as claimed in claim 1, characterized in that: The calculating the embedding vector of each segmentation context in the segmentation context set includes: Convert each segmentation context in the segmentation context set into a context vector; The context vector is embedded and encoded using a pre-trained encoding language model to obtain an embedding vector of each segmentation context in the segmentation context set.
3. The intelligent question answering method based on a large model as claimed in claim 1, characterized in that: The step of constructing a text vector of the question text according to the word context vector comprises: Calculating the inverse document frequency of the word segmentation context corresponding to each of the word context vectors in the word segmentation context set; Multiplying the inverse document frequency by the word context vector to obtain a frequency vector; The frequency vectors are vector-concatenated to obtain a text vector of the question text.
4. The intelligent question answering method based on a large model as claimed in claim 1, characterized in that: The step of reconstructing the question text according to the target vector to obtain a target reconstructed text of the question text includes: Using a pre-built semantic encoder to semantically encode the question text to obtain encoding vectors of different encoding layers; Performing nonlinear mapping on the encoding vector to obtain a mapping encoding vector; Performing vector superposition on the mapping coding vectors to obtain a fused semantic vector of the question text; A fully connected activation calculation is performed on the fused semantic vector to obtain a target reconstructed text of the question text.
5. The intelligent question answering method based on a large model as claimed in claim 1, characterized in that: The step of respectively constructing word embedding matrices corresponding to the answer corpus and the target reconstructed text includes: Performing text preprocessing on the answer corpus and the target reconstructed text to obtain a clean text; Performing character segmentation and character filling on the clean text to obtain text characters; The text characters are mapped into character vectors, and a word embedding matrix corresponding to the answer corpus and the target reconstructed text is generated according to the character vectors.
6. The large model-based intelligent question answering method according to claim 1, characterized in that: The performing attention interaction on the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text includes: Calculate a similarity matrix between the answer corpus and the target reconstructed text according to the word embedding matrix; Performing row activation operations and column activation operations on the similarity matrix respectively to obtain an activation matrix; The activation matrix is matrix-multiplied by the word embedding matrix to obtain an interaction matrix between the answer corpus and the target reconstructed text.
7. The intelligent question answering method based on a large model as claimed in claim 1, characterized in that: The calculating the similarity between the target reconstructed text and the answer corpus according to the interaction matrix includes: Performing residual connection on the interaction matrix using a pre-built feedforward neural network to obtain residual features; Calculate the fusion features of the interaction matrix according to the residual features; The fusion feature of the interaction matrix is calculated using the following formula: N=[u a ;u b ;u a -u b ;u a *u b ] Among them, N represents the fusion feature, u a Represents the residual features corresponding to the answer corpus in the residual features, u b represents the residual feature corresponding to the target reconstructed text in the residual feature, and * represents the vector cross product symbol; The fused features are fully connected to obtain the similarity between the target reconstructed text and the answer corpus.
8. The intelligent question-answering method based on a large model as claimed in claim 7, characterized in that: The fully connecting the fusion features to obtain the similarity between the target reconstructed text and the answer corpus includes: Performing a first full connection on the fused features to obtain a first fully connected vector; Performing activation calculation on the first fully connected vector to obtain an activation vector; Performing a second full connection on the activation vector to obtain a second fully connected vector; The second fully connected vector is normalized to obtain the similarity between the target reconstructed text and the answer corpus.
9. An intelligent question-answering system based on a large model, characterized in that: The system comprises: An embedding vector calculation module is used to obtain a question text, segment the question text to obtain text segmentations, search a segmentation context set corresponding to each text segmentation in a pre-built corpus, and calculate an embedding vector for each segmentation context in the segmentation context set; A word context vector generation module is used to perform word embedding clustering on the word segmentation context set according to the embedding vector to obtain a context clustering cluster, calculate the probability distribution of each word segmentation context in the word segmentation context set in the context clustering cluster, and generate a word context vector for each word segmentation context according to the probability distribution; The probability distribution of each word segment context in the context cluster is calculated using the following formula: Among them, p i,k represents the probability distribution of the i-th word segment context in the k-th context cluster, C represents the total number of context clusters, c k 、c j Respectively represent the cluster centers of the kth and jth context clusters, x i represents the clustering vector corresponding to the i-th segmentation context, and m represents the preset clustering parameter; A text reconstruction module is used to construct a text vector of the question text according to the word context vector, perform anisotropic disambiguation on the text vector to obtain a target vector of the question text, and perform text reconstruction on the question text according to the target vector to obtain a target reconstructed text of the question text; the anisotropic disambiguation on the text vector to obtain the target vector of the question text includes: decomposing the text vector into a word segmentation vector set, calculating the covariance matrix corresponding to the word segmentation vector set; converting the covariance matrix into a unit matrix to obtain a unit covariance matrix; performing singular value decomposition on the unit covariance matrix to obtain a decomposition matrix; performing linear transformation on the word segmentation vector set according to the decomposition matrix to obtain a transformation vector; The word segmentation vector set is linearly transformed using the following formula to obtain a transformation vector: in, Represents the transformation vector corresponding to the lth word segmentation vector in the word segmentation vector set, y l represents the lth word segmentation vector in the word segmentation vector set, μ represents the expectation between the word segmentation vector set, Λ represents the positive diagonal matrix in the decomposition matrix, and U represents the orthogonal matrix in the decomposition matrix; Constructing a target vector of the question text according to the transformation vector; A word embedding matrix attention interaction module is used to obtain a pre-constructed answer corpus, respectively construct word embedding matrices corresponding to the answer corpus and the target reconstructed text, perform attention interaction on the word embedding matrices, and obtain an interaction matrix between the answer corpus and the target reconstructed text; The target answer corpus determination module is used to calculate the similarity between the target reconstructed text and the answer corpus according to the interaction matrix, and determine the target answer corpus corresponding to the question text according to the similarity.
Citation Information
Patent Citations
Intelligent question answering method and device
CN109033318A
Implementation method and device for viewpoint type machine reading understanding
CN110390001A
