Chinese text generation system and method based on semantic analysis

By adopting semantic analysis-based methods in the Chinese text generation system, combining the dual-channel attention mechanism and graph neural network, the problem of insufficient understanding ability of traditional systems when dealing with complex sentence patterns and multimodal data is solved, and more accurate semantic understanding and more efficient feature learning are achieved.

CN120068879AActive Publication Date: 2025-05-30SHANDONG NORMAL UNIV

Patent Information

Application Number
CN202510224239.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-05-30
Estimated Expiration
2045-02-27

AI Technical Summary

Technical Problem

Traditional Chinese text generation systems are difficult to effectively capture the grammatical structure levels in sentences and the dependence between words, resulting in insufficient understanding of complex sentence patterns and long sentences, and poor performance when processing multimodal data.

Method used

The Chinese text generation system based on semantic analysis is adopted, and local semantic details and global context are analyzed and fusion through data acquisition, data processing, semantic analysis, semantic reasoning and text generation modules, combining the dual-channel attention mechanism, graph neural network and adaptive activation function.

Benefits of technology

It enhances the model's processing ability on multimodal data, can understand the dependence between long sentences and complex sentences more accurately, avoids ignoring context information, and improves the efficiency and expression ability of feature learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120068879A_ABST
    Figure CN120068879A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence, and discloses a Chinese text generation system and method based on semantic analysis, and the system comprises a data obtaining module which is used for obtaining multi-modal text data; the data processing module is used for preprocessing the obtained multi-modal text data to obtain preprocessed multi-modal text data; performing feature extraction on the preprocessed multi-modal text data, extracting a local dependency relationship by using a dependency tree, and obtaining a local semantic detail feature data set; bi LSTM is used to extract context information, and a global context feature data set is obtained; the semantic analysis module is used for analyzing the local semantic detail feature data set and the global context feature data set by adopting a double-channel attention mechanism to obtain a weighted local semantic detail feature data set and a weighted global context feature data set; the method can strengthen the processing capability of a complex language structure and automatically generate a high-quality Chinese text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology. More specifically, the present invention relates to a Chinese text generation system and method based on semantic analysis. Background Art

[0002] A patent with the application publication number CN113806619A discloses a semantic analysis system and a semantic analysis method. By using the key strings input by the user on the client side and the string data set obtained by recognizing the text of the file, the system performs segmentation using a word segmentation algorithm, calculates the distance degree between the key strings and the string data set, and then selects a connection sequence according to the distance degree. The connection sequence is sent to the client side through a cloud server to achieve efficient information processing of a large number of paper documents, and to realize the intelligent recommendation sorting according to the theme relevance of the large number of paper documents for display on the client side.

[0003] The following are the main problems existing in traditional Chinese text generation systems and methods:

[0004] It may not be able to effectively capture the syntactic structure level in a sentence and the dependency relationship between words, resulting in insufficient understanding ability for complex sentence patterns and long sentences. It only focuses on semantic information or structural information, but lacks the ability to process both simultaneously, resulting in poor performance when dealing with multi-modal data, especially in long texts, polysemous words, and complex syntactic structures, where understanding deviations are likely to occur. Traditional methods may ignore the global context when processing local semantics, resulting in the loss or confusion of context information in the analysis of the dependency relationship of long sentences and complex sentences. When updating features, there is a lack of fusion of adjacent information, resulting in low efficiency of feature learning, inability to fully utilize the information in the graph structure, and thus affecting the expression ability of features. Without an adaptive activation function mechanism, it may cause too much or too little information to spread in the deep network, resulting in problems such as gradient disappearance and gradient explosion, affecting the training effect of the network.

[0005] Some traditional graph calculation methods need to process the calculation of the entire graph, resulting in high computational and memory loads, especially when the graph is large, the computational efficiency is low. The lack of a dimensionality reduction mechanism may lead to too large feature dimensions, causing an excessive computational burden and easily leading to overfitting, affecting the generalization ability of the model. Without a mechanism for dynamically adjusting weights, it may cause the model to pay uneven attention to local and global features in different contexts, thereby affecting the accuracy of semantic understanding. Without the ability to flexibly adjust feature updates according to different contexts, it may cause the model to perform unstably in different scenarios and be unable to adapt to various language changes and context dependencies.

[0006] In view of this, the present invention proposes a Chinese text generation system and method based on semantic analysis to solve the above problems. Summary of the Invention

[0007] To overcome the above-mentioned defects of the prior art and to achieve the above object, the present invention provides the following technical solution: A Chinese text generation system based on semantic analysis, comprising:

[0008] A data acquisition module for acquiring multi-modal text data;

[0009] A data processing module for preprocessing the acquired multi-modal text data to obtain preprocessed multi-modal text data; extracting features from the preprocessed multi-modal text data, using a dependency tree to extract local dependency relationships to obtain a local semantic detail feature data set; using a BiLSTM to extract context information to obtain a global context feature data set;

[0010] A semantic analysis module that analyzes the local semantic detail feature data set and the global context feature data set using a dual-channel attention mechanism to obtain a weighted local semantic detail feature data set and a weighted global context feature data set; updating the weighted local semantic detail feature data set, and performing weighted fusion on the updated weighted local semantic detail feature data set and the weighted global context feature data set based on dynamic weight allocation to obtain a semantic vector space;

[0011] A semantic reasoning module for training a semantic reasoning model based on the semantic vector space; predicting multi-dimensional text labels based on the semantic reasoning model;

[0012] A text generation module for automatically generating Chinese text by a GPT decoder according to the multi-dimensional text labels; and the various modules are connected by wired and / or wireless means.

[0013] Further, the multi-modal text data includes literal text, structured text, colloquial text, and classical Chinese text.

