An English-Chinese text processing system and method based on cross-language feature alignment
Patent Information
- Application Number
- CN202611089049.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-08-28
AI Technical Summary
[0005]本发明的目的在于提供一种基于跨语言特征对齐的英汉文本处理系统及方法,从而解决了上述背景中下游跨语言检索任务的匹配准确率低的问题
1.本发明通过提取英文、中文初始语义向量对应的词性标签序列,利用词性筛选掩码筛选出核心语法锚点节点,规避了虚词等冗余信息的干扰,结合跨语言节点距离构建语言结构关联图,实现对英汉语言结构翻转逻辑的微观约束,解决了现有技术中全局特征平铺注意力计算导致的局部语义边界错位、特征分布发散问题,提升了英汉文本跨语言特征对齐的精准度;
Smart Images

Figure CN122655792A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of semantic processing technology, specifically to an English-Chinese text processing system and method based on cross-linguistic feature alignment. Background Technology
[0002] With the deepening application of natural language processing technology in cross-border business scenarios, the demand for multilingual information retrieval and bilingual corpus alignment has increased dramatically. In practical information processing systems, it is often necessary to calculate the semantic consistency between English and Chinese texts in the vector space. In related technologies, when performing English-Chinese bilingual text processing, English and Chinese texts are usually input into a pre-trained language model to extract sequence vectors. Then, a global self-attention mechanism is used to calculate the correlation distribution matrix between text sequences, and a vector alignment space is constructed based on the distribution features to complete downstream data processing tasks.
[0003] However, the related technologies have the following technical defects: there is an objective asymmetry in the underlying grammatical systems of English and Chinese. For example, English often uses post-modifier clauses to restrict the modified objects, while Chinese has a structural preference for using long pre-modifiers. The related technologies adopt a global feature tiling attention calculation method, which lacks micro-constraints on the cross-language structural flipping logic. This leads to the phenomenon of local semantic boundary misalignment in the vector mapping stage, causing the cross-language features to diverge in the dimensionality reduction space, which objectively reduces the matching accuracy of downstream cross-language retrieval tasks.
[0004] To address the above issues, a cross-linguistic feature alignment-based English-Chinese text processing system and method are proposed. Summary of the Invention
[0005] The purpose of this invention is to provide an English-Chinese text processing system and method based on cross-language feature alignment, thereby solving the problem of low matching accuracy in downstream cross-language retrieval tasks in the aforementioned context.
[0006] To achieve the above objectives, the present invention provides the following technical solution: A method for processing English and Chinese text based on cross-linguistic feature alignment, the method comprising: Obtain the English and Chinese text data to be processed; Perform word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese text data; Obtain the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; filter the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain the English grammar anchor node and the Chinese grammar anchor node; Obtain the cross-language node distance between English grammar anchor nodes and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, establish graph node connection edges between the corresponding English grammar anchor nodes and Chinese grammar anchor nodes to generate a language structure association graph; Calculate the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph; Based on the cross-attention weight matrix, feature fusion is performed on the initial English semantic vector and the initial Chinese semantic vector to generate a target-aligned feature representation.
[0007] Furthermore, based on the language structure association graph, the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector is calculated, including: Extract the graph node connection edges from the language structure association graph and generate the association structure bias matrix; Calculate the dot product matrix between the query matrix of the initial English semantic vector and the key matrix of the initial Chinese semantic vector; Add the bias matrix of the associated structure to the dot product result matrix to generate the target alignment matrix; Activation function operations are performed on the target alignment matrix to generate a cross-attention weight matrix.
[0008] Furthermore, feature fusion is performed on the initial English semantic vector and the initial Chinese semantic vector based on the cross-attention weight matrix to generate a target alignment feature representation, including: Convert the initial Chinese semantic vector into a value vector matrix; Calculate the product of the cross-attention weight matrix and the value vector matrix to generate an intermediate context vector; The initial semantic vector of English and the intermediate context vector are concatenated using tensors to generate the target-aligned feature representation.
[0009] Furthermore, after performing tensor concatenation between the initial English semantic vector and the intermediate context vector to generate the target alignment feature representation, the process also includes: The target alignment feature representation is input into the preset contrast loss function module to calculate the alignment deviation value; Adjust the mapping parameters of the word vector mapping based on the alignment deviation value.
[0010] Furthermore, the target alignment feature representation is input into a preset contrastive loss function module to calculate the alignment deviation value, including: Obtain the positive and negative sample alignment features from the target alignment feature representation; Calculate the first cosine similarity between the positive sample alignment features and the baseline semantic vector; Calculate the second cosine similarity between the negative sample alignment features and the baseline semantic vector; An alignment deviation value is generated based on the first cosine similarity and the second cosine similarity using a loss function.
[0011] Furthermore, word vector mapping is performed on the English and Chinese text data to generate initial semantic vectors for English and Chinese, including: Determine the clause boundary markers contained in the English and Chinese text data; The relative positional encoding weights are reset based on the clause boundary markers to generate a structured positional encoding matrix; Input the English and Chinese text sequences into the mBERT model to perform character embedding, obtain character embedding features, and add them to the structured positional encoding matrix to generate the initial semantic vectors for English and Chinese.
[0012] Furthermore, after establishing graph node connection edges between the corresponding English and Chinese grammar anchor nodes to generate a language structure association graph, the process also includes: Calculate the connection weight coefficients corresponding to the edges connecting each graph node in the language structure association graph. Compare the connection weight coefficients with the preset sparsity retention threshold; When the connection weight coefficient is less than the sparsity preservation threshold, delete the corresponding graph node connection edges and update the language structure association graph.
[0013] Furthermore, an activation function operation is performed on the target alignment matrix to generate a cross-attention weight matrix, including: Get the data length value corresponding to the Chinese syntax anchor node; Determine the asymmetric temperature scaling factor based on the data length value; Divide the element values in the target alignment matrix by the asymmetric temperature scaling factor to generate the scaled feature matrix; A normalized exponential function operation is performed on the scaled feature matrix to generate a cross-attention weight matrix.
[0014] Furthermore, after performing word vector mapping on the English and Chinese text data to generate initial semantic vectors for English and Chinese, the process also includes: Extract features of unregistered nodes from the initial English semantic vector and the initial Chinese semantic vector; Calculate the feature difference distance between the features of unlogged nodes and the features of adjacent known nodes; When the feature difference distance is greater than the preset distribution threshold, the features of known nodes within the adjacent preset range are extracted, the mean is calculated, and a compensation vector is generated. Add the features of unlogged nodes to the compensation vector to update the initial semantic vectors for English and Chinese.
[0015] A cross-linguistic feature alignment-based English-Chinese text processing system includes: The text data acquisition module acquires English and Chinese text data to be processed. The word vector mapping module performs word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese text data. The grammar anchor filtering module obtains the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; it filters the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain English grammar anchor nodes and Chinese grammar anchor nodes. The association graph generation module obtains the cross-language node distance between English grammar anchor nodes and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, it establishes graph node connection edges between the corresponding English grammar anchor nodes and Chinese grammar anchor nodes to generate a language structure association graph. The cross-attention calculation module calculates the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph. The feature fusion module performs feature fusion on the initial English semantic vector and the initial Chinese semantic vector based on the cross-attention weight matrix to generate a target-aligned feature representation.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention extracts the part-of-speech tag sequences corresponding to the initial semantic vectors of English and Chinese, uses part-of-speech filtering masks to filter out core grammatical anchor nodes, avoids interference from redundant information such as function words, and constructs a language structure association graph by combining cross-language node distances, thereby realizing micro-constraints on the logic of English and Chinese language structure flipping. It solves the problems of local semantic boundary misalignment and feature distribution divergence caused by global feature tiling attention calculation in the prior art, and improves the accuracy of cross-language feature alignment of English and Chinese texts. 2. This invention transforms the structural information of the language structure association graph into an association structure bias matrix, integrates it into the cross-attention calculation process, and combines it with an asymmetric temperature scaling factor to dynamically adjust the activation function operation. This makes the attention weight allocation not only dependent on semantic similarity, but also subject to the precise constraints of grammatical structure, avoiding misalignment of nodes that are semantically similar but grammatically mismatched, and further improving the rationality and pertinence of weight allocation. 3. Improve the processing effect of downstream cross-language tasks and enhance practicality. This invention achieves accurate feature fusion of the initial English semantic vector and the initial Chinese semantic vector through a cross-attention weight matrix, generating a target aligned feature representation with unified dimensions and semantic alignment. This effectively eliminates cross-language semantic bias and significantly improves the matching accuracy and processing quality of downstream English-Chinese translation, semantic retrieval, text matching and other tasks, and is suitable for a variety of practical application scenarios. 4. This invention integrates clause structure information through structured positional encoding, avoiding the shortcomings of traditional positional encoding that only focuses on word segmentation order and ignores clause structure; at the same time, it effectively compensates for semantic loss caused by out-of-vocabulary words through an out-of-vocabulary node feature compensation mechanism; by comparing the loss function to quantify alignment deviation and dynamically adjusting word vector mapping parameters, it continuously optimizes the integrity and accuracy of the initial semantic vector, providing more reliable feature support for subsequent cross-language alignment. 5. This invention reduces the complexity of subsequent cross-attention calculations by removing redundant connection edges with weak semantic associations through sparsification of the language structure association graph. At the same time, it adopts simple and efficient linear mapping and Euclidean distance calculation methods, which do not require a large amount of labeled data and complex network structure, thus balancing computational efficiency and alignment accuracy. It can flexibly adapt to the needs of English and Chinese text processing of different lengths and in different scenarios, and supports adaptive parameter adjustment, making it more adaptable. Attached Figure Description
[0017] Figure 1 This is a flowchart of the English-Chinese text processing method based on cross-language feature alignment according to the present invention. Figure 2 This is a diagram of the English-Chinese text processing system architecture based on cross-language feature alignment according to the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Example 1: like Figure 1 As shown, this embodiment provides an English-Chinese text processing method based on cross-linguistic feature alignment, including: Step 101: Obtain the English and Chinese text data to be processed; Specifically, the system reads English and Chinese text data to be processed through a preset data interface. The text data format supports common formats such as TXT, XML, and JSON, and is compatible with various input formats such as plain text and marked text. The English and Chinese text data to be processed can cover various scenarios such as news reports, technical documents, daily conversations, and academic papers. The text length can be flexibly adapted, and it can stably process texts from short sentences to long texts. English text data refers to a continuous text sequence with English words, phrases, and sentences as basic units, while Chinese text data refers to a continuous text sequence with Chinese characters, words, and sentences as basic units. The two can correspond to the same semantic scenario or semantically related scenarios.
[0020] Step 102: Perform word vector mapping on the English text data and Chinese text data to generate initial semantic vectors for English and Chinese. Step 103: Obtain the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; filter the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain the English grammar anchor node and the Chinese grammar anchor node.
[0021] Specifically, this step uniformly uses English and Chinese word segmentation sequences as annotation objects, with a one-to-one correspondence between the part-of-speech tag sequence and the word segmentation sequence, and is performed in two steps: The first step, part-of-speech tagging, employs open-source, precise part-of-speech tagging tools. For English word segments, NLTK is used uniformly, while for Chinese word segments, Jieba is used uniformly. Part-of-speech tagging is performed word-by-word for both English and Chinese word segments, generating a first part-of-speech tag sequence and a second part-of-speech tag sequence with the exact same length as the English and Chinese word segments. The first part-of-speech tag sequence corresponds to the English word segmentation sequence, with each tag corresponding to the part of speech of an English word; the second part-of-speech tag sequence corresponds to the Chinese word segmentation sequence, with each tag corresponding to the part of speech of a Chinese word.
[0022] The second step is filtering. The preset part-of-speech filtering mask is a binary vector with a length consistent with the type of part-of-speech tag. The position corresponding to the core part-of-speech tag that has grammatical representativeness is set to 1, and the position corresponding to the function word is set to 0. The part-of-speech filtering mask is matched element-wise with the first part-of-speech tag sequence and the second part-of-speech tag sequence respectively. The word segment with a mask value of 1 is retained, and the English initial semantic vector or Chinese initial semantic vector corresponding to the effective word segment is extracted as a vector node. The vector nodes corresponding to the word segment with a mask value of 0 are filtered. The retained vector nodes are the English grammatical anchor nodes and the Chinese grammatical anchor nodes.
[0023] Step 104: Obtain the cross-language node distance between English and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, establish graph node connection edges between the corresponding English and Chinese grammar anchor nodes to generate a language structure association graph; specifically as follows: The first step is to calculate the cross-language node distance. The Euclidean distance algorithm is used to calculate the semantic distance between each English grammar anchor node and each Chinese grammar anchor node. The calculation process is as follows: select any English grammar anchor node and any Chinese grammar anchor node, calculate the sum of squares of the differences between the corresponding dimension elements of the two nodes, and then take the square root of the sum of squares to obtain the Euclidean distance. The smaller the distance value, the higher the semantic similarity between the two nodes.
[0024] The second step is to set a distance threshold. The preset distance threshold is based on the overall distribution characteristics of the initial English semantic vector and the initial Chinese semantic vector output by mBERT pre-training. By statistically analyzing the semantic distance distribution range between a large number of general English grammar anchor nodes and Chinese grammar anchor nodes, a critical value that can accurately distinguish semantically matched or non-matched node pairs is selected as the basic threshold. At the same time, this threshold can be flexibly fine-tuned in the system parameters to adapt to different professional text scenarios.
[0025] The third step is to generate a language structure association graph. This involves traversing the distances between all English and Chinese grammatical anchor nodes. When the distance between nodes is less than a preset distance threshold, it is determined that the two nodes have a semantic correspondence, and a graph node connection edge is established between the two nodes. All valid connection edges and grammatical anchor nodes are arranged according to the spatial topology to generate the language structure association graph. The language structure association graph is an undirected graph with grammatical anchor nodes as vertices and semantic correspondences as edges, which intuitively reflects the grammatical and semantic associations between English and Chinese texts.
[0026] Step 105: Calculate the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph.
[0027] Step 106: Perform feature fusion on the initial English semantic vector and the initial Chinese semantic vector according to the cross-attention weight matrix to generate the target alignment feature representation.
[0028] In another implementation, when the text to be processed contains professional domain terms, domain terminology fine-tuning can be added to the pre-trained word vector model: collect English-Chinese bilingual terminology pairs in the domain, construct a fine-tuning dataset, and use mini-batch gradient descent to fine-tune the parameters of the pre-trained word vector model, optimize the word vector mapping accuracy of professional terms, and improve the domain adaptability of the target alignment features. The English-Chinese bilingual terminology pairs were obtained through bilingual terminology databases, industry standard documents, professional English-Chinese dictionaries, and bilingual parallel corpora. The specific process of fine-tuning the model parameters is as follows: the fine-tuning targets are the word embedding layer parameters, Transformer encoder layer weight parameters and bias parameters of the mBERT pre-trained model; freeze the general semantic parameters of the model at the bottom layer, and only fine-tune the top-level feature extraction parameters and word vector mapping parameters. This preserves the model's general cross-language semantic capabilities and optimizes the vector representation accuracy of professional terms in a targeted manner, avoiding overfitting caused by full fine-tuning.
[0029] The above technical solution establishes cross-linguistic structural associations with grammatical anchor nodes as the core, avoiding the shortcomings of traditional alignment methods that rely solely on semantic similarity and ignore grammatical structure. The cross-attention weight matrix, combined with linguistic structural information, makes semantic alignment more targeted and effectively reduces cross-linguistic semantic bias. The feature fusion process preserves the core semantics of English and Chinese texts, and the generated target alignment feature representation has a unified semantic space, providing high-precision feature support for downstream cross-linguistic tasks. Moreover, the entire process does not require a large amount of labeled data and is computationally efficient.
[0030] In some embodiments, step S105, which calculates the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph, includes: Step 201: Extract the graph node connection edges from the language structure association graph and generate the association structure bias matrix; details are as follows: (1) Traverse and extract: Traverse all graph nodes and connecting edges in the language structure association graph, and record the English grammar anchor node index, Chinese grammar anchor node index, and cross-language node distance between the two nodes corresponding to each edge.
[0031] (2) Distance normalization: Normalization calculation is performed on the cross-language node distances of the records. The min-max normalization algorithm is used to map the distance values to a bias coefficient between 0 and 1. The calculation process is as follows: subtract the distance between the current two nodes from the maximum value among all node distances, and then divide by the difference between the maximum and minimum values among all graph node distances to obtain the normalized bias coefficient.
[0032] (3) Matrix construction: Construct an association structure bias matrix that matches the dimensions of the initial English semantic vector and the initial Chinese semantic vector. The matrix dimension is the length of the initial English semantic vector × the length of the initial Chinese semantic vector. In this matrix, the node positions with connecting edges are filled with normalized bias coefficients, and the node positions without connecting edges are filled with 0. The association structure bias matrix refers to the matrix that reflects the association strength of English and Chinese grammatical anchor nodes, providing structural constraints for the calculation of cross-attention weights. The specific construction method of the association structure bias matrix is as follows: First, count the number of word segments M of the initial English semantic vector and the number of word segments N of the initial Chinese semantic vector, and initialize and generate a zero matrix with a dimension of M×N. Then, traverse all effective connecting edges, and fill the normalized bias coefficients into the corresponding row and column positions of the matrix according to the row index of the English node and the column index of the Chinese node corresponding to each connecting edge. The row and column positions without effective grammatical associations are always kept at 0. Finally, the complete construction of the association structure bias matrix is completed, realizing the matrix representation of grammatical structure information.
[0033] Step 202: Calculate the dot product matrix between the query matrix of the initial English semantic vector and the key matrix of the initial Chinese semantic vector; the details are as follows: (1) Linear mapping: The initial semantic vector of English has a dimension of M×d, where M is the number of English words and d is the vector dimension. The initial semantic vector of English is converted into a query matrix Q through a preset linear mapping layer. The weight matrix of the linear mapping layer has a dimension of d×d. The calculation process is to multiply the initial semantic vector of English with the linear mapping weight of the query matrix to obtain the query matrix Q. The initial semantic vector of Chinese has a dimension of N×d, where N is the number of Chinese words. The initial semantic vector of Chinese is converted into a key matrix K through another preset linear mapping layer. The weight matrix of this linear mapping layer has a dimension of d×d. The calculation process is to multiply the initial semantic vector of Chinese with the linear mapping weight of the key matrix to obtain the key matrix K. (2) Matrix transpose: Perform a transpose operation on the key matrix K to obtain the transposed key matrix; (3) Dot product operation: Perform matrix dot product operation on the query matrix Q and the transposed key matrix to calculate the original similarity between each English vector node and each Chinese vector node, and generate the dot product result matrix with the dimension of M×N. The calculation process is as follows: multiply the query matrix Q with the transposed key matrix to obtain the dot product result matrix; each element value of the dot product result matrix corresponds to the original semantic similarity between the i-th English vector node and the j-th Chinese vector node.
[0034] Step 203: Add the associated structure bias matrix to the dot product result matrix to generate the target alignment matrix; the details are as follows: Element-wise matrix addition is performed, adding each element of the associated structural bias matrix to the corresponding element in the dot product matrix. The calculation process is as follows: the element of the dot product matrix is added to the corresponding bias coefficient to obtain the corresponding element of the target alignment matrix, thus achieving the fusion of structural bias and original semantic similarity. Since only the nodes of the connecting edges in the associated structural bias matrix have non-zero bias coefficients, this addition operation strengthens the similarity of semantically similar and syntactically related node pairs, while weakening the similarity of non-syntactically related node pairs, generating a target alignment matrix with structural constraints, with a matrix dimension of M×N.
[0035] Step 204: Perform activation function operations on the target alignment matrix to generate the cross-attention weight matrix; details are as follows: (1) Activation operation: The normalized exponential function is used to normalize the elements of each row of the target alignment matrix. The calculation process is to divide the exponential value of the corresponding element of the target alignment matrix by the sum of the exponential values of all elements in that row to obtain the corresponding element of the cross attention weight matrix. (2) Output the results. After normalization, the sum of each row of the target alignment matrix is 1, resulting in the cross-attention weight matrix with a dimension of M×N. The value of each normalized element is the attention weight of the English vector node to the Chinese vector node. The larger the weight value, the greater the semantic contribution of the Chinese vector node to the English vector node. The cross-attention weight matrix refers to the attention allocation matrix that integrates the grammatical structure association, which can accurately capture the semantic correspondence between English and Chinese texts.
[0036] The above technical solution transforms the structural information of the language structure association graph into an association structure bias matrix, which is then integrated into the cross-attention calculation process. This ensures that the attention weight allocation depends not only on semantic similarity but also on grammatical structure constraints, avoiding misalignment of nodes that are semantically similar but grammatically mismatched. The dot product operation combined with the activation function achieves accurate normalization of the attention weights. The generated cross-attention weight matrix has both semantic and structural constraints, providing a weight basis for subsequent feature fusion. Moreover, the calculation process is simple and can be quickly adapted to large-scale text processing scenarios.
[0037] In some embodiments, step S106 involves performing feature fusion on the initial English semantic vector and the initial Chinese semantic vector based on the cross-attention weight matrix to generate a target alignment feature representation, specifically including: Step 301: Convert the initial Chinese semantic vector into a value vector matrix; the details are as follows: A linear mapping calculation is performed, inputting the initial Chinese semantic vector into a preset linear mapping layer. The weight matrix of the linear mapping layer has a dimension of d×d, and the initial Chinese semantic vector has a dimension of N×d. Through weight matrix operations, the initial Chinese semantic vector is converted into a value vector matrix V, with a matrix dimension of N×d. The calculation process is to multiply the initial Chinese semantic vector with the linear mapping weights of the value vector matrix to obtain the value vector matrix V. This value vector matrix retains the core semantic information of the initial Chinese semantic vector and adapts to the multiplication operation requirements of the cross-attention weight matrix. Here, the value vector matrix refers to the Chinese semantic feature matrix used for subsequent attention weighting, and each element corresponds to the semantic feature value of the Chinese vector node.
[0038] Step 302: Calculate the product of the cross-attention weight matrix and the value vector matrix to generate the intermediate context vector; specifically as follows: Matrix multiplication is performed by multiplying the cross-attention weight matrix and the value vector matrix V. The cross-attention weight matrix has dimensions M×N, and the value vector matrix V has dimensions N×d. The intermediate context vector, with dimensions M×d, is obtained by multiplying the cross-attention weight matrix and the value vector matrix V. Specifically, the attention weight corresponding to each English vector node is weighted and summed with all Chinese value vector nodes. That is, for the i-th row of the intermediate context vector, the calculation process is to multiply each attention weight with the corresponding value vector node element, and then sum all the product results to obtain the i-th row of the intermediate context vector. This intermediate context vector integrates Chinese semantic features that are highly related to English semantics, realizing the supplementation and calibration of English semantics by Chinese semantics. Among them, the intermediate context vector is the Chinese semantic feature after attention weighting, which can accurately match the semantic requirements of English text.
[0039] Step 303: Perform tensor concatenation between the initial English semantic vector and the intermediate context vector to generate the target alignment feature representation; specifically as follows: (1) Tensor concatenation: The initial English semantic vector and the intermediate context vector are concatenated along the feature dimension. The initial English semantic vector has a dimension of M×d, the intermediate context vector has a dimension of M×d, and the resulting feature matrix has a dimension of M×2d. The concatenation process involves connecting the features of each English vector node to the corresponding intermediate context vector features end to end to form a feature vector with doubled dimensions.
[0040] (2) Layer normalization: Layer normalization is performed on the concatenated feature matrix. The calculation process is as follows: First, the mean and variance of all elements in the feature matrix are calculated. Then, the mean is subtracted from each element value and divided by the square root of the sum of the variance and a small constant. The small constant is used to prevent the variance from being 0. Finally, the normalized element values are obtained by adjusting the scaling factor and the offset factor. After normalization, the influence of feature dimension differences is eliminated, and a target aligned feature representation with unified dimension and semantic alignment is generated. The dimension is M×2d. The target aligned feature representation refers to a unified feature vector that integrates English and Chinese dual semantics and eliminates cross-language bias. It can be directly input into the downstream cross-language task model.
[0041] (3) After tensor concatenation, residual connections can be introduced to perform element-wise addition of the concatenated feature matrix and the initial English semantic vector. The calculation process is to add the concatenated feature matrix and the initial English semantic vector element-wise to obtain the residual vector, which alleviates the loss of semantic information in the feature fusion process and improves the semantic integrity of the target aligned features. The weights of the residual connections can be adaptively adjusted through model training to further optimize the feature fusion effect. After tensor concatenation, residual connections are performed first, and then layer normalization is performed. The specific logic is as follows: First, the concatenated fused feature matrix and the original initial English semantic vector are added element-wise to make up for the semantic loss in the concatenation process. Then, layer normalization is performed on the feature matrix after residual enhancement to unify the feature distribution, eliminate dimensional differences, and finally generate a target aligned feature representation with unified dimensions and semantic alignment.
[0042] The above technical solution converts the initial Chinese semantic vector into a value vector matrix, achieves accurate semantic weighting through a cross-attention weight matrix, and captures Chinese features that match the English semantics through the intermediate context vector. Tensor concatenation achieves deep fusion of English and Chinese semantics, layer normalization ensures feature consistency, and the generated target-aligned feature representation combines the advantages of both English and Chinese semantics, eliminates cross-linguistic semantic bias, provides high-quality feature input for downstream tasks, and has high computational efficiency.
[0043] In some embodiments, after performing tensor concatenation on the initial English semantic vector and the intermediate context vector to generate the target alignment feature representation, the method further includes: Step 401: Input the target alignment feature representation into the preset contrast loss function module to calculate the alignment deviation value; specifically, the contrast loss function module is preset to a triplet loss function, which calculates the similarity difference between positive samples, negative samples and the benchmark semantic vector to obtain the alignment deviation value; where the alignment deviation value refers to the degree of deviation between the target alignment feature representation and the ideal alignment state. The smaller the deviation value, the better the cross-language alignment effect; the larger the deviation value, the worse the alignment effect, and the word vector mapping parameters need to be adjusted.
[0044] Step 402: Adjust the mapping parameters of the word vector mapping based on the alignment deviation value; the details are as follows: (1) Gradient calculation: Using the alignment deviation as the loss value, the backpropagation algorithm is used to calculate the partial derivative of the loss value with respect to all parameters in the word vector mapping module, and the gradient value of each parameter is obtained.
[0045] (2) Gradient update: The mini-batch gradient descent method is used to adjust each parameter according to the gradient value. The update formula is that the updated parameter is equal to the parameter before the update minus the product of the learning rate and the gradient of the loss value on the parameter. The learning rate is preset to 0.001 and can be adjusted adaptively.
[0046] (3) The iteration terminates. Repeat steps 401-402 until the alignment deviation value is less than the preset deviation threshold or the number of iterations reaches the preset maximum value. Stop parameter adjustment and complete the optimization of word vector mapping parameters.
[0047] In one implementation, an adaptive learning rate algorithm can be used to replace mini-batch gradient descent. The learning rate is adaptively adjusted according to the first and second moments of the parameter gradient, which speeds up parameter convergence and avoids gradient explosion or gradient vanishing problems.
[0048] The above technical solution utilizes a contrastive loss function to calculate the alignment deviation value, accurately quantifying the cross-language alignment effect. By adjusting the word vector mapping parameters through backpropagation and gradient update, the accuracy of word vector mapping is continuously optimized, making the subsequently generated English initial semantic vectors and Chinese initial semantic vectors have higher semantic relevance. This further improves the quality of the target alignment feature representation, reduces cross-language semantic deviation, and provides more reliable feature support for downstream tasks.
[0049] In some embodiments, inputting the target alignment feature representation into a preset contrast loss function module to calculate the alignment deviation value includes: Step 501: Obtain positive and negative sample alignment features from the target alignment feature representation. Specifically, preset the selection rules for positive and negative samples: positive sample alignment features refer to target alignment features that are semantically consistent with the benchmark semantic vector, i.e., alignment features generated from English and Chinese texts corresponding to the same semantic scenario; negative sample alignment features refer to target alignment features that are semantically inconsistent with the benchmark semantic vector, i.e., alignment features generated from English and Chinese texts corresponding to different semantic scenarios; extract the set of positive and negative sample alignment features from the target alignment feature representation according to a preset ratio; wherein, the benchmark semantic vector refers to a preset standard vector with clear semantics, used as a benchmark for similarity comparison.
[0050] Step 502: Calculate the first cosine similarity between the positive sample alignment features and the benchmark semantic vector. Specifically, for each feature vector in the positive sample alignment feature set, calculate the cosine similarity with the benchmark semantic vector. The calculation process is to divide the dot product of the two vectors by the product of the magnitudes of the two vectors. Calculate the cosine similarity between all positive sample alignment features and the benchmark semantic vector, and take the average value as the first cosine similarity. The value range of the first cosine similarity is [-1, 1]. The closer the value is to 1, the higher the semantic consistency between the positive sample alignment features and the benchmark semantic vector.
[0051] Step 503: Calculate the second cosine similarity between the negative sample alignment features and the reference semantic vector. Specifically, using the same cosine similarity calculation method as in step 502, calculate the cosine similarity between each feature vector in the negative sample alignment feature set and the reference semantic vector. The calculation process is to divide the dot product of the two vectors by the product of the magnitudes of the two vectors. Calculate the cosine similarity between all negative sample alignment features and the reference semantic vector, and take the average value as the second cosine similarity. The range of the second cosine similarity is [-1, 1]. The closer the value is to -1, the lower the semantic consistency between the negative sample alignment features and the reference semantic vector.
[0052] Step 504: Generate alignment deviation values based on the first cosine similarity and the second cosine similarity. Specifically, the alignment deviation value is calculated using a triplet loss function. The calculation process involves taking the larger of 0 and the result of subtracting the first cosine similarity from the second cosine similarity and adding the boundary value. The boundary value is preset to 0.5 to differentiate the similarity between positive and negative samples. When the result of subtracting the first cosine similarity from the second cosine similarity and adding the boundary value is less than 0, the loss value is 0, indicating good alignment and a deviation value of 0. When the result of subtracting the first cosine similarity from the second cosine similarity and adding the boundary value is greater than or equal to 0, the loss value is the alignment deviation value. The larger the deviation value, the smaller the difference in similarity between positive and negative samples, and the worse the alignment effect.
[0053] In one implementation, the cross-entropy loss function can be used instead of the triplet loss function. The first cosine similarity and the second cosine similarity are converted into probability distributions, and the cross-entropy between the probability distribution and the true label is calculated as the alignment deviation value. This method is suitable for scenarios with a large number of samples and can improve the accuracy of the deviation value calculation.
[0054] The above technical solution utilizes cosine similarity to accurately measure the semantic consistency between the alignment features of positive and negative samples and the baseline semantic vector. By calculating the alignment deviation value through the triplet loss function, the similarity gap between positive and negative samples can be effectively widened, accurately quantifying the cross-language alignment effect. This provides a reliable quantitative basis for the subsequent adjustment of word vector mapping parameters and further optimizes the cross-language alignment accuracy.
[0055] In some embodiments, step S102, which involves performing word vector mapping on the English text data and the Chinese text data to generate initial English semantic vectors and initial Chinese semantic vectors, specifically includes: Step 601: Determine the clause boundary markers contained in the English and Chinese text data; details are as follows: (1) Set boundary rules: English clause boundaries are marked with punctuation marks, and Chinese clause boundaries are marked with punctuation marks.
[0056] (2) Traversal recognition: Traverse each character of the English text data and the Chinese text data respectively, identify characters that conform to the boundary rules, mark them as clause boundary identifiers, and record the position index of each clause boundary identifier in the text, thereby dividing the English text into multiple English clauses and the Chinese text into multiple Chinese clauses.
[0057] Step 602: Reset the relative positional encoding weights based on the clause boundary identifiers to generate a structured positional encoding matrix; specifically as follows: (1) Initialize position encoding. Use sine and cosine position encoding. Initialize an initial position encoding vector with the same length as the text. The text length is the number of English text segments and the number of Chinese text segments. For position i and dimension k, when k is even, the initial position encoding is the sine value of i divided by 10000 to the power of 2k / d. When k is odd, the initial position encoding is the cosine value of i divided by 10000 to the power of 2(k-1) / d, where d is the vector dimension.
[0058] (2) Reset weights: Based on the position index of the clause boundary marker, reset the weights of the initial position codes: For word segmentation within the same clause, the position code weights are linearly distributed according to their distance from the beginning of the clause, with the weights being greater for closer distances; The position code weights at the clause boundary markers are set to the maximum value and used as markers for clause separation. (3) Matrix generation: Arrange the positional encoding vectors after resetting the weights according to the spatial position of the text segmentation to generate a structured positional encoding matrix. The dimension of the English structured positional encoding matrix is M×d, and the dimension of the Chinese structured positional encoding matrix is N×d.
[0059] Step 603: Add the character embedding features of the English and Chinese text data to the structured positional encoding matrix to generate the initial semantic vectors for English and Chinese text; specifically as follows: (1) Input the English text segmentation sequence into the mBERT model to perform character embedding, and obtain the English character embedding feature matrix with a dimension of M×d; perform character embedding on the Chinese text segmentation sequence into the mBERT model to obtain the Chinese character embedding feature matrix with a dimension of N×d; then, perform element-wise addition of the English character embedding feature matrix and the English structured positional encoding matrix. The calculation process is to add the English character embedding feature matrix and the English structured positional encoding matrix element-wise to obtain the English initial semantic vector with a dimension of M×d; perform element-wise addition of the Chinese character embedding feature matrix and the Chinese structured positional encoding matrix. The calculation process is to add the Chinese character embedding feature matrix and the Chinese structured positional encoding matrix element-wise to obtain the Chinese initial semantic vector with a dimension of N×d; this addition operation integrates the semantic information of the text with the positional information of the clause structure, so that the generated initial semantic vector can capture the semantic association within the clause and the structural differences between clauses.
[0060] The cross-lingual word vector model is a pre-trained general mBERT model based on the Transformer encoder architecture. It employs a bilingual (Chinese and English) pre-training mechanism, possesses built-in general cross-lingual semantic mapping capabilities, requires no additional specialized training data, and is adaptable to various text scenarios. The cross-lingual word vectors used in this step for vector mapping calculation are fixed word embedding weight parameters learned during the mBERT model's pre-training phase. These parameters are directly fixed and called upon after the model pre-training is completed, enabling accurate mapping from Chinese and English word segmentation to high-dimensional semantic vectors.
[0061] In one implementation, learnable positional coding can be used instead of sine and cosine positional coding. The weights of the structured positional coding matrix are used as learnable parameters and are adaptively adjusted through model training to further improve the adaptability of positional coding to text semantics and optimize the quality of the initial semantic vector.
[0062] By using the above technical solutions, clause boundary markers are identified and positional encoding weights are reset, enabling positional encoding to reflect the clause structure of the text and avoiding the shortcomings of traditional positional encoding, which only focuses on word segmentation order and ignores clause structure. By integrating character embedding features with structured positional encoding, the generated initial semantic vector not only contains the semantic information of the text but also the positional information of the clause structure, providing richer feature support for subsequent grammatical anchor selection and cross-language alignment, and improving the accuracy of cross-language alignment.
[0063] In some embodiments, after establishing graph node connection edges between the English grammar anchor node and the Chinese grammar anchor node corresponding to step S104 to generate a language structure association graph, the method further includes: Step 701: Calculate the connection weight coefficients corresponding to the edges connecting each graph node in the language structure association graph; details are as follows: (1) Obtain basic parameters, extract the cross-language node distance between the English grammar anchor node and the Chinese grammar anchor node corresponding to each graph node connection edge, and the semantic similarity between the two nodes. The semantic similarity is the normalized inverse value of the cross-language node distance. The calculation process is 1 minus the difference between the current node distance and the minimum distance of all nodes divided by the difference between the maximum and minimum distances of all nodes.
[0064] (2) The second step is to calculate the weight coefficient. The weighted summation method is used to calculate the connection weight coefficient. The calculation process is to add 1 to the product of the weight coefficient and semantic similarity, and then add the product of the weight coefficient and the bias coefficient. The weight coefficient is preset to 0.6 to balance the influence of semantic similarity and bias coefficient. The bias coefficient comes from the bias matrix of the association structure. The value range of the connection weight coefficient is 0-1. The larger the value, the stronger the semantic association between the two nodes corresponding to the connection edge and the higher the grammatical matching degree.
[0065] Step 702: Compare the connection weight coefficients with the preset sparsity retention threshold. Specifically, the preset sparsity retention threshold can be flexibly adjusted according to the text scenario. This threshold is used to filter out connection edges with strong semantic associations and remove connection edges with weak semantic associations to achieve sparsification of the language structure association graph. Traverse all graph node connection edges in the language structure association graph, compare the connection weight coefficient of each edge with the sparsity retention threshold, and determine whether the connection weight coefficient is greater than or equal to the sparsity retention threshold.
[0066] Step 703: When the connection weight coefficient is less than the sparsity retention threshold, delete the corresponding graph node connection edge and update the language structure association graph. Specifically, for each graph node connection edge, if its connection weight coefficient is less than the sparsity retention threshold, it is determined that the semantic association between the two nodes corresponding to the connection edge is weak, and the connection edge is deleted; if the connection weight coefficient is greater than or equal to the sparsity retention threshold, the connection edge is retained. After deleting all connection edges that do not meet the conditions, the updated language structure association graph is obtained. The updated language structure association graph only retains node connection edges with strong semantic association and high grammatical matching degree, reducing redundant connections and reducing the overhead of subsequent cross-attention calculation.
[0067] In one implementation, a dynamic sparsity threshold can be used instead of a fixed sparsity retention threshold. The threshold is dynamically adjusted according to the distribution of connection weight coefficients in the language structure association graph, making the sparsity processing more adaptable to the association characteristics of different text scenarios.
[0068] By using the above technical solution, the connection weight coefficients are calculated and the connection edges are filtered by combining the sparsity retention threshold, so as to realize the sparsity update of the language structure association graph, eliminate redundant connections with weak semantic association, reduce the complexity of subsequent calculations, and improve computational efficiency; at the same time, the connection edges with strong semantic association and high grammatical matching are retained to ensure that the language structure association graph can accurately reflect the grammatical and semantic associations of English and Chinese texts, and provide more accurate structural constraints for the calculation of the cross-attention weight matrix.
[0069] In some embodiments, step 204 of step S105 involves performing an activation function operation on the target alignment matrix to generate a cross-attention weight matrix, including: Step 801: Obtain the data length value corresponding to the Chinese grammatical anchor node; specifically, count the number of Chinese grammatical anchor nodes and use this number as the data length value corresponding to the Chinese grammatical anchor node; the data length value reflects the number of core grammatical nodes in the Chinese text. The larger the value, the more complex the grammatical structure of the Chinese text, and the more necessary it is to adjust the temperature scaling factor to optimize the attention weight allocation.
[0070] Step 802: Determine the asymmetric temperature scaling factor based on the data length value. Specifically, the asymmetric temperature scaling factor is determined using a dynamic calculation method. The calculation process is the square root of the vector dimension divided by the square root of the data length value of the Chinese grammar anchor node, where d is the vector dimension. This calculation method makes the temperature scaling factor negatively correlated with the number of Chinese grammar anchor nodes: the larger the data length value, the smaller the temperature scaling factor; the smaller the data length value, the larger the temperature scaling factor. The role of the asymmetric temperature scaling factor is to adjust the numerical distribution of the target alignment matrix and avoid the concentration or dispersion of attention weights due to too many or too few Chinese grammar nodes.
[0071] Step 803: Divide the element values in the target alignment matrix by the asymmetric temperature scaling factor to generate a scaled feature matrix. Specifically, perform element-wise matrix division, dividing each element value in the target alignment matrix by the asymmetric temperature scaling factor. The calculation process is to divide the element value of the target alignment matrix by the temperature scaling factor to obtain the corresponding element of the scaled feature matrix, generating a scaled feature matrix with a dimension of M×N. This operation can adjust the numerical range of the target alignment matrix, making the distribution of matrix element values more reasonable and facilitating the normalization processing of the subsequent activation function.
[0072] Step 804: Perform a normalized exponential function operation on the scaled feature matrix to generate a cross-attention weight matrix. Specifically, the same normalized exponential function as in step 204 is used to perform the normalization calculation. The calculation process is to divide the exponential value of the corresponding element of the scaled feature matrix by the sum of the exponential values of all elements in that row to obtain the corresponding element of the cross-attention weight matrix. After normalization, the sum of the elements in each row of the scaled feature matrix is 1, resulting in the cross-attention weight matrix with a matrix dimension of M×N. Compared with the activation operation of the traditional fixed temperature factor, the asymmetric temperature scaling factor can be dynamically adjusted according to the number of anchor nodes in Chinese grammar, making the attention weight allocation more suitable for the text grammar structure and improving the accuracy of weight allocation.
[0073] In one implementation, the asymmetric temperature scaling factor can be adjusted a second time based on the data length value of the English grammar anchor node. The adjustment formula is the temperature scaling factor multiplied by the square root of the data length value of the English grammar anchor node divided by the square root of the data length value of the Chinese grammar anchor node. This allows the temperature scaling factor to adapt to the difference in the number of English and Chinese grammar anchor nodes, further optimizing the attention weight allocation effect.
[0074] The above technical solution dynamically determines the asymmetric temperature scaling factor based on the data length value of the Chinese grammatical anchor node, adjusts the numerical distribution of the target alignment matrix, and avoids the attention weights from being concentrated in a few nodes or being overly dispersed. The normalized exponential function combined with asymmetric temperature scaling enables the generated cross-attention weight matrix to more accurately capture the semantic correspondence between English and Chinese texts, improve the accuracy of cross-language alignment, and adapt to text scenarios with different grammatical complexities.
[0075] In some embodiments, after performing word vector mapping on English text data and Chinese text data to generate initial English semantic vectors and initial Chinese semantic vectors, the method further includes: Step 901: Extract the features of unregistered nodes from the initial English semantic vector and the initial Chinese semantic vector; the details are as follows: (1) Set the rules for determining unregistered nodes. Unregistered nodes refer to the vector nodes corresponding to the word segments that cannot be matched with the pre-trained word vectors during the word vector mapping process. Their vector values are either all-zero vectors or randomly initialized vectors, and their vector dimensions are consistent with those of normal nodes. (2) Traversal recognition: Traverse all nodes of the initial English semantic vector and the initial Chinese semantic vector respectively, identify nodes with vector values of all zero or randomly initialized, extract them as features of unlogged-in nodes, and record the spatial location index of each unlogged-in node.
[0076] Step 902: Calculate the feature difference distance between the features of unlogged nodes and the features of adjacent known nodes; specifically as follows: (1) Determine adjacent known nodes. For each unlogged node, take its spatial location index as the center and select normal nodes within the adjacent preset range as adjacent known nodes. If there are no normal nodes in the adjacent position, expand the range. (2) Calculate the difference distance. The Euclidean distance algorithm is used to calculate the distance between the feature vector of the unregistered node and the feature vector of each adjacent known node. The calculation process is to select the feature vector of the unregistered node and the feature vector of the adjacent known node. The two vectors have the same dimension. Calculate the sum of squares of the differences between the corresponding dimension elements of the two vectors, and then take the square root of the sum of squares to obtain the Euclidean distance. Take the average distance between all adjacent known nodes and the unregistered node as the feature difference distance of the unregistered node.
[0077] Step 903: When the feature difference distance is greater than a preset distribution threshold, extract the features of known nodes within the adjacent preset range, calculate the mean, and generate a compensation vector. Specifically, the preset distribution threshold is set according to the characteristics of word vector distribution and is used to determine the degree of semantic difference between the unregistered node and the adjacent known nodes. If the feature difference distance of the unregistered node is greater than the preset distribution threshold, it indicates that the semantic difference between the unregistered node and the adjacent known nodes is large, and feature compensation is required. Extract the feature vectors of all known nodes within the adjacent preset range, calculate their mean, and generate a compensation vector. The calculation process is the sum of the feature vectors of all adjacent known nodes divided by the number of adjacent known nodes. The dimension of the compensation vector is consistent with the feature vector of the unregistered node, which can make up for the semantic loss of the unregistered node.
[0078] Step 904: Add the features of the unregistered nodes to the compensation vector to update the initial English semantic vector and the initial Chinese semantic vector. Specifically, perform element-wise addition, adding each unregistered node feature vector to its corresponding compensation vector. The calculation process is to add the unregistered node feature vector and the compensation vector element-wise to obtain the updated unregistered node feature vector. Replace the corresponding positions in the original initial semantic vector with the updated unregistered node feature vector to obtain the updated initial English semantic vector and the initial Chinese semantic vector. If the feature difference distance of the unregistered node is less than or equal to the preset distribution threshold, it indicates that its semantics are less different from those of the adjacent known nodes, and no compensation is required. The original node features remain unchanged.
[0079] In one implementation, a weighted average can be used instead of a regular average to generate the compensation vector. The weights are assigned based on the distance between adjacent known nodes and unlogged nodes, with closer nodes having larger weights. The calculation process is to sum the products of the feature vectors of each adjacent known node and their corresponding weights, divide by the sum of all weights, and assign a weight of 1 by dividing the distance between the unlogged node and the adjacent known node by a small constant. This small constant is used to avoid the denominator being 0, making the compensation vector more in line with the semantic requirements of the unlogged nodes.
[0080] The above technical solutions identify and compensate for the features of unregistered nodes, effectively solving the semantic loss problem caused by unregistered words; the determination of feature difference distance can accurately distinguish the unregistered nodes that need compensation, avoiding invalid compensation; the compensation vector is generated based on the features of adjacent known nodes, which can make the features of unregistered nodes fit the semantic context of the text, improve the integrity and accuracy of the initial semantic vector, provide more reliable feature support for subsequent cross-language alignment, and reduce the impact of unregistered words on the alignment effect.
[0081] Example 2: Please see Figure 2 Based on Example 1, this embodiment also provides an English-Chinese text processing system based on cross-linguistic feature alignment, including: The text data acquisition module acquires English and Chinese text data to be processed. The word vector mapping module performs word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese text data. The grammar anchor filtering module obtains the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; it filters the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain English grammar anchor nodes and Chinese grammar anchor nodes. The association graph generation module obtains the cross-language node distance between English grammar anchor nodes and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, it establishes graph node connection edges between the corresponding English grammar anchor nodes and Chinese grammar anchor nodes to generate a language structure association graph. The cross-attention calculation module calculates the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph. The feature fusion module performs feature fusion on the initial English semantic vector and the initial Chinese semantic vector based on the cross-attention weight matrix to generate a target-aligned feature representation.
[0082] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0083] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for processing English and Chinese text based on cross-linguistic feature alignment, characterized in that the method... include: Obtain the English and Chinese text data to be processed; Perform word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese text data; Obtain the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; filter the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain the English grammar anchor node and the Chinese grammar anchor node; Obtain the cross-language node distance between English grammar anchor nodes and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, establish graph node connection edges between the corresponding English grammar anchor nodes and Chinese grammar anchor nodes to generate a language structure association graph; Calculate the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph; Based on the cross-attention weight matrix, feature fusion is performed on the initial English semantic vector and the initial Chinese semantic vector to generate a target-aligned feature representation.
2. The English-Chinese text processing method based on cross-linguistic feature alignment according to claim 1, characterized in that, The cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector is calculated based on the language structure association graph, including: Extract the graph node connection edges from the language structure association graph and generate the association structure bias matrix; Calculate the dot product matrix between the query matrix of the initial English semantic vector and the key matrix of the initial Chinese semantic vector; Add the bias matrix of the associated structure to the dot product result matrix to generate the target alignment matrix; Activation function operations are performed on the target alignment matrix to generate a cross-attention weight matrix.
3. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 1, characterized in that, Based on the cross-attention weight matrix, feature fusion is performed on the initial English semantic vector and the initial Chinese semantic vector to generate a target alignment feature representation, including: Convert the initial Chinese semantic vector into a value vector matrix; Calculate the product of the cross-attention weight matrix and the value vector matrix to generate an intermediate context vector; The initial semantic vector of English and the intermediate context vector are concatenated using tensors to generate the target-aligned feature representation.
4. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 3, characterized in that, After performing tensor concatenation between the initial English semantic vector and the intermediate context vector to generate the target alignment feature representation, the process also includes: The target alignment feature representation is input into the preset contrast loss function module to calculate the alignment deviation value; Adjust the mapping parameters of the word vector mapping based on the alignment deviation value.
5. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 4, characterized in that, The target alignment feature representation is input into a preset contrastive loss function module to calculate the alignment bias value, including: Obtain the positive and negative sample alignment features from the target alignment feature representation; Calculate the first cosine similarity between the positive sample alignment features and the baseline semantic vector; Calculate the second cosine similarity between the negative sample alignment features and the baseline semantic vector; An alignment deviation value is generated based on the first cosine similarity and the second cosine similarity using a loss function.
6. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 1, characterized in that, Perform word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese, including: Determine the clause boundary markers contained in the English and Chinese text data; The relative positional encoding weights are reset based on the clause boundary markers to generate a structured positional encoding matrix; Input the English and Chinese text sequences into the mBERT model to perform character embedding, obtain character embedding features, and add them to the structured positional encoding matrix to generate the initial semantic vectors for English and Chinese.
7. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 2, characterized in that, After establishing graph node connection edges between the corresponding English and Chinese grammar anchor nodes to generate a language structure association graph, the process also includes: Calculate the connection weight coefficients corresponding to the edges connecting each graph node in the language structure association graph. Compare the connection weight coefficients with the preset sparsity retention threshold; When the connection weight coefficient is less than the sparsity preservation threshold, delete the corresponding graph node connection edges and update the language structure association graph.
8. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 2, characterized in that, Activation function operations are performed on the target alignment matrix to generate a cross-attention weight matrix, including: Get the data length value corresponding to the Chinese syntax anchor node; Determine the asymmetric temperature scaling factor based on the data length value; Divide the element values in the target alignment matrix by the asymmetric temperature scaling factor to generate the scaled feature matrix; A normalized exponential function operation is performed on the scaled feature matrix to generate a cross-attention weight matrix.
9. A method for processing English and Chinese text based on cross-linguistic feature alignment according to claim 1, characterized in that, After performing word vector mapping on the English and Chinese text data to generate initial semantic vectors for English and Chinese, the process also includes: Extract features of unregistered nodes from the initial English semantic vector and the initial Chinese semantic vector; Calculate the feature difference distance between the features of unlogged nodes and the features of adjacent known nodes; When the feature difference distance is greater than the preset distribution threshold, the features of known nodes within the adjacent preset range are extracted, the mean is calculated, and a compensation vector is generated. Add the features of unlogged nodes to the compensation vector to update the initial semantic vectors for English and Chinese.
10. An English-Chinese text processing system based on cross-linguistic feature alignment, used to implement the method as described in any one of claims 1-9, characterized in that the system include: The text data acquisition module acquires English and Chinese text data to be processed. The word vector mapping module performs word vector mapping on English and Chinese text data to generate initial semantic vectors for English and Chinese text data. The grammar anchor filtering module obtains the first part-of-speech tag sequence corresponding to the initial English semantic vector and the second part-of-speech tag sequence corresponding to the initial Chinese semantic vector; it filters the first part-of-speech tag sequence and the second part-of-speech tag sequence according to the preset part-of-speech filtering mask to obtain English grammar anchor nodes and Chinese grammar anchor nodes. The association graph generation module obtains the cross-language node distance between English grammar anchor nodes and Chinese grammar anchor nodes; when the cross-language node distance is less than a preset distance threshold, it establishes graph node connection edges between the corresponding English grammar anchor nodes and Chinese grammar anchor nodes to generate a language structure association graph. The cross-attention calculation module calculates the cross-attention weight matrix between the initial English semantic vector and the initial Chinese semantic vector based on the language structure association graph. The feature fusion module performs feature fusion on the initial English semantic vector and the initial Chinese semantic vector based on the cross-attention weight matrix to generate a target-aligned feature representation.