File semantic similarity calculation method based on improved DeBERTa model
By improving the structural role coupling and energy spectrum dynamic resonance mechanism of the DeBERTa model, the problems of semantic hierarchy confusion and cross-domain expression differences in long text files are solved, and high-precision and stable calculation of semantic similarity between files is achieved.
Patent Information
- Application Number
- CN202511660681.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2045-11-13
AI Technical Summary
When dealing with long, complex, and semantically diverse documents, the existing DeBERTa model struggles to accurately reflect the hierarchical relationships and logical threads of the overall semantics. Furthermore, it suffers from semantic drift and feature mismatch issues in cross-domain corpora or heterogeneous document scenarios, resulting in insufficient accuracy and stability in similarity calculation.
By introducing a structural role coupling attention module, a main vein topology reconstruction module, and a self-correction consistency module, hierarchical modeling and self-alignment across semantic spaces of files are achieved through a semantic energy spectrum dynamic resonance mechanism and a semantic field curvature function. Semantic energy resonance spectrum features are constructed and weighted fusion is performed to calculate the semantic similarity between files.
It improves the accuracy and stability of semantic similarity calculation for long text files, enhances the robustness and interpretability of the model across cross-domain files, and significantly improves the accuracy and consistency of semantic similarity calculation between files.
Smart Images