[0014] Further, the method for preprocessing the acquired multi-modal text data includes:

[0015] Performing text cleaning on the acquired multi-modal text data to remove punctuation marks, redundant spaces, and non-language symbols; standardizing the expression of numbers and time and uniformly converting them into a standard format; performing word segmentation on the multi-modal text data after text cleaning using a forward maximum matching algorithm to obtain a text word sequence X = [x 1 ,..., x o ,..., x n ; where x 1 is the first word in the text word sequence; x nis the nth word in the text word sequence; n is the total number of words in the text word sequence; o is the index of the word sequence number in the text word sequence, o = 1, 2,..., n; the text word sequence is converted into a word vector representation through the Word2Vec model, and then the word embedding sequence E = [e 1 ,..., e o ,..., e n ; where, e 1 is the word vector corresponding to the first word in the text word sequence; e o is the word vector corresponding to the oth word in the text word sequence; e n is the word vector corresponding to the nth word in the text word sequence.

[0016] Furthermore, the method for feature extraction of the preprocessed multi-modal text data includes: capturing local semantic details of the multi-modal text data through dependency syntactic analysis, and generating a local semantic detail feature data set in combination with the word embedding sequence; capturing the global context dependency relationship of the multi-modal text data through BiLSTM, and then obtaining a global context feature data set;

[0017] S41. Generate a dependency tree for the text word sequence X through the dependency syntactic analysis tool SpaCy; each node of the dependency tree has a parent node and a dependency relationship; for any word x o in the text word sequence, the local dependency information in the multi-modal text data is Dep o =(x o , x P(o) , r(x o , x P(o) )); where, x P(o) is the parent node of the word x o ; r(x o , x P(o) ) is the dependency relationship between the word x o and its parent node word x P(o) ;

[0018] S42. Concatenate the local dependency information Dep o of the word x o with the word vector representation of the word x o , and then obtain the local semantic detail feature of the word x o where, e o is the word vector representation of the word x o ; e P(o) is the parent node word x o of the word x P(o)The word vector representation; concat() is the concatenation operation symbol; collect the local semantic detail features of all words in the text word sequence, and then obtain the local semantic detail feature dataset;

[0019] S43. Take the word embedding sequence E as the input data of the BiLSTM, and generate the forward hidden state and backward hidden state of each word in the word embedding sequence; for any word vector representation e o in the word embedding sequence, concatenate the forward hidden state and backward hidden state of e o to obtain the word vector representation containing context information. Collect the word vector representations containing context information of all words, and then obtain the global context feature dataset.

[0020] Furthermore, the method for analyzing the local semantic detail feature dataset and the global context feature dataset by using the dual-channel attention mechanism includes:

[0021] The dual-channel attention mechanism includes a content attention channel and a structure attention channel; analyze the global context feature dataset in the content attention channel to capture the semantic features at the content level; analyze the local semantic detail feature dataset in the structure attention channel to capture the semantic features at the structure level;

[0022] S51. Preset the local semantic detail feature dataset as: X oc ∈R n×d ; where n represents the number of words; d represents the feature dimension; perform a linear transformation on the local semantic detail feature dataset to calculate the query matrix and key matrix of the local semantic detail feature dataset; preset the query matrix of the local semantic detail feature dataset as: Q oc =X oc W Q ; where W Q is the trainable parameter of the query matrix; preset the key matrix of the local semantic detail feature dataset as: K oc =X oc W K ; where W K is the trainable parameter of the key matrix; the where d k is the feature dimension in the attention calculation, and d k ≤d; S52. Calculate the structural association degree between words through the dot product of the query matrix and key matrix of the local semantic detail feature dataset, and then obtain the structural attention weight: where A ru is the structural attention weight matrix; sx is the normalization operation; is the transpose of the key matrix of the local semantic detail feature dataset;

[0023] S53. Weight all local semantic detail features in the local semantic detail feature dataset respectively through the structural attention weights, and then obtain the weighted local semantic detail feature dataset;

[0024] S54. Construct a dependency tree adjacency matrix; Preset \(A\in R\) n×n as the dependency tree adjacency matrix, and the elements in the dependency tree adjacency matrix \(A\) where \(dp(i,j) = 1\) indicates that there is a dependency relationship between word \(i\) and word \(j\); \(dp(i,j)\neq1\) indicates that there is no dependency relationship between word \(i\) and word \(j\);

[0025] S55. Update the obtained weighted local semantic detail feature dataset through a graph neural network; Use the weighted local semantic detail feature dataset as the initial local feature of the input layer of the graph neural network, and preset the initial local feature as \(H\) oc (0), and use the graph neural network to iterate through \(L\) layers, and then obtain the updated weighted local semantic detail feature dataset;

[0026] S56. Preset the global context feature dataset as \(X\) ob \(\in R\) n×d , perform a linear transformation on the global context feature dataset, and calculate the query matrix and key matrix of the global context feature dataset; Through the dot product of the query matrix and key matrix of the global context feature dataset, calculate the correlation between each word and other words, and then obtain the content attention weights;

[0027] S57. Weight all global context features in the global context feature dataset respectively through the content attention weights, and then obtain the weighted global context feature dataset.

[0028] Further, the method of using the graph neural network to iterate through \(L\) layers includes:

[0029] In each layer of the graph neural network, update the local features through the local feature update formula; The local feature update formula is: \(H\) oc (L + 1)=\(\sigma\) θ(L) (AH\(^{ oc (L)W(L)+b(L))); where \(H\) oc (L + 1) is the local feature representation of the \((L + 1)\)-th layer; \(\sigma\) θ(L) is the adaptive activation function; \(A\) is the dependency tree adjacency matrix; \(H\) oc (L) is the local feature representation of the \(L\)-th layer; \(W(L)\) is the trainable weight of the \(L\)-th layer; \(b(L)\) is the bias term of the \(L\)-th layer;

[0030] The adaptive activation function is: where \(\theta\)1 is the adjustment coefficient for the graph neural network layer; θ 2 is the adjustment coefficient for the number of features; r is the input of the adaptive activation function; θ 3 is the bias term of the translation adaptive activation function.

[0031] Furthermore, the method for obtaining the semantic vector space includes:

[0032] Fuse the updated weighted local semantic detail feature dataset and the weighted global context feature dataset through a weighted model to obtain a comprehensive feature dataset; aggregate the comprehensive feature dataset through global average pooling, and then perform a dimensionality reduction operation to map the aggregated comprehensive feature dataset to a low-dimensional space, thereby obtaining the semantic vector space;

[0033] The weighted model is: HG = g·H 1 +(1 - g)·H 2 ; where H 1 is the updated weighted local semantic detail feature dataset; H 2 is the weighted global context feature dataset; g is the weight coefficient of the updated weighted local semantic detail feature dataset, which is adjusted through a dynamic weight allocation formula; (1 - g) is the weight coefficient of the weighted global context feature dataset;

[0034] The dynamic weight allocation formula is where h 1i is the updated weighted local semantic detail feature of word i; h 2i is the weighted global context feature of word i; w 1 is the weight matrix of the gating network; b g is the bias term; is the Sigmoid activation function; i is the index of the word sequence number; [h 1i , h 2i is a vector containing the updated weighted local semantic detail feature and the weighted global context feature of word i.

[0035] Furthermore, the training method of the semantic reasoning model includes:

[0036] Divide the dataset into a training set, a validation set, and a test set; construct a semantic reasoning model, which includes an input layer, a self-attention layer, a feed-forward network layer, and an output layer; the input layer of the model is used to input the historical semantic vector space, and the output layer of the model is used to output the corresponding multi-dimensional text label; use the softmax function as the activation function; the semantic reasoning model is a multi-dimensional text label;

[0037] Use multi-class cross-entropy as the loss function of the model to measure the difference between the predicted value and the actual value of the model; use the training set to train the semantic reasoning model, and update the model parameters through the backpropagation algorithm to minimize the loss function; use the validation set to evaluate the performance of the semantic reasoning model by calculating the accuracy metric;

[0038] Select the SGD optimization algorithm as the optimizer, tune the model according to the performance feedback of the validation set, and adjust the model parameters until the performance no longer improves or reaches the preset number of iterations and then stop; use the test set to evaluate the performance of the model in the prediction task, and use the trained semantic reasoning model to predict the current fault status data to obtain the semantic reasoning model.

[0039] Furthermore, the multi-dimensional text labels include text category labels, semantic role labels, sentiment tendency labels, text theme labels, text style labels, text tense labels, and text voice labels.

[0040] Furthermore, the Chinese text generation system based on semantic analysis includes:

[0041] S1. Obtain multi-modal text data;

[0042] S2. Preprocess the obtained multi-modal text data to obtain preprocessed multi-modal text data; extract features from the preprocessed multi-modal text data, use the dependency tree to extract local dependency relationships to obtain a local semantic detail feature dataset; use BiLSTM to extract context information to obtain a global context feature dataset;

[0043] S3. Analyze the local semantic detail feature dataset and the global context feature dataset using a dual-channel attention mechanism to obtain a weighted local semantic detail feature dataset and a weighted global context feature dataset; update the weighted local semantic detail feature dataset, and perform weighted fusion on the updated weighted local semantic detail feature dataset and the weighted global context feature dataset based on dynamic weight allocation to obtain a semantic vector space;

[0044] S4. Train to obtain a semantic reasoning model according to the semantic vector space; based on the semantic reasoning model, predict to obtain multi-dimensional text labels;

[0045] S5. Automatically generate Chinese text through the GPT decoder according to the multi-dimensional text labels.

[0046] The technical effects and advantages of the Chinese text generation system based on semantic analysis of the present invention:

[0047] Through the structural attention channel, the dependency relationship between words can be captured, thereby capturing the hierarchical features of the grammatical structure, which is very important for understanding the grammatical structure of sentences and the relationship between words; through the content attention channel, the semantic association between words can be effectively captured. The content attention channel can explore the actual semantics of vocabulary and help understand the deep meaning of the text; by processing content and structural information through two independent channels respectively, the model can pay attention to semantic and structural features at the same time, enhancing the model's ability to process multimodal data, which enables the model to perform well in complex text analysis tasks, such as long texts, complex sentences and polysemous words; through the combined analysis of local semantic details and global context, the model can weight local semantics within the framework of the global context, thereby forming a more accurate semantic understanding, which is particularly suitable for processing dependencies in long and complex sentences, avoiding the neglect of contextual information in traditional methods; using graph neural networks, dependency information can be introduced into the feature update process, and local features can be efficiently learned;

[0048] At each layer, local features are updated through the iterative update formula of the graph neural network, which enables the model to gradually incorporate more adjacent information through a multi-layer structure, thereby better capturing the relationships and dependencies between nodes. The update of each layer takes into account the information of adjacent nodes and combines the features of the current node to regenerate the updated feature representation; the use of adaptive activation functions allows the feature updates of each layer to be dynamically adjusted according to the input of the current layer, the number of features, and the number of layers. The adaptive activation function introduces adjustment coefficients for the number of layers and features, allowing the model to more flexibly adapt to differences in feature propagation and feature importance at different layers, thereby improving the expressiveness of the model;

[0049] By adjusting the coefficient of the graph neural network layer and controlling the effect of the number of layers on the activation function, the model can reasonably maintain or suppress the intensity of information propagation in the deep network to avoid excessive information accumulation or loss. The graph neural network updates features layer by layer, avoiding the need to directly process the complex calculations of the entire graph, and improves computing efficiency and memory utilization through the gradual fusion of local information. The feature update of each layer depends only on the information of the current node and its adjacent nodes, thereby reducing the complexity of the calculation of the entire graph;

[0050] Through the dynamic weight allocation formula, the model can automatically adjust the weights of local and global features according to specific words and contextual information. This dynamic adjustment mechanism enables the model to flexibly adjust the focus according to different contexts, thereby improving the flexibility and expressiveness of the model; global average pooling and dimensionality reduction operations can effectively reduce the dimension of features, reduce the computational burden of the model, and avoid the accumulation of redundant information. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 Structural schematic diagram of the Chinese text generation system based on semantic analysis of the present invention;

[0052] Figure 2 Flow schematic diagram of the Chinese text generation method based on semantic analysis of the present invention. Specific implementation manners

[0053] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0054] Embodiment 1

[0055] Please refer to Figure 1 As shown, the Chinese text generation system based on semantic analysis in this embodiment includes:

[0056] A data acquisition module for acquiring multimodal text data;

[0057] A data processing module for preprocessing the acquired multimodal text data to obtain preprocessed multimodal text data; extracting features from the preprocessed multimodal text data, using a dependency tree to extract local dependency relationships to obtain a local semantic detail feature dataset; using a BiLSTM to extract context information to obtain a global context feature dataset;

[0058] A semantic analysis module that analyzes the local semantic detail feature dataset and the global context feature dataset using a dual-channel attention mechanism to obtain a weighted local semantic detail feature dataset and a weighted global context feature dataset; updating the weighted local semantic detail feature dataset, and performing weighted fusion on the updated weighted local semantic detail feature dataset and the weighted global context feature dataset based on dynamic weight allocation to obtain a semantic vector space;

[0059] A semantic reasoning module for training a semantic reasoning model based on the semantic vector space; predicting multi-dimensional text labels based on the semantic reasoning model;

[0060] A text generation module for automatically generating Chinese text according to the multi-dimensional text labels through a GPT decoder; each module is connected in a wired and / or wireless manner.

[0061] The multimodal text data includes literal text, structured text, colloquial text, and classical Chinese text.

[0062] The method for preprocessing the acquired multimodal text data includes:

[0063] Perform text cleaning on the acquired multimodal text data, removing punctuation, redundant spaces, and non-verbal symbols; standardize the expression of numbers and time, and uniformly convert them into a standard format; use the forward maximum matching algorithm to segment the multimodal text data after text cleaning, splitting the text into meaningful words to improve the semantic modeling effect, and then obtain the text word sequence X = [x 1 ,..., x o ,..., x n ; where x 1 is the first word in the text word sequence; x n is the nth word in the text word sequence; n is the total number of words in the text word sequence, that is, the length of the sequence; o is the index of the word sequence number in the text word sequence, o = 1, 2,..., n; the maximum matching method is a segmentation algorithm based on dictionary matching, belonging to the greedy algorithm, mainly used for tasks such as Chinese word segmentation and string splitting; its core idea is: in the given dictionary, each time select the longest word that matches the text prefix (or suffix) for segmentation, applicable to tasks such as Chinese word segmentation and string splitting, and can efficiently process large-scale text; convert the text word sequence into a word vector representation through the Word2Vec model to capture the semantic relationship between words, and then obtain the word embedding sequence E = 9e 1 ,..., e o ,..., e n ; where e 1 is the word vector corresponding to the first word in the text word sequence; e o is the word vector corresponding to the oth word in the text word sequence; e n is the word vector corresponding to the nth word in the text word sequence.

[0064] The method for feature extraction of the preprocessed multimodal text data includes:

[0065] Capture local semantic details of the multimodal text data through dependency syntactic analysis, and generate a local semantic detail feature dataset in combination with the word embedding sequence; capture the global context dependency relationship of the multimodal text data through BiLSTM, and then obtain the global context feature dataset;

[0066] S41. Dependency syntactic analysis is an important technology in natural language processing, used to analyze the grammatical relationship between words in a sentence; generate a dependency tree for the text word sequence X through the dependency syntactic analysis tool SpaCy; each node of the dependency tree has a parent node and a dependency relationship; for any word x o in the text word sequence, the local dependency information in the multimodal text data is Dep o = (xo ,x P(o) ,r(x o ,x P(o) )); where x P(o) For word x o The parent node of r(x o ,x P(o) ) is word x o Its parent node word x P(o) The dependencies between them;

[0067] The dependency tree is the result of dependency syntactic analysis. It uses a tree structure to represent the dependency relationship between words in a text word sequence. Each node of the dependency tree represents a word in the text word sequence. The edges between nodes represent the dependency relationship between words, which is usually represented by a label (such as subject-predicate, verb-object, attributive, etc.). Except for the root node, each node has a parent node, which indicates that the word depends on another word. The root node is the only node in the dependency tree without a parent node, and usually represents the core predicate of a sentence. For example, for a text sequence X = [I, like, eat, apple], after the text sequence is converted into a dependency tree, the root node is [like], and the local dependency information of the text sequence is: Dep 1 =(I, like, subject), Dep 3 =(eat, like, object), etc.;

[0068] S42, word x o The local dependency information Dep o With word x o The word vector representation of is concatenated to obtain the word x o Local semantic detail features Among them, e o For word x o The word vector representation of P(o) For word x o The parent node word x P(o) The word vector representation of ; concat() is the concatenation operation symbol; collect the local semantic detail features of all words in the text word sequence, and then obtain the local semantic detail feature data set;

[0069] S43, take the word embedding sequence E as the input data of BiLSTM, generate the forward hidden state and reverse hidden state of each word in the word embedding sequence; for any word vector representation e in the word embedding sequence o , e o The forward hidden state and the reverse hidden state are concatenated to obtain the word vector representation containing the context information. Collect the word vector representations of all words that include context information, and then obtain the global context feature dataset; the forward hidden state is the hidden state generated for each word when the forward LSTM processes the word embedding sequence from left to right, capturing the context information before the word; the backward hidden state is the hidden state generated for each word when the backward LSTM processes the word sequence from right to left, capturing the context information after the word.

[0070] The method for analyzing the local semantic detail feature dataset and the global context feature dataset using a dual-channel attention mechanism includes:

[0071] The dual-channel attention mechanism includes a content attention channel and a structure attention channel; analyze the global context feature dataset in the content attention channel to capture semantic features at the content level; analyze the local semantic detail feature dataset in the structure attention channel to capture semantic features at the structure level; the dual-channel attention mechanism combines the attention mechanisms of content and structure information, aiming to capture semantic features at different levels in the input data through two independent channels (content attention channel and structure attention channel), and can effectively process complex multi-modal text data;

[0072] S51. Preset the local semantic detail feature dataset as: X oc ∈R n×d ; where n represents the number of words; d represents the feature dimension; perform a linear transformation on the local semantic detail feature dataset to calculate the query matrix and key matrix of the local semantic detail feature dataset; the query matrix of the preset local semantic detail feature dataset is: Q oc =X oc W Q ; where W Q is the trainable parameter of the query matrix; the key matrix of the preset local semantic detail feature dataset is: K oc =X oc W K ; where W K is the trainable parameter of the key matrix; the where d k is the feature dimension in the attention calculation, and d k ≤d; S52. Calculate the structural association degree between words through the dot product of the query matrix and the key matrix of the local semantic detail feature dataset, and then obtain the structural attention weight: where A ru is the structural attention weight matrix; sx is the normalization operation used to make the sum of the weights equal to 1; is the transpose of the key matrix of the local semantic detail feature dataset;

[0073] S53. Weight all local semantic detail features in the local semantic detail feature dataset respectively through structural attention weights, and then obtain a weighted local semantic detail feature dataset;

[0074] S54. Construct a dependency tree adjacency matrix; Preset A ∈ R n×n as the dependency tree adjacency matrix, and the elements in the dependency tree adjacency matrix A where dp(i, j) = 1 indicates that there is a dependency relationship between word i and word j; dp(i, j) ≠ 1 indicates that there is no dependency relationship between word i and word j;

[0075] S55. Update the obtained weighted local semantic detail feature dataset through a graph neural network; Use the weighted local semantic detail feature dataset as the initial local feature of the input layer of the graph neural network, and preset the initial local feature as H oc (0), and use the graph neural network to perform L-layer iteration, and then obtain an updated weighted local semantic detail feature dataset;

[0076] S56. Preset the global context feature dataset as X ob ∈ R n×d , perform a linear transformation on the global context feature dataset, and calculate the query matrix and key matrix of the global context feature dataset; Through the dot product of the query matrix and key matrix of the global context feature dataset, calculate the correlation between each word and other words, and then obtain content attention weights;

[0077] S57. Weight all global context features in the global context feature dataset respectively through content attention weights, and then obtain a weighted global context feature dataset.

[0078] The method of using the graph neural network to perform L-layer iteration includes:

[0079] In each layer of the graph neural network, update the local feature through the local feature update formula; The local feature update formula is: H oc (L + 1) = σ θ(L) (AH oc (L)W(L) + b(L)); where, H oc (L + 1) is the local feature representation of the (L + 1)-th layer; σ θ(L) is an adaptive activation function; A is the dependency tree adjacency matrix; H oc (L) is the local feature representation of the L-th layer; W(L) is the trainable weight of the L-th layer; b(L) is the bias term of the L-th layer;

[0080] The adaptive activation function is: where θ 1is the adjustment coefficient for the graph neural network layer, which is used to control the influence of the number of graph neural network layers on the adaptive activation function; θ 2 is the adjustment coefficient for the number of features, which is used to control the influence of the number of local features on the adaptive activation function; r is the input of the adaptive activation function, usually the weighted sum result of the output of the previous layer; θ 3 is the bias term of the translational adaptive activation function.

[0081] The method for obtaining the semantic vector space includes:

[0082] Fuse the updated weighted local semantic detail feature dataset and the weighted global context feature dataset through a weighted model to obtain a comprehensive feature dataset; aggregate the comprehensive feature dataset through global average pooling, and then perform a dimensionality reduction operation to map the aggregated comprehensive feature dataset to a low-dimensional space, thereby obtaining the semantic vector space; the weighted model is: HG = g·H 1 +(1 - g)·H 2 ; where, H 1 is the updated weighted local semantic detail feature dataset; H 2 is the weighted global context feature dataset; g is the weight coefficient of the updated weighted local semantic detail feature dataset, which is adjusted through the dynamic weight allocation formula; (1 - g) is the weight coefficient of the weighted global context feature dataset;

[0083] The dynamic weight allocation formula is where, h 1i is the updated weighted local semantic detail feature of word i; h 2i is the weighted global context feature of word i; w 1 is the weight matrix of the gating network; b g is the bias term; is the Sigmoid activation function; i is the index of the word sequence number; [h 1i , h 2i is a vector containing the updated weighted local semantic detail feature and the weighted global context feature of word i.

[0084] The training method of the semantic reasoning model includes:

[0085] Divide the dataset into a training set, a validation set, and a test set; construct a semantic reasoning model, which includes an input layer, a self-attention layer, a feed-forward network layer, and an output layer; the input layer of the model is used to input the historical semantic vector space, and the output layer of the model is used to output the corresponding multi-dimensional text label; use the softmax function as the activation function; the semantic reasoning model is a multi-dimensional text label;

[0086] Use multi-class cross-entropy as the loss function of the model to measure the difference between the predicted value and the actual value of the model; use the training set to train the semantic reasoning model, and update the model parameters through the backpropagation algorithm to minimize the loss function; use the validation set to evaluate the performance of the semantic reasoning model by calculating the accuracy metric;

[0087] Select the SGD optimization algorithm as the optimizer, tune the model according to the performance feedback of the validation set, and stop adjusting the model parameters until the performance no longer improves or reaches the preset number of iterations; use the test set to evaluate the performance of the model in the prediction task, and use the trained semantic reasoning model to predict the current fault status data to obtain the semantic reasoning model.

[0088] The multi-dimensional text labels include text category labels, semantic role labels, sentiment tendency labels, text theme labels, text style labels, text tense labels, and text voice labels.

[0089] In this embodiment, through the structural attention channel, the dependency relationship between words can be captured, thereby capturing the hierarchical features of the grammatical structure, which is very important for understanding the grammatical structure of sentences and the mutual relationship between words; through the content attention channel, the semantic association between words can be effectively captured, and the content attention channel can mine the actual semantics of words to help understand the deep meaning of the text; by processing content and structural information through two independent channels, the model can simultaneously focus on semantic and structural features, enhancing the model's processing ability for multi-modal data, which enables the model to perform well in complex text analysis tasks, such as the processing of long texts, complex sentence patterns, and polysemous words; through the combined analysis of local semantic details and global context, the model can weight the local semantics within the framework of the global context, thereby forming a more accurate semantic understanding, which is particularly suitable for dealing with the dependency relationships in long sentences and complex sentences and avoiding the neglect of context information in traditional methods; using the graph neural network, the dependency relationship information can be introduced into the feature update process to efficiently learn local features;

[0090] At each layer, the local features will be updated through the iterative update formula of the graph neural network, which enables the model to gradually incorporate more adjacent information through multiple layers of structures, thereby better capturing the mutual relationships and dependencies between nodes. The update of each layer takes into account the information of adjacent nodes and combines the features of the current node to regenerate the updated feature representation; using the adaptive activation function can make the feature update of each layer be dynamically adjusted according to the input of the current layer, the number of features, and the number of layers. The adaptive activation function introduces adjustment coefficients for the number of layers and the number of features, enabling the model to more flexibly adapt to the differences in feature propagation and feature importance at different layers, thereby improving the model's expressive ability;

[0091] By adjusting the coefficients of the graph neural network layer, the influence of the number of layers on the activation function is controlled, so that in the deep network, the model can reasonably maintain or suppress the propagation intensity of information, avoiding excessive accumulation or loss of information. The graph neural network updates features iteratively layer by layer, avoiding complex calculations that directly process the entire graph. By gradually fusing local information, the computational efficiency and memory utilization are improved. The feature update of each layer only depends on the information of the current node and its adjacent nodes, thus reducing the complexity of the full-graph calculation;

[0092] Through the dynamic weight allocation formula, the model can automatically adjust the weights of local and global features according to specific words and context information. This dynamic adjustment mechanism enables the model to flexibly adjust the focus according to different contexts, thus enhancing the flexibility and expressive ability of the model; Global average pooling and dimensionality reduction operations can effectively reduce the dimensionality of features, lightening the computational burden of the model and avoiding the accumulation of redundant information.

[0093] Embodiment 2

[0094] Please refer to Figure 2 As shown, for the parts not described in detail in this embodiment, refer to the description content of Embodiment 1. A Chinese text generation method based on semantic analysis is provided, including:

[0095] S1. Obtain multimodal text data;

[0096] S2. Preprocess the obtained multimodal text data to obtain preprocessed multimodal text data; Extract features from the preprocessed multimodal text data, use the dependency tree to extract local dependency relationships, and obtain a local semantic detail feature dataset; Use Bi LSTM to extract context information and obtain a global context feature dataset;

[0097] S3. Analyze the local semantic detail feature dataset and the global context feature dataset using a dual-channel attention mechanism to obtain a weighted local semantic detail feature dataset and a weighted global context feature dataset; Update the weighted local semantic detail feature dataset, and perform weighted fusion on the updated weighted local semantic detail feature dataset and the weighted global context feature dataset based on dynamic weight allocation to obtain a semantic vector space;

[0098] S4. Train a semantic reasoning model according to the semantic vector space; Based on the semantic reasoning model, predict multi-dimensional text labels;

[0099] S5. Automatically generate Chinese text through the GPT decoder according to the multi-dimensional text labels.

[0100] Since the electronic device introduced in this embodiment is the electronic device adopted by the Chinese text generation system and method based on semantic analysis in the embodiments of the present application, based on the Chinese text generation system and method based on semantic analysis introduced in the embodiments of the present application, those skilled in the art can understand the specific implementation manners and various variations of the electronic device in this embodiment. Therefore, the specific implementation of how this electronic device implements the method in the embodiments of the present application will not be described in detail here. As long as those skilled in the art implement the electronic device adopted by the Chinese text generation system and method based on semantic analysis in the embodiments of the present application, it falls within the protection scope of the present application.

[0101] The above formulas are all dimensionless and take their numerical values for calculation. The formulas are obtained by collecting a large amount of data and performing software simulation to obtain a formula that is closest to the actual situation. The preset parameters and threshold selection in the formulas are set by those skilled in the art according to the actual situation.

[0102] The above description is only a preferred embodiment of the present invention. The protection scope of the present invention is not limited to the above embodiments. All technical solutions within the idea of the present invention belong to the protection scope of the present invention. It should be noted that for ordinary technical users in the technical field, several improvements and refinements made without departing from the principle of the present invention should also be regarded as within the protection scope of the present invention.

Claims

1. A Chinese text generation system based on semantic analysis, characterized in that: include: A data acquisition module, used to acquire multimodal text data; A data processing module is used to preprocess the acquired multimodal text data to obtain preprocessed multimodal text data; perform feature extraction on the preprocessed multimodal text data, use a dependency tree to extract local dependency relationships, and obtain a local semantic detail feature data set; Use BiLSTM to extract context information and obtain a global context feature dataset; The semantic analysis module uses a dual-channel attention mechanism to analyze the local semantic detail feature dataset and the global context feature dataset to obtain a weighted local semantic detail feature dataset and a weighted global context feature dataset; updates the weighted local semantic detail feature dataset, and performs weighted fusion on the updated weighted local semantic detail feature dataset and the weighted global context feature dataset based on dynamic weight allocation to obtain a semantic vector space; The semantic reasoning module is used to obtain a semantic reasoning model based on semantic vector space training; based on the semantic reasoning model, multi-dimensional text labels are predicted; The text generation module is used to automatically generate Chinese text according to multi-dimensional text tags through a GPT decoder; each module is connected by wire and / or wireless means.

2. The Chinese text generation system based on semantic analysis according to claim 1 is characterized in that: The multimodal text data includes textual text, structured text, colloquial text, and classical text.

3. The Chinese text generation system based on semantic analysis according to claim 2 is characterized in that: The method for preprocessing the acquired multimodal text data comprises: The obtained multimodal text data is cleaned to remove punctuation, redundant spaces and non-language symbols; the digital and time expressions are normalized and converted into a standard format; the forward maximum matching algorithm is used to segment the multimodal text data after text cleaning, and then the text word sequence X = x1,...,x o ,...,x n ]; x1 is the first word in the text word sequence; x n is the nth word in the text word sequence; n is the total number of words in the text word sequence; o is the index of the word sequence in the text word sequence, o = 1, 2, ..., n; the text word sequence is converted into a word vector representation through the Word2Vec model, and then the word embedding sequence E = [e1, ..., e o ,...,e n ]; where e1 is the word vector corresponding to the first word in the text word sequence; e o is the word vector corresponding to the oth word in the text word sequence; e n is the word vector corresponding to the nth word in the text word sequence.

4. The Chinese text generation system based on semantic analysis according to claim 3 is characterized in that: The method for extracting features from preprocessed multimodal text data includes: The local semantic details of multimodal text data are captured through dependency syntactic analysis, and a local semantic detail feature dataset is generated by combining word embedding sequences. The global context dependency of multimodal text data is captured through BiLSTM, thereby obtaining a global context feature dataset. S41. Generate a dependency tree for the text word sequence X through the dependency syntactic analysis tool SpaCy. Each node in the dependency tree has a parent node and a dependency relationship. For any word x in the text word sequence, o , the local dependency information in multimodal text data is Dep o =(x o ,x P(o) ,r(x o ,x P(o) )); where x P(o) For word x o The parent node of r(x o ,x P(o) ) is word x o Its parent node word x P(o) The dependencies between them; S42, word x o Local dependency information Dep o With word x o The word vector representation of is concatenated to obtain the word x o Local semantic detail features Among them, e o For word x o The word vector representation of P(o) For word x o The parent node word x P(o) The word vector representation of ; concat() is a concatenation operation symbol; collect the local semantic detail features of all words in the text word sequence, and then obtain the local semantic detail feature data set; S43, take the word embedding sequence E as the input data of BiLSTM, generate the forward hidden state and reverse hidden state of each word in the word embedding sequence; for any word vector representation e in the word embedding sequence o , e o The forward hidden state and the reverse hidden state are concatenated to obtain the word vector representation containing the context information. Collect word vector representations of all words containing contextual information to obtain a global context feature dataset.

5. The Chinese text generation system based on semantic analysis according to claim 4 is characterized in that: The method for analyzing the local semantic detail feature dataset and the global context feature dataset using the dual-channel attention mechanism includes: The dual-channel attention mechanism includes a content attention channel and a structural attention channel. In the content attention channel, the global context feature dataset is analyzed to capture the semantic features of the content level; in the structural attention channel, the local semantic detail feature dataset is analyzed to capture the semantic features of the structure level. S51. The preset local semantic detail feature dataset is: X oc ∈R n×d ; Where n represents the number of words; d represents the feature dimension; perform linear transformation on the local semantic detail feature data set to calculate the query matrix and key matrix of the local semantic detail feature data set; the query matrix of the local semantic detail feature data set is preset as: Q oc =X oc W Q ; Among them, W Q is the trainable parameter of the query matrix; the key matrix of the preset local semantic detail feature dataset is: K oc =X oc W K ; Among them, W K is the trainable parameter of the key matrix; Among them, d k is the feature dimension in attention calculation, and d k ≤d; S52. The structural association degree between words is calculated by taking the dot product of the query matrix and the key matrix of the local semantic detail feature data set, thereby obtaining the structural attention weight: Among them, A ru is the structural attention weight matrix; sx is the normalization operation; is the transpose of the key matrix of the local semantic detail feature dataset; S53, weighting all local semantic detail features in the local semantic detail feature dataset respectively by using the structural attention weight, thereby obtaining a weighted local semantic detail feature dataset; S54, construct dependency tree adjacency matrix; preset A∈R n×n is the dependency tree adjacency matrix. The elements in the dependency tree adjacency matrix A are Among them, dp(i,j)=1 means that there is a dependency relationship between word i and word j; dp(i,j)≠1 means that there is no dependency relationship between word i and word j; S55, updating the obtained weighted local semantic detail feature dataset through the graph neural network; using the weighted local semantic detail feature dataset as the initial local feature of the graph neural network input layer, and presetting the initial local feature as H oc (0) Use the graph neural network to iterate through L layers to obtain an updated weighted local semantic detail feature dataset; S56, presetting the global context feature dataset as X ob ∈R n×d , perform linear transformation on the global context feature dataset, calculate the query matrix and key matrix of the global context feature dataset; calculate the correlation between each word and other words through the dot product of the query matrix and key matrix of the global context feature dataset, and then obtain the content attention weight; S57. Weight all global context features in the global context feature dataset respectively by using content attention weights, and then obtain a weighted global context feature dataset.

6. The Chinese text generation system based on semantic analysis according to claim 5 is characterized in that: The method of iterating through L layers using a graph neural network includes: In each layer of the graph neural network, the local features are updated by the local feature update formula; the local feature update formula is: oc (L+1)=σ θ(L) (AH oc (L)W(L)+b(L)); where H oc (L+1) is the local feature representation of the L+1th layer; σ θ(L) is the adaptive activation function; A is the dependency tree adjacency matrix; H oc (L) is the local feature representation of the Lth layer; W(L) is the trainable weight of the Lth layer; b(L) is the bias term of the Lth layer; The adaptive activation function is: Among them, θ1 is the graph neural network layer adjustment coefficient; θ2 is the feature quantity adjustment coefficient; r is the input of the adaptive activation function; θ3 is the bias term of the translation adaptive activation function.

7. The Chinese text generation system based on semantic analysis according to claim 6 is characterized in that: The method for acquiring the semantic vector space includes: The updated weighted local semantic detail feature dataset and the weighted global context feature dataset are fused through a weighted model to obtain a comprehensive feature dataset; the comprehensive feature dataset is aggregated through global average pooling, and then a dimensionality reduction operation is performed to map the aggregated comprehensive feature dataset to a low-dimensional space, thereby obtaining a semantic vector space; The weighted model is: HG = g·H1+(1-g)·H2; where H1 is the updated weighted local semantic detail feature dataset; H2 is the weighted global context feature dataset; g is the weight coefficient of the updated weighted local semantic detail feature dataset, which is adjusted by the dynamic weight allocation formula; (1-g) is the weight coefficient of the weighted global context feature dataset; The dynamic weight allocation formula is g = θ·(w1·[h 1i ,h 2i ]+b g ), where h 1i is the updated weighted local semantic detail feature of word i; h 2i is the weighted global context feature of word i; w1 is the weight matrix of the gating network; b g is the bias term; θ is the Sigmoid activation function; i is the index of the word number; [h 1i ,h 2i ] is a vector containing the updated weighted local semantic detail features and weighted global context features of word i.

8. The Chinese text generation system based on semantic analysis according to claim 7 is characterized in that: The training method of the semantic reasoning model includes: Divide the data set into a training set, a validation set and a test set; construct a semantic reasoning model, which includes an input layer, a self-attention layer, a feedforward network layer and an output layer; the input layer of the model is used to input the historical semantic vector space, and the output layer of the model is used to output the corresponding multi-dimensional text label; use the softmax function as the activation function; the semantic reasoning model is a multi-dimensional text label; Use multi-classification cross entropy as the model's loss function to measure the difference between the model's predicted value and the actual value; use the training set to train the semantic reasoning model, and update the model parameters through the back-propagation algorithm to minimize the loss function; use the validation set to evaluate the performance of the semantic reasoning model by calculating the accuracy index; The SGD optimization algorithm is selected as the optimizer, and the model is tuned according to the performance feedback of the validation set. The model parameters are adjusted until the performance no longer improves or the preset number of iterations is reached. The performance of the model in the prediction task is evaluated using the test set, and the trained semantic reasoning model is used to predict the current fault status data to obtain the semantic reasoning model.

9. The Chinese text generation system based on semantic analysis according to claim 8, characterized in that: The multi-dimensional text labels include text category labels, semantic role labels, sentiment tendency labels, text topic labels, text style labels, text tense labels and text voice labels.

10. A Chinese text generation method based on semantic analysis, used to implement the Chinese text generation system based on semantic analysis as claimed in any one of claims 1 to 9, characterized in that: include: S1, obtaining multimodal text data; S2, preprocessing the acquired multimodal text data to obtain preprocessed multimodal text data; Perform feature extraction on the preprocessed multimodal text data, use the dependency tree to extract local dependencies, and obtain a local semantic detail feature dataset; Use BiLSTM to extract context information and obtain a global context feature dataset; S3, using a dual-channel attention mechanism to analyze the local semantic detail feature dataset and the global context feature dataset to obtain a weighted local semantic detail feature dataset and a weighted global context feature dataset; updating the weighted local semantic detail feature dataset, and performing weighted fusion on the updated weighted local semantic detail feature dataset and the weighted global context feature dataset based on dynamic weight allocation to obtain a semantic vector space; S4, obtaining a semantic reasoning model according to semantic vector space training; based on the semantic reasoning model, predicting a multi-dimensional text label; S5. Automatically generate Chinese text based on multi-dimensional text labels through the GPT decoder.

Citation Information

Patent Citations

  • Semantic analysis system and semantic analysis method

    CN113806619A

  • Semantic analysis method and system for dialogue scene

    CN117332789A

  • Method for keyword extraction and electronic device implementing the same

    US20210209356A1

Cited By

  • Method and system for detecting AI generation text and medium

    CN120849593A

  • Semantic splicing method and system, electronic equipment and storage medium

    CN120930653A

  • Text generation method and device, equipment, storage medium and program product

    CN121256024A