Prompt reasoning method and system for long text semantic abstract
By constructing a system for parsing institutional documents based on a large language model, and combining dynamic construction of semantic rules with a prompt-based semantic reasoning model, the system addresses the issues of insufficient generalization and contextual understanding in the parsing of institutional documents, achieving efficient and low-cost automated parsing.
Patent Information
- Application Number
- CN202510942424.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-11-14
AI Technical Summary
Existing technologies face challenges in compliance audits in heavily regulated sectors such as finance, healthcare, and manufacturing. These challenges include a lack of natural language generalization capabilities, weak contextual understanding, and soaring costs associated with rule iteration. Consequently, the cost of parsing regulatory documents is high and inefficient.
A system document parsing model based on a large language model is constructed. It combines a dynamic semantic rule construction model and a prompt-based semantic reasoning model. Through the Jinja2 template engine and the Few-shot learning algorithm, the system achieves semantic understanding, preference alignment, and rule intent completion of system documents, generates dynamic prompts, and performs automated parsing.
It enhances the generalization and semantic understanding capabilities of policy document parsing, reduces parsing costs, and automates the processing of implicit logical dependencies and cross-clause references, significantly improving parsing efficiency and accuracy.
Smart Images

Figure CN120951985A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence-driven document parsing technology, and in particular to a prompting reasoning method and system for semantic summarization of long texts. Background Technology
[0002] In compliance audits and policy enforcement scenarios within heavily regulated sectors such as finance, healthcare, and manufacturing, the accurate parsing of massive amounts of regulatory documents (including policies, regulations, corporate standards, and operational procedures) is the technological cornerstone for building intelligent regulatory systems. Current mainstream industry solutions rely on rule engine frameworks (such as Drools and Jess) to automatically parse these documents by converting them into structured conditional expressions (such as logical rules like "IF [condition] THEN [action]"). However, with the deepening of digital transformation, this traditional approach is facing the following technological bottlenecks:
[0003] 1. Lack of natural language generalization ability:
[0004] The policy documents exhibit typical semantic complexity: a) Variety of expressions: The same constraint may be expressed in multiple ways (e.g., "transaction amount ≥ 50,000 RMB", "remittances exceeding 50,000 RMB", "transfers not less than 50,000 RMB"); b) Implicit logical dependencies: For example, "significant client" in overseas regulatory provisions specifically refers to "entities with annual transaction volume > $1 million", while internal regulations may define it as "AAA-rated clients"; c) Cross-clause references: The specific definition of "abnormal transactions" in a certain securities regulation requires cross-referencing with corresponding clauses and appendices. Existing rule engines, which use keyword matching and regular expression technology, cannot identify such semantic variations and contextual relationships.
[0005] 2. Weak ability to understand context:
[0006] The implementation of the system relies on the ability to parameterize scenarios. For example, the "approval for overseas transmission of sensitive data" clause can be applied through a fast track in the R&D department, while the finance department needs to add the CEO's signature. However, the current system lacks a context-aware mechanism.
[0007] 3. The cost of rule iteration has skyrocketed:
[0008] Regulatory documents are updated on average 12%-15% per month (Source: IBM 2023 Compliance Technology White Paper). A single financial regulatory document often contains more than 200 dynamic clauses. Traditional rule engines require manual reconstruction of logical expressions one by one, and the high frequency of updates leads to an exponential increase in system maintenance costs.
[0009] Therefore, how to provide a prompting reasoning method and system for semantic summarization of long texts, so as to improve the generalization ability and semantic understanding ability of institutional document parsing and reduce parsing costs, has become an urgent technical problem to be solved. Summary of the Invention
[0010] The technical problem to be solved by this invention is to provide a prompting reasoning method and system for semantic summarization of long texts, thereby improving the generalization ability and semantic understanding ability of institutional document parsing and reducing parsing costs.
[0011] In a first aspect, the present invention provides a prompting reasoning method for semantic summarization of long texts, comprising the following steps:
[0012] Step S1: Create a policy document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model;
[0013] The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results.
[0014] Step S2: Obtain a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively;
[0015] Step S3: Deploy the trained system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and automatically parse real-time system documents using the deployed system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
[0016] Furthermore, in step S1, the institutional document parsing model is constructed based on a large language model, used to extract document summaries and instruction corpora from institutional documents, perform semantic understanding and preference alignment on institutional documents based on the document summaries and instruction corpora, and output style-adapted documents.
[0017] The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples.
[0018] The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
[0019] Furthermore, step S2 specifically includes:
[0020] A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents.
[0021] The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
[0022] Furthermore, in step S2, during the training process of the institutional document parsing model, a model fine-tuning method, a model preference comparison mechanism, and a direct preference optimization strategy are combined.
[0023] Furthermore, step S3 specifically includes:
[0024] The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.
[0025] Secondly, the present invention provides a prompting reasoning system for semantic summarization of long texts, comprising the following modules:
[0026] The reasoning engine creation module is used to create a system document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model;
[0027] The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results.
[0028] The inference engine training module is used to acquire a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively.
[0029] The institutional document reasoning module is used to deploy the trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and to automatically parse real-time institutional documents through the deployed institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
[0030] Furthermore, in the inference engine creation module, the institutional document parsing model is built based on a large language model, which is used to extract document summaries and instruction corpora from institutional documents, perform semantic understanding and preference alignment on institutional documents based on the document summaries and instruction corpora, and output style-adapted documents.
[0031] The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples.
[0032] The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
[0033] Furthermore, the inference engine training module is specifically used for:
[0034] A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents.
[0035] The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
[0036] Furthermore, in the inference engine training module, during the training process of the institutional document parsing model, a model fine-tuning method, a model preference comparison mechanism, and a direct preference optimization strategy are combined.
[0037] Furthermore, the institutional document reasoning module is specifically used for:
[0038] The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.
[0039] The advantages of this invention are:
[0040] 1. This involves creating a policy document parsing model, a dynamic semantic rule construction model, and a prompt-based semantic reasoning model. The policy document parsing model performs semantic understanding and preference alignment on policy documents to obtain style-adapted documents. The dynamic semantic rule construction model matches Prompt templates to style-adapted documents and generates prompt instructions based on the Prompt templates. The prompt-based semantic reasoning model performs reasoning on policy documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results. Then, a large number of historical policy documents are acquired, preprocessed, and labeled to construct a dataset. The policy document parsing model, dynamic semantic rule construction model, and prompt-based semantic reasoning model are trained and deployed using this dataset. The deployed policy document parsing model, dynamic semantic rule construction model, and prompt-based semantic reasoning model are then used to automatically parse real-time policy documents. In other words, this involves constructing a system based on a large language... The system document parsing model first extracts document summaries and instruction corpora to achieve semantic consistency and preference alignment, generating style-adapted documents to address the issue of diverse expressions. Then, it dynamically constructs a model using semantic rules to dynamically identify rule types and business contexts. Multi-dimensional contextual variables are injected into the Prompt template via the Jinja2 template engine to generate prompts with integrated scenario parameters, giving the system context awareness. Finally, the prompt-based semantic reasoning model uses a Few-shot learning mechanism for intent completion and reasoning guidance, automating the handling of implicit logical dependencies and cross-article references. While improving semantic understanding accuracy, it utilizes a Prompt template reuse mechanism and an end-to-end automated process with containerized deployment to transform traditional manual rule reconstruction into model adaptive iteration, significantly reducing parsing and maintenance costs in high-frequency update scenarios. Ultimately, this greatly enhances the generalization and semantic understanding capabilities of system document parsing, significantly reducing parsing costs.
[0041] 2. By creating a semantic rule dynamic construction model, i.e., setting a semantic rule dynamic construction mechanism (SemanticRule Dynamic Composer, SRDC), it supports three-layer mapping and semantic fusion of rule type, element structure, and business context; a dynamic prompt template automatic generation mechanism based on the Jinja2 template engine realizes the cascading of prompts and conditional arrangement of semantic fragments and contextual variables in institutional documents; through the prompt instruction optimization selection mechanism of the Few-shot learning algorithm, i.e., constructing a sub-model optimization selection function based on semantic distance and redundancy penalty, it effectively improves inference accuracy; through the large model reinforcement training paradigm, it introduces a model preference comparison mechanism and a direct preference optimization strategy, effectively improving the strategy alignment capability.
[0042] 3. By integrating three major models—document parsing, dynamic semantic rule construction, and prompt-based semantic reasoning—efficient, intelligent, and automated processing of long-text document parsing is achieved. A dynamic prompt generation mechanism based on a large language model (Jinja2 template + multi-dimensional variable filling) adapts to diverse document styles and rule types. Combined with Few-shot learning, it enhances semantic completion and compliance reasoning capabilities, significantly improving the summarization accuracy and decision support effect of complex long texts. Simultaneously, containerized deployment and end-to-end training optimization (preference alignment mechanism + direct preference optimization strategy) ensure high robustness, low-cost operation and maintenance, and rapid response in real-time scenarios, comprehensively addressing the bottlenecks of traditional methods in document parsing, such as semantic bias, strong reliance on manual intervention, and low deployment efficiency. Attached Figure Description
[0043] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0044] Figure 1 This is a flowchart of a prompting reasoning method for semantic summarization of long texts according to the present invention.
[0045] Figure 2 This is a schematic diagram of the structure of a prompting reasoning system for semantic summarization of long texts according to the present invention. Detailed Implementation
[0046] The technical solution in this application embodiment follows the following general approach: First, a system document parsing model based on a large language model is constructed. This involves extracting document summaries and instruction corpora to achieve semantic uniformity and preference alignment, generating style-adaptive documents to address the issue of diverse expressions. Then, a model is dynamically constructed using semantic rules to dynamically identify rule types and business contexts. Multi-dimensional contextual variables are injected into the Prompt template via the Jinja2 template engine to generate prompts that integrate scenario parameters, enabling the system to possess context-aware capabilities. Finally, the Few-shot learning mechanism of the prompt-based semantic reasoning model is used for intent completion and reasoning guidance, automating the processing of implicit logical dependencies and cross-article references. This improves semantic understanding accuracy while utilizing the Prompt template reuse mechanism and containerized deployment of an end-to-end automated process, transforming traditional manual rule reconstruction into model adaptive iteration. This enhances the generalization ability and semantic understanding capability of system document parsing, while reducing parsing costs.
[0047] Please refer to Figures 1 to 2 As shown, a preferred embodiment of the suggestion reasoning method for semantic summarization of long texts according to the present invention includes the following steps:
[0048] Step S1: Create a policy document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model;
[0049] The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results.
[0050] The institutional document parsing model is built upon a large language model. Through summary generation, instruction corpus construction, efficient parameter fine-tuning, and DPO (Direct Preference Optimization) reinforcement training, it achieves semantic understanding and preference alignment of institutional language fragments. The dynamic semantic rule construction model consists of a multi-level mapping mechanism comprising rule type, element structure, and business context. Combined with the Jinja2 template engine, it generates dynamically adjustable prompts and instructions, realizing natural language rule construction. The prompt-based semantic reasoning model supports various execution scenarios for different types of institutional documents based on prompt instruction execution compliance analysis, semantic completion, and task analysis.
[0051] Step S2: Obtain a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively;
[0052] Step S3: Deploy the trained system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and automatically parse real-time system documents using the deployed system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
[0053] In step S1, the institutional document parsing model is constructed based on the Large Language Model (LLM) and is used to extract document summaries and instruction corpora from institutional documents. Based on the document summaries and instruction corpora, the institutional documents are semantically understood and preference aligned, and style-adapted documents are output.
[0054] The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples.
[0055] The semantic rule dynamic construction model is used to effectively integrate unstructured institutional language with structured business contexts to generate prompting and guiding instructions. Its core functions include:
[0056] 1. Multi-level mapping mechanism between rule type and template path: Design a three-level mapping system of "rule type → element structure → Prompt template path"; First, perform semantic segmentation and intent recognition on the content of the system (style-adapted document) to extract the rule type; then match its element structure (such as project number, amount range, etc.) according to the invoice attributes, and finally select the corresponding parameterized template path (Prompt template path) to realize the automatic mapping from semantic rules to templates.
[0057] 2. Parametric Prompt Template (Prompt Instruction) Construction: The Jinja2 template engine is used to construct the prompt instruction structure. Multi-dimensional contextual variables such as organizational hierarchy, invoice type, and expense purpose are embedded as semantic fill elements into the template, achieving dynamic integration of policy elements and business context. The template can adapt to different rule contexts and automatically adjust the instruction expression structure. An example is shown below:
[0058] {%if elememt1%}The rule1:{{elememt1}}{%else%}[lose elememt1]{%endif%}
[0059] {%if elememt2%}The rule2:{{elememt2}}{%else%}[lose elememt2]{%endif%}
[0060] {%if elememt3%}The rule3:{{elememt2}}to{{elememt3|default("[loseelememt3]")}}{%else%}[lose elememt2]{%endif%}
[0061] The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
[0062] To enhance the generalization ability and context adaptability in the task of parsing institutional documents, a Few-shot example selection algorithm (Few-shot learning algorithm) based on semantic relevance and diversity constraints is proposed. This algorithm takes institutional document fragments and invoice context as input, and automatically selects the most semantically relevant and content-diverse examples from the historical audit case library to form a Prompt, thereby achieving effective completion of rule intent and guidance of reasoning.
[0063] Let x be the input to the current inference task, representing a composite input consisting of a summary fragment of a policy document and the context of a ticket; let the dataset be H = {s1, s2, s3, ..., s}. n Each example contains a policy document, a ticket sample, and an audit conclusion (the policy document parsing result). The goal is to select K examples from the dataset to constitute few-shot PromptS(x)∈H, maximizing the model's accuracy and robustness in the inference task. The objective optimization function is:
[0064]
[0065] Where S*(x) represents the target set; Sim(x,s i ) represents the semantic similarity between the input and the example; Q(s) i ,s j) This indicates the degree of redundancy between examples. The calculation methods for similarity and redundancy are defined as follows:
[0066]
[0067] Q(s i ,s j )=exp(-λ·||f(s i )-f(s j )||1);
[0068] Here, f() represents the result after embedding through the SigLip model.
[0069] Step S2 specifically involves:
[0070] A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents.
[0071] The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
[0072] In step S2, during the training of the institutional document parsing model, model fine-tuning methods (such as LoRA, Adapter, etc.), inter-model preference comparison mechanisms, and direct preference optimization strategies are combined.
[0073] Based on the constructed instruction corpus, a lightweight customization of the large language model is carried out using an efficient parameter fine-tuning method to adapt to the language style and instruction form of institutional documents, thereby obtaining an initial student model with basic semantic parsing capabilities.
[0074] By introducing a pairwise preference modeling mechanism to construct a preference comparison sample set, and then applying the Direct Preference Optimization (DPO) strategy on this basis, the model's policy selection and response output are optimized through reinforcement learning, thereby improving its judgment ability and reasoning performance in complex institutional scenarios.
[0075] Step S3 specifically involves:
[0076] The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.
[0077] A preferred embodiment of the present invention provides a prompting and reasoning system for semantic summarization of long texts, comprising the following modules:
[0078] The reasoning engine creation module is used to create a system document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model;
[0079] The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results.
[0080] The institutional document parsing model is built upon a large language model. Through summary generation, instruction corpus construction, efficient parameter fine-tuning, and DPO (Direct Preference Optimization) reinforcement training, it achieves semantic understanding and preference alignment of institutional language fragments. The dynamic semantic rule construction model consists of a multi-level mapping mechanism comprising rule type, element structure, and business context. Combined with the Jinja2 template engine, it generates dynamically adjustable prompts and instructions, realizing natural language rule construction. The prompt-based semantic reasoning model supports various execution scenarios for different types of institutional documents based on prompt instruction execution compliance analysis, semantic completion, and task analysis.
[0081] The inference engine training module is used to acquire a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively.
[0082] The institutional document reasoning module is used to deploy the trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and to automatically parse real-time institutional documents through the deployed institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
[0083] In the inference engine creation module, the institutional document parsing model is built based on the Large Language Model (LLM) and is used to extract document summaries and instruction corpora from institutional documents. Based on the document summaries and instruction corpora, the institutional documents are semantically understood and preference aligned, and style-adapted documents are output.
[0084] The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples.
[0085] The semantic rule dynamic construction model is used to effectively integrate unstructured institutional language with structured business contexts to generate prompting and guiding instructions. Its core functions include:
[0086] 1. Multi-level mapping mechanism between rule type and template path: Design a three-level mapping system of "rule type → element structure → Prompt template path"; First, perform semantic segmentation and intent recognition on the content of the system (style-adapted document) to extract the rule type; then match its element structure (such as project number, amount range, etc.) according to the invoice attributes, and finally select the corresponding parameterized template path (Prompt template path) to realize the automatic mapping from semantic rules to templates.
[0087] 2. Parametric Prompt Template (Prompt Instruction) Construction: The Jinja2 template engine is used to construct the prompt instruction structure. Multi-dimensional contextual variables such as organizational hierarchy, invoice type, and expense purpose are embedded as semantic fill elements into the template, achieving dynamic integration of policy elements and business context. The template can adapt to different rule contexts and automatically adjust the instruction expression structure. An example is shown below:
[0088] {%if elememt1%}The rule1:{{elememt1}}{%else%}[lose elememt1]{%endif%}
[0089] {%if elememt2%}The rule2:{{elememt2}}{%else%}[lose elememt2]{%endif%}
[0090] {%if elememt3%}The rule3:{{elememt2}}to{{elememt3|default("[loseelememt3]")}}{%else%}[lose elememt2]{%endif%}
[0091] The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
[0092] To enhance the generalization ability and context adaptability in the task of parsing institutional documents, a Few-shot example selection algorithm (Few-shot learning algorithm) based on semantic relevance and diversity constraints is proposed. This algorithm takes institutional document fragments and invoice context as input, and automatically selects the most semantically relevant and content-diverse examples from the historical audit case library to form a Prompt, thereby achieving effective completion of rule intent and guidance of reasoning.
[0093] Let χ be the input to the current inference task, representing a composite input consisting of a summary fragment of a policy document and the context of a ticket; let the dataset be H = {s1, s2, s3, ..., s}. n Each example contains a policy document, a ticket sample, and an audit conclusion (the policy document parsing result). The goal is to select K examples from the dataset to constitute few-shot PromptS(x)∈H, maximizing the model's accuracy and robustness in the inference task. The objective optimization function is:
[0094]
[0095] Where S*(x) represents the target set; Sim(x,s i ) represents the semantic similarity between the input and the example; Q(s) i ,s j The similarity and redundancy levels are defined as follows:
[0096]
[0097] Q(s i ,s j )=exp(-λ·||f(s i )-f(s j )||1);
[0098] Here, f() represents the result after embedding through the SigLip model.
[0099] The inference engine training module is specifically used for:
[0100] A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents.
[0101] The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
[0102] In the inference engine training module, during the training of the institutional document parsing model, model fine-tuning methods (such as LoRA, Adapter, etc.), inter-model preference comparison mechanisms, and direct preference optimization strategies are combined.
[0103] Based on the constructed instruction corpus, a lightweight customization of the large language model is carried out using an efficient parameter fine-tuning method to adapt to the language style and instruction form of institutional documents, thereby obtaining an initial student model with basic semantic parsing capabilities.
[0104] By introducing a pairwise preference modeling mechanism to construct a preference comparison sample set, and then applying the Direct Preference Optimization (DPO) strategy on this basis, the model's policy selection and response output are optimized through reinforcement learning, thereby improving its judgment ability and reasoning performance in complex institutional scenarios.
[0105] The institutional document reasoning module is specifically used for:
[0106] The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.
[0107] Compared with traditional rule engines, this invention has the following advantages:
[0108]
[0109]
[0110] In summary, the advantages of this invention are:
[0111] 1. This involves creating a policy document parsing model, a dynamic semantic rule construction model, and a prompt-based semantic reasoning model. The policy document parsing model performs semantic understanding and preference alignment on policy documents to obtain style-adapted documents. The dynamic semantic rule construction model matches Prompt templates to style-adapted documents and generates prompt instructions based on the Prompt templates. The prompt-based semantic reasoning model performs reasoning on policy documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results. Then, a large number of historical policy documents are acquired, preprocessed, and labeled to construct a dataset. The policy document parsing model, dynamic semantic rule construction model, and prompt-based semantic reasoning model are trained and deployed using this dataset. The deployed policy document parsing model, dynamic semantic rule construction model, and prompt-based semantic reasoning model are then used to automatically parse real-time policy documents. In other words, this involves constructing a system based on a large language... The system document parsing model first extracts document summaries and instruction corpora to achieve semantic consistency and preference alignment, generating style-adapted documents to address the issue of diverse expressions. Then, it dynamically constructs a model using semantic rules to dynamically identify rule types and business contexts. Multi-dimensional contextual variables are injected into the Prompt template via the Jinja2 template engine to generate prompts with integrated scenario parameters, giving the system context awareness. Finally, the prompt-based semantic reasoning model uses a Few-shot learning mechanism for intent completion and reasoning guidance, automating the handling of implicit logical dependencies and cross-article references. While improving semantic understanding accuracy, it utilizes a Prompt template reuse mechanism and an end-to-end automated process with containerized deployment to transform traditional manual rule reconstruction into model adaptive iteration, significantly reducing parsing and maintenance costs in high-frequency update scenarios. Ultimately, this greatly enhances the generalization and semantic understanding capabilities of system document parsing, significantly reducing parsing costs.
[0112] 2. By creating a semantic rule dynamic construction model, i.e., setting a semantic rule dynamic construction mechanism (SemanticRule Dynamic Composer, SRDC), it supports three-layer mapping and semantic fusion of rule type, element structure, and business context; a dynamic prompt template automatic generation mechanism based on the Jinja2 template engine realizes the cascading of prompts and conditional arrangement of semantic fragments and contextual variables in institutional documents; through the prompt instruction optimization selection mechanism of the Few-shot learning algorithm, i.e., constructing a sub-model optimization selection function based on semantic distance and redundancy penalty, it effectively improves inference accuracy; through the large model reinforcement training paradigm, it introduces a model preference comparison mechanism and a direct preference optimization strategy, effectively improving the strategy alignment capability.
[0113] 3. By integrating three major models—document parsing, dynamic semantic rule construction, and prompt-based semantic reasoning—efficient, intelligent, and automated processing of long-text document parsing is achieved. A dynamic prompt generation mechanism based on a large language model (Jinja2 template + multi-dimensional variable filling) adapts to diverse document styles and rule types. Combined with Few-shot learning, it enhances semantic completion and compliance reasoning capabilities, significantly improving the summarization accuracy and decision support effect of complex long texts. Simultaneously, containerized deployment and end-to-end training optimization (preference alignment mechanism + direct preference optimization strategy) ensure high robustness, low-cost operation and maintenance, and rapid response in real-time scenarios, comprehensively addressing the bottlenecks of traditional methods in document parsing, such as semantic bias, strong reliance on manual intervention, and low deployment efficiency.
[0114] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A suggestion-based reasoning method for semantic summarization of long texts, characterized in that: Includes the following steps: Step S1: Create a policy document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model; The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results. Step S2: Obtain a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively; Step S3: Deploy the trained system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and automatically parse real-time system documents using the deployed system document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
2. The suggestion reasoning method for semantic summarization of long texts as described in claim 1, characterized in that: In step S1, the institutional document parsing model is built based on a large language model and is used to extract document summaries and instruction corpora from institutional documents. Based on the document summaries and instruction corpora, the institutional documents are semantically understood and preference aligned, and style-adapted documents are output. The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples. The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
3. The suggestion reasoning method for semantic summarization of long texts as described in claim 1, characterized in that: Step S2 specifically involves: A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents. The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
4. The suggestion reasoning method for semantic summarization of long texts as described in claim 1, characterized in that: In step S2, during the training of the institutional document parsing model, a model fine-tuning method, a preference comparison mechanism between models, and a direct preference optimization strategy are combined.
5. The suggestion reasoning method for semantic summarization of long texts as described in claim 1, characterized in that: Step S3 specifically involves: The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.
6. A prompting and reasoning system for semantic summarization of long texts, characterized in that: Includes the following modules: The reasoning engine creation module is used to create a system document parsing model, a semantic rule dynamic construction model, and a prompting semantic reasoning model; The institutional document parsing model is used to perform semantic understanding and preference alignment on institutional documents to obtain style-adapted documents; the semantic rule dynamic construction model is used to match the style-adapted documents with Jinja dynamically rendered Prompt templates, and generate prompt instructions based on the Prompt templates and Few-shot historical samples; the prompt-based semantic reasoning model is used to perform reasoning on institutional documents based on prompt instructions, including at least compliance analysis, semantic completion, and task analysis, and output the institutional document parsing results. The inference engine training module is used to acquire a large number of historical institutional documents, preprocess and annotate each of the historical institutional documents to construct a dataset, and train the institutional document parsing model, the semantic rule dynamic construction model and the prompting semantic reasoning model using the dataset respectively. The institutional document reasoning module is used to deploy the trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model, and to automatically parse real-time institutional documents through the deployed institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model.
7. A prompting reasoning system for semantic summarization of long texts as described in claim 6, characterized in that: In the inference engine creation module, the institutional document parsing model is built based on a large language model. It is used to extract document summaries and instruction corpora from institutional documents, perform semantic understanding and preference alignment on institutional documents based on the document summaries and instruction corpora, and output style-adapted documents. The semantic rule dynamic construction model is used to perform semantic segmentation and intent recognition on style-adapted documents, thereby extracting rule types, matching element structures based on rule types, matching Prompt template paths based on element structures, obtaining Jinja dynamically rendered Prompt templates based on Prompt template paths, extracting multi-dimensional context variables from policy documents as business contexts through the Jinja2 template engine and populating them into the Prompt template, and generating prompt instructions by combining Few-shot historical samples. The prompt-based semantic reasoning model is used to complete the rules and intentions of prompt instructions and guide reasoning through the Few-shot learning algorithm. Then, based on the prompt instructions, it performs reasoning on the policy document, including at least compliance analysis, semantic completion, and task analysis, and outputs the policy document parsing results.
8. A prompting reasoning system for semantic summarization of long texts as described in claim 6, characterized in that: The inference engine training module is specifically used for: A large number of historical institutional documents are acquired, and data cleaning and preprocessing are performed on each of the historical institutional documents. The preprocessed historical institutional documents are annotated with at least the following: document summary, instruction corpus, style-adapted document, rule type, element structure, Prompt template path, prompt instructions, and institutional document parsing results. A dataset is constructed based on the annotated historical institutional documents. The dataset is divided into a training set, a validation set, and a test set based on a preset ratio. The system document parsing model, the semantic rule dynamic construction model, and the prompting semantic reasoning model are trained, validated, and tested respectively using the training set, validation set, and test set.
9. A prompting reasoning system for semantic summarization of long texts as described in claim 6, characterized in that: In the inference engine training module, during the training of the institutional document parsing model, a model fine-tuning method, a preference comparison mechanism between models, and a direct preference optimization strategy are combined.
10. A prompting reasoning system for semantic summarization of long texts as described in claim 6, characterized in that: The institutional document reasoning module is specifically used for: The trained institutional document parsing model, semantic rule dynamic construction model, and prompt-based semantic reasoning model are deployed using containerization technology to obtain real-time institutional documents to be parsed. After preprocessing the real-time institutional documents, they are input into the deployed institutional document parsing model to obtain real-time style-adapted documents. The real-time style-adapted documents are then input into the deployed semantic rule dynamic construction model to obtain real-time prompt instructions. Finally, the real-time prompt instructions are input into the deployed prompt-based semantic reasoning model to obtain the real-time institutional document parsing result, thereby completing the automatic parsing of the real-time institutional documents.