A natural language recognition and analysis method based on universal large model technology

By calculating the attention weight value and target representation value between word vectors and dynamically adjusting the convolution kernel size, the problem of instability and recognition accuracy caused by improper setting of the convolution kernel size during the training process of the convolutional neural network is solved. Improved accuracy and reliability of natural language recognition.

CN118520872BActive Publication Date: 2024-10-01SHANDONG SHENGDE INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410993250.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-10-01
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

In the existing natural language recognition technology based on general large models, the convolution kernel size of the convolutional neural network is set to the default or empirical value during the training process, resulting in unstable models and poor generalization ability and recognition accuracy.

Method used

By obtaining the attention weight values ​​between word vectors in the training text matrix, calculating the target representation value, dynamically adjusting the convolution kernel size, building a convolutional neural network model for training, and improving the generalization ability of the model.

Benefits of technology

It improves the accuracy and reliability of natural language recognition and enhances the model's recognition ability of the text matrix to be recognized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118520872B_ABST
    Figure CN118520872B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of natural language recognition, and in particular to a natural language recognition and analysis method based on a general large model technology. The method comprises: obtaining a training text matrix; obtaining an attention weight value between any two word vectors in the training text matrix according to each word vector in the training text matrix, obtaining a target representation value corresponding to each word vector according to the attention weight value, and obtaining a convolution kernel size corresponding to each word vector according to the target representation value; constructing a convolution neural network model, inputting each word vector into the convolution neural network model, performing a convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and completing the training of the convolution neural network model to obtain a target network model; obtaining a text matrix to be recognized, inputting the text matrix to be recognized into the target network model, and outputting a recognition result of the text matrix to be recognized. The present invention can improve the accuracy of recognizing the text matrix to be recognized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language recognition, and in particular to a natural language recognition and analysis method based on a general large model technology. Background Art

[0002] Natural Language Understanding (NLU) is an important branch in the field of artificial intelligence. It enables computers to recognize and process human voice input, so as to perform corresponding operations or provide services, that is, it aims to enable computers to understand and use natural language like humans. With the continuous development of artificial intelligence technology and the increasing requirements for the efficiency and accuracy of natural language recognition, natural language recognition is usually achieved based on general large models, that is, general large models are usually widely used in the field of natural language recognition; in addition, the general large model is a model based on deep learning, which is a neural network trained on large-scale data sets to achieve the understanding and generation of human language.

[0003] The specific process of natural language recognition based on the current general large model is to first obtain a text data sequence for neural network training and construct a neural network model, for example, a CNN convolutional neural network can be constructed, and finally the convolutional neural network is trained and tested based on the text data sequence for neural network training to obtain a trained network model, and then the trained network model is used to realize the recognition of natural language; in addition, the constructed convolutional neural network model includes a convolutional layer, and the convolutional layer contains a convolutional kernel. The size of the convolutional kernel directly affects the receptive field and feature extraction of the network model. In the process of network training, the size of the convolutional kernel is usually set to a default value or an empirical value. The size of the convolutional kernel determined in this way will cause the convolutional neural network to be unstable during the training process, and will also cause the performance or generalization ability of the trained network model to be weak, and will also cause the trained network model to have poor accuracy or reliability for natural language recognition. Therefore, how to adaptively obtain or dynamically adjust the size of the convolutional kernel during the training process of the convolutional neural network is an urgent problem to be solved. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a natural language recognition and analysis method based on a general large model technology, and the technical solution adopted is as follows:

[0005] An embodiment of the present invention provides a natural language recognition and analysis method based on a general large model technology, comprising the following steps:

[0006] Get the training text matrix corresponding to the training text data sequence;

[0007] According to each word vector in the training text matrix, obtaining an attention weight value between any two word vectors in the training text matrix;

[0008] According to the attention weight value, the target representation value corresponding to each word vector is obtained;

[0009] According to the target representation value, obtain the convolution kernel size corresponding to each word vector;

[0010] Constructing a convolutional neural network model, inputting each word vector into the convolutional neural network model, performing a convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and completing the training of the convolutional neural network model to obtain the trained convolutional neural network model, and recording the trained convolutional neural network model as the target network model;

[0011] A text matrix to be recognized corresponding to the text data sequence to be recognized is obtained, and the text matrix to be recognized is input into the target network model, and the target network model outputs a recognition result of the text matrix to be recognized.

[0012] Preferably, the method for obtaining the training text matrix includes:

[0013] Obtain a text data sequence for convolutional neural network training and record it as a training text data sequence;

[0014] Perform word embedding conversion on the training text data sequence to obtain a training text matrix corresponding to the training text data sequence, wherein the training text matrix is ​​composed of word vectors corresponding to each training text data subsequence obtained by word segmentation of the training text data sequence, and the position of the word vector in the training text matrix corresponds to the position of the training text data subsequence corresponding to the word vector in the training text data sequence.

[0015] Preferably, the method for obtaining the attention weight value between any two word vectors in the training text matrix includes:

[0016] For the ath word vector and the bth word vector in the training text matrix, a is not equal to b:

[0017] A dot product operation is performed on the a-th word vector and the b-th word vector, and a normalized value of a value obtained by the dot product operation is recorded as an attention weight value between the a-th word vector and the b-th word vector.

[0018] Preferably, the method for obtaining the target representation value corresponding to each word vector according to the attention weight value includes:

[0019] Obtaining a neighborhood word vector set corresponding to each word vector and a non-neighborhood word vector set corresponding to each word vector;

[0020] For any word vector c in the training text matrix:

[0021] The attention weight value set constructed by the attention weight value between the word vector c and each word vector in its corresponding neighborhood word vector set is recorded as the first attention weight value set corresponding to the word vector c, and the set constructed by the attention weight value between the word vector c and each word vector in its corresponding non-neighborhood word vector set is recorded as the second attention weight value set corresponding to the word vector c;

[0022] According to the first attention weight value set and the second attention weight value set, a target representation value corresponding to the word vector c is obtained.

[0023] Preferably, the method for obtaining the neighborhood word vector set corresponding to each word vector includes:

[0024] For the word vector c:

[0025] In the training text matrix, a set constructed by a preset number of consecutive word vectors located on the left side of the word vector c and adjacent to the word vector c is recorded as a first word vector set corresponding to the word vector c, and a set constructed by a preset number of consecutive word vectors located on the right side of the word vector c and adjacent to the word vector c is recorded as a second word vector set corresponding to the word vector c;

[0026] If the word vectors on the left side of the word vector c are less than the preset number, the set constructed by all the word vectors on the left side of the word vector c is recorded as the first word vector set corresponding to the word vector c; if the word vectors on the right side of the word vector c are less than the preset number, the set constructed by all the word vectors on the right side of the word vector c is recorded as the second word vector set corresponding to the word vector c;

[0027] The new set constructed by the first word vector set and the second word vector set is recorded as the neighborhood word vector set corresponding to the word vector c.

[0028] Preferably, a method for obtaining a set of non-neighborhood word vectors corresponding to each word vector includes:

[0029] For the word vector c:

[0030] In the training text matrix, a set constructed by all word vectors except the word vectors in the neighborhood word vector set corresponding to the word vector c is recorded as the non-neighborhood word vector set corresponding to the word vector c.

[0031] Preferably, the method for obtaining the target representation value corresponding to the word vector c according to the first attention weight value set and the second attention weight value set includes:

[0032] Obtaining a first short-range dependency representation value corresponding to the word vector c according to the mean of all attention weight values ​​in the first attention weight value set and the mean of all attention weight values ​​in the second attention weight value set;

[0033] Obtaining a second short-range dependency representation value corresponding to the word vector c according to the attention weight values ​​in the first attention weight value set, the attention weight values ​​in the second attention weight value set, the maximum attention weight value in the first attention weight value set, and the maximum attention weight value in the second attention weight value set;

[0034] A weighted sum is performed on the first short-range dependency representation value and the second short-range dependency representation value, and the value obtained by the weighted sum is recorded as the target representation value corresponding to the word vector c.

[0035] Preferably, the method for obtaining the first short-range dependency representation value corresponding to the word vector c includes:

[0036] Obtaining the mean of all attention weight values ​​in the first attention weight value set, and recording it as a first mean; obtaining the mean of all attention weight values ​​in the second attention weight value set, and recording it as a second mean;

[0037] The normalized value of the absolute value of the difference between the first mean and the second mean is recorded as the first short-range dependency representation value corresponding to the word vector c.

[0038] Preferably, the method for obtaining the second short-range dependency representation value corresponding to the word vector c includes:

[0039] Obtaining a preset first threshold;

[0040] In the first attention weight value set, the number of attention weight values ​​not less than the preset first threshold is obtained by counting and recorded as a first quantity representation value; in the second attention weight value set, the number of attention weight values ​​not less than the preset first threshold is obtained by counting and recorded as a second quantity representation value;

[0041] The normalized value of the ratio of the first quantity representation value to the second quantity representation value is recorded as the feature ratio; the normalized value of the absolute value of the difference between the maximum attention weight value in the first attention weight value set and the maximum attention weight value in the second attention weight value set is calculated and recorded as the feature difference; the value of the weighted sum of the feature ratio and the feature difference is recorded as the second short-range dependency representation value corresponding to the word vector c.

[0042] Preferably, the method for obtaining the convolution kernel size corresponding to each word vector includes:

[0043] Obtaining a value interval of the target characterization value and recording it as a comprehensive value interval; dividing the comprehensive value interval into X sub-intervals, and recording them as target characterization value sub-intervals;

[0044] Obtaining the convolution kernel size corresponding to each of the target characterization value subintervals; the larger the value in the target characterization value subinterval, the larger the convolution kernel corresponding to the corresponding target characterization value subinterval;

[0045] For the word vector c: the convolution kernel size corresponding to the target representation value sub-interval containing the target representation value corresponding to the word vector c is used as the convolution kernel size corresponding to the word vector c.

[0046] Beneficial effect: The present invention first obtains a training text matrix; then obtains the attention weight value between any two word vectors in the training text matrix according to each word vector in the training text matrix, obtains the target representation value corresponding to each word vector according to the attention weight value, and obtains the convolution kernel size corresponding to each word vector according to the target representation value; then constructs a convolutional neural network model, and inputs each word vector into the convolutional neural network model, performs convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and completes the training of the convolutional neural network model to obtain a target network model; finally, the text matrix to be recognized corresponding to the obtained text sequence to be recognized is input into the target network model, and the target network model outputs the recognition result of the text matrix to be recognized. The present invention can improve the generalization ability of the target network model according to the convolution kernel size corresponding to each word vector determined by the target representation value, and thus can improve the accuracy or reliability of recognizing the text matrix to be recognized. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 The present invention is a flowchart of a natural language recognition and analysis method based on a general large model technology. DETAILED DESCRIPTION

[0049] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the embodiments of the present invention.

[0050] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0051] This embodiment provides a natural language recognition and analysis method based on a general large model technology, which is described in detail as follows:

[0052] like Figure 1 As shown, the natural language recognition and analysis method based on the general large model technology includes the following steps:

[0053] Step S001, obtaining a training text matrix corresponding to a training text data sequence.

[0054] The main purpose of this embodiment is to adaptively obtain or dynamically adjust the convolution kernel size used in the training process of a general large model, that is, the main purpose is to adaptively obtain or dynamically adjust the convolution kernel size used in the training process of a neural network, and the neural network or the general large model is mainly used for natural language recognition; in addition, the subsequent embodiment is mainly to realize the recognition of natural language of text type, so the neural network model to be trained in this embodiment is the TCN text convolution neural network in the CNN convolutional neural network.

[0055] Since neural networks need to be trained before application, this embodiment first obtains a text data sequence for convolutional neural network training and records it as a training text data sequence; then, the training text data sequence is subjected to text preprocessing to obtain all training text data subsequences corresponding to the training text data sequence after text preprocessing, and all the obtained training text data subsequences are subjected to word embedding conversion to obtain a word vector corresponding to each training text data subsequence, and then a matrix constructed by the word vectors corresponding to all the training text data subsequences is recorded as a training text matrix corresponding to the training text data sequence, wherein the training text data subsequence is obtained by performing word segmentation on the training text data, that is, the training text data subsequence may be a phrase, a character, a phrase, etc. belonging to the training text data sequence; and the number of rows of the training text matrix in this embodiment is 1 row, and the number of columns is the number of word vectors.

[0056] In addition, the position of the word vector in the training text matrix corresponds to the position of the training text data subsequence corresponding to the word vector in the training text data sequence. For example, if the word vector a0 and the word vector a1 in the training text matrix are the word vectors corresponding to the training text data subsequence b0 and the training text data subsequence b1 in the training text data sequence, respectively, and in the training text matrix, if the word vector a0 is adjacent to the word vector a1 and is located on the left side of the word vector a1, then in the training text data sequence, the training text data subsequence b0 is also adjacent to the training text data subsequence b1 and is located on the left side of the training text data subsequence b1.

[0057] The text preprocessing process in this embodiment at least includes performing text cleaning, word segmentation, word form restoration and other operations on the training text data sequence; and the text cleaning operation can remove special characters, punctuation marks and HTML tags in the training text data sequence; the word segmentation operation can split the training text data sequence into multiple words, phrases, etc., and this embodiment records each word or phrase obtained by the split as a training text data subsequence; the word form restoration operation can restore phrases, words, etc. to their basic form to reduce vocabulary variants; since the text preprocessing process is a well-known technology, it will not be described in detail in this embodiment.

[0058] In addition, this embodiment mainly implements word embedding conversion based on a pre-trained word embedding model. For example, word embedding conversion can be implemented based on word embedding models such as Word2Vec and GloVe. Since the process of word embedding conversion is a well-known technology, this embodiment will not be described in detail.

[0059] Therefore, this embodiment obtains the training text matrix through the above process.

[0060] Step S002, according to each word vector in the training text matrix, obtain the attention weight value between any two word vectors in the training text matrix; according to the attention weight value, obtain the target representation value corresponding to each word vector; according to the target representation value, obtain the convolution kernel size corresponding to each word vector.

[0061] This embodiment subsequently needs to train the convolutional neural network based on each word vector in the training text matrix obtained in step S001, and the convolution operation is a core operation in the convolutional neural network model. Because the convolution operation is implemented based on the convolution kernel, and the size of the convolution kernel will directly affect the receptive field and feature extraction ability of the network model, it is very important to reliably determine the size of the convolution kernel. Currently, in the process of network training, the size of the convolution kernel is usually set to a default value or an empirical value, and the size of the convolution kernel determined in this way will cause the convolutional neural network to become unstable during the training process, and will also cause the performance or generalization ability of the trained convolutional neural network model to be weak, and will also cause the trained convolutional neural network model to have poor accuracy or reliability for natural language recognition. Therefore, the main purpose of this embodiment is to adaptively obtain or dynamically adjust the size of the convolution kernel during the convolutional neural network training process.

[0062] Because smaller convolution kernels can better capture local features and short-range dependencies, and larger convolution kernels can better capture global features and long-range dependencies, it is necessary to analyze the short-range dependency features or long-range dependency features presented by word vectors. Also, when adjacent words or phrases appear in the training text data sequence, the local features of the word vectors corresponding to these adjacent words or phrases are more obvious or the word vectors corresponding to these adjacent words or phrases have stronger short-range dependency features. When the correlation of data in a longer range in the training text data sequence is stronger or the information correlation in the training text data sequence is distributed in a longer range, that is, the data correlation is not strong in a small local range or the information correlation is distributed in a small local range, then it means that the word vector corresponding to the data in a longer range has a stronger long-range dependency feature or the global features of the word vector corresponding to the training text data sequence are more obvious; therefore, for any word vector in the training text matrix corresponding to the training text data sequence, In general, if the local features of the word vector are strong or have strong short-range dependency features, then a smaller convolution kernel should be selected when performing a convolution operation on the word vector, and if the global features of the word vector are strong or have strong long-range dependency features, then a larger convolution kernel should be selected when performing a convolution operation on the word vector; therefore, based on the above analysis, if you want to achieve adaptive acquisition or dynamic adjustment of the size of the convolution kernel, this embodiment next needs to analyze the short-range or long-range dependency features of each word vector in the training text matrix, that is, it is necessary to determine the target representation value corresponding to each word vector, which can reflect the strength of the short-range or long-range dependency features of the corresponding word vector, so the specific process of obtaining the target representation value corresponding to each word vector is:

[0063] First, according to each word vector in the training text matrix, the attention weight value between any two word vectors in the training text matrix is ​​obtained, and the attention weight value is the basis for determining the target representation value later. Therefore, the process of obtaining the attention weight value between any two word vectors is:

[0064] For the a-th word vector and the b-th word vector in the training text matrix, where a is not equal to b:

[0065] Perform a dot product operation on the ath word vector and the bth word vector, and record the normalized value of the dot product operation as the attention weight value between the ath word vector and the bth word vector; and the specific expression for obtaining the attention weight value between the ath word vector and the bth word vector is:

[0066]

[0067] in, is the attention weight value between the a-th word vector and the b-th word vector in the training text matrix, Softmax() is the activation function, which mainly normalizes the value obtained by performing the dot product operation on the a-th word vector and the b-th word vector so that the obtained attention weight value ranges from 0 to 1; and It is represented as the dot product operation of the a-th word vector and the b-th word vector. The larger the value of the dot product operation of the a-th word vector and the b-th word vector, The larger the value of The larger the value of , the greater the similarity between the a-th word vector and the b-th word vector. Conversely, the smaller the similarity between the a-th word vector and the b-th word vector.

[0068] Therefore, according to the above process of obtaining the attention weight value, the attention weight value between any two word vectors in the training text matrix can be obtained; in addition, since the attention mechanism in the recurrent neural network (RNN) and the Transformer model usually determines the attention weight between the two by calculating the similarity or correlation between two vectors or two matrices, and usually reflects the long-range or short-range dependency based on the attention weight, this embodiment also obtains the correlation or similarity between the two word vectors in this embodiment based on the idea of ​​obtaining the attention weight in the attention mechanism, and this embodiment subsequently determines the strength of the short-range or long-range dependency of the word vector by analyzing the attention weight value.

[0069] Then, the neighborhood word vector set and the corresponding non-neighborhood word vector set corresponding to each word vector in the training text matrix are obtained; the specific acquisition method is:

[0070] For any word vector c in the training text matrix:

[0071] In the training text matrix, the set constructed by a preset number of consecutive word vectors located on the left side of word vector c and adjacent to word vector c is recorded as the first word vector set corresponding to word vector c, and the set constructed by a preset number of consecutive word vectors located on the right side of word vector c and adjacent to word vector c is recorded as the second word vector set corresponding to word vector c.

[0072] There may be a situation where the number of word vectors on the left or right side of word vector c is less than the preset number. In this embodiment, if the word vectors on the left side of word vector c are less than the preset number, the set constructed by all word vectors on the left side of word vector c is recorded as the first word vector set corresponding to word vector c. If the word vectors on the right side of word vector c are less than the preset number, the set constructed by all word vectors on the right side of word vector c is recorded as the second word vector set corresponding to word vector c.

[0073] Then, a new set constructed by the first word vector set corresponding to the word vector c and the second word vector set corresponding to the word vector c is recorded as the neighborhood word vector set corresponding to the word vector c.

[0074] In the training text matrix, the set constructed by all word vectors except the word vectors in the neighborhood word vector set corresponding to the word vector c is recorded as the non-neighborhood word vector set corresponding to the word vector c.

[0075] In addition, in this embodiment, it is necessary to set the preset number of values ​​according to the total number of word vectors in the training text matrix. For example, if the total number of word vectors in the training text matrix is ​​A, then in this embodiment, the preset number can be set to the integer value of the product of A and 5 percent.

[0076] Therefore, through the above method of obtaining the neighborhood word vector set corresponding to the word vector c and its corresponding non-neighborhood word vector set, the neighborhood word vector set and non-neighborhood word vector set corresponding to each word vector can be obtained.

[0077] Then, the target representation value corresponding to each word vector is obtained based on the neighborhood word vector set and the non-neighborhood word vector set corresponding to each word vector. In order to facilitate understanding of this embodiment, the process of obtaining the target representation value corresponding to the word vector c is analyzed as an example. Therefore, the specific process of obtaining the target representation value corresponding to the word vector c in this embodiment is as follows:

[0078] For word vector c:

[0079] The attention weight value set constructed by the attention weight values ​​between the word vector c and each word vector in its corresponding neighborhood word vector set is recorded as the first attention weight value set corresponding to the word vector c, and the set constructed by the attention weight values ​​between the word vector c and each word vector in its corresponding non-neighborhood word vector set is recorded as the second attention weight value set corresponding to the word vector c.

[0080] Then, according to the first attention weight value set corresponding to the word vector c and its corresponding second attention weight value set, the target representation value corresponding to the word vector c is obtained; and according to the first attention weight value set corresponding to the word vector c and its corresponding second attention weight value set, the specific process of obtaining the target representation value corresponding to the word vector c is:

[0081] According to the mean of all attention weight values ​​in the first attention weight value set corresponding to the word vector c and the mean of all attention weight values ​​in the second attention weight value set corresponding to the word vector c, the first short-range dependency representation value corresponding to the word vector c is obtained; and the specific method for obtaining the first short-range dependency representation value is:

[0082] First, the mean of all attention weight values ​​in the first attention weight value set corresponding to the word vector c is obtained, and recorded as the first mean; then the mean of all attention weight values ​​in the second attention weight value set corresponding to the word vector c is obtained, and recorded as the second mean; then the normalized value of the absolute value of the difference between the first mean and the second mean is obtained, and recorded as the first short-range dependency representation value corresponding to the word vector c, and the first short-range dependency representation value corresponding to the word vector c can reflect the strength of the short-range or long-range dependency feature of the word vector c; in addition, the specific expression for obtaining the first short-range dependency representation value corresponding to the word vector c in this embodiment is:

[0083]

[0084] Wherein, L0 is the first short-range dependency representation value corresponding to the word vector c, tanh() is the hyperbolic tangent function, M is the total number of attention weight values ​​in the first attention weight value set corresponding to the word vector c, is the i-th attention weight value in the first attention weight value set corresponding to the word vector c, N is the total number of attention weight values ​​in the second attention weight value set corresponding to the word vector c, is the jth attention weight value in the second attention weight value set corresponding to the word vector c, is the first mean, is the second mean. The purpose of tanh() here is to normalize the absolute value of the difference between the first mean and the second mean, and tanh() can make the difference between the first mean and the second mean closer to 1 when the absolute value is larger, and closer to 0 when the absolute value is smaller.

[0085] In addition, when the absolute value of the difference between the first mean and the second mean is larger, the value of L0 is larger, and the larger the value of L0 is, the stronger the short-range dependency feature of the word vector c is; when the absolute value of the difference between the first mean and the second mean is smaller, the value of L0 is smaller, and the smaller the value of L0 is, the stronger the long-range dependency feature of the word vector c is; and based on the representational significance of the first mean and the second mean, it can be seen that when the difference between the first mean and the second mean is larger, it can be shown that the value in the first attention weight value set corresponding to the word vector c and the value in the second attention weight value set corresponding to the word vector c are larger, which also indicates that the local dependence of the word vector c is stronger, that is, it also indicates that the word vector c has a stronger short-range dependency feature.

[0086] Then, according to the attention weight value in the first attention weight value set corresponding to the word vector c, the attention weight value in the second attention weight value set corresponding to the word vector c, the maximum attention weight value in the first attention weight value set corresponding to the word vector c, and the maximum attention weight value in the second attention weight value set corresponding to the word vector c, the second short-range dependency representation value corresponding to the word vector c is obtained; and the specific method for obtaining the second short-range dependency representation value is:

[0087] First, obtain the preset first threshold; then, in the first attention weight value set corresponding to the word vector c, count the number of attention weight values ​​that are not less than the preset first threshold, and record it as the first quantity representation value; then, in the second attention weight value set corresponding to the word vector c, count the number of attention weight values ​​that are not less than the preset first threshold, and record it as the second quantity representation value.

[0088] The method for obtaining the preset first threshold in this embodiment is: first obtain the integer value of the product of the total number of word vectors in the training text matrix and thirty percent, and record it as Q, then sort all the word vectors in the training text matrix in order from large to small according to the attention weight value, and record the sequence after sorting as the word vector sequence, and then select the average of the attention weight values ​​corresponding to the first Q word vectors in the word vector sequence as the preset first threshold; as other implementation methods, the implementer can also directly set the preset first threshold according to actual conditions, for example, the preset first threshold can be directly set to 0.7.

[0089] Then, the normalized value of the ratio of the first quantity representation value to the second quantity representation value is calculated and recorded as the feature ratio, and then the normalized value of the absolute value of the difference between the maximum attention weight value in the first attention weight value set corresponding to the word vector c and the maximum attention weight value in the second attention weight value set corresponding to it is calculated and recorded as the feature difference; then, the feature ratio and the feature difference are weighted and summed, and the value obtained by the weighted summation is recorded as the second short-range dependency representation value corresponding to the word vector c, and the second short-range dependency representation value corresponding to the word vector c can reflect the strength of the short-range or long-range dependency feature of the word vector c; in addition, the specific expression of the second short-range dependency representation value in this embodiment is:

[0090]

[0091] Among them, L1 is the second short-range dependency representation value corresponding to the word vector c, is the first preset weight value, is the second preset weight value, Norm() is the normalization function, U0 is the first quantity characterization value, U1 is the second quantity characterization value, is the maximum attention weight value in the first attention weight value set corresponding to the word vector c, is the maximum attention weight value in the second attention weight value set corresponding to the word vector c; and the purpose of Norm() and tanh() in the expression of the second short-range dependency representation value is normalization, so that The larger it is, the closer it is to 1, making The larger it is, the closer it is to 1.

[0092] In addition, when The larger the value, the The larger the value of is, the larger the value of L1 is. The larger the value of L1 is, the stronger the short-range dependency feature of the word vector c is. On the contrary, when The smaller the value of The smaller the value of is, the smaller the value of L1 is. The smaller the value of L1 is, the stronger the long-range dependency feature of the word vector c is. The larger the value, the The larger the value of , the larger the attention weight value between the word vector c and each word vector in the corresponding neighborhood word vector set in the training text matrix, which further indicates that the local dependence of the word vector c is stronger, that is, the short-range dependence feature of the word vector c is stronger.

[0093] In a specific application, the implementer needs to set the first preset weight value and the second preset weight value according to the actual situation. For example, in this embodiment, the first preset weight value is set to 0.3, and the second preset weight value is set to 0.7.

[0094] Since the first short-range dependency representation value and the corresponding second short-range dependency representation value corresponding to the word vector c calculated above can both reflect the short-range dependency characteristics or long-range dependency characteristics presented by the word vector c, this embodiment then performs a weighted summation on the first short-range dependency representation value corresponding to the word vector c and the corresponding second short-range dependency representation value, and records the value after the weighted summation as the target representation value corresponding to the word vector c, and the specific expression for obtaining the target representation value corresponding to the word vector c is:

[0095]

[0096] in, is the target representation value corresponding to the word vector c, is the first weight value, is the second weight value; and the larger the first short-range dependency representation value and the second short-range dependency representation value corresponding to the word vector c are, the larger the target representation value corresponding to the word vector c is, and thus the short-range dependency feature of the word vector c is stronger, and vice versa.

[0097] In a specific application, the implementer needs to set the first weight value and the second weight value according to the actual situation. For example, in this embodiment, the first weight value and the second weight value are both set to 0.5.

[0098] Therefore, this embodiment can obtain the target representation value corresponding to each word vector according to the above method of calculating the target representation value corresponding to the word vector c.

[0099] This embodiment then obtains the convolution kernel size corresponding to each word vector based on the target representation value corresponding to each word vector, specifically:

[0100] First, the target representation value interval is obtained and recorded as the comprehensive value interval, and the comprehensive value interval is [0,1]; then the comprehensive value interval is divided into X sub-intervals, and each is recorded as the target representation value sub-interval, and then the convolution kernel size corresponding to each target representation value sub-interval is obtained, and the larger the value in the target representation value sub-interval, the larger the convolution kernel corresponding to the target representation value sub-interval.

[0101] In specific applications, the implementer needs to set the interval division method, set the value of X, and also set the convolution kernel size corresponding to each target characterization value sub-interval according to the actual situation; for example, the present embodiment sets the uneven division method when performing interval division. The present embodiment sets the value of X to 3, that is, the number of target characterization value sub-intervals is 3, and they are [0, 0.4), [0.4, 0.6), and [0.6, 1], respectively, and sets the convolution kernel size corresponding to the target characterization value sub-interval [0, 0.4) to , the convolution kernel size corresponding to the target representation value subinterval [0.4,0.6) is , the convolution kernel size corresponding to the target representation value subinterval [0.6,1] is ; In addition, as another implementation method, a uniform division method can be used when dividing the interval, and the value of X can be set to 2, that is, the number of target characterization value sub-intervals is 2, and they are [0,0.5) and [0.5,0.1] respectively, and the convolution kernel size corresponding to the target characterization value sub-interval [0,0.5) is set to , the convolution kernel size corresponding to the target representation value subinterval [0.5, 0.1] is .

[0102] Next, determine which target representation value subinterval the target representation value corresponding to the word vector belongs to, and determine the convolution kernel size corresponding to each word vector based on the determination result. Specifically, for any target representation value subinterval, if it is determined that the target representation value corresponding to the word vector c belongs to the target representation value subinterval, then the convolution kernel size corresponding to the target representation value subinterval is used as the convolution kernel size corresponding to the word vector c.

[0103] Therefore, this embodiment can obtain the convolution kernel size corresponding to each word vector according to the above method of obtaining the convolution kernel size corresponding to the word vector c.

[0104] Step S003, construct a convolutional neural network model, input each word vector into the convolutional neural network model, perform convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and complete the training of the convolutional neural network model to obtain the trained convolutional neural network model, and record the trained convolutional neural network model as the target network model; obtain the text matrix to be recognized corresponding to the text data sequence to be recognized, input the text matrix to be recognized into the target network model, and the target network model outputs the recognition result of the text matrix to be recognized.

[0105] Since the convolution kernel size corresponding to each word vector has been obtained in step S002, a convolutional neural network model is then built, and then network training is performed. The convolutional neural network model in this embodiment is a text convolutional neural network model, specifically:

[0106] Each word vector is input into the convolutional neural network model, and the corresponding word vector is convolved according to the convolution kernel size corresponding to each word vector. Then the convolution layer of the convolutional neural network model outputs the convolution feature corresponding to each word vector. Then the convolutional neural network model is trained based on the output convolution feature and the pooling layer, fully connected layer and loss function of the convolutional neural network model, that is, the trained convolutional neural network model is obtained, and the trained convolutional neural network model is recorded as the target network model; and H0 and H1 word vectors are arbitrarily selected in the training text matrix as the verification set and test set in the training process respectively; the loss function and optimizer selected in the training process are the cross entropy loss function and the Adam optimizer respectively.

[0107] In specific applications, implementers can set the values ​​of H0 and H1 according to actual conditions, for example, setting the values ​​of H0 and H1 to be half of the total number of word vectors in the training text matrix.

[0108] And because the detailed training process of the convolutional neural network is a well-known technology, it is no longer described in this embodiment. However, when using the convolutional neural network to realize natural language recognition and analysis, it is combined with a pre-trained word embedding model and a general large model technology, such as BERT or GPT, so as to improve the performance and generalization ability of the model. For example, the pre-trained BERT model can be used as the input layer of the convolutional neural network to obtain context-related text representations, and then extract features through convolution and pooling operations and perform classification or other tasks. In this way, the semantic understanding ability of the general large model can be fully utilized, and combined with the feature extraction ability of the convolutional neural network, the purpose of natural language recognition and analysis can be achieved more accurately and efficiently; that is, in the process of network model training, by dynamically adjusting the convolution kernel size, the model can dynamically adjust the receptive field size at different positions or channels, so as to better capture the information in the input features and improve the performance and generalization ability of the model, that is, the target network model obtained based on the above training can improve the accuracy and reliability of natural language recognition.

[0109] Then, the text data sequence to be recognized is obtained, and then the text matrix to be recognized corresponding to the text data sequence to be recognized is obtained according to the above method of obtaining the training text matrix corresponding to the training text data sequence, and finally the text matrix to be recognized is input into the target network model, and the target network model outputs the recognition result of the text matrix to be recognized; and both the text data sequence to be recognized and the training text data sequence belong to natural language.

[0110] In addition, the target network model in this embodiment can be used for scenarios or tasks such as text classification and sentiment analysis. However, if the above-mentioned trained network model is mainly used for text classification, then the text matrix to be recognized will be input into the target network model subsequently, and the target network model outputs the result of text classification of the text matrix to be recognized.

[0111] In summary, the present embodiment first obtains a training text matrix; then obtains the attention weight value between any two word vectors in the training text matrix according to each word vector in the training text matrix, obtains the target representation value corresponding to each word vector according to the attention weight value, and obtains the convolution kernel size corresponding to each word vector according to the target representation value; then constructs a convolutional neural network model, and inputs each word vector into the convolutional neural network model, performs convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and completes the training of the convolutional neural network model to obtain a target network model; finally, the text matrix to be recognized corresponding to the obtained text sequence to be recognized is input into the target network model, and the target network model outputs the recognition result of the text matrix to be recognized. The present embodiment can improve the generalization ability of the target network model according to the convolution kernel size corresponding to each word vector determined by the target representation value, and thus can improve the accuracy or reliability of the recognition of the text matrix to be recognized.

[0112] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A natural language recognition and analysis method based on a general large model technology, characterized in that: The method comprises the following steps: Get the training text matrix corresponding to the training text data sequence; According to each word vector in the training text matrix, obtaining an attention weight value between any two word vectors in the training text matrix; According to the attention weight value, the target representation value corresponding to each word vector is obtained; According to the target representation value, obtain the convolution kernel size corresponding to each word vector; Constructing a convolutional neural network model, inputting each word vector into the convolutional neural network model, performing a convolution operation on the corresponding word vector according to the convolution kernel size corresponding to each word vector, and completing the training of the convolutional neural network model to obtain the trained convolutional neural network model, and recording the trained convolutional neural network model as the target network model; Obtaining a text matrix to be recognized corresponding to the text data sequence to be recognized, inputting the text matrix to be recognized into the target network model, and the target network model outputting a recognition result of the text matrix to be recognized; The method for obtaining the attention weight value between any two word vectors in the training text matrix includes: For the ath word vector and the bth word vector in the training text matrix, a is not equal to b: Performing a dot product operation on the a-th word vector and the b-th word vector, and recording a normalized value of a value obtained by performing the dot product operation as an attention weight value between the a-th word vector and the b-th word vector; The method of obtaining the target representation value corresponding to each word vector according to the attention weight value includes: Obtaining a neighborhood word vector set corresponding to each word vector and a non-neighborhood word vector set corresponding to each word vector; For any word vector c in the training text matrix: The attention weight value set constructed by the attention weight value between the word vector c and each word vector in its corresponding neighborhood word vector set is recorded as the first attention weight value set corresponding to the word vector c, and the set constructed by the attention weight value between the word vector c and each word vector in its corresponding non-neighborhood word vector set is recorded as the second attention weight value set corresponding to the word vector c; Obtaining a target representation value corresponding to the word vector c according to the first attention weight value set and the second attention weight value set; The method for obtaining a neighborhood word vector set corresponding to each word vector includes: For the word vector c: In the training text matrix, a set constructed by a preset number of consecutive word vectors located on the left side of the word vector c and adjacent to the word vector c is recorded as a first word vector set corresponding to the word vector c, and a set constructed by a preset number of consecutive word vectors located on the right side of the word vector c and adjacent to the word vector c is recorded as a second word vector set corresponding to the word vector c; If the word vectors on the left side of the word vector c are less than the preset number, the set constructed by all the word vectors on the left side of the word vector c is recorded as the first word vector set corresponding to the word vector c; if the word vectors on the right side of the word vector c are less than the preset number, the set constructed by all the word vectors on the right side of the word vector c is recorded as the second word vector set corresponding to the word vector c; A new set constructed by the first word vector set and the second word vector set is recorded as the neighborhood word vector set corresponding to the word vector c; The method for obtaining the non-neighborhood word vector set corresponding to each word vector includes: For the word vector c: In the training text matrix, a set constructed by all word vectors except the word vectors in the neighborhood word vector set corresponding to the word vector c is recorded as the non-neighborhood word vector set corresponding to the word vector c; The method of obtaining a target representation value corresponding to the word vector c according to the first attention weight value set and the second attention weight value set includes: Obtaining a first short-range dependency representation value corresponding to the word vector c according to the mean of all attention weight values ​​in the first attention weight value set and the mean of all attention weight values ​​in the second attention weight value set; Obtaining a second short-range dependency representation value corresponding to the word vector c according to the attention weight values ​​in the first attention weight value set, the attention weight values ​​in the second attention weight value set, the maximum attention weight value in the first attention weight value set, and the maximum attention weight value in the second attention weight value set; Performing a weighted summation on the first short-range dependency representation value and the second short-range dependency representation value, and recording the value after the weighted summation as the target representation value corresponding to the word vector c; The method for obtaining the first short-range dependency representation value corresponding to the word vector c includes: Obtaining the mean of all attention weight values ​​in the first attention weight value set, and recording it as a first mean; obtaining the mean of all attention weight values ​​in the second attention weight value set, and recording it as a second mean; Record the normalized value of the absolute value of the difference between the first mean and the second mean as the first short-range dependency representation value corresponding to the word vector c; The method for obtaining the second short-range dependency representation value corresponding to the word vector c includes: Obtaining a preset first threshold; In the first attention weight value set, the number of attention weight values ​​not less than the preset first threshold is obtained by counting and recorded as a first quantity representation value; in the second attention weight value set, the number of attention weight values ​​not less than the preset first threshold is obtained by counting and recorded as a second quantity representation value; The normalized value of the ratio of the first quantity representation value to the second quantity representation value is recorded as the feature ratio; the normalized value of the absolute value of the difference between the maximum attention weight value in the first attention weight value set and the maximum attention weight value in the second attention weight value set is calculated and recorded as the feature difference; the value of the weighted sum of the feature ratio and the feature difference is recorded as the second short-range dependency representation value corresponding to the word vector c; The method for obtaining the convolution kernel size corresponding to each word vector includes: Obtaining the value interval of the target characterization value and recording it as the comprehensive value interval; Divide the comprehensive value interval into X sub-intervals, and record them as target characterization value sub-intervals; Obtaining the convolution kernel size corresponding to each of the target characterization value subintervals; the larger the value in the target characterization value subinterval, the larger the convolution kernel corresponding to the corresponding target characterization value subinterval; For the word vector c: the convolution kernel size corresponding to the target representation value sub-interval containing the target representation value corresponding to the word vector c is used as the convolution kernel size corresponding to the word vector c.

2. A natural language recognition and analysis method based on general large model technology as claimed in claim 1, characterized in that: The method for obtaining the training text matrix includes: Obtain a text data sequence for convolutional neural network training and record it as a training text data sequence; Perform word embedding conversion on the training text data sequence to obtain a training text matrix corresponding to the training text data sequence, wherein the training text matrix is ​​composed of word vectors corresponding to each training text data subsequence obtained by word segmentation of the training text data sequence, and the position of the word vector in the training text matrix corresponds to the position of the training text data subsequence corresponding to the word vector in the training text data sequence.