Figure CN121328568A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence and natural language processing, and particularly relates to a file semantic similarity calculation method based on an improved DeBERTa model. BACKGROUND
[0002] With the rapid development of natural language processing technology and pre-training language models, semantic understanding methods based on deep learning have gradually become the mainstream means of file content analysis and similarity calculation. Among them, the bidirectional encoding structure represented by BERT and its improved model DeBERTa has achieved high precision in short text semantic modeling. However, when facing long documents, complex structures, and multiple semantic levels, the existing models generally cut the document into independent segments for local coding, and then obtain the global semantic representation through averaging or splicing. This method is easy to cause the loss of long text structure information and the rupture of semantic association, and it is difficult to accurately reflect the hierarchical relationship and logical main line of the overall semantic of the file.
[0003] Although the existing DeBERTa model improves the word-level semantic capture ability to some extent by decoupling the position encoding and attention distribution, it is still mainly optimized for sentence-level or paragraph-level short text tasks, and lacks modeling mechanisms for document internal structure roles (such as titles, main texts, introductions, summaries, etc.). Traditional semantic similarity calculation relies mainly on cosine similarity or dot product operations in vector space, without considering the conduction rules of text semantic energy between different levels, and cannot capture the dynamic balance relationship of semantic structure between layers, resulting in insufficient accuracy of file similarity calculation under complex semantic levels.
[0004] In the prior art, there are generally semantic drift and feature mismatch problems in cross-domain corpora or heterogeneous file scenarios. The model lacks self-alignment capability between different semantic spaces, and when the file content comes from different styles, domains or formats, the semantic representation will be offset, resulting in distortion of the similarity calculation result. Lack of constraints on semantic stability and consistency, it is easy to cause the instability of the model output and the lack of explainability, which is difficult to support complex application scenarios such as high-precision semantic retrieval and knowledge reasoning.
[0005] Therefore, how to provide a file semantic similarity calculation method based on an improved DeBERTa model is a problem that those skilled in the art need to solve. SUMMARY
[0006] One object of the present application is to propose a file semantic similarity calculation method based on an improved DeBERTa model. The present application fully combines deep semantic modeling, semantic energy field analysis and semantic self-alignment mechanism, and designs an improved DeBERTa semantic modeling structure and energy spectrum alignment calculation framework to solve the problems of structural information loss, semantic level confusion and cross-domain expression difference in long text files, which lead to distortion of similarity. The present application realizes hierarchical modeling of document semantics by introducing a structural role coupled attention module, a main vein topology reconstruction module and a self-correction consistency module; calculates the internal semantic energy distribution and hierarchical resonance law of the file through a semantic energy spectrum dynamic resonance mechanism; and realizes dynamic matching across semantic space by combining a semantic field curvature function and a gravitational self-alignment mechanism. The present application can maintain the integrity of the semantic structure and cross-domain robustness in the semantic similarity calculation of long text files, and has the advantages of high semantic understanding precision, strong similarity calculation stability and good result interpretability.
[0007] The file semantic similarity calculation method based on the improved DeBERTa model according to the embodiment of the present application comprises: performing text hierarchical preprocessing on the files to be compared, cutting and labeling the structural role tags of the files according to chapters, paragraphs and sentences, denoising, tokenizing and subword encoding the text content, and generating hierarchical input sequences containing structural role information; inputting the hierarchical input sequences into the improved DeBERTa model, wherein the improved DeBERTa model comprises a structural role coupled attention module, a main vein topology reconstruction module and a counterfactual self-correction consistency module, and outputting file semantic representation vectors; inputting the file semantic representation vectors into a semantic energy spectrum dynamic resonance module, constructing a semantic energy resonance graph according to semantic vectors of different levels, calculating the energy conduction path and coupling strength between semantic nodes of each level, forming a file semantic energy resonance spectrum, and generating semantic energy resonance spectrum features; calculating the energy distribution law and resonance correlation strength of file semantics between different levels according to the semantic energy resonance spectrum features, and forming a semantic energy spectrum feature vector; mapping the semantic energy spectrum feature vector and the file semantic representation vector to a continuous variable semantic field space, dynamically adjusting the spatial curvature and distance measurement between semantic representations by constructing a semantic field curvature function, and obtaining file-level semantic alignment representation; weighting and fusing the semantic energy resonance spectrum features and the file-level semantic alignment representation, calculating the comprehensive semantic similarity score between files, and outputting the final file semantic similarity result.
[0008] Optionally, the splitting the file by chapters, paragraphs and sentences and labeling the structural role tags specifically refers to structured hierarchical processing of the file content, dividing the text into chapter-level units according to the format characteristics and semantic boundaries of the file, then dividing each chapter-level unit into paragraph-level units, and further refining into sentence-level units, then performing semantic analysis on each hierarchical unit, and labeling the corresponding structural role tags according to the function of each hierarchical unit in the document.
[0009] Optionally, the denoising, word segmentation and subword encoding of the text content specifically refers to cleaning the file text, removing non-semantic characters, redundant spaces, headers and footers, format symbols and special marks, performing word segmentation processing on the cleaned text according to linguistic rules, dividing continuous text into words or symbols with independent meaning, and then performing subword-level encoding according to a model word table, further dividing low-frequency words or unregistered words into subword units, and mapping them to corresponding index or vector representations.
[0010] Optionally, the output file semantic representation vector includes: Receiving hierarchical input sequences, establishing a corresponding relationship between content representation, structural role label, relative position and hierarchical distance for each token, initializing the role coupling graph and hierarchical parameters for the current document, and obtaining an initial encoding sequence; In the structural role coupling attention module, the token pair attention weight is calculated according to the query vector, key vector and value vector generated by the initial encoding sequence, the role coupling graph is updated online combined with the intra-layer statistical results, and the value vector is weighted and aggregated to obtain the token-level hidden state set and the corresponding attention weight distribution; Performing bidirectional hierarchical refinement on the token-level hidden state set, first performing sentence-level, paragraph-level and chapter-level pooling from bottom to top to form hierarchical vectors, then back-filling chapter and title information to sentence-level and token-level from top to bottom to correct local representation, obtaining the back-filled token-level hidden state set, hierarchical representation set and role-level semantic representation; In the main vein topology reconstruction module, the main vein candidate score of each paragraph is calculated according to the paragraph-level and chapter-level vectors, a fixed number of main vein paragraphs are selected according to the score and the in-document order is determined, a main vein set is formed and a main vein-level semantic representation is generated; Asymmetrical recalibration of the attention weight distribution is performed with the main vein set as the control point, the main vein correlation and the connection within adjacent chapters are enhanced and the cross-chapter noise connection is suppressed, and the main vein guided document-level representation and the updated token-level hidden state set are obtained based on the recalibrated attention weight. In the self-correcting consistency module, high-contribution fragments are identified according to attention weights and contribution degree metrics, counterfactual inputs of masking, same-role replacement and cross-main-vein exchange are constructed respectively, replacement representations are generated using role prototype memory, consistency constraints are imposed between original representations, counterfactual representations and replacement representations, and parameter updating is performed jointly with comparison constraints to obtain a stabilized set of token-level hidden states and hierarchical representations; The sentence-level, section-level, role-level and main-vein-level semantic representations are adaptively weighted and pooled, the main-vein guided document-level representation is fused with the overall file structure embedding, the full-text level semantic representation is generated, and the sentence-level, section-level, role-level, main-vein-level and full-text-level semantic representations are combined to form a set of hierarchical semantic vectors, and the file semantic representation vector is output.
[0011] Optionally, the semantic energy resonance spectrum feature generation includes: The file semantic representation vector and the set of hierarchical semantic vectors are received, a hierarchical index and order consistent with the structural role label are established, a semantic energy spectrum dynamic resonance module composed of a hierarchical energy flow construction unit, a cross-layer phase-locked coordination unit and a resonance stabilization and debiasing unit are constructed; In the hierarchical energy flow construction unit, the energy metrics of each vector are calculated according to the set of hierarchical semantic vectors, a directed energy conduction graph is generated according to the cosine similarity between vectors and the structural role compatibility relationship, only a few conduction edges with the highest weights are retained for each node, and a decay factor consistent with the hierarchical distance is embedded in the edge weight to obtain an initial energy flow. In the cross-layer phase-locked coordination unit, energy propagation iteration is performed in the fixed order of sentence-level, section-level, role-level, main-vein-level and full-text-level, energy propagation iteration is performed along the directed conduction edges of the initial energy flow, the energy aggregation amount and the change rate of each hierarchical level are calculated, the conduction coefficients of adjacent hierarchical levels are synchronized and calibrated according to the main-vein-level as an anchor point, and an initial resonance spectrum is output. In the resonance stabilization and debiasing unit, the propagation path formed by the initial energy flow is used as the basis for resonance iteration, and three stabilization processes are performed on the initial resonance spectrum: First, high-weight noise edges unrelated to the main vein are removed according to the main vein consistency test; Second, redundant nodes with high similarity are merged according to the near-duplicate suppression strategy; Third, high-contribution nodes are masked and resonance spectrum deviation is detected according to the counterfactual disturbance test; When the resonance spectrum deviation exceeds a threshold, the corresponding edge weight is recovered to obtain a stable semantic energy resonance spectrum feature; The stable semantic energy resonance spectrum feature is grouped into a semantic energy spectrum feature vector in the fixed order of sentence-level, section-level, role-level, main-vein-level and full-text-level.
[0012] Optionally, the semantic energy spectrum feature vector formation includes: It receives semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets; The hierarchical semantic vector set is statistically analyzed by level, and the energy measurement of all nodes in each level is summarized to obtain the total energy of each level. The total energy of all levels is then proportionalized to form the energy ratio distribution of each level. Based on the edge weights between nodes in the directed energy transmission graph, the total number of cross-layer connection edge weights is accumulated by pairing them up at each level to obtain the resonance correlation strength between each level pair. The edge weights are the result of weighting node semantic similarity and structural role compatibility. The energy proportion distribution and resonance correlation intensity are normalized and calibrated at the same scale, and the energy dispersion within each level is calculated. The energy dispersion is obtained by comparing the deviation of the energy of each node within the level from the average energy of the level. The energy proportion distribution of each level, the resonance correlation strength with other levels, and the energy dispersion of each level are weighted and combined to obtain semantic energy spectrum feature vectors arranged in the order of sentence level, paragraph level, role level, main line level, and full text level.
[0013] Optionally, obtaining the file-level semantic alignment representation includes: Receive semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets. Set the main vein level vectors and full text level vectors as field anchors, and set the sentence level, paragraph level, and role level vectors as field particles. Establish a one-to-one correspondence between field anchors and field particles. Based on the semantic energy spectrum feature vector, the field anchor point and field particle are assigned weights. The main direction and feedback direction of the field are determined along the outgoing and incoming edges of the directed semantic energy transmission graph. An initial semantic field distribution is generated in the vector space, and a directional field channel is formed with the main pulse level vector as the center. Construct a semantic field curvature function, and dynamically adjust the hierarchical semantic vectors based on the semantic field curvature function: Centered on the semantic vectors at the main vein level and the full text level, a semantic field reference coordinate system is established along the main direction and feedback direction determined by the field channel. Multiple sets of equidistant sampling layers are divided in the main direction and feedback direction. Sampling nodes corresponding to the layered semantic vectors are arranged in each sampling layer, and the semantic field intensity and inter-layer difference data of each node are recorded. Second-order difference is performed on the field intensity difference between adjacent sampling layers to obtain the interlayer curvature scalar. The directional curvature is calculated along the principal direction and the feedback direction respectively. The difference between directions is extracted to form anisotropic parameters. The interlayer curvature scalar and directional curvature are summarized in hierarchical order to generate a curvature sequence. Using the curvature sequence of each file in the self-aligned semantic field as the baseline, a one-to-one correspondence is established according to the hierarchy and structural role. The curvature sequences of the two files are normalized and phase-aligned. The difference sequence at the corresponding position is calculated, the semantic field curvature function is output, and zero-bias calibration is completed.
[0014] Optionally, the final output of the file semantic similarity result includes: It receives the semantic energy spectrum feature vector and the file-level semantic alignment representation of the two files, performs unified scaling on the semantic energy spectrum feature vector, and performs unit length standardization on the file-level semantic alignment representation; The fusion weight vector is generated by comparing the component-wise features of the semantic energy spectrum of two files. It is stipulated that when the spectrum values of the two files at the same level are close, the level weight is increased, and when the difference is large, the level weight is decreased. The weight of each level is limited to between zero and one and is standardized as a whole. Three types of similarity are calculated: spectral similarity is calculated based on the directional similarity of the semantic energy spectrum feature vectors of the two files; alignment representation similarity is calculated based on the directional similarity of the file-level semantic alignment representations of the two files; and fusion similarity is calculated based on the directional similarity after weighting the semantic energy spectrum feature vectors and the file-level semantic alignment representations according to the fusion weight vector. By setting non-negative weighting coefficients and summing all coefficients to one, the spectral similarity, alignment representation similarity, and fusion similarity are weighted and summed to obtain the comprehensive semantic similarity score between documents.
[0015] The beneficial effects of this invention are: This invention achieves deep modeling and accurate representation of document-level semantic structure by introducing a multi-layered semantic enhancement mechanism into the DeBERTa model structure. By setting up a structure-role coupling attention module, the model can establish dynamic interaction relationships between sentence, paragraph, role, and main thread levels, enabling the adaptive construction of hierarchical semantics within the document. This effectively solves the problems of semantic structure information loss and weakened contextual dependencies in traditional pre-trained models in long text scenarios, significantly improving the completeness and consistency of document semantic representation.
[0016] The semantic energy spectrum dynamic resonance mechanism constructed in this invention can capture the distribution and transmission patterns of semantic energy within a file in a multi-layered semantic space, quantify the resonance intensity and energy stability between different semantic levels, thereby achieving hierarchical recognition of semantic structures and global feature aggregation. Compared with traditional methods that rely solely on vector space similarity, this invention not only focuses on the semantic content itself but also reflects the inter-layer coupling and dynamic balance characteristics of semantic information, making the semantic similarity calculation between files more consistent with actual semantic associations and improving the accuracy and discriminative ability of long text similarity calculation.
[0017] This invention dynamically maps document-level semantic representations using a semantic field curvature function and a gravitational self-alignment mechanism. This enables documents from different domains and structural types to achieve nonlinear self-alignment within a unified semantic space, reducing bias caused by differences in cross-semantic domain representations. During the alignment process, the balance and curvature stability of the semantic field are maintained, resulting in higher robustness and adaptability in similarity calculations for heterogeneous texts or cross-domain documents. This invention balances semantic accuracy with computational stability and interpretability, making it highly valuable for application and promotion. Attached Figure Description
[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of the document semantic similarity calculation method based on the improved DeBERTa model proposed in this invention; Figure 2 This is a schematic diagram of the structure of the improved DeBERTa model, which is based on the improved DeBERTa model for calculating file semantic similarity proposed in this invention. Detailed Implementation
[0019] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0020] refer to Figure 1 and Figure 2 A document semantic similarity calculation method based on the improved DeBERTa model includes: The files to be compared are preprocessed by hierarchical text structure, which involves segmenting the files by chapters, paragraphs, and sentences and labeling them with structural role tags. The text content is then denoised, segmented, and encoded with sub-words to generate a hierarchical input sequence containing structural role information. The hierarchical input sequence is fed into the improved DeBERTa model, which includes a structural role coupling attention module, a main vein topology reconstruction module, and a counterfactual self-correcting consistency module, and outputs a file semantic representation vector. The semantic representation vector of the file is input into the semantic energy spectrum dynamic resonance module. A semantic energy resonance graph is constructed based on the semantic vectors at different levels. By calculating the energy transmission path and coupling strength between semantic nodes at each level, a semantic energy resonance spectrum of the file is formed, and semantic energy resonance spectrum features are generated. Based on the semantic energy resonance spectrum features, the energy distribution pattern and resonance correlation strength of the document semantics at different levels are calculated to form an energy spectrum feature vector. The semantic energy spectrum feature vector and the file semantic representation vector are jointly mapped to a continuous and variable semantic field space. By constructing a semantic field curvature function, the spatial curvature and distance metric between semantic representations are dynamically adjusted to obtain a file-level semantic alignment representation. The semantic energy resonance spectrum features and the file-level semantic alignment representation are weighted and fused to calculate the comprehensive semantic similarity score between files, and the final file semantic similarity result is output.
[0021] In this embodiment, the step of segmenting the file by chapters, paragraphs, and sentences and labeling them with structural role tags specifically refers to performing structured layering processing on the file content, dividing the text into chapter-level units based on the file's format features and semantic boundaries, then dividing each chapter-level unit into paragraph-level units, and further refining them into sentence-level units. Subsequently, semantic analysis is performed on each level of unit, and corresponding structural role tags are labeled according to the functional role of each level of unit in the document.
[0022] In this embodiment, the denoising, word segmentation, and sub-word encoding of the text content specifically refers to cleaning the file text, removing non-semantic characters, redundant spaces, headers and footers, formatting symbols, and special markers, segmenting the cleaned text according to linguistic rules, dividing the continuous text into words or symbols with independent meaning, and then performing sub-word-level encoding based on the model vocabulary, further dividing low-frequency words or out-of-vocabulary words into sub-word units and mapping them to corresponding indexes or vector representations.
[0023] In this embodiment, the output file semantic representation vector includes: Receive a hierarchical input sequence, establish a correspondence between content representation, structural role label, relative position and hierarchical distance for each tag, initialize the role coupling graph and hierarchical parameters for the current document, and obtain the initial encoding sequence. The role coupling graph is a directed weighted graph used to represent the semantic relationship between different structural roles in the document. Nodes correspond to the semantic representation of different role units, and the weight of the edges reflects the strength of the semantic dependency and hierarchical distance between roles. In the structural role coupling attention module, the attention weights of the tag pairs are calculated based on the query vector, key vector and value vector generated from the initial encoding sequence. The role coupling graph is updated online in combination with the intra-layer statistical results, and the value vectors are weighted and aggregated to obtain the tag-level hidden state set and the corresponding attention weight distribution. Bidirectional hierarchical refinement is performed on the tag-level hidden state set. First, sentence-level, paragraph-level, and chapter-level pooling is performed from bottom to top to form hierarchical vectors. Then, chapter and title information is fed back to sentence-level and tag-level from top to bottom to correct local representations, resulting in the fed-back tag-level hidden state set, hierarchical representation set, and role-level semantic representation. In the main vein topology reconstruction module, each paragraph is scored as a main vein candidate based on segment-level and chapter-level vectors. A fixed number of main vein segments are selected according to the scores, and their order within the text is determined to form a main vein set and generate a main vein-level semantic representation. Specifically, the scoring of each paragraph as a main vein candidate based on segment-level and chapter-level vectors is as follows: Calculate the semantic relevance between each paragraph vector and the chapter center vector. The higher the semantic relevance, the closer the paragraph is to the core content in the chapter's semantic structure. Assess the structural importance of paragraphs within the document hierarchy, assigning higher weights to paragraphs that contribute significantly to the structure based on their position, role labels, and the strength of their association with the title or abstract. By combining semantic relevance and structural importance scores with contextual continuity constraints, a candidate score for the main vein of each paragraph is generated to determine the priority and selection order of the main vein segments. Asymmetric recalibration of attention weight distribution is performed using the main vein set as control point to enhance the main vein-related connections and connections within adjacent chapters while suppressing cross-chapter noisy connections. Based on the recalibrated attention weights, the document-level representation guided by the main vein and the updated tag-level hidden state set are obtained. In the self-correcting consistency module, high-contribution segments are identified based on attention weight and contribution measurement. Counterfactual inputs for occlusion, same-role substitution, and cross-main-pulse exchange are constructed respectively. Alternative representations are generated using role prototype memory. Consistency constraints are applied to the original representation, counterfactual representation, and alternative representation, and parameters are updated by combining comparison constraints, resulting in a stable set of labeled hidden states and a hierarchical representation set. Specifically, the generation of alternative representations using role prototype memory involves: During the training of the DeBERTa model, a character prototype memory unit is established for each structural character to store the stable semantic center vectors learned by the character in multiple documents, which are used to represent the typical semantic features of the character. After constructing counterfactual input, for the high-contribution fragments that are obscured or replaced, the closest prototype vector is retrieved from the character prototype memory unit based on the original character label, and interpolation and fusion are performed in combination with the current context semantic information to generate an alternative representation that is consistent with the semantics of the original fragment. The generated alternative representation, the original representation, and the counterfactual representation are all input into the consistency constraint unit to minimize the semantic deviation among the three. The semantic representations at the sentence, paragraph, role, and main line levels are adaptively weighted and pooled. At the same time, the document-level representation guided by the main line is embedded and integrated with the overall file structure to generate a full-text semantic representation. Then, the semantic representations at the sentence, paragraph, role, main line, and full-text levels are combined to form a hierarchical semantic vector set, and the file semantic representation vector is output.
[0024] In this embodiment, the generation of semantic energy resonance spectrum features includes: Receive the file semantic representation vector and the hierarchical semantic vector set, establish a hierarchical index and order consistent with the structural role label, and construct a semantic energy spectrum dynamic resonance module composed of hierarchical energy flow construction unit, cross-layer phase-locked coordination unit and resonance stability and debiasing unit; In the hierarchical energy flow construction unit, the energy metric of each vector is calculated based on the hierarchical semantic vector. A directed energy transmission graph is generated based on the cosine similarity and structural role compatibility between vectors. For each node, only the highest weighted transmission edges are retained, and a decay factor consistent with the hierarchical distance is embedded in the edge weights to obtain the initial energy flow. Specifically, the calculation of the energy metric of each vector based on the hierarchical semantic vector is as follows: Semantic strength is calculated for semantic vectors at the sentence, paragraph, role, main thread, and full-text levels. Semantic strength is determined by the norm of the vector in the semantic space or the information entropy level. By combining structural role labels and hierarchical positions, hierarchical weighting coefficients are applied to semantic vectors at different levels, so that the energy metric of higher levels has a higher weight in the overall calculation. The energy measurement results of each semantic vector are normalized to ensure that the energy is comparable across different levels. In the cross-layer phase-locked coordination unit, energy propagation iterations are performed in a fixed order: sentence level, paragraph level, role level, main vein level, and full text level. Energy propagation iterations are executed along the directed transmission edge of the initial energy flow, calculating the energy aggregation amount and rate of change at each level. The transmission coefficients of adjacent levels are synchronously calibrated using the main vein level as the anchor point, and the initial resonance spectrum is output. Specifically, the calculation of the energy aggregation amount and rate of change at each level involves: In each energy propagation iteration, the total amount of energy input received by each level of nodes at the sentence level, paragraph level, role level, main thread level and full text level is counted, and the energy convergence value within the current iteration cycle is accumulated. The energy aggregation amount of the same level in two adjacent iterations is compared, the energy increase or decrease ratio is calculated, and the result is used as the energy change rate of the level to reflect the dynamic equilibrium state of energy during the propagation process. By combining the energy change rate and aggregation trend of all levels, an inter-layer energy conduction matrix is established to record the energy flow direction and intensity between each level. In the resonant stabilization and debiasing unit, the propagation path formed by the initial energy flow is used as the basis for resonant iteration, and the initial resonant spectrum is subjected to triple stabilization: First, high-weighted noise edges that are irrelevant to the main vein are removed based on the main vein consistency test. Second, redundant nodes with high similarity are merged according to the near repetition suppression strategy. The near repetition suppression strategy refers to merging nodes with highly similar semantic content and close positions in the semantic energy transmission graph by comparing the semantic similarity and structural distance between nodes, retaining representative nodes and re-labeling their energy weights and connection relationships to form a set of semantic nodes without redundancy. Third, high-contribution nodes are masked and resonance spectrum shifts are detected based on counterfactual perturbation tests, specifically: Nodes with high energy contribution during semantic energy transmission are selected as target nodes for testing, and corresponding counterfactual perturbation inputs are generated based on structural role labels. Perturbation samples are constructed through semantic substitution. The semantic energy resonance spectrum is recalculated under the input of perturbation sample. The energy distribution and resonance intensity changes of the node's level and adjacent levels before and after perturbation are compared, and the energy shift value and spectrum shape difference are recorded. The stability of a node is determined based on the offset magnitude and the degree of spectral difference. When the offset exceeds a set threshold, it is marked as an unstable node, and the node connection edge weights and energy weights are corrected to keep the semantic energy resonance spectrum balanced and consistent. When the resonance spectrum shift exceeds the threshold, the corresponding edge weights are recovered to obtain stable semantic energy resonance spectrum features; The stable semantic energy resonance spectrum features are arranged in a fixed order of sentence level, paragraph level, role level, main theme level, and full text level to form a semantic energy spectrum feature vector.
[0025] In this embodiment, forming the energy spectrum feature vector includes: It receives semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets; The hierarchical semantic vector set is statistically analyzed by level, and the energy measurement of all nodes in each level is summarized to obtain the total energy of each level. The total energy of all levels is then proportionalized to form the energy ratio distribution of each level. Based on the edge weights between nodes in the directed energy transmission graph, the total number of cross-layer connection edge weights is accumulated by pairing them up at each level to obtain the resonance correlation strength between each level pair. The edge weights are the result of weighting node semantic similarity and structural role compatibility. The energy proportion distribution and resonance correlation intensity are normalized and calibrated at the same scale, and the energy dispersion within each level is calculated. The energy dispersion is obtained by comparing the deviation of the energy of each node within the level from the average energy of the level. The energy proportion distribution of each level, the resonance correlation strength with other levels, and the energy dispersion of each level are weighted and combined to obtain semantic energy spectrum feature vectors arranged in the order of sentence level, paragraph level, role level, main line level, and full text level.
[0026] In this embodiment, obtaining the file-level semantic alignment representation includes: Receive semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets. Set the main vein level vectors and full text level vectors as field anchors, and set the sentence level, paragraph level, and role level vectors as field particles. Establish a one-to-one correspondence between field anchors and field particles. Based on the semantic energy spectrum feature vector, the field anchor point and field particle are assigned weights. The main direction and feedback direction of the field are determined along the outgoing and incoming edges of the directed semantic energy transmission graph. An initial semantic field distribution is generated in the vector space, and a directional field channel is formed with the main pulse level vector as the center. Construct a semantic field curvature function, and dynamically adjust the hierarchical semantic vectors based on the semantic field curvature function: Centered on the semantic vectors at the main vein level and the full text level, a semantic field reference coordinate system is established along the main direction and feedback direction determined by the field channel. Multiple sets of equidistant sampling layers are divided in the main direction and feedback direction. Sampling nodes corresponding to the layered semantic vectors are arranged in each sampling layer, and the semantic field intensity and inter-layer difference data of each node are recorded. A second-order difference is performed on the field intensity difference between adjacent sampling layers to obtain the interlayer curvature scalar. The directional curvature is then calculated along both the principal and feedback directions. The differences between directions are extracted to form anisotropic parameters. The interlayer curvature scalar and directional curvature are summarized in hierarchical order to generate a curvature sequence. Specifically, the calculation of directional curvature along the principal and feedback directions involves: Starting with the main vein-level semantic representation, several consecutive sampling layers are selected along the main direction of semantic propagation. The rate of change of semantic field intensity between adjacent sampling layers is calculated, and the cumulative difference of the rate of change reflects the curvature change trend of the direction. Starting with the full-text semantic representation, the same sampling and rate of change calculation are performed along the feedback direction opposite to the main direction to obtain the convergence and diffusion characteristics of the semantic field intensity during the reverse semantic propagation process; By comparing the curvature change magnitude and gradient difference between the principal direction and the feedback direction, the difference parameters between the two directions are extracted and recorded as anisotropy indices to describe the spatial curvature characteristics of the semantic field in different propagation directions. Using the curvature sequence of each file in the self-aligned semantic field as the baseline, a one-to-one correspondence is established according to the hierarchy and structural role. The curvature sequences of the two files are normalized and phase-aligned. The difference sequence at the corresponding position is calculated, the semantic field curvature function is output, and zero-bias calibration is completed. The dynamic adjustment of the hierarchical semantic vector based on the semantic field curvature function is specifically as follows: The positions of field particles are updated in small steps along the direction of lowest curvature, so that the curvature difference between the two files at the same level and with the same role gradually decreases. The side length ratio, main vein order and chapter adjacency relationship of the directed energy transmission graph are used as constraints to limit the displacement amplitude, direction deviation and sequence consistency of each update until the curvature difference and displacement amplitude meet the preset convergence conditions. The converged hierarchical semantic vectors are weighted and converged according to the weights in the semantic energy spectrum feature vectors to generate a file-level semantic alignment representation.
[0027] In this embodiment, the output of the final file semantic similarity result includes: It receives the semantic energy spectrum feature vector and the file-level semantic alignment representation of the two files, performs unified scaling on the semantic energy spectrum feature vector, and performs unit length standardization on the file-level semantic alignment representation; The fusion weight vector is generated by comparing the component-wise features of the semantic energy spectrum of two files. It is stipulated that when the spectrum values of the two files at the same level are close, the level weight is increased, and when the difference is large, the level weight is decreased. The weight of each level is limited to between zero and one and is standardized as a whole. Three types of similarity are calculated: spectral similarity is calculated based on the directional similarity of the semantic energy spectrum feature vectors of the two files; alignment representation similarity is calculated based on the directional similarity of the file-level semantic alignment representations of the two files; and fusion similarity is calculated based on the directional similarity after weighting the semantic energy spectrum feature vectors and the file-level semantic alignment representations according to the fusion weight vector. By setting non-negative weighting coefficients and summing all coefficients to one, the spectral similarity, alignment representation similarity, and fusion similarity are weighted and summed to obtain the comprehensive semantic similarity score between documents.
[0028] Example 1: To verify the feasibility of this invention in practice, it was applied to the document semantic retrieval system of a large architectural design and consulting firm's document management center. This firm undertakes numerous engineering projects nationwide, including subway lines, urban complexes, and bridge structures. It internally stores over 100,000 documents, including contracts, design specifications, construction plans, and meeting minutes. These documents are lengthy, hierarchical, and often contain cross-disciplinary terminology differences. Traditional semantic retrieval models based on BERT or TF-IDF exhibit significant biases in long text similarity calculations, especially in cases with different document structures or cross-domain semantic expressions, easily leading to misjudgments or omissions of high similarity. This invention is specifically proposed to address the technical problems of missing semantic structure in long texts, hierarchical semantic confusion, and large alignment errors across semantic spaces.
[0029] In practical applications, the system first performs hierarchical preprocessing on the documents, dividing the content into chapters, paragraphs, and sentences. It then automatically identifies structural roles such as titles, abstracts, main text, and appendices through text structure analysis, generating input sequences labeled with these roles. Subsequently, an improved DeBERTa model encodes the input sequences: the model includes a structural role-coupled attention module to identify semantic interactions between different text roles; a main thread topology reconstruction module to extract the core semantic thread of the document; and a self-correcting consistency module to perturb and learn consistency constraints on high-contribution semantic segments, thus forming a stable set of hierarchical semantic representations. Next, a semantic energy spectrum dynamic resonance module calculates the energy transmission and resonance intensity at the sentence, paragraph, role, main thread, and full-text levels, obtaining semantic energy spectrum feature vectors. Finally, in the semantic gravity field self-alignment mechanism, a semantic field curvature function is constructed. Using the main thread and full-text semantic representations as anchors, curvature calibration and gravity alignment are performed on the semantic representation spaces of the two documents, outputting the final document-level semantic similarity score.
[0030] The experiment selected 5,000 contracts and technical solution documents from the company between 2022 and 2024 as a sample. The average document length was 7,200 words. Technical solution documents accounted for 54%, design specification documents for 28%, and contracts and reports for 18%. 1,200 semantically relevant document pairs and 800 semantically unrelated document pairs were randomly selected as the test set. The traditional BERT-based model, the original DeBERTa model, and the improved model of this invention were compared. The models were run in the same hardware environment, and the response speed, accuracy, recall, and consistency with human evaluation were statistically analyzed in a real retrieval system.
[0031] Experimental results show that the model of this invention significantly outperforms the comparative model in semantic similarity calculation of long text files. Especially in structurally complex design scheme files, the main vein topology reconstruction mechanism effectively identifies the core technical content of the document, improving the recall rate of the model in identifying "partially semantically similar files" by more than 10%. The semantic energy spectrum dynamic resonance mechanism effectively reduces the imbalance of semantic weights at different levels, ensuring a reasonable proportion of sentence-level and paragraph-level semantic information in the overall similarity calculation. The introduction of the semantic field curvature function makes the model stable in cross-domain semantic alignment, significantly improving the accuracy of similarity determination in scenarios with significant stylistic differences, such as engineering contracts and design reports.
[0032] Table 1. Comparison of experimental results for document semantic similarity calculation methods based on the improved DeBERTa model. As shown in Table 1, the proposed document semantic similarity calculation method based on the improved DeBERTa model significantly outperforms existing mainstream models across multiple performance metrics. In terms of average accuracy, the proposed model achieves 93.8%, an improvement of approximately 11.2 percentage points compared to the traditional BERT-based model and nearly 5 percentage points compared to the original DeBERTa-v3 model. This indicates that the introduced structural role coupling attention mechanism and main vein topology reconstruction mechanism effectively improve the recognition capability of document semantic levels, enabling the model to more accurately capture the core semantic relationships in long texts.
[0033] The recall rate and F1 score of this invention's model reached 92.7%, and the F1 score was 0.93, both significantly higher than the comparison model. This indicates that the method achieves better performance in terms of coverage and balance in similar file identification. Especially in scenarios with complex file structures or cross-domain text comparison, traditional models tend to miss files that are semantically similar but have different expressions. However, this invention, through a dynamic resonance mechanism of semantic energy spectrum, realizes energy coupling and feedback between semantic levels, improving the model's comprehensive recognition ability under multi-layer semantics.
[0034] In terms of system efficiency, the average response time of the model in this invention is only 1.97 seconds per pair, representing a performance improvement of nearly 40% compared to the response speed of other models, which is generally over 3 seconds. This is attributed to the hierarchical aggregation of semantic representations and the dynamic adjustment mechanism of semantic field curvature within the model, making long text processing more efficient. The long text bias rate of the model in this invention is only 3.6%, far lower than the 8%-11% range of traditional models, indicating that it maintains high semantic stability when processing ultra-long documents. The expert consensus score reached 9.2 points, significantly higher than the average of 7.7 points of the comparison models, indicating that the semantic judgment results of this invention are closer to human understanding and have stronger interpretability and practicality. In summary, this invention not only significantly improves the accuracy and recall rate of semantic similarity calculation, but also demonstrates excellent engineering feasibility in terms of computational efficiency and result stability.
[0035] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for calculating document semantic similarity based on an improved DeBERTa model, characterized in that, include: The files to be compared are preprocessed by hierarchical text structure, which involves segmenting the files by chapters, paragraphs, and sentences and labeling them with structural role tags. The text content is then denoised, segmented, and encoded with sub-words to generate a hierarchical input sequence containing structural role information. The hierarchical input sequence is fed into the improved DeBERTa model, which includes a structural role coupling attention module, a main vein topology reconstruction module, and a counterfactual self-correcting consistency module, and outputs a file semantic representation vector. The semantic representation vector of the file is input into the semantic energy spectrum dynamic resonance module. A semantic energy resonance graph is constructed based on the semantic vectors at different levels. By calculating the energy transmission path and coupling strength between semantic nodes at each level, a semantic energy resonance spectrum of the file is formed, and semantic energy resonance spectrum features are generated. Based on the semantic energy resonance spectrum features, the energy distribution pattern and resonance correlation strength of the document semantics at different levels are calculated to form a semantic energy spectrum feature vector. The semantic energy spectrum feature vector and the file semantic representation vector are jointly mapped to a continuous and variable semantic field space. By constructing a semantic field curvature function, the spatial curvature and distance metric between semantic representations are dynamically adjusted to obtain a file-level semantic alignment representation. The semantic energy resonance spectrum features and the file-level semantic alignment representation are weighted and fused to calculate the comprehensive semantic similarity score between files, and the final file semantic similarity result is output.
2. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The process of segmenting a file by chapters, paragraphs, and sentences and labeling them with structural role tags specifically refers to performing structured layering processing on the file content. Based on the file's format characteristics and semantic boundaries, the text is divided into chapter-level units, then each chapter-level unit is divided into paragraph-level units, and further refined into sentence-level units. Subsequently, semantic analysis is performed on each level of unit, and corresponding structural role tags are labeled according to the functional role of each level of unit in the document.
3. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The denoising, word segmentation, and sub-word encoding of the text content specifically refers to cleaning the file text, removing non-semantic characters, redundant spaces, headers and footers, formatting symbols, and special markers, segmenting the cleaned text according to linguistic rules, dividing continuous text into words or symbols with independent meaning, and then performing sub-word-level encoding based on the model vocabulary, further dividing low-frequency words or out-of-vocabulary words into sub-word units and mapping them to corresponding indexes or vector representations.
4. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The output file semantic representation vector includes: Receive a hierarchical input sequence, establish a correspondence between content representation, structural role label, relative position and hierarchical distance for each tag, initialize the role coupling graph and hierarchical parameters for the current document, and obtain the initial encoding sequence; In the structural role coupling attention module, the attention weights of the tag pairs are calculated based on the query vector, key vector and value vector generated from the initial encoding sequence. The role coupling graph is updated online in combination with the intra-layer statistical results, and the value vectors are weighted and aggregated to obtain the tag-level hidden state set and the corresponding attention weight distribution. Bidirectional hierarchical refinement is performed on the tag-level hidden state set. First, sentence-level, paragraph-level, and chapter-level pooling is performed from bottom to top to form hierarchical vectors. Then, chapter and title information is fed back to sentence-level and tag-level from top to bottom to correct local representations, resulting in the fed-back tag-level hidden state set, hierarchical representation set, and role-level semantic representation. In the main vein topology reconstruction module, each paragraph is scored as a candidate main vein based on the segment-level and chapter-level vectors. A fixed number of main vein segments are selected according to the scores and the order in the text is determined to form a main vein set and generate a main vein-level semantic representation. Asymmetric recalibration of attention weight distribution is performed using the main vein set as control point to enhance the main vein-related connections and connections within adjacent chapters while suppressing cross-chapter noisy connections. Based on the recalibrated attention weights, the document-level representation guided by the main vein and the updated tag-level hidden state set are obtained. In the self-correcting consistency module, high-contribution segments are identified based on attention weight and contribution measurement. Counterfactual inputs such as occlusion, same-role replacement and cross-main-pulse exchange are constructed respectively. Alternative representations are generated using role prototype memory. Consistency constraints are applied to the original representation, counterfactual representation and alternative representation, and parameters are updated by joint comparison constraints to obtain the stabilized tag-level hidden state set and hierarchical representation set. The semantic representations at the sentence, paragraph, role, and main line levels are adaptively weighted and pooled. At the same time, the document-level representation guided by the main line is embedded and integrated with the overall file structure to generate a full-text semantic representation. Then, the semantic representations at the sentence, paragraph, role, main line, and full-text levels are combined to form a hierarchical semantic vector set, and the file semantic representation vector is output.
5. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The generated semantic energy resonance spectrum features include: Receive the file semantic representation vector and the hierarchical semantic vector set, establish a hierarchical index and order consistent with the structural role label, and construct a semantic energy spectrum dynamic resonance module composed of hierarchical energy flow construction unit, cross-layer phase-locked coordination unit and resonance stability and debiasing unit; In the hierarchical energy flow construction unit, the energy metric of each vector is calculated based on the hierarchical semantic vector. A directed energy transmission graph is generated based on the cosine similarity between vectors and the structural role compatibility relationship. Only the transmission edges with the highest weights are retained for each node, and a decay factor consistent with the hierarchical distance is embedded in the edge weights to obtain the initial energy flow. In the cross-layer phase-locked coordination unit, energy propagation iteration is performed in a fixed order of sentence level, paragraph level, role level, main vein level, and full text level. Energy propagation iteration is performed along the directed transmission edge of the initial energy flow, the energy aggregation amount and rate of change of each level are calculated, and the transmission coefficient of adjacent levels is synchronously calibrated according to the main vein level as the anchor point, and the initial resonance spectrum is output. In the resonant stabilization and debiasing unit, the propagation path formed by the initial energy flow is used as the basis for resonant iteration, and the initial resonant spectrum is subjected to triple stabilization: First, high-weighted noise edges that are irrelevant to the main vein are removed based on the main vein consistency test. Second, redundant nodes with high similarity are merged according to the near-repetition suppression strategy; Third, high-contribution nodes are masked and resonance spectrum shifts are detected using the counterfactual perturbation test. When the resonance spectrum shift exceeds the threshold, the corresponding edge weights are recovered to obtain stable semantic energy resonance spectrum features; The stable semantic energy resonance spectrum features are arranged in a fixed order of sentence level, paragraph level, role level, main theme level, and full text level to form a semantic energy spectrum feature vector.
6. The method for calculating document semantic similarity based on the improved DeBERTa model according to claim 1, characterized in that, The formation of the semantic energy spectrum feature vector includes: It receives semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets; The hierarchical semantic vector set is statistically analyzed by level, and the energy measurement of all nodes in each level is summarized to obtain the total energy of each level. The total energy of all levels is then proportionalized to form the energy ratio distribution of each level. Based on the edge weights between nodes in the directed energy transmission graph, the total number of cross-layer connection edge weights is accumulated by pairing them up at each level to obtain the resonance correlation strength between each level pair. The edge weights are the result of weighting node semantic similarity and structural role compatibility. The energy proportion distribution and resonance correlation intensity are normalized and calibrated at the same scale, and the energy dispersion within each level is calculated. The energy dispersion is obtained by comparing the deviation of the energy of each node within the level from the average energy of the level. The energy proportion distribution of each level, the resonance correlation strength with other levels, and the energy dispersion of each level are weighted and combined to obtain semantic energy spectrum feature vectors arranged in the order of sentence level, paragraph level, role level, main line level, and full text level.
7. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The process of obtaining the file-level semantic alignment representation includes: Receive semantic energy spectrum feature vectors, directed energy transmission graphs, and hierarchical semantic vector sets. Set the main vein level vectors and full text level vectors as field anchors, and set the sentence level, paragraph level, and role level vectors as field particles. Establish a one-to-one correspondence between field anchors and field particles. Based on the semantic energy spectrum feature vector, the field anchor point and field particle are assigned weights. The main direction and feedback direction of the field are determined along the outgoing and incoming edges of the directed semantic energy transmission graph. An initial semantic field distribution is generated in the vector space, and a directional field channel is formed with the main pulse level vector as the center. Construct a semantic field curvature function, and dynamically adjust the hierarchical semantic vectors based on the semantic field curvature function: Centered on the semantic vectors at the main vein level and the full text level, a semantic field reference coordinate system is established along the main direction and feedback direction determined by the field channel. Multiple sets of equidistant sampling layers are divided in the main direction and feedback direction. Sampling nodes corresponding to the layered semantic vectors are arranged in each sampling layer, and the semantic field intensity and inter-layer difference data of each node are recorded. Second-order difference is performed on the field intensity difference between adjacent sampling layers to obtain the interlayer curvature scalar. The directional curvature is calculated along the principal direction and the feedback direction respectively. The difference between directions is extracted to form anisotropic parameters. The interlayer curvature scalar and directional curvature are summarized in hierarchical order to generate a curvature sequence. Using the curvature sequence of each file in the self-aligned semantic field as the baseline, a one-to-one correspondence is established according to the hierarchy and structural role. The curvature sequences of the two files are normalized and phase-aligned. The difference sequence at the corresponding position is calculated, the semantic field curvature function is output, and zero-bias calibration is completed.
8. The document semantic similarity calculation method based on the improved DeBERTa model according to claim 1, characterized in that, The final output of the file semantic similarity result includes: It receives the semantic energy spectrum feature vector and the file-level semantic alignment representation of the two files, performs unified scaling on the semantic energy spectrum feature vector, and performs unit length standardization on the file-level semantic alignment representation; A fusion weight vector is generated by comparing the component-wise semantic energy spectrum feature vectors of two files. It is stipulated that when the spectrum values of the two files at the same level are close, the level weight is increased, and when the difference is large, the level weight is decreased. The weights of each level are limited to between zero and one and are standardized as a whole. Three types of similarity are calculated: spectral similarity is calculated based on the directional similarity of the semantic energy spectrum feature vectors of the two files; alignment representation similarity is calculated based on the directional similarity of the file-level semantic alignment representations of the two files; and fusion similarity is calculated based on the directional similarity after weighting the semantic energy spectrum feature vectors and the file-level semantic alignment representations according to the fusion weight vector. By setting non-negative weighting coefficients and summing all coefficients to one, the spectral similarity, alignment representation similarity, and fusion similarity are weighted and summed to obtain the comprehensive semantic similarity score between documents.
Citation Information
Patent Citations
Data association maintenance processing method and system based on file reference
CN120296021A
Text sentiment analysis method and system based on dynamic semantic segmentation and feature perception
CN120562424A
Work order generation method, work order processing method and work order management system
CN120654039A
Semantics analysis device and method, and program
JP2010198246A
Information search method, related apparatuses, and communication system
WO2025011390A1
Cited By
Federal learning method, device and equipment based on semantic resonance and expert selection
CN121543670A
