A long text intelligent processing method and device based on domain adaptation
By employing a domain-adaptive intelligent long-text processing method, the system dynamically identifies the text domain and loads an appropriate Prompt template. Combined with semantic coherence segmentation and multi-dimensional importance assessment, it solves the accuracy problem of cross-domain text segmentation and summary extraction, achieving efficient and flexible text processing and summary generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INSPUR GENERSOFT CO LTD
- Filing Date
- 2026-04-20
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies are difficult to adapt to text segmentation and abstract extraction in different professional fields, resulting in inaccurate segmentation, poor abstract professionalism, and the need for retraining when processing across fields, which increases the cost and difficulty of migration.
We employ a domain-adaptive intelligent long text processing method, which identifies text domain categories through a pre-trained domain classification model, dynamically loads adapted Prompt templates, and combines semantic coherence segmentation and multi-dimensional importance assessment to generate high-quality summaries.
It achieves accuracy and flexibility in cross-domain text processing, reduces reliance on large-scale labeled data, improves user experience and segmentation boundary accuracy, and ensures semantic coherence and information integrity of summaries.
Smart Images

Figure CN122432339A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the interdisciplinary field of artificial intelligence and text mining, and specifically relates to a method and apparatus for intelligent processing of long text based on domain adaptation. Background Technology
[0002] With the rapid development of artificial intelligence technology, the demand for processing unstructured text data is increasing daily. Document segmentation and summarization technologies have become the infrastructure for enterprise digital transformation. In practical applications, for example, large enterprises often need to process documents covering multiple areas such as financial statements, risk analysis reports, and bidding contracts. If a single large model or other single technology is used, the accuracy of document segmentation and summarization is difficult to guarantee. Using different technologies for different areas increases the maintenance costs for enterprises. In other words, current technologies mainly have the following shortcomings: (1) Traditional text segmentation and summarization methods usually adopt general models, which are difficult to adapt to the terminology, text structure and semantic features of different professional fields (such as law, finance, etc.), resulting in inaccurate segmentation and poor professionalism of summarization.
[0003] (2) Most existing Prompt-based text processing methods use fixed Prompt templates and cannot be dynamically adjusted according to domain characteristics. Their performance drops significantly when processing cross-domain texts (such as financial and legal contracts). After the model is trained, it cannot dynamically adjust domain knowledge. When processing new domains, it needs to be retrained, resulting in high transfer costs.
[0004] (3) Segmentation methods based on fixed windows or rules cannot capture semantic coherence, resulting in inaccurate segmentation positions and incorrect summary extraction. Existing technologies often fail to accurately identify semantic boundaries when processing long texts such as novels, financial reports, and legal documents, leading to omissions of key information in the summary.
[0005] Therefore, how to achieve cross-domain adaptive text segmentation and summary extraction has become a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0006] To address the aforementioned issues, this invention provides a domain-adaptive intelligent long text processing method and apparatus, which can be widely applied to automated text processing scenarios in multiple professional fields such as contract document processing, financial report analysis, and risk analysis.
[0007] In a first aspect, the technical solution of the present invention provides a domain-adaptive intelligent processing method for long texts, comprising the following steps: The long text to be processed is input into a pre-trained domain classification model, which identifies and outputs the domain category to which the long text belongs; Based on the domain category, a target Prompt that is adapted to the domain category is dynamically loaded and generated from a pre-built hierarchical Prompt template library; The long text to be processed and the target Prompt are input into the dynamic segmentation engine. The dynamic segmentation engine adaptively segments the long text based on semantic coherence and outputs multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. Based on the semantic vectors of the paragraphs and combined with multi-dimensional importance evaluation indicators, key information is extracted from multiple paragraphs to generate a summary for the long text.
[0008] As a further limitation of the technical solution of the present invention, the step of dynamically loading and generating a target Prompt that is adapted to the domain category includes: Determine whether the domain category output by the domain classification model indicates that the long text is cross-domain text; If the long text is not cross-domain text, then the basic template corresponding to the domain category is obtained from the hierarchical Prompt template library. Extract the dynamic feature set of the long text. The dynamic feature set includes at least one of the following: domain keyword density, text length factor, and user demand tags; dynamic adjustment items are generated based on the dynamic feature set. The dynamic adjustment item includes at least one of the following adjustment methods: parameter-level adjustment of configurable parameters in the basic template, instruction-level adjustment of example instructions in the basic template, and weight-level adjustment of weight coefficients when multiple templates are combined; the dynamic adjustment item is fused with the basic template to generate the target Prompt; If the long text is cross-domain text, then obtain the multiple domain categories corresponding to the long text and their classification probabilities. Load multiple domain-specific basic templates corresponding to the multiple domain categories from the hierarchical Prompt template library. A weighted fusion strategy is adopted. The target Prompt is generated by weighted combination of the multiple domain-based templates.
[0009] Based on the text's domain category and dynamic characteristics, adapted prompts are generated in real time, making instructions more targeted and flexible. For cross-domain texts such as financial and legal contracts, a weighted fusion strategy is used to integrate templates from multiple domains, avoiding processing biases caused by single-domain templates and improving the accuracy of cross-domain text processing. Through a dynamic adjustment mechanism, high-quality text processing is achieved with limited or even no labeled data, reducing reliance on large-scale labeled data, making it particularly suitable for specialized applications. User-defined tag input is supported, allowing prompt instructions to be dynamically adjusted according to individual user needs, enhancing the user experience.
[0010] As a further limitation of the technical solution of the present invention, the parameter-level adjustment of the configurable parameters in the basic template includes: Based on the keyword density of the domain, adjust the parameters related to keyword weight in the basic template; the higher the keyword density, the higher the weight. According to the text length factor Adjust the parameters related to the summary length in the basic template, wherein the parameters related to the summary length include the compression ratio parameter and the segment window size parameter; Based on the user's demand tags, adjust the parameters related to information extraction preferences in the basic template.
[0011] The higher the density of domain keywords, the higher the keyword weight, ensuring that the importance of specialized terminology is fully reflected in segmentation and summarization, and avoiding the omission of key domain information. The compression rate and segmentation window size are dynamically adjusted based on the text length factor; shorter texts employ a more refined processing strategy, while longer texts use a more macro-level strategy, achieving adaptive processing for texts of different lengths. Information extraction preferences are adjusted based on user demand tags, making the summarization results more aligned with users' actual needs.
[0012] As a further limitation of the technical solution of the present invention, the dynamic segmentation engine specifically performs: The initial sliding window size and overlap ratio are dynamically configured based on the total number of tokens in the long text and the domain category. Multi-head self-attention computation is performed within each sliding window to generate a window semantic vector, and the mean and variance of the attention weights within the window are calculated; based on the window semantic vectors of adjacent windows, the semantic correlation between adjacent windows is calculated, and cross-window fusion weights are generated based on the semantic correlation. The text is divided into sliding window segments with a first preset window size and a second preset window size, respectively. Local attention calculation is performed to generate short window semantic features and long window semantic features. The fusion weights of the short window, the basic window and the long window are dynamically calculated through the weight generation network to generate a multi-scale fusion semantic vector. Based on the mean and variance of the attention weights within the window, the semantic correlation between adjacent windows, and the multi-scale fused semantic vector, a boundary feature vector is constructed; the boundary feature vector is input into a pre-trained segmented boundary probability model, and the result of judging whether the current position is a segmented boundary is output. Based on the segmentation boundary judgment result, the long text is divided into multiple semantically coherent paragraphs, and the multi-scale fused semantic vector is output as the paragraph semantic vector corresponding to each paragraph.
[0013] Abandoning traditional segmentation methods based on fixed windows or rules, this paper adopts a dynamic segmentation engine based on semantic coherence to ensure that segmentation boundaries match the semantic structure of the text, resulting in segmentation results that better align with human reading comprehension habits. Window size is dynamically adjusted based on text length and domain category; larger windows are used for legal texts to preserve clause integrity, while smaller windows are used for novels to maintain plot coherence, achieving domain-adaptive window configuration. Simultaneously, it captures sentence-level details in short windows, paragraph-level semantics in basic windows, and cross-paragraph dependencies in long windows, forming a multi-layered and comprehensive semantic understanding. Semantic jumps are identified through the variance of attention weights within windows, semantic breaks are detected through cross-window attenuation factors, and boundary probability prediction is performed using the LightGBM model; multiple mechanisms ensure the accuracy of segmentation boundaries. Through cross-window semantic fusion, overlapping areas of adjacent windows are weighted and fused to eliminate artificial semantic fragmentation caused by window division, ensuring natural and smooth segmentation boundaries.
[0014] As a further limitation of the technical solution of the present invention, the step of performing multi-head self-attention calculation also includes: Multi-head self-attention computation is performed within each sliding window to generate a window semantic vector, and the mean and variance of the attention weights within the window are extracted from the attention weight matrix. For adjacent windows, the semantic vectors of the overlapping parts are extracted, and the semantic relevance of the semantic vectors of the overlapping parts of adjacent windows is calculated using the cosine similarity formula. The cross-window fusion weight is calculated based on the semantic relevance, and the semantic vectors of the overlapping parts are weighted and fused based on the cross-window fusion weight to generate a smooth cross-window semantic representation.
[0015] By extracting the mean and variance of attention weights, the concentration and dispersion of semantics within a window are quantified, providing semantic structural features within the window for boundary decisions. Cosine similarity is used to calculate the semantic correlation of overlapping regions between adjacent windows, quantifying the semantic coherence between windows into a computable numerical value. Weighted fusion generates smooth cross-window semantic representations, ensuring that adjacent windows have consistent semantic representations in overlapping regions and avoiding semantic discontinuities caused by independent window calculations. The cross-window fusion weights are directly used to calculate the attenuation factor, providing a key basis for semantic tomography detection.
[0016] As a further limitation of the technical solution of the present invention, the step of generating multi-scale fused semantic vectors also includes: The text is divided into sliding window segments with a first preset window size, local attention calculation is performed, and short window semantic features are generated by pooling. The text is divided into sliding windows based on a second preset window size, and a rotation position embedding technique is introduced to generate long window semantic features. The short window semantic features, the basic window semantic vector, and the long window semantic features are concatenated into a multi-scale feature vector, and the fusion weights of the features at each scale are calculated through a weight generation network. The short window semantic features, the basic window semantic vector, and the long window semantic features are weighted and summed according to the fusion weights to generate a multi-scale fused semantic vector.
[0017] Short windows capture fine-grained semantics at the sentence level, basic windows capture paragraph-level semantics, and long windows capture long-distance dependencies across paragraphs, forming a multi-layered semantic understanding. A rotational position embedding technique is introduced to enhance the computational ability of semantic associations between long-distance tokens within the long window, solving the problem of difficulty in capturing contextual relationships in long texts. A weighted generation network dynamically calculates the fusion weights of features at each scale, automatically adjusting the contribution ratios of short, medium, and long window features based on text characteristics. Optimal multi-scale fused semantic vectors are generated through weighted summation, providing high-quality paragraph semantic representations for subsequent boundary decisions and summary extraction.
[0018] As a further limitation of the technical solution of the present invention, the step of dividing the long text into multiple semantically coherent paragraphs based on the judgment result of the segmentation boundary, and outputting the multi-scale fused semantic vector as the paragraph semantic vector corresponding to each paragraph includes: For adjacent windows, construct a boundary feature vector containing the mean, variance, and mean difference of the attention weights within the window; The decay factor is calculated based on the cross-window fusion weight. When the decay factor exceeds a preset threshold, it is determined to be a potential semantic fault, which is used as the judgment result of the rule engine. The boundary feature vector is input into a pre-trained segmented boundary probability model, and the boundary probability is output as the judgment result of the machine learning model. The judgment results of the rule engine and the machine learning model are combined using a weighted voting method to generate the final segment boundary decision.
[0019] Boundary feature vectors integrate multi-dimensional information such as semantic concentration within a window, semantic dispersion, and semantic differences between windows, providing rich feature inputs for boundary judgment. The judgment results of the rule engine and machine learning model are combined, and weighted voting is used to improve the accuracy and robustness of boundary decisions. The rule engine provides interpretable criteria for boundary judgment, while the machine learning model learns the segmentation patterns from manually labeled data; the combination of the two balances interpretability and accuracy.
[0020] As a further limitation of the technical solution of the present invention, the steps of extracting key information from multiple paragraphs and generating a summary for the long text based on the paragraph semantic vector and combined with multi-dimensional importance evaluation indicators include: Based on the paragraph semantic vector, combined with multi-dimensional importance evaluation indicators, the importance score of each paragraph is calculated, and all paragraphs are sorted in descending order according to the importance score; Paragraphs are selected sequentially according to the order described above. Sentence-level importance assessment and compression are performed on the selected paragraphs, and they are then merged to generate a preliminary summary. The preliminary summary is then optimized for coherence, verified for information integrity, and its length is adjusted to generate the final summary.
[0021] By comprehensively considering multiple dimensions such as basic semantic score, multi-scale feature fusion score, keyword density, semantic centrality, and positional decay factor, the comprehensiveness and accuracy of paragraph importance assessment are ensured. Key sentences from the original text are preserved while also being compressed and optimized to ensure the summary is both faithful to the original and concise. A closed-loop optimization mechanism is formed through coherence optimization, information integrity verification, and length adjustment to ensure the final summary is fluent, information-complete, and of appropriate length. The paragraph boundaries requiring transitional connectors are identified based on cross-window decay factor identification to ensure the logical coherence of the summary's context.
[0022] As a further limitation of the technical solution of the present invention, the step of calculating the importance score of each paragraph based on the paragraph semantic vector and combined with multi-dimensional importance evaluation indicators, and sorting all paragraphs in descending order according to the importance scores, includes: The paragraph semantic vector is input into the Transformer encoder, and the semantic dependencies between paragraphs are captured through a multi-head self-attention mechanism to generate an enhanced paragraph semantic vector. The enhanced paragraph semantic vectors are input into a fully connected neural network, which outputs a basic importance score for each paragraph. The semantic features of the short window, the semantic vector of the basic window, and the semantic features of the long window are input into a fully connected neural network to obtain the importance scores of the short window, the basic window, and the long window; and the multi-scale feature fusion score is calculated based on the fusion weights. Calculate the keyword density, semantic centrality, and positional decay factor for each paragraph, and then perform a weighted sum to obtain a semantic importance evaluation score; The final importance score for each paragraph is obtained by summing the basic importance score, multi-scale feature fusion score, and semantic importance assessment score. All paragraphs are sorted in descending order based on the final importance score.
[0023] The Transformer encoder captures semantic dependencies between paragraphs, avoiding isolated evaluation of each paragraph and ensuring that importance assessment considers context. Weighted fusion of importance scores from three levels—short window, basic window, and long window—ensures paragraph importance assessment considers sentence-level details, paragraph-level semantics, and cross-paragraph global dependencies simultaneously. A comprehensive assessment of paragraph semantic importance is achieved by weighted summation of keyword density, semantic centrality, and positional decay. The basic importance score, multi-scale feature fusion score, and semantic importance assessment score are then added together, integrating paragraph semantics, multi-scale features, and domain importance to ensure the accuracy and robustness of the final importance score.
[0024] As a further limitation of the technical solution of the present invention, the steps of selecting paragraphs in the order described above, performing sentence-level importance assessment and compression on the selected paragraphs, and merging them to generate a preliminary summary include: A greedy algorithm is used to select paragraphs in descending order of importance until the cumulative length of the selected paragraphs reaches a preset summary length threshold, which is 15% of the original text length. The selected paragraphs are split into sentences, and the semantic vector of each sentence is generated using the BERT sentence embedding model. The semantic vector of the sentence and the semantic vector of the paragraph to which it belongs are input into a binary classification model based on an attention mechanism, and the output is 0 or 1 to determine whether the sentence is a key sentence; For sentences identified as key sentences, compression is performed using a combination of rule-based methods and deep learning methods. The rule-based methods include removing redundant modifiers and merging synonymous phrases, while the deep learning method uses the sequence-to-sequence model T5. The compressed key sentences are merged according to the paragraph order in the original text to form a preliminary summary.
[0025] As a further limitation of the technical solution of the present invention, the steps of optimizing the coherence, verifying the information integrity, and adjusting the length of the preliminary summary include: Based on the cross-window attention decay factor output by the dynamic segmentation engine, for paragraph boundaries with d>0.7, transitional connectors are forcibly retained in the summary; the long-distance dependency features of multi-scale window fusion are used to adjust the sentence order of the summary to match the logical chain of the original paragraphs; the language model is used to evaluate the coherence between sentences, and if the score is lower than the threshold, connectors are added or the sentence order is rearranged. The Sentence-BERT model is used to calculate the semantic similarity between the preliminary summary and the original text. If the similarity is lower than the preset value, the process returns to the key paragraph filtering step to re-filter paragraphs or supplement key information. If the length of the abstract exceeds the preset threshold, the sentences in the abstract are compressed again; if the length of the abstract is less than the preset threshold, sentences of higher importance are selected from the remaining paragraphs to supplement it until the length requirement is met.
[0026] Secondly, the present invention also provides a domain-adaptive intelligent long text processing device, comprising: The domain classification module is used to input the long text to be processed into the pre-trained domain classification model, identify and output the domain category to which the long text belongs; The dynamic Prompt loading module is used to dynamically load and generate a target Prompt that is adapted to the domain category from a pre-built hierarchical Prompt template library based on the domain category. The dynamic segmentation engine module is used to take the long text to be processed and the target Prompt as input, and adaptively segment the long text based on semantic coherence, and output multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. The summary extraction module is used to extract key information from multiple paragraphs based on the paragraph semantic vectors and combined with multi-dimensional importance evaluation indicators, and generate a summary for the long text.
[0027] As can be seen from the above technical solutions, this application has the following advantages: It automatically identifies the professional field to which the text belongs through a pre-classification model, enabling subsequent processing to be customized according to the characteristics of the field, avoiding the problem of unstable performance of general models across different fields. A complete technical chain is formed from text input to summary output, requiring no manual intervention and simplifying the deployment process. A dynamic segmentation engine based on semantic coherence is adopted to replace traditional fixed-window or rule-based segmentation methods, ensuring that the segmentation results conform to the inherent semantic structure of the text. Summary extraction is performed by combining multi-dimensional importance evaluation indicators, ensuring that the generated summary contains key information while maintaining semantic coherence. Attached Figure Description
[0028] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart illustrating the method provided in an embodiment of the present invention.
[0030] Figure 2 A flowchart illustrating a method provided in another embodiment of the present invention.
[0031] Figure 3 A block diagram of the apparatus provided in an embodiment of the present invention. Detailed Implementation
[0032] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0033] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this application and in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0034] Please refer to Figure 1 This invention provides a domain-adaptive intelligent long text processing method, comprising the following steps: S1. Input the long text to be processed into the pre-trained domain classification model to identify and output the domain category to which the long text belongs. In this embodiment, the domain classification model uses a large-scale pre-trained language model as the foundation, and adds a classification layer on top of it for fine-tuning. Specifically, BERT (Bidirectional Encoder Representations from Transformers) is selected as the base pre-trained model. A classification head is added to the output layer of the BERT model, with the following specific structure: Input: The [CLS] token output vector of the BERT model, with a dimension of 768; Fully connected layer: maps a 768-dimensional vector to the number of domain categories, K dimensions; Activation function: Softmax, which converts the output into a probability distribution.
[0035] The formula for calculating the classification layer is:
[0036] in, The [CLS] token vector output by the BERT model; Here is the weight matrix of the fully connected layer, with dimension 1. ; For bias terms; This represents the total number of domain categories.
[0037] We collect professional text data from various fields, including financial news, financial reports, legal documents, contracts, medical reports, and scientific papers, ensuring a balanced amount of data across each field to avoid class imbalance. Each text sample is labeled with a category label using one-hot encoding, e.g., [1,0,0,0] for finance and [0,1,0,0] for law. The model training process is as follows: The text is segmented and converted to the input format for the BERT model. Special markers are added: [CLS] is placed at the beginning of the sentence, and [SEP] at the end. An attention mask is generated to mark the positions of valid tokens. The preprocessed text is input into the BERT model, and the output vector of the [CLS] token is extracted. The domain category probability distribution is calculated through a fully connected layer and Softmax. The cross-entropy loss is calculated, and the predicted probabilities are compared with the true labels. The cross-entropy loss function quantifies the difference between the model's predicted probability distribution and the true labels. ;in, The first for the real label dimension, The model predicts the first Class probability, This represents the total number of domain categories. The gradient is calculated, and the BERT model parameters and classification layer parameters are updated, with gradient pruning used to prevent gradient surge. After each training round, the accuracy is evaluated on the validation set, and the model parameters that perform best on the validation set are saved.
[0038] S2. Based on the domain category, dynamically load and generate a target Prompt adapted to the domain category from a pre-built hierarchical Prompt template library; in this embodiment of the invention, as shown... Figure 2 As shown, the steps for dynamically loading and generating a target Prompt that adapts to the domain category include: S21. Determine whether the domain category output by the domain classification model indicates that the long text is cross-domain text; If the long text is not cross-domain text, execute S22; if the long text is cross-domain text, execute S26. S22. Obtain the basic template corresponding to the domain category from the hierarchical Prompt template library. ; S23. Extract the dynamic feature set of the long text. The dynamic feature set includes at least one of the following: domain keyword density, text length factor, and user demand tags; in this step, keywords are extracted from the text using the TF-IDF algorithm, specifically including: Calculate the frequency of each word in the document, i.e., term frequency. ; Calculate the inverse document frequency, which measures the general importance of words. ; Calculate the TF-IDF value: ; The top N words with the highest TF-IDF values are selected as candidate keywords, and then matched with a predefined domain terminology database to filter out terms belonging to the professional field as domain keywords.
[0039] Domain keyword density The calculation formula is: ; Text length factor The calculation formula is: , This represents the total number of tokens in the text, i.e., the number of lexical units after word segmentation.
[0040] S24. Generate dynamic adjustment items based on the dynamic feature set. The dynamic adjustment item includes at least one of the following adjustment methods: parameter-level adjustment of configurable parameters in the basic template, instruction-level adjustment of example instructions in the basic template, and weight-level adjustment of weight coefficients when multiple templates are combined. Dynamic adjustment item The formula for generating it is: ;in It is a mapping function that maps the above features to specific Prompt parameter adjustment values.
[0041]
[0042] in, These are preset coefficients, mapped to preset adjustment vectors based on user needs and labels. .
[0043] In this embodiment of the invention, parameter-level adjustment of the configurable parameters in the basic template includes: Based on the domain keyword density, adjust the parameters related to keyword weight in the basic template; the higher the domain keyword density, the higher the weight; based on the text length factor... Adjust the parameters related to the summary length in the basic template, including compression ratio and segment window size parameters; adjust the parameters related to information extraction preferences in the basic template according to the user demand tags.
[0044] Based on the calculation The following parameters are dynamically adjusted: Adjusted compression ratio parameters ,when When the value is >0 (for long texts), the compression rate decreases, and the summary becomes longer; when... When the value is less than 0 (short text), the compression rate is improved and the summary is shorter.
[0045] The formula for calculating the basic window size is: The window size is dynamically adjusted by Indirect impact, because based on Calculation, and Also based on Calculation; the two work together.
[0046] S25, through formula The dynamic adjustment items are merged with the base template to generate the target Prompt; S26. Obtain the multiple domain categories corresponding to the long text and their classification probabilities. ; S27. Load multiple domain-based templates corresponding to the multiple domain categories from the hierarchical Prompt template library. ; S28. Employing a weighted fusion strategy The target Prompt is generated by weighted combination of the multiple domain-based templates.
[0047] Prompt Template Library Three-Level Category Structure Design Principles: General Layer (G): Cross-domain basic templates for handling common tasks; Vertical Layer (D): Customized templates for specific professional fields, including a domain terminology library; Subdomain layer (S): Subdivided scene templates, supporting fine-tuning of parameters; Among them, the general layer template example is shown in Table 1, the vertical layer template example is shown in Table 2 for the financial domain (D_FIN), the legal domain template example is shown in Table 3, and the sub-domain layer template example is shown in Table 4 for the financial-credit report (S_FIN_CREDIT).
[0048] Table 1
[0049] Table 2
[0050] Table 3
[0051] Table 4
[0052] S3. Input the long text to be processed and the target Prompt into the dynamic segmentation engine. The dynamic segmentation engine adaptively segments the long text based on semantic coherence, and outputs multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. In this step, the dynamic segmentation engine specifically performs the following: S31. Dynamically configure the initial sliding window size and overlap rate based on the total number L of tokens in the long text and the domain category; and dynamically configure the domain window coefficient corresponding to the domain category. Adjust to get the final window size Window size constraint is ∈[128,2048]; The overlap rate is initialized to 20%, and the overlap rate is increased to 50% for windows with keyword density exceeding a preset threshold; S32. Perform multi-head self-attention calculation within each sliding window to generate a window semantic vector, and calculate the mean and variance of the attention weights within the window; calculate the semantic correlation between adjacent windows based on the window semantic vectors of adjacent windows, and generate cross-window fusion weights based on the semantic correlation. Here, the steps for performing multi-head self-attention calculation also include: Multi-head self-attention computation is performed within each sliding window to generate a window semantic vector, and the mean and variance of the attention weights within the window are extracted from the attention weight matrix. For adjacent windows, the semantic vectors of the overlapping parts are extracted, and the semantic relevance S of the semantic vectors of the overlapping parts of adjacent windows is calculated using the cosine similarity formula. The cross-window fusion weight is then calculated based on the semantic relevance. The semantic vectors of the overlapping parts are weighted and fused based on the cross-window fusion weights to generate a smooth cross-window semantic representation.
[0053] S33. The text is divided into sliding window segments with a first preset window size of 128 and a second preset window size of 2048, respectively. Local attention calculation is performed to generate short window semantic features and long window semantic features. The fusion weights of the short window, the basic window, and the long window are dynamically calculated through a weight generation network to generate a multi-scale fused semantic vector. Here, the step of generating the multi-scale fused semantic vector also includes: The text is divided into sliding window segments with a first preset window size, local attention calculation is performed, and short window semantic features are generated by pooling. The text is then divided into sliding window segments with a second preset window size, and rotation position embedding technology is introduced to generate long window semantic features. The short window semantic features, basic window semantic vector, and long window semantic features are concatenated into a multi-scale feature vector, and the fusion weights of each scale feature are calculated through a weighted generation network. The short window semantic features, basic window semantic vector, and long window semantic features are weighted and summed according to the fusion weights to generate a multi-scale fused semantic vector.
[0054] S34. Based on the mean and variance of the attention weights within the window, the semantic correlation between adjacent windows, and the multi-scale fused semantic vector, construct a boundary feature vector; input the boundary feature vector into a pre-trained segmented boundary probability model, and output the judgment result of whether the current position is a segmented boundary; S35. Based on the judgment result of the segmentation boundary, the long text is divided into multiple semantically coherent paragraphs, and the multi-scale fused semantic vector is output as the paragraph semantic vector corresponding to each paragraph.
[0055] S4. Based on the paragraph semantic vectors and combined with multi-dimensional importance evaluation metrics, extract key information from multiple paragraphs to generate a summary for the long text. Specifically, this includes: S41. Based on the paragraph semantic vector and combined with multi-dimensional importance evaluation indicators, calculate the importance score of each paragraph, and sort all paragraphs in descending order according to the importance score; S42. Select paragraphs in the order described above, perform sentence-level importance assessment and compression on the selected paragraphs, and merge them to generate a preliminary summary; S43. Perform coherence optimization, information integrity verification, and length adjustment on the preliminary summary to generate the final summary.
[0056] In some embodiments, the step of dividing the long text into multiple semantically coherent paragraphs based on the segmentation boundary determination result, and outputting the multi-scale fused semantic vector as the paragraph semantic vector corresponding to each paragraph, includes: For adjacent windows, a boundary feature vector is constructed containing the mean, variance, and mean difference of the attention weights within the window. A decay factor is calculated based on the cross-window fusion weights. When the decay factor exceeds a preset threshold, it is determined as a latent semantic fault and used as the judgment result of the rule engine. The boundary feature vector is input into a pre-trained segmented boundary probability model, and the boundary probability is output as the judgment result of the machine learning model. The judgment result of the rule engine and the judgment result of the machine learning model are fused using a weighted voting method to generate the final segmented boundary decision.
[0057] In some embodiments, the step of calculating the importance score of each paragraph based on the paragraph semantic vector and combined with multi-dimensional importance evaluation indicators, and sorting all paragraphs in descending order according to the importance scores, includes: The paragraph semantic vectors are input into a Transformer encoder, which uses a multi-head self-attention mechanism to capture semantic dependencies between paragraphs, generating enhanced paragraph semantic vectors. These enhanced vectors are then input into a fully connected neural network, which outputs a basic importance score for each paragraph. Keyword density is calculated for each paragraph. The semantic centrality of each paragraph is calculated, where the semantic centrality is the cosine similarity between the paragraph vector and the document center vector. Finally, a position decay factor for each paragraph is calculated using the following formula: The final importance score of each paragraph is calculated by weighting and summing the base score, keyword density, semantic centrality, and positional decay factor; all paragraphs are then sorted in descending order based on the final importance score.
[0058] In some embodiments, the steps of selecting paragraphs sequentially according to the ordered sequence, performing sentence-level importance assessment and compression on the selected paragraphs, and merging them to generate a preliminary summary include: A greedy algorithm is used to select paragraphs in descending order of importance until the cumulative length of the selected paragraphs reaches a preset summary length threshold. The selected paragraphs are then split into sentences, and a semantic vector for each sentence is generated using the BERT sentence embedding model. A binary classification model based on an attention mechanism is used to determine whether each sentence is a key sentence. For sentences identified as key sentences, a combination of rule-based and deep learning methods is used for compression. The rule-based method includes removing redundant modifiers and merging synonymous phrases, while the deep learning method uses the sequence-to-sequence model T5. The compressed key sentences are then merged according to the paragraph order in the original text to form a preliminary summary.
[0059] In some embodiments, the steps of performing coherence optimization, information integrity verification, and length adjustment on the preliminary summary include: Based on the cross-window attention decay factor output by the dynamic segmentation engine, for paragraph boundaries with d>0.7, transitional connectors are forcibly retained in the summary; the long-distance dependency features of multi-scale window fusion are used to adjust the sentence order of the summary to match the logical chain of the original paragraphs; the language model is used to evaluate the coherence between sentences, and if the score is lower than the threshold, connectors are added or the sentence order is rearranged. The Sentence-BERT model is used to calculate the semantic similarity between the preliminary summary and the original text. If the similarity is lower than the preset value, the process returns to the key paragraph filtering step to re-filter paragraphs or supplement key information. If the length of the abstract exceeds the preset threshold, the sentences in the abstract are compressed again; if the length of the abstract is less than the preset threshold, sentences of higher importance are selected from the remaining paragraphs to supplement it until the length requirement is met.
[0060] like Figure 3 As shown, this embodiment of the invention provides a domain-adaptive intelligent long text processing device, comprising: The domain classification module is used to input the long text to be processed into the pre-trained domain classification model, identify and output the domain category to which the long text belongs; The dynamic Prompt loading module is used to dynamically load and generate a target Prompt that is adapted to the domain category from a pre-built hierarchical Prompt template library based on the domain category. The dynamic segmentation engine module is used to take the long text to be processed and the target Prompt as input, and adaptively segment the long text based on semantic coherence, and output multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. The summary extraction module is used to extract key information from multiple paragraphs based on the paragraph semantic vectors and combined with multi-dimensional importance evaluation indicators, and generate a summary for the long text.
[0061] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.
[0062] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0063] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0064] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0065] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A domain-adaptive intelligent processing method for long texts, characterized in that, Includes the following steps: The long text to be processed is input into a pre-trained domain classification model, which identifies and outputs the domain category to which the long text belongs; Based on the domain category, a target Prompt that is adapted to the domain category is dynamically loaded and generated from a pre-built hierarchical Prompt template library; The long text to be processed and the target Prompt are input into the dynamic segmentation engine. The dynamic segmentation engine adaptively segments the long text based on semantic coherence and outputs multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. Based on the semantic vectors of the paragraphs and combined with multi-dimensional importance evaluation indicators, key information is extracted from multiple paragraphs to generate a summary for the long text.
2. The domain-adaptive intelligent long text processing method according to claim 1, characterized in that, The steps for dynamically loading and generating a target Prompt that fits the domain category include: Determine whether the domain category output by the domain classification model indicates that the long text is cross-domain text; If the long text is not cross-domain text, then the basic template corresponding to the domain category is obtained from the hierarchical Prompt template library. Extract the dynamic feature set of the long text. The dynamic feature set includes at least one of the following: domain keyword density, text length factor, and user demand tags; dynamic adjustment items are generated based on the dynamic feature set. The dynamic adjustment item includes at least one of the following adjustment methods: parameter-level adjustment of configurable parameters in the basic template, instruction-level adjustment of example instructions in the basic template, and weight-level adjustment of weight coefficients when multiple templates are combined; the dynamic adjustment item is fused with the basic template to generate the target Prompt; If the long text is cross-domain text, then obtain the multiple domain categories corresponding to the long text and their classification probabilities. Load multiple domain-specific basic templates corresponding to the multiple domain categories from the hierarchical Prompt template library. A weighted fusion strategy is adopted. The target Prompt is generated by weighted combination of the multiple domain-based templates.
3. The domain-adaptive intelligent long text processing method according to claim 2, characterized in that, Parameter-level adjustments to the configurable parameters in the base template include: Based on the keyword density of the domain, adjust the parameters related to keyword weight in the basic template; the higher the keyword density, the higher the weight. According to the text length factor Adjust the parameters related to the summary length in the basic template, wherein the parameters related to the summary length include the compression ratio parameter and the segment window size parameter; Based on the user's demand tags, adjust the parameters related to information extraction preferences in the basic template.
4. The domain-adaptive intelligent long text processing method according to claim 2, characterized in that, The dynamic segmentation engine specifically executes as follows: The initial sliding window size and overlap ratio are dynamically configured based on the total number of tokens in the long text and the domain category. Multi-head self-attention computation is performed within each sliding window to generate a window semantic vector, and the mean and variance of the attention weights within the window are calculated. Based on the semantic vectors of adjacent windows, the semantic correlation between adjacent windows is calculated, and cross-window fusion weights are generated based on the semantic correlation. The text is divided into sliding window segments with the first preset window size and the second preset window size respectively. Local attention calculation is performed to generate short window semantic features and long window semantic features. The fusion weights of short window, basic window and long window are dynamically calculated by the weight generation network to generate multi-scale fusion semantic vectors; Based on the mean and variance of the attention weights within the window, the semantic correlation between adjacent windows, and the multi-scale fused semantic vector, a boundary feature vector is constructed; the boundary feature vector is input into a pre-trained segmented boundary probability model, and the result of judging whether the current position is a segmented boundary is output. Based on the segmentation boundary judgment result, the long text is divided into multiple semantically coherent paragraphs, and the multi-scale fused semantic vector is output as the paragraph semantic vector corresponding to each paragraph.
5. The domain-adaptive intelligent long text processing method according to claim 4, characterized in that, The steps for performing multi-head self-attention calculations also include: Multi-head self-attention computation is performed within each sliding window to generate a window semantic vector, and the mean and variance of the attention weights within the window are extracted from the attention weight matrix. For adjacent windows, the semantic vectors of the overlapping parts are extracted, and the semantic relevance of the semantic vectors of the overlapping parts of adjacent windows is calculated using the cosine similarity formula. The cross-window fusion weight is calculated based on the semantic relevance, and the semantic vectors of the overlapping parts are weighted and fused based on the cross-window fusion weight to generate a smooth cross-window semantic representation.
6. The domain-adaptive intelligent long text processing method according to claim 5, characterized in that, The steps for generating multi-scale fused semantic vectors also include: The text is divided into sliding window segments with a first preset window size, local attention calculation is performed, and short window semantic features are generated by pooling. The text is divided into sliding windows based on a second preset window size, and a rotation position embedding technique is introduced to generate long window semantic features. The short window semantic features, the basic window semantic vector, and the long window semantic features are concatenated into a multi-scale feature vector, and the fusion weights of the features at each scale are calculated through a weight generation network. The short window semantic features, the basic window semantic vector, and the long window semantic features are weighted and summed according to the fusion weights to generate a multi-scale fused semantic vector.
7. The domain-adaptive intelligent long text processing method according to claim 4, characterized in that, Based on the segmentation boundary determination result, the step of dividing the long text into multiple semantically coherent paragraphs and outputting the multi-scale fused semantic vector as the paragraph semantic vector corresponding to each paragraph includes: For adjacent windows, construct a boundary feature vector containing the mean, variance, and mean difference of the attention weights within the window; The decay factor is calculated based on the cross-window fusion weight. When the decay factor exceeds a preset threshold, it is determined to be a potential semantic fault, which is used as the judgment result of the rule engine. The boundary feature vector is input into a pre-trained segmented boundary probability model, and the boundary probability is output as the judgment result of the machine learning model. The judgment results of the rule engine and the machine learning model are combined using a weighted voting method to generate the final segment boundary decision.
8. The domain-adaptive intelligent long text processing method according to claim 4, characterized in that, Based on the paragraph semantic vectors and combined with multi-dimensional importance evaluation metrics, the steps for extracting key information from multiple paragraphs and generating a summary for the long text include: Based on the paragraph semantic vector, combined with multi-dimensional importance evaluation indicators, the importance score of each paragraph is calculated, and all paragraphs are sorted in descending order according to the importance score; Paragraphs are selected sequentially according to the order described above. Sentence-level importance assessment and compression are performed on the selected paragraphs, and they are then merged to generate a preliminary summary. The preliminary summary is then optimized for coherence, verified for information integrity, and its length is adjusted to generate the final summary.
9. The domain-adaptive intelligent long text processing method according to claim 8, characterized in that, Based on the paragraph semantic vector, and combined with multi-dimensional importance evaluation indicators, the steps of calculating the importance score of each paragraph and sorting all paragraphs in descending order according to the importance scores include: The paragraph semantic vector is input into the Transformer encoder, and the semantic dependencies between paragraphs are captured through a multi-head self-attention mechanism to generate an enhanced paragraph semantic vector. The enhanced paragraph semantic vectors are input into a fully connected neural network, which outputs a basic importance score for each paragraph. The semantic features of the short window, the semantic vector of the basic window, and the semantic features of the long window are input into a fully connected neural network to obtain the importance scores of the short window, the basic window, and the long window; and the multi-scale feature fusion score is calculated based on the fusion weights. Calculate the keyword density, semantic centrality, and positional decay factor for each paragraph, and then perform a weighted sum to obtain a semantic importance evaluation score; The final importance score for each paragraph is obtained by summing the basic importance score, multi-scale feature fusion score, and semantic importance assessment score. All paragraphs are sorted in descending order based on the final importance score.
10. A domain-adaptive intelligent long text processing device, characterized in that, include: The domain classification module is used to input the long text to be processed into the pre-trained domain classification model, identify and output the domain category to which the long text belongs; The dynamic Prompt loading module is used to dynamically load and generate a target Prompt that is adapted to the domain category from a pre-built hierarchical Prompt template library based on the domain category. The dynamic segmentation engine module is used to take the long text to be processed and the target Prompt as input, and adaptively segment the long text based on semantic coherence, and output multiple semantically coherent paragraphs and their corresponding paragraph semantic vectors. The summary extraction module is used to extract key information from multiple paragraphs based on the paragraph semantic vectors and combined with multi-dimensional importance evaluation indicators, and generate a summary for the long text.