Text analysis method and device, computer device, and storage medium
By using text analysis methods and a multi-task specific reasoning module to extract and classify semantic features from student responses, this approach solves the problem of low efficiency in traditional manual analysis, achieves automated and efficient assessment of students' scientific thinking, and provides precise teaching guidance.
Patent Information
- Application Number
- CN202510896358.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-07-01
AI Technical Summary
In existing technologies, the text analysis of students' answers relies on manual analysis line by line, which is costly in terms of manpower and time, makes it difficult to objectively reflect the development of students' scientific thinking, and is also inefficient.
A text analysis method is adopted, which utilizes multiple task-specific reasoning modules to analyze the semantic feature matrix and perform category reasoning, including a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature reorganization layer, and a linear layer, to achieve semantic feature extraction and classification calculation.
It enables automated and efficient analysis of student texts, helping teachers understand students' cognitive trajectories in real time and providing a basis for precise teaching interventions.
Smart Images

Figure CN120409496B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a text analysis method, apparatus, computer device, and storage medium. Background Technology
[0002] Current educational trends increasingly emphasize the role of scientific thinking in STEM (Science, Technology, Engineering, Mathematics) education. The essential characteristics of scientific thinking (such as systematic reasoning, model building, and evidence weighing) are often fully demonstrated and enhanced in open-ended scientific explanation questions. Currently, in order to train students to develop scientific thinking, teachers will ask students to analyze real-world situations based on subject concepts and answer questions in the form of texts.
[0003] However, in actual teaching, the process of analyzing students' answers relies on manual analysis of multiple indicators such as the accuracy of concepts, the suitability of evidence, and the logical coherence. This is costly in terms of manpower and time, and the analysis process depends on the teacher's subjective opinion. It is difficult to objectively and accurately analyze students' answers and to reflect the current development of students' scientific thinking. Summary of the Invention
[0004] Based on this, the purpose of this invention is to provide a text analysis method, apparatus, computer device, and storage medium that extracts semantic features from the corpus to be analyzed, utilizes multiple task-specific reasoning modules to perform corresponding task-specific reasoning on the obtained semantic feature matrix, and obtains multiple task-specific reasoning matrices for text analysis. This solves the problem of low efficiency in the analysis of traditional open-ended scientific explanations, helps teachers understand students' cognitive trajectories in real time, and provides a precise basis for teaching intervention.
[0005] In a first aspect, embodiments of this application provide a text analysis method, comprising the following steps:
[0006] The system obtains the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning module includes a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer.
[0007] The corpus to be analyzed is input into the feature extraction module for semantic feature extraction to obtain the semantic feature matrix of the corpus to be analyzed;
[0008] The semantic feature matrix of the corpus to be analyzed is input into several task-specific reasoning modules. The dynamic sparse attention layer extracts dynamic sparse attention features from the semantic feature matrix of the corpus to be analyzed, obtaining several dynamic sparse attention matrices. The gated interaction layer extracts gated features and performs feature interaction on the several dynamic sparse attention matrices, obtaining several gated interaction matrices. The hybrid position-aware attention layer extracts hybrid position-aware attention features from the several gated interaction matrices, obtaining several hybrid position-aware attention matrices. The adaptive feature recombination layer reconstructs features from the several hybrid position-aware attention matrices, obtaining several adaptive feature recombination matrices. The linear layer performs linear classification calculations on the several adaptive feature recombination matrices, obtaining several analysis category reasoning matrices.
[0009] Several analysis category inference matrices are input into the category prediction module to calculate the analysis category prediction probability, thereby obtaining several analysis category prediction probability data; based on the several analysis category prediction probability data, the text analysis result is obtained.
[0010] Secondly, embodiments of this application provide a text analysis device, including:
[0011] The data acquisition module is used to acquire the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning modules include a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer.
[0012] The feature processing module is used to input the corpus to be analyzed into the feature extraction module to extract semantic features and obtain the semantic feature matrix of the corpus to be analyzed.
[0013] The analysis category reasoning module is used to input the semantic feature matrix of the corpus to be analyzed into several task-specific reasoning modules. Through the dynamic sparse attention layer, dynamic sparse attention features are extracted from the semantic feature matrix of the corpus to be analyzed, resulting in several dynamic sparse attention matrices. Through the gated interaction layer, gated features are extracted and features are interacted with from the several dynamic sparse attention matrices, resulting in several gated interaction matrices. Through the hybrid position-aware attention layer, hybrid position-aware attention features are extracted from the several gated interaction matrices, resulting in several hybrid position-aware attention matrices. Through the adaptive feature recombination layer, features are recombined from the several hybrid position-aware attention matrices, resulting in several adaptive feature recombination matrices. Through the linear layer, linear classification calculations are performed on the several adaptive feature recombination matrices, resulting in several analysis category reasoning matrices.
[0014] The text analysis module is used to input several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability and obtain several analysis category prediction probability data; based on the several analysis category prediction probability data, the text analysis result is obtained.
[0015] Thirdly, embodiments of this application provide a computer device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor; when the computer program is executed by the processor, it implements the steps of the text analysis method as described in the first aspect.
[0016] Fourthly, embodiments of this application provide a storage medium storing a computer program that, when executed by a processor, implements the steps of the text analysis method as described in the first aspect.
[0017] In this application embodiment, a text analysis method, apparatus, computer device, and storage medium are provided. The method extracts semantic features from the corpus to be analyzed, and uses multiple task-specific reasoning modules to perform analysis category reasoning on the obtained semantic feature matrix for the corresponding task, thereby obtaining multiple task-specific analysis category reasoning matrices for text analysis. This solves the problem of low efficiency in the analysis of traditional open-ended scientific explanation questions, and can help teachers understand students' cognitive trajectories in real time and provide a basis for precise teaching intervention.
[0018] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description
[0019] Figure 1 A flowchart illustrating the text analysis method provided in the first embodiment of this application;
[0020] Figure 2 This is a flowchart illustrating step S2 of the text analysis method provided in the first embodiment of this application.
[0021] Figure 3 This is a flowchart illustrating step S3 of the text analysis method provided in the first embodiment of this application.
[0022] Figure 4 This is a flowchart illustrating step S3 of the text analysis method provided in the second embodiment of this application.
[0023] Figure 5 This is a flowchart illustrating step S3 of the text analysis method provided in the third embodiment of this application.
[0024] Figure 6 This is a flowchart illustrating step S3 of the text analysis method provided in the fourth embodiment of this application.
[0025] Figure 7 This is a flowchart illustrating step S3 of the text analysis method provided in the fifth embodiment of this application.
[0026] Figure 8 This is a flowchart illustrating step S4 of the text analysis method provided in the first embodiment of this application.
[0027] Figure 9 This is a flowchart illustrating step S5 of the text analysis method provided in the sixth embodiment of this application.
[0028] Figure 10 This is a flowchart illustrating step S6 of the text analysis method provided in the seventh embodiment of this application.
[0029] Figure 11 This is a schematic diagram of the structure of the text analysis system provided in the eighth embodiment of this application;
[0030] Figure 12 This is a schematic diagram of the structure of a computer device provided in the ninth embodiment of this application. Detailed Implementation
[0031] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0032] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0033] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0034] The data sending end can be a computer device or a mobile terminal device, used to establish a network connection with the data receiving end, and is capable of encoding the data information sent to the data receiving end and parsing the data information sent from the data receiving end.
[0035] The data receiving end can be a computer device or a mobile terminal device, used to establish a network connection with the data sending end, and is capable of encoding the data information sent to the data sending end and parsing the data information sent from the data sending end.
[0036] Please see Figure 1 , Figure 1 The flowchart of the text analysis method provided in the first embodiment of this application is shown. The method includes the following steps:
[0037] S1: Obtain the corpus to be analyzed and the text evaluation model.
[0038] The execution entity of the text analysis method is the text analysis device (hereinafter referred to as the analysis device). In an optional embodiment, the analysis device may be a computer device, a server, or a server cluster composed of multiple computer devices.
[0039] In this embodiment, the analysis device obtains the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning modules include a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer.
[0040] S2: Input the corpus to be analyzed into the feature extraction module to extract semantic features and obtain the semantic feature matrix of the corpus to be analyzed.
[0041] In this embodiment, the analysis device inputs the corpus to be analyzed into the feature extraction module to extract semantic features and obtain the semantic feature matrix of the corpus to be analyzed.
[0042] The feature extraction module includes several encoder layers, each comprising a multi-head self-attention unit and a post-processing unit; please refer to [link to relevant documentation]. Figure 2 , Figure 2 The flowchart of S2 in the text analysis method provided in the first embodiment of this application is shown below, including steps S21 to S23, as follows:
[0043] S21: Perform word segmentation and word vector mapping on the corpus to be analyzed to obtain a word vector sequence; add the word vector sequence to a preset sine and cosine position encoding matrix to obtain a word embedding matrix.
[0044] In this embodiment, the analysis device performs word segmentation and word vector mapping on the corpus to be analyzed to obtain a word vector sequence. Specifically, the analysis device uses the BERT word segmenter to generate a corresponding sub-word sequence for the corpus to be analyzed, wherein the sub-word sequence includes several sub-words. The analysis device maps each sub-word in the sub-word sequence to a 768-dimensional word vector to obtain a word vector sequence.
[0045] The analysis device adds the word vector sequence to a preset sine and cosine positional encoding matrix to obtain a word embedding matrix. The sine and cosine positional encoding matrix includes sine and cosine encoded vectors at several positions across several dimensions. These sine and cosine encoded vectors are:
[0046]
[0047] In the formula, k For dimensional indexing, i For location index, For the 2nd k The first dimension i Sine and cosine encoded vectors at each position, For the (2) k+1) Dimension of the i A sine and cosine encoded vector at each position.
[0048] In an optional embodiment, the analysis device performs standardization processing on the word vector sequence, and adds the standardized word vector sequence to a preset sine and cosine position encoding matrix to obtain a word embedding matrix.
[0049] S22: The word embedding matrix is used as the input matrix of the first layer encoder. The input matrix is decomposed by split projection through the multi-head self-attention unit to obtain the first split projection matrix. According to the preset first multi-head self-attention feature extraction algorithm, the first split projection matrix is subjected to multi-head self-attention feature extraction to obtain the first multi-head self-attention matrix.
[0050] In this embodiment, the analysis device uses the word embedding matrix as the input matrix of the first-layer encoder. Through the multi-head self-attention unit, the input matrix is decomposed into a first-head projection matrix, which includes a first-head query matrix, a first-head key matrix, and a first-head value matrix, as described below:
[0051]
[0052] In the formula, For the first h The first branch of the matrix is queried. For the first h The first branch key matrix of the head. For the first h The first value matrix of the head. X For word embedding matrix, , , The first h The first, second, and third heads of each size can learn weight parameters.
[0053] The analysis device performs multi-head self-attention feature extraction based on the first split-head projection matrix and a preset first multi-head self-attention feature extraction algorithm to obtain the first multi-head self-attention matrix. The first multi-head self-attention feature extraction algorithm is as follows:
[0054]
[0055] In the formula, For the first h The first attention feature output of the size, For dimension parameters, T It is the transpose symbol. For normalized exponential functions, This is the first multi-head self-attention matrix. For concatenation functions, The first multi-head self-attention weight parameter.
[0056] S23: The post-processing unit sequentially performs fully connected processing and activation processing on the first multi-head self-attention matrix to obtain a first intermediate feature matrix. The first multi-head self-attention matrix and the first intermediate feature matrix are then subjected to residual connection and layer normalization processing to obtain a post-processing matrix, which serves as the output matrix of the first layer encoder. The output matrix of the first layer encoder is used as the input matrix of the next coding layer. This process is repeated until the output matrix of the last layer encoder is obtained, which serves as the semantic feature matrix.
[0057] In this embodiment, the analysis device performs fully connected processing and activation processing on the first multi-head self-attention matrix sequentially through the post-processing unit to obtain a first intermediate feature matrix, wherein the first intermediate feature matrix is:
[0058]
[0059] In the formula, This is the first intermediate feature matrix. For activation function, As the first weight parameter, This is the second weighting parameter. This is the first bias parameter. This is the second bias parameter.
[0060] The analysis device performs residual concatenation and layer normalization on the first multi-head self-attention matrix and the first intermediate feature matrix to obtain a post-processing matrix, which serves as the output matrix of the first-layer encoder. The post-processing matrix is as follows:
[0061]
[0062] In the formula, This is a post-processing matrix. This is the layer normalization function.
[0063] The analysis device uses the output matrix of the first encoder as the input matrix of the next encoding layer, repeating the process until the output matrix of the last encoder is obtained, which is then used as the semantic feature matrix.
[0064] S3: The semantic feature matrix of the corpus to be analyzed is input into several task-specific inference modules. Through the dynamic sparse attention layer, dynamic sparse attention features are extracted from the semantic feature matrix of the corpus to be analyzed, resulting in several dynamic sparse attention matrices. Through the gated interaction layer, gated features are extracted and features are interacted with from the several dynamic sparse attention matrices, resulting in several gated interaction matrices. Through the hybrid position-aware attention layer, hybrid position-aware attention features are extracted from the several gated interaction matrices, resulting in several hybrid position-aware attention matrices. Through the adaptive feature recombination layer, features are recombined from the several hybrid position-aware attention matrices, resulting in several adaptive feature recombination matrices. Through the linear layer, linear classification calculations are performed on the several adaptive feature recombination matrices, resulting in several analysis category inference matrices.
[0065] In this embodiment, the analysis device inputs the semantic feature matrix of the corpus to be analyzed into several task-specific inference modules. Through the dynamic sparse attention layer, dynamic sparse attention features are extracted from the semantic feature matrix of the corpus to be analyzed, resulting in several dynamic sparse attention matrices. Through the gated interaction layer, gated features are extracted and features are interacted with from the several dynamic sparse attention matrices, resulting in several gated interaction matrices. Through the hybrid position-aware attention layer, hybrid position-aware attention features are extracted from the several gated interaction matrices, resulting in several hybrid position-aware attention matrices. Through the adaptive feature recombination layer, features are recombined from the several hybrid position-aware attention matrices, resulting in several adaptive feature recombination matrices. Through the linear layer, linear classification calculations are performed on the several adaptive feature recombination matrices, resulting in several analysis category inference matrices.
[0066] To better learn the different features of claims, reasoning, and evidence, the analysis device uses hardware-level parallel channels to copy the shared representation semantic feature matrix to the corresponding task-specific reasoning modules of claims, reasoning, and evidence. Each task-specific reasoning module is allocated an independent GPU memory page-locked buffer to avoid data migration overhead. The input of each task-specific sub-network is an independent semantic feature matrix.
[0067] Please see Figure 3 , Figure 3The flowchart of S3 in the text analysis method provided in the first embodiment of this application is shown below, including steps S301 to S302, as follows:
[0068] S301: Perform convolution processing on the semantic feature matrix to obtain a convolution matrix; construct a sparse mask matrix from the convolution matrix to obtain a sparse mask matrix.
[0069] In this embodiment, the analysis device employs a lightweight CNN convolutional layer with a kernel size of 3×3 and 8 output channels. This layer performs convolution processing on the semantic feature matrix to obtain a convolution matrix. A sparse mask matrix is then constructed from the convolution matrix to preserve high-attention regions. The sparse mask matrix comprises several sparse mask vectors, which are:
[0070]
[0071] In the formula, Let i be the sparse mask vector at index i, j in the sparse mask matrix. It is the sigmoid activation function. It is a convolution function. This is the semantic feature matrix.
[0072] S302: Perform global projection decomposition on the semantic feature matrix to obtain a global projection matrix; perform dynamic sparse attention feature extraction on the sparse mask matrix and the global projection matrix according to a preset dynamic sparse attention feature extraction algorithm to obtain a dynamic sparse attention matrix.
[0073] In this embodiment, the analysis device performs global projection decomposition on the semantic feature matrix to obtain a global projection matrix, wherein the global projection matrix includes a global query matrix, a global key matrix, and a global value matrix, as described below:
[0074]
[0075] In the formula, For global query matrix, The global key matrix, For global value matrix, H The semantic feature matrix, , , These are the first, second, and third globally learnable weight parameters, respectively.
[0076] The analysis device performs dynamic sparse attention feature extraction based on the sparse mask matrix, the global projection matrix, and a preset dynamic sparse attention feature extraction algorithm to obtain a dynamic sparse attention matrix. The dynamic sparse attention feature extraction algorithm is as follows:
[0077]
[0078] In the formula, For dynamic sparse attention matrix, M It is a sparse mask matrix. For global query matrix, The global key matrix, For global value matrix, This is the preset number of channels.
[0079] Please see Figure 4 , Figure 4 The flowchart of S3 in the text analysis method provided in the second embodiment of this application is shown below, including steps S303 to S304:
[0080] S303: Perform activation processing based on the dynamic sparse attention matrix, the preset gating parameter matrix, and the preset activation function to construct a gating weight matrix.
[0081] In this embodiment, the analysis device performs activation processing based on the dynamic sparse attention matrix, a preset gating parameter matrix, and a preset activation function to construct a gating weight matrix, wherein the gating weight matrix is:
[0082]
[0083] In the formula, For the gated weight matrix, G This is the gating parameter matrix.
[0084] S304: Multiply the dynamic sparse attention matrix and the gate weight matrix element-wise to obtain the gate feature matrix; perform residual concatenation between the dynamic sparse attention matrix and the gate feature matrix to obtain the residual concatenation matrix; perform layer normalization on the residual concatenation matrix to obtain the layer normalized residual concatenation matrix, which is used as the gate interaction matrix.
[0085] In this embodiment, the analysis device performs element-wise multiplication of the dynamic sparse attention matrix and the gated weight matrix to obtain the gated feature matrix; and performs residual concatenation of the dynamic sparse attention matrix and the gated feature matrix to obtain the residual concatenation matrix.
[0086] The analysis device performs layer normalization on the residual connection matrix to obtain a layer-normalized residual connection matrix, which serves as the gated interaction matrix. The gated interaction matrix is as follows:
[0087]
[0088] In the formula, For gating interaction matrix, This is the residual connection matrix.
[0089] Please see Figure 5 , Figure 5 The flowchart of S3 in the text analysis method provided in the first and third embodiments of this application is shown below, including steps S305 to S306, as follows:
[0090] S305: Perform split-projection decomposition on the gated interaction matrix to obtain a second split-projection matrix, the second split-projection matrix including a second split-query matrix, a second split-key matrix and a second split-value matrix; superimpose the second split-query matrix and the second split-key matrix with a preset dual-mode position encoding matrix to obtain a third split-query matrix and a third split-key matrix.
[0091] In this embodiment, the analysis device performs split-projection decomposition on the gated interaction matrix to obtain a second split-projection matrix, wherein the second split-projection matrix includes a second split-query matrix, a second split-key matrix, and a second split-value matrix, as described below:
[0092]
[0093] In the formula, For the first h The second branch of the matrix is queried. For the first h The second branch key matrix of the head. For the first h The second sub-value matrix of the head. , , The first h The fourth, fifth, and sixth heads can learn weight parameters.
[0094] The analysis device superimposes the second head query matrix and the second head key matrix with a preset dual-mode position encoding matrix to obtain a third head query matrix and a third head key matrix. The dual-mode position encoding matrix includes dual-mode encoding vectors for several positions across several dimensions. The dual-mode encoding vectors are as follows:
[0095]
[0096] In the formula, For the 2nd k The first dimension i A dual-mode encoded vector at each position, For the (2) k +1) Dimension of the i A dual-mode encoded vector at each position.
[0097] The third header query matrix and the third header key matrix are described below:
[0098]
[0099] In the formula, For the first h The third branch of the matrix is used for querying the head. For the first h The third branch key matrix of the head, For the first h The learnable fusion coefficient of the size This is a dual-mode positional encoding matrix.
[0100] S306: Based on the third head query matrix, the third head key matrix, the second head value matrix, and the preset second multi-head self-attention feature extraction algorithm, a second multi-head self-attention matrix is obtained, which serves as the hybrid position-aware attention matrix.
[0101] In this embodiment, the analysis device obtains a second multi-head self-attention matrix based on the third branch query matrix, the third branch key matrix, the second branch value matrix, and a preset second multi-head self-attention feature extraction algorithm, which serves as the hybrid position-aware attention matrix. The second multi-head self-attention feature extraction algorithm is as follows:
[0102]
[0103] In the formula, For the first h The second attention feature output of the size, This is the second multi-head self-attention matrix. This is the second multi-head self-attention weight parameter.
[0104] Please see Figure 6 , Figure 6 The flowchart of S3 in the text analysis method provided in the fourth embodiment of this application is shown below, including steps S307 to S308, as follows:
[0105] S307: Divide the hybrid position-aware attention matrix into several dimensional division matrices, perform intra-group information interaction on the several dimensional division matrices respectively, and obtain several information interaction matrices; obtain the intra-group self-attention matrix based on the several information interaction matrices and the preset intra-group self-attention algorithm.
[0106] In this embodiment, the analysis device divides the hybrid position-aware attention matrix into several dimensional division matrices, and performs intra-group information interaction on the several dimensional division matrices to obtain several information interaction matrices.
[0107] The analysis device obtains an intra-group self-attention matrix based on several sets of information interaction matrices and a preset intra-group self-attention algorithm, wherein the intra-group self-attention algorithm is as follows:
[0108]
[0109] In the formula, For the first The output of the group's within-group self-attention features. For the number of groups, For the first Group information interaction matrix, This is the in-group self-attention matrix. This is a data integer shaping function.
[0110] S308: Perform a linear transformation on the in-group self-attention matrix to obtain an importance weight matrix; multiply the hybrid position-aware attention matrix and the importance weight matrix channel by channel to obtain a second intermediate feature matrix; perform an outer product and dimensionality reduction on the second intermediate feature matrix to obtain several adaptive feature recombination matrices.
[0111] In this embodiment, the analysis device performs a linear transformation on the in-group self-attention matrix to obtain an importance weight matrix, multiplies the hybrid position-aware attention matrix and the importance weight matrix channel by channel to obtain a second intermediate feature matrix, and performs an outer product and dimensionality reduction on the second intermediate feature matrix to obtain several adaptive feature recombination matrices.
[0112] Please see Figure 7 , Figure 7 The flowchart of S3 in the text analysis method provided in the fifth embodiment of this application is as follows, including steps S309 to S311:
[0113] S309: Perform global linear projection and grouped convolution processing on the adaptive feature recombination matrix to obtain a global linear projection matrix and a grouped convolution matrix; perform feature fusion on the global linear projection matrix and the grouped convolution matrix to obtain a feature fusion matrix.
[0114] In this embodiment, the analysis device performs global linear projection and grouped convolution processing on the adaptive feature reconstruction matrix to obtain a global linear projection matrix and a grouped convolution matrix; and performs feature fusion on the global linear projection matrix and the grouped convolution matrix to obtain a feature fusion matrix.
[0115] S310: Perform normalized similarity calculation based on the feature fusion matrix, the preset set of prototype vectors of several analysis categories, and the preset normalized similarity calculation algorithm to obtain the normalized similarity of several analysis categories.
[0116] In this embodiment, the analysis device performs normalized similarity calculation based on the feature fusion matrix, a preset set of prototype vectors for several analysis categories, and a preset normalized similarity calculation algorithm to obtain normalized similarity for several analysis categories. The analysis categories are used to indicate the cognitive level reflected in the response text. The normalized similarity calculation algorithm is as follows:
[0117]
[0118] In the formula, For the first c Normalized similarity of each analysis category, For temperature coefficient, For the feature fusion matrix, For the first c A set of prototype vectors for each analysis category. C To analyze the number of categories.
[0119] S311: Perform linear classification calculation based on the normalized similarity of the several analysis categories, the feature fusion matrix, and the preset linear classification algorithm to obtain a linear classification matrix.
[0120] In this embodiment, the analysis device performs linear classification calculations based on the normalized similarity of the corresponding analysis categories of the task-specific reasoning module, the feature fusion matrix, and a preset linear classification algorithm to obtain a linear classification matrix. The linear classification matrix includes linear classification vectors for several analysis categories, and the linear classification algorithm is as follows:
[0121]
[0122] In the formula, For the first t The linear classification matrix corresponding to each task-specific reasoning module For linear classification weight parameters, This is the linear classification bias parameter.
[0123] S4: Input several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability and obtain several analysis category prediction probability data; obtain the text analysis result based on the several analysis category prediction probability data.
[0124] In this embodiment, the analysis device inputs several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability, thereby obtaining several analysis category prediction probability data; based on the several analysis category prediction probability data, the text analysis result is obtained.
[0125] Please see Figure 8 , Figure 8 The flowchart of S4 in the text analysis method provided in the first embodiment of this application is shown below, including steps S41 to S42, as follows:
[0126] S41: Extract the linear classification vectors of several analysis categories at several positions in the analysis category inference matrix, calculate the analysis category prediction probability according to the preset analysis category prediction probability algorithm, and obtain the analysis category prediction probability data.
[0127] In this embodiment, linear classification vectors of several analysis categories at several positions in the analysis category inference matrix are extracted. Analysis category prediction probabilities are calculated according to a preset analysis category prediction probability algorithm to obtain analysis category prediction probability data. The analysis category prediction probability data includes prediction probability vectors of several analysis categories at several positions. The analysis category prediction probability algorithm is as follows:
[0128]
[0129] In the formula, For the first t The first of the analysis category prediction probability data corresponding to the task-specific reasoning module. n The position of the first c The predicted probability vector for each analysis category, For the first t The first in the analysis category reasoning matrix corresponding to the task-specific reasoning module. n The position of the first c A linear classification vector for each analysis category.
[0130] S42: Averaging the predicted probability vectors of several positions of the same analysis category in the predicted probability data of the analysis category, to obtain the average predicted probability vector of several analysis categories; identifying the analysis category corresponding to the largest average predicted probability vector, to obtain the analysis categories corresponding to several task-specific reasoning modules; obtaining the text analysis results based on the analysis categories corresponding to several task-specific reasoning modules and the preset evaluation correspondence table.
[0131] In this embodiment, the analysis device averages the prediction probability vectors of several positions of the same analysis category in the analysis category prediction probability data to obtain the average prediction probability vectors of several analysis categories; the analysis category corresponding to the largest average prediction probability vector is identified to obtain the analysis categories corresponding to several task-specific reasoning modules.
[0132] The analysis device obtains text analysis results based on the analysis categories corresponding to several task-specific reasoning modules and a preset evaluation correspondence table.
[0133] Semantic features are extracted from the corpus to be analyzed. Using multiple task-specific reasoning modules, the obtained semantic feature matrices are used to perform analysis category reasoning for the corresponding tasks, resulting in analysis category reasoning matrices for multiple tasks. This is used for text analysis, which solves the problem of low efficiency in the analysis of traditional open-ended scientific explanation questions. It can help teachers understand students' cognitive trajectories in real time and provide a basis for precise teaching intervention.
[0134] In an optional embodiment, step S9 is further included: training the text evaluation model. See also... Figure 9 , Figure 9 The flowchart of S5 in the text analysis method provided in the sixth embodiment of this application is shown below, including steps S51 to S53, as follows:
[0135] S51: Obtain several training corpora, input the several training corpora into the text evaluation model, and obtain several analysis category prediction probability data of the several training corpora.
[0136] In this embodiment, the analysis device obtains several training corpora, wherein the training corpora include training question texts and several corresponding answer texts of the training question texts.
[0137] The analysis device inputs several training corpora into the text evaluation model to obtain several analysis category prediction probability data for the training corpora.
[0138] S52: Obtain the true probability data of the analysis category of the training corpus corresponding to the task-specific reasoning modules; calculate the cross-entropy loss of the predicted probability data of the analysis category and the true probability data of the analysis category to obtain the cross-entropy loss value of the training corpus corresponding to the task-specific reasoning modules; sum up the cross-entropy loss values corresponding to the same task-specific reasoning module to obtain the total cross-entropy loss value corresponding to the task-specific reasoning modules.
[0139] In this embodiment, the analysis device obtains the true probability data of the analysis categories of several training corpora corresponding to several task-specific inference modules. Based on the predicted probability data of the analysis categories and the true probability data of the analysis categories of the training corpora corresponding to several task-specific inference modules, cross-entropy loss is calculated to obtain cross-entropy loss values for the training corpora corresponding to several task-specific inference modules. The cross-entropy loss values corresponding to the same task-specific inference module are then summed to obtain the total cross-entropy loss value corresponding to the several task-specific inference modules. The cross-entropy loss function is:
[0140]
[0141] In the formula, This represents the cross-entropy loss value. For the training corpus t The first item in the true probability data of the analysis category corresponding to the task-specific reasoning module. n The position of the first c The true probability vector of task classification for each analysis category. For the training corpus t The first of the analysis category prediction probability data corresponding to the task-specific reasoning module. n The position of the first c A predicted probability vector for each analysis category.
[0142] The analysis device accumulates several cross-entropy loss values corresponding to the same task-specific inference module to obtain the total cross-entropy loss value corresponding to several task-specific inference modules.
[0143] S53: Calculate the joint loss value for multiple tasks based on the cross-entropy loss value corresponding to the same task-specific inference module to obtain a joint loss value corresponding to several task-specific inference modules. Summate the total cross-entropy loss value and the joint loss value to obtain a total loss value. Train the text evaluation model based on the total loss value.
[0144] In this embodiment, the analysis device calculates a multi-task joint loss value based on the cross-entropy loss value corresponding to the same task-specific inference module, thereby obtaining a joint loss value corresponding to several task-specific inference modules, wherein the multi-task joint loss value is:
[0145]
[0146] In the formula, This is the joint loss value for multiple tasks. Z The number of cross-entropy loss values for the training corpus. For the first t The log-variance parameter corresponding to each task-specific inference module.
[0147] The analysis device accumulates several total cross-entropy loss values and several joint loss values to obtain a total loss value; the text evaluation model is trained based on the total loss value.
[0148] The analysis device accumulates the total cross-entropy loss and joint loss values corresponding to several task-specific inference modules to obtain a total loss value. Based on this total loss value, backpropagation is used to repeatedly calculate the gradient and train the text evaluation model. Variational inference derives the relative confidence between tasks, causing the gradient norm of high-uncertainty tasks to adaptively decay during parameter updates, while simultaneously strengthening the dominance of low-uncertainty tasks in the shared representation space. This mechanism achieves dynamic equilibrium in multi-task optimization of the text evaluation model by implicitly coupling the geometric features of the loss surface.
[0149] In an optional embodiment, step S6 is further included: training the text evaluation model. See also... Figure 10 , Figure 10 The flowchart of S6 in the text analysis method provided in the seventh embodiment of this application is shown below, including steps S61 to S63, as follows:
[0150] S61: Construct several prompt templates corresponding to training question texts, input the prompt templates corresponding to several training question texts into a preset large language model for text generation, and obtain the mixed text corresponding to several training question texts.
[0151] In this embodiment, the analysis device constructs several prompt templates corresponding to training question texts, wherein the prompt templates include training question texts and prompt texts.
[0152] The analysis device inputs the prompt templates corresponding to several training question texts into a preset large language model to generate text, thereby obtaining mixed text corresponding to several training question texts. The large language model can be based on DeepSeek-671B or GPT-4o large language model.
[0153] S62: Perform dynamic masking language modeling on the mixed text corresponding to several training question texts to obtain the dynamic masking text corresponding to several training question texts and the context information of several words in the dynamic masking text.
[0154] In this embodiment, the analysis device performs dynamic masking language modeling on the mixed text corresponding to several training question texts to randomly mask 15%-30% of the key scientific terms in the mixed text, thereby obtaining the dynamic masked text corresponding to several training question texts and the context information of several words in the dynamic masked text.
[0155] S63: Calculate the loss value based on the context information of several words in the dynamic masked text corresponding to several training question texts and the preset loss function to obtain the sub-loss value, and train the feature extraction module in the text evaluation model based on the sub-loss value.
[0156] In this embodiment, the analysis device calculates the error loss value based on the contextual information of several words in the dynamic masked text corresponding to several training question texts and a preset error loss function. Based on the error loss value, the feature extraction module in the text evaluation model is trained. The error loss function is:
[0157]
[0158] In the formula, This is the error loss value. J The number of dynamically masked text. For the first q The dynamic mask text corresponding to each training question text. For the first dynamic mask text q One word, This represents the contextual information for the q-th word.
[0159] Please refer to Figure 11 , Figure 11 This is a schematic diagram of the structure of a text analysis device provided in the eighth embodiment of this application. The text analysis device can be implemented entirely or partially through software, hardware, or a combination of both. The text analysis device 11 includes:
[0160] The data acquisition module 111 is used to acquire the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning modules include a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer.
[0161] The feature processing module 112 is used to input the corpus to be analyzed into the feature extraction module for semantic feature extraction to obtain the semantic feature matrix of the corpus to be analyzed;
[0162] The category reasoning module 113 is used to input the semantic feature matrix of the corpus to be analyzed into several task-specific reasoning modules. Through the dynamic sparse attention layer, dynamic sparse attention features are extracted from the semantic feature matrix of the corpus to be analyzed, resulting in several dynamic sparse attention matrices. Through the gated interaction layer, gated features are extracted and interacted with from the several dynamic sparse attention matrices, resulting in several gated interaction matrices. Through the hybrid position-aware attention layer, hybrid position-aware attention features are extracted from the several gated interaction matrices, resulting in several hybrid position-aware attention matrices. Through the adaptive feature recombination layer, features are recombined from the several hybrid position-aware attention matrices, resulting in several adaptive feature recombination matrices. Through the linear layer, linear classification calculations are performed on the several adaptive feature recombination matrices, resulting in several category reasoning matrices.
[0163] The text analysis module 114 is used to input several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability, thereby obtaining several analysis category prediction probability data; and to obtain the text analysis result based on the several analysis category prediction probability data.
[0164] In this embodiment, a data acquisition module obtains the corpus to be analyzed and a text evaluation model. The corpus to be analyzed includes a target question text and corresponding answer texts. The text evaluation model includes a feature extraction module, several task-specific inference modules, and a category prediction module. The task-specific inference module includes a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature reorganization layer, and a linear layer. A feature processing module inputs the corpus to be analyzed into the feature extraction module for semantic feature extraction, obtaining a semantic feature matrix of the corpus. A category inference module inputs the semantic feature matrix of the corpus to be analyzed into several task-specific inference modules. The dynamic sparse attention layer performs dynamic sparse attention feature extraction on the semantic feature matrix of the corpus to be analyzed, obtaining several dynamic sparse attention features. A sparse attention matrix is generated. Through the gated interaction layer, gated feature extraction and feature interaction are performed on several dynamic sparse attention matrices to obtain several gated interaction matrices. Through the hybrid position-aware attention layer, hybrid position-aware attention features are extracted from several gated interaction matrices to obtain several hybrid position-aware attention matrices. Through the adaptive feature recombination layer, features are recombined from several hybrid position-aware attention matrices to obtain several adaptive feature recombination matrices. Through the linear layer, linear classification calculation is performed on several adaptive feature recombination matrices to obtain several analysis category inference matrices. Through the text analysis module, several analysis category inference matrices are input into the category prediction module for analysis category prediction probability calculation to obtain several analysis category prediction probability data. Based on the several analysis category prediction probability data, text analysis results are obtained. Semantic features are extracted from the corpus to be analyzed. Using multiple task-specific reasoning modules, the obtained semantic feature matrices are used to perform analysis category reasoning for the corresponding tasks, resulting in analysis category reasoning matrices for multiple tasks. This is used for text analysis, which solves the problem of low efficiency in the analysis of traditional open-ended scientific explanation questions. It can help teachers understand students' cognitive trajectories in real time and provide a basis for precise teaching intervention.
[0165] Please refer to Figure 12 , Figure 12 This is a schematic diagram of the structure of a computer device provided in the ninth embodiment of this application. The computer device 12 includes: a processor 121, a memory 122, and a computer program 123 stored in the memory 122 and executable on the processor 121. The computer device can store multiple instructions, which are applicable to the method steps of the embodiments shown in the first to seventh embodiments above being loaded and executed by the processor 121. For the specific execution process, please refer to the specific description of the embodiments shown in the first to seventh embodiments, which will not be repeated here.
[0166] The processor 121 may include one or more processing cores. The processor 121 connects to various parts of the server using various interfaces and lines, and executes various functions of the text analysis device 11 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 122, and by calling data stored in the memory 122. Optionally, the processor 121 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 121 may integrate one or a combination of several of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required to be displayed on the touch screen; and the modem is used for wireless communication. It is understood that the modem may also not be integrated into the processor 121 and may be implemented as a separate chip.
[0167] The memory 122 may include random access memory (RAM) or read-only memory. Optionally, the memory 122 may include a non-transitory computer-readable storage medium. The memory 122 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 122 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions), instructions for implementing the various method embodiments described above, etc.; the data storage area may store data involved in the various method embodiments described above, etc. Optionally, the memory 122 may also be at least one storage device located remotely from the aforementioned processor 121.
[0168] This application also provides a storage medium that can store multiple instructions. These instructions are applicable to being loaded by a processor and executed by the method steps of the first to seventh embodiments described above. For details of the execution process, please refer to the specific descriptions of the first to seventh embodiments, which will not be repeated here.
[0169] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0170] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0171] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the algorithm. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0172] In the embodiments provided by this invention, it should be understood that the disclosed apparatus / terminal devices and methods can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0173] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0174] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0175] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms.
[0176] This invention is not limited to the above-described embodiments. If any modifications or variations to this invention do not depart from the spirit and scope of this invention, and if such modifications and variations fall within the scope of the claims and equivalent technologies of this invention, then this invention also intends to include such modifications and variations.
Claims
1. A text analysis method, characterized in that, Includes the following steps: The system obtains the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning module includes a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer. The corpus to be analyzed is input into the feature extraction module for semantic feature extraction to obtain the semantic feature matrix of the corpus to be analyzed; The semantic feature matrix is input into several task-specific reasoning modules respectively. The semantic feature matrix is then convolved through the dynamic sparse attention layer to obtain a convolution matrix. A sparse mask matrix is then constructed from the convolution matrix to obtain a sparse mask matrix. The semantic feature matrix is decomposed by global projection to obtain a global projection matrix; according to a preset dynamic sparse attention feature extraction algorithm, dynamic sparse attention features are extracted from the sparse mask matrix and the global projection matrix to obtain several dynamic sparse attention matrices. Through the gated interaction layer, gated feature extraction and feature interaction are performed on several dynamic sparse attention matrices to obtain several gated interaction matrices. The hybrid position-aware attention layer decomposes the gated interaction matrix into a second projection matrix by performing a split projection decomposition. The second projection matrix includes a second query matrix, a second key matrix, and a second value matrix. The second query matrix and the second key matrix are then superimposed on a preset dual-mode position encoding matrix to obtain a third query matrix and a third key matrix. Based on the third head query matrix, the third head key matrix, the second head value matrix, and the preset second multi-head self-attention feature extraction algorithm, a second multi-head self-attention matrix is obtained, which serves as a hybrid position-aware attention matrix, and several hybrid position-aware attention matrices are obtained. The adaptive feature reorganization layer divides the hybrid position-aware attention matrix into several dimensional partitioning matrices; intra-group information interaction is performed on the several dimensional partitioning matrices to obtain several information interaction matrices; and intra-group self-attention matrix is obtained based on the several information interaction matrices and a preset intra-group self-attention algorithm. A linear transformation is performed on the in-group self-attention matrix to obtain an importance weight matrix. The hybrid position-aware attention matrix is multiplied channel by channel with the importance weight matrix to obtain a second intermediate feature matrix. The second intermediate feature matrix is then subjected to outer product and dimensionality reduction to obtain several adaptive feature recombination matrices. Through the linear layer, a linear classification calculation is performed on several adaptive feature recombination matrices to obtain several analysis category inference matrices; Several analysis category inference matrices are input into the category prediction module to calculate the analysis category prediction probability, thereby obtaining several analysis category prediction probability data; based on the several analysis category prediction probability data, the text analysis result is obtained.
2. The text analysis method according to claim 1, characterized in that: The feature extraction module includes several layers of encoders, and the encoders include multi-head self-attention units and post-processing units. The step of inputting the corpus to be analyzed into the feature extraction module for semantic feature extraction to obtain the semantic feature matrix of the corpus to be analyzed includes the following steps: The corpus to be analyzed is segmented into words and mapped into word vectors to obtain a word vector sequence; the word vector sequence is added to a preset sine and cosine position encoding matrix to obtain a word embedding matrix; The word embedding matrix is used as the input matrix of the first layer encoder. The input matrix is decomposed by split projection through the multi-head self-attention unit to obtain the first split projection matrix. According to the preset first multi-head self-attention feature extraction algorithm, multi-head self-attention features are extracted from the first split projection matrix to obtain the first multi-head self-attention matrix. The post-processing unit sequentially performs fully connected processing and activation processing on the first multi-head self-attention matrix to obtain the first intermediate feature matrix. The first multi-head self-attention matrix and the first intermediate feature matrix are subjected to residual concatenation and layer normalization to obtain a post-processing matrix, which is used as the output matrix of the first layer encoder. The output matrix of the first layer encoder is used as the input matrix of the next coding layer. This process is repeated until the output matrix of the last layer encoder is obtained, which is used as the semantic feature matrix.
3. The text analysis method according to claim 1, characterized in that, The step of performing gated feature extraction and feature interaction on several dynamic sparse attention matrices through the gated interaction layer to obtain several gated interaction matrices includes the following steps: Based on the preset gating parameter matrix and the preset activation function, the dynamic sparse attention matrix is activated to construct the gating weight matrix. The dynamic sparse attention matrix is multiplied element-wise with the gate weight matrix to obtain the gated feature matrix; The dynamic sparse attention matrix and the gated feature matrix are residually concatenated to obtain a residual concatenation matrix; The residual connection matrix is subjected to layer normalization to obtain the layer-normalized residual connection matrix, which is used as the gated interaction matrix.
4. The text analysis method according to claim 3, characterized in that, The step of inputting several adaptive feature recombination matrices into the linear layer for linear classification calculation to obtain several linear classification matrices includes the following steps: The adaptive feature reconstruction matrix is subjected to global linear projection and grouped convolution to obtain a global linear projection matrix and a grouped convolution matrix; the global linear projection matrix and the grouped convolution matrix are then fused to obtain a feature fusion matrix. Based on the feature fusion matrix, the preset set of prototype vectors of several analysis categories, and the preset normalized similarity calculation algorithm, normalized similarity is calculated to obtain the normalized similarity of several analysis categories. Linear classification is calculated based on the normalized similarity of the several analysis categories, the feature fusion matrix, and the preset linear classification algorithm to obtain the linear classification matrix.
5. The text analysis method according to claim 4, characterized in that, The step of inputting several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability and obtain several analysis category prediction probability data; and obtaining the text analysis result based on the several analysis category prediction probability data, includes the following steps: Extract linear classification vectors of several analysis categories at several positions in the analysis category inference matrix, calculate the analysis category prediction probability according to a preset analysis category prediction probability algorithm, and obtain analysis category prediction probability data, wherein the analysis category prediction probability data includes prediction probability vectors of several analysis categories at several positions. The predicted probability vectors of several positions within the same analysis category in the predicted probability data of the analysis category are averaged to obtain the average predicted probability vectors of several analysis categories; the analysis category corresponding to the largest average predicted probability vector is identified to obtain the analysis categories corresponding to several task-specific reasoning modules; and the text analysis results are obtained based on the analysis categories corresponding to several task-specific reasoning modules and a preset evaluation correspondence table.
6. The text analysis method according to claim 1, characterized in that, It also includes the step of training the text evaluation model; Training the text evaluation model includes the following steps: A number of training corpora are obtained, and the training corpora are input into the text evaluation model to obtain the analysis category prediction probability data of the training corpora corresponding to the task-specific reasoning modules. The training corpora include training question text and a number of corresponding answer texts of the training question text. Obtain the true probability data of the analysis categories of several training corpora corresponding to several task-specific reasoning modules; calculate the cross-entropy loss of several predicted probability data of several analysis categories and several true probability data of several analysis categories to obtain the cross-entropy loss value of several training corpora corresponding to several task-specific reasoning modules; accumulate the cross-entropy loss values of several cross-entropy loss values corresponding to the same task-specific reasoning module to obtain the total cross-entropy loss value corresponding to several task-specific reasoning modules; The joint loss value for multiple tasks is calculated based on the cross-entropy loss value corresponding to the same task-specific inference module, and the joint loss values corresponding to several task-specific inference modules are obtained. The total cross-entropy loss value and the joint loss value are accumulated to obtain the total loss value. The text evaluation model is trained based on the total loss value.
7. A text analysis device, characterized in that, include: The data acquisition module is used to acquire the corpus to be analyzed and the text evaluation model. The corpus to be analyzed includes the target question text and the corresponding answer text. The text evaluation model includes a feature extraction module, several task-specific reasoning modules and a category prediction module. The task-specific reasoning modules include a dynamic sparse attention layer, a gated interaction layer, a hybrid position-aware attention layer, an adaptive feature recombination layer and a linear layer. The feature processing module is used to input the corpus to be analyzed into the feature extraction module to extract semantic features and obtain the semantic feature matrix of the corpus to be analyzed. The analysis category reasoning module is used to input the semantic feature matrix of the corpus to be analyzed into several task-specific reasoning modules respectively, and to perform convolution processing on the semantic feature matrix through the dynamic sparse attention layer to obtain a convolution matrix; and to construct a sparse mask matrix from the convolution matrix to obtain a sparse mask matrix. The semantic feature matrix is decomposed by global projection to obtain a global projection matrix; according to a preset dynamic sparse attention feature extraction algorithm, dynamic sparse attention features are extracted from the sparse mask matrix and the global projection matrix to obtain several dynamic sparse attention matrices. Through the gated interaction layer, gated feature extraction and feature interaction are performed on several dynamic sparse attention matrices to obtain several gated interaction matrices. The hybrid position-aware attention layer decomposes the gated interaction matrix into a second projection matrix by performing a split projection decomposition. The second projection matrix includes a second query matrix, a second key matrix, and a second value matrix. The second query matrix and the second key matrix are then superimposed on a preset dual-mode position encoding matrix to obtain a third query matrix and a third key matrix. Based on the third head query matrix, the third head key matrix, the second head value matrix, and the preset second multi-head self-attention feature extraction algorithm, a second multi-head self-attention matrix is obtained, which serves as a hybrid position-aware attention matrix, and several hybrid position-aware attention matrices are obtained. The adaptive feature reorganization layer divides the hybrid position-aware attention matrix into several dimensional partitioning matrices; intra-group information interaction is performed on the several dimensional partitioning matrices to obtain several information interaction matrices; and intra-group self-attention matrix is obtained based on the several information interaction matrices and a preset intra-group self-attention algorithm. A linear transformation is performed on the in-group self-attention matrix to obtain an importance weight matrix. The hybrid position-aware attention matrix is multiplied channel by channel with the importance weight matrix to obtain a second intermediate feature matrix. The second intermediate feature matrix is then subjected to outer product and dimensionality reduction to obtain several adaptive feature recombination matrices. Through the linear layer, a linear classification calculation is performed on several adaptive feature recombination matrices to obtain several analysis category inference matrices; The text analysis module is used to input several analysis category inference matrices into the category prediction module to calculate the analysis category prediction probability and obtain several analysis category prediction probability data; based on the several analysis category prediction probability data, the text analysis result is obtained.
Citation Information
Patent Citations
Emotion recognition method and device for question and answer text and electronic equipment
CN116303947A