A method for engineering a large model prompt word

By adopting a modular design and configuration inheritance mechanism, the problems of high maintenance costs and poor scalability in traditional prompt word engineering are solved, and efficient and accurate prompt word generation and compliance detection are achieved, which is suitable for professional scenarios such as financial contract review.

CN122433702APending Publication Date: 2026-07-21JIANGSU XINHE YIJIA INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGSU XINHE YIJIA INFORMATION TECH CO LTD
Filing Date
2026-04-29
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Traditional prompt word engineering lacks modular design, cannot handle complex logic and conditions, resulting in high maintenance costs, poor scalability, difficulty in quickly responding to business needs, and inability to maintain consistent prompt word styles and rules across different contract types.

Method used

It adopts a modular design and configuration inheritance mechanism. By loading organ-level configurations, determining inheritance relationships, recursively loading parent configuration files, merging configuration parameters, and generating the final configuration, it generates complete prompts by combining atomic-level components, molecular-level configurations, and individual-level components, supporting security and compliance detection.

Benefits of technology

It significantly reduces the maintenance cost of prompt words, shortens the time for new business integration, improves test coverage and accuracy, ensures that the generated prompt words comply with regulatory requirements, and supports multimodal data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122433702A_ABST
    Figure CN122433702A_ABST
Patent Text Reader

Abstract

The application relates to the field of artificial intelligence and discloses a method for engineering construction of a large model prompt word, which comprises the following steps: loading organ layer configuration and judging whether an inheritance relationship exists; if the inheritance relationship exists, recursively loading a parent configuration file and combining parameters to generate a final configuration; otherwise, directly combining current configuration parameters as the final configuration; initializing a prompt word container; judging whether an atomic layer component exists according to the final configuration; if the atomic layer component exists, loading the content of the atomic layer component one by one and storing the content into the prompt word container; otherwise, keeping the current prompt word container unchanged; judging whether a molecular layer configuration exists in the final configuration; if the molecular layer configuration exists, adding a field extraction rule title, then traversing each molecular field configuration, loading and rendering a corresponding molecular template and storing the template into the prompt word container; otherwise, keeping the current prompt word container unchanged; and generating a complete prompt word on the basis of all the content in the prompt word container after safety compliance detection. The application significantly reduces the maintenance cost of the prompt word.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence, and more specifically, to a method for constructing large model prompt words. Background Technology

[0002] With the rapid development of Large Language Model (LLM) technology, enterprises have an increasing demand for high-quality prompt words, especially in professional scenarios such as financial contract review and legal document analysis, where the quality of prompt words directly affects the accuracy and reliability of the model's output.

[0003] However, traditional prompt word engineering mainly adopts hard-coding to directly write the complete prompt words into the code or configuration file, or uses simple string replacement templates, or manually concatenates prompt words according to different scenarios. These methods generally lack modular design, cannot handle complex logic and conditions, and lack inheritance mechanisms, resulting in each prompt word being independent of each other, and unable to share and reuse common components.

[0004] The resulting drawbacks are quite prominent: modifying prompts requires a complete overhaul of the entire file, resulting in high maintenance costs and a high risk of introducing errors; adding new contract types requires writing prompts from scratch, leading to poor scalability; it is difficult to maintain consistency in the style and rules of prompts for different contract types; furthermore, due to the difficulty in performing unit testing and integration testing on prompts, the manual writing and modification cycle is long, making it impossible to quickly respond to business needs and severely restricting the application effect of large language models in professional scenarios.

[0005] No effective solutions have yet been proposed to address the problems in the relevant technologies. Summary of the Invention

[0006] To address the problems in related technologies, this invention proposes a method for constructing large-scale prompt word engineering, thereby overcoming the aforementioned technical problems existing in existing related technologies.

[0007] Therefore, the specific technical solution adopted by the present invention is as follows: According to one aspect of the present invention, a method for constructing a large model of prompt words is provided, the method comprising: S1. Load the organ layer configuration and determine whether there is an inheritance relationship in the organ layer configuration; if there is an inheritance relationship, recursively load the parent configuration file and merge all configuration parameters to generate the final configuration; if there is no inheritance relationship, merge the current configuration parameters as the final configuration. S2. Initialize the prompt container used to store the content of each component loaded subsequently; S3. Based on the final configuration, determine whether atomic layer components exist; if atomic layer components exist, load the content of each atomic layer component one by one and store the loaded atomic layer component content into the prompt word container; if atomic layer components do not exist, keep the current prompt word container unchanged. S4. Determine if a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, first add the field extraction rule title, then iterate through each molecular field configuration, load the corresponding molecular template, render the molecular template, and store the rendering result in the prompt word container. If a molecular layer configuration does not exist, keep the current prompt word container unchanged. S5. Based on the content of all components in the prompt word container, and after security and compliance testing, generate a complete prompt word at the individual level.

[0008] Furthermore, the organ-level configuration defines how atomic-level components and molecular-level configurations can be combined, and supports a configuration inheritance mechanism to reduce redundant configurations. The atomic layer component is used to provide basic functions, including role definition, skill extraction, workflow, and constraints. The molecular layer configuration is used to implement the extraction logic and rules for specific fields based on the atomic layer components; The individual layer is used to combine all the component contents stored in the prompt word container to generate the final complete prompt word.

[0009] Furthermore, the organ-level configuration is loaded, and it is determined whether there is an inheritance relationship in the organ-level configuration. If an inheritance relationship exists, the parent configuration file is recursively loaded, and all configuration parameters are merged to generate the final configuration. If no inheritance relationship exists, the current configuration parameters are merged as the final configuration, including the following steps: S11. Read the current organ layer configuration and check if the organ layer configuration exists. If the organ layer configuration does not exist, the output file will not exist. If the organ layer configuration exists, parse the YAML configuration content of the organ layer configuration to obtain the current configuration. S12. Check if the current configuration contains the `extends` field. If it does not contain the `extends` field, use the current configuration as the initial merge configuration. If it contains the `extends` field, recursively load the merge result of the parent configuration file and configure a copy according to the parent configuration file path specified by the `extends` field, and use it as the initial merge configuration. S13. Check if the current configuration contains the components field; if it does not contain the components field, use the initial merge configuration as the final configuration and return it; if it contains the components field, further check if the components field contains the molecules field. S14. If the components do not contain the molecules field, the initial merged configuration is used as the final configuration and returned. If the components contain the molecules field, each molecular field configuration in the current configuration is traversed and molecular field merging is performed. The processing result is updated to the initial merged configuration, and the merged configuration is finally obtained as the final configuration.

[0010] Furthermore, the molecular field merging process includes the following steps: Iterate through each molecular field configuration in the molecules field under the currently configured components field; For each molecule field configuration encountered during the traversal, determine whether the molecule field already exists in the initial merge configuration; If the molecule field does not exist in the initial merge configuration, then add the molecule field configuration to the initial merge configuration; If the molecule field already exists in the initial merge configuration, then it is further determined whether the molecule field configuration contains the params field; If the params field is included, the params parameter in the sub-field configuration will be merged into the existing field configuration with the same name in the initial merge configuration, and the params parameter of the sub-configuration will override the parameter with the same name in the parent configuration. If the params field is not included, the original configuration of this subfield in the initial merge configuration will remain unchanged.

[0011] Furthermore, rendering the molecular template includes the following steps: Receive the molecular name and parameter list of the molecular template; Process the molecule names, remove the template file extensions, and construct the template file path based on the processed molecule names; Check if the template file corresponding to the template file path exists; if the template file does not exist, return an error message; if the template file exists, read the complete content of the template file and use it as the template content to be rendered. Check if the parameter list is empty; if the parameter list is empty, return the original content of the template file as the rendering result; if the parameter list is not empty, replace the template content to be rendered and return the replaced template content as the rendering result.

[0012] Furthermore, the replacement process includes the following steps: Iterate through each parameter in the parameter list; For each parameter encountered, find the placeholder corresponding to the parameter name in the template content to be rendered, and replace the placeholder with the actual value of the parameter.

[0013] Furthermore, based on the content of all components in the prompt word container, and after security and compliance testing, the complete prompt word is generated at the individual level, including the following steps: S51. At the individual level, combine all the component contents stored in the prompt word container to generate the prompt word to be detected; S52. Perform security and compliance checks on the prompts to be detected, including personal identity information desensitization and legal compliance checks. S53. If the security compliance test passes, the detected prompt word will be returned as the complete prompt word at the individual level; if the security compliance test fails, an error message will be returned.

[0014] Furthermore, the anonymization of personally identifiable information includes: Regular expression matching is performed on the prompts to be detected to obtain personal identification information; The personal identification information is replaced, encrypted, or obscured by at least one of the following methods:

[0015] Further legal compliance checks include: Based on relevant laws, regulations, rules, and industry-specific compliance standards, content checks are performed on the keywords to be detected; these content checks include checks on prohibited content, sensitive topics, and data usage. The compliance risk level is assessed based on the content inspection results, a compliance inspection report is generated, and risk mitigation recommendations are provided.

[0016] According to another aspect of the present invention, a system for constructing large model prompt words is provided, the system comprising: a configuration loading module, a container initialization module, an atom loading module, a molecular rendering module, and a secure generation module; The configuration loading module is used to load organ-level configurations and determine whether there is an inheritance relationship in the organ-level configuration. If there is an inheritance relationship, the parent configuration file is loaded recursively, and all configuration parameters are merged to generate the final configuration. If there is no inheritance relationship, the current configuration parameters are merged as the final configuration. The container initialization module is used to initialize the prompt word container that stores the content of each component loaded subsequently; The atomic loading module is used to determine whether atomic layer components exist based on the final configuration. If atomic layer components exist, the content of each atomic layer component is loaded one by one, and the loaded atomic layer component content is stored in the prompt word container. If atomic layer components do not exist, the current prompt word container remains unchanged. The molecular rendering module is used to determine whether a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, the field extraction rule title is added first, then each molecular field configuration is traversed, the corresponding molecular template is loaded, the molecular template is rendered, and the rendering result is stored in the prompt word container. If no molecular layer configuration exists, the current prompt word container remains unchanged. The security generation module is used to generate complete prompts at the individual level by combining all the component contents in the prompt word container, after passing security and compliance checks.

[0017] The beneficial effects of this invention are as follows: Through modular design and configuration inheritance mechanism, this invention significantly reduces the maintenance cost of prompt words, decreasing maintenance time by approximately 78%. When adding new contract types, only the basic configuration needs to be inherited and necessary fields covered, shortening the new business access time by 83%. Shared atomic and molecular components ensure a high degree of consistency in the style and rules of prompt words for different contract types, while facilitating unit testing and integration testing, increasing test coverage by 163%. The combination of dynamic assembly and configuration inheritance greatly accelerates the speed of prompt word updates, reducing the error rate by 72%. Furthermore, built-in functions for desensitizing personal identity information and checking legal compliance ensure that the generated prompt words meet regulatory requirements and support multimodal data processing such as text and images, effectively guaranteeing accuracy in complex scenarios. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of a method for constructing a large model prompt word project according to an embodiment of the present invention; Figure 2 This is a flowchart of the configuration inheritance process in a method for constructing a large model prompt word project according to an embodiment of the present invention; Figure 3 This is a flowchart of template rendering in a method for constructing a large model prompt word project according to an embodiment of the present invention; Figure 4 This is an architecture diagram of a system for constructing a large model prompt word project according to an embodiment of the present invention. Detailed Implementation

[0020] To further illustrate the various embodiments, the present invention provides accompanying drawings, which are part of the disclosure of the present invention. These drawings are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of the present invention. The components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components.

[0021] According to an embodiment of the present invention, a method for constructing a large model prompt word project is provided.

[0022] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments, such as... Figures 1-4 As shown, a method for constructing a large model prompt word project according to an embodiment of the present invention includes: S1. Load the organ layer configuration and determine whether there is an inheritance relationship in the organ layer configuration; if there is an inheritance relationship, recursively load the parent configuration file and merge all configuration parameters to generate the final configuration; if there is no inheritance relationship, merge the current configuration parameters as the final configuration. In this optional embodiment, the organ-level configuration is loaded, and it is determined whether there is an inheritance relationship in the organ-level configuration. If there is an inheritance relationship, the parent configuration file is recursively loaded, and all configuration parameters are merged to generate the final configuration. If there is no inheritance relationship, the current configuration parameters are merged as the final configuration, including the following steps: S11. Read the current organ layer configuration and check if the organ layer configuration exists. If the organ layer configuration does not exist, the output file will not exist. If the organ layer configuration exists, parse the YAML configuration content of the organ layer configuration to obtain the current configuration. S12. Check if the current configuration contains the `extends` field. If it does not contain the `extends` field, use the current configuration as the initial merge configuration. If it contains the `extends` field, recursively load the merge result of the parent configuration file and configure a copy according to the parent configuration file path specified by the `extends` field, and use it as the initial merge configuration. S13. Check if the current configuration contains the components field; if it does not contain the components field, use the initial merge configuration as the final configuration and return it; if it contains the components field, further check if the components field contains the molecules field. S14. If the components do not contain the molecules field, the initial merged configuration is used as the final configuration and returned. If the components contain the molecules field, each molecular field configuration in the current configuration is traversed and molecular field merging is performed. The processing result is updated to the initial merged configuration, and the merged configuration is finally obtained as the final configuration.

[0023] In this optional embodiment, the molecular field merging process includes the following steps: Iterate through each molecular field configuration in the molecules field under the currently configured components field; For each molecule field configuration encountered during the traversal, determine whether the molecule field already exists in the initial merge configuration; If the molecule field does not exist in the initial merge configuration, then add the molecule field configuration to the initial merge configuration; If the molecule field already exists in the initial merge configuration, then it is further determined whether the molecule field configuration contains the params field; If the params field is included, the params parameter in the sub-field configuration will be merged into the existing field configuration with the same name in the initial merge configuration, and the params parameter of the sub-configuration will override the parameter with the same name in the parent configuration. If the params field is not included, the original configuration of this subfield in the initial merge configuration will remain unchanged.

[0024] It needs to be explained that, for example Figure 2 As shown, the configuration inheritance process is as follows: 1. Start loading: Initiate the configuration loading process and prepare to process organ configuration files.

[0025] 2. File Check: Read the specified organ configuration file and check if the file exists; if the file does not exist, throw a file not found exception; if the file exists, parse the YAML configuration content.

[0026] 3. Inheritance handling: Check if there is an "extends" field in the configuration (indicating inheritance relationship); if there is no "extends" field, return the current configuration directly; if there is an "extends" field, recursively load the parent configuration file and create a copy of the parent configuration as the basis for merging the configuration.

[0027] 4. Configuration Merge: Check if the current configuration has a components field; if not, return the merged configuration directly; if there is a components field, check if there is a molecules field; if not, return the merged configuration directly; if there is a molecules field, iterate through the configuration of each molecule field.

[0028] 5. Field processing: For each subfield, check if it already exists in the merge configuration; if the field does not exist, add the new field configuration to the merge configuration directly; if the field already exists, check if there is a params field; if there is a params field, merge the params parameters (sub-configuration overrides parent configuration); repeat the processing for all subfields.

[0029] 6. Return result: The final merged configuration is returned, and the process ends.

[0030] Configuration inheritance is implemented as follows: "# Configure inheritance handling def load_organ_config(self, organ_name): # 1. Load the configuration file config_path = os.path.join(self.organs_path, f"{organ_name}.yaml") if not os.path.exists(config_path): raise FileNotFoundError(f"Organ configuration does not exist: {config_path}") with open(config_path, 'r', encoding='utf-8') as f: config = yaml.safe_load(f) # 2. Handle inheritance relationships if config.get('extends'): base_config = self.load_organ_config(config['extends']) # 3. Merge the configurations merged_config = base_config.copy() # 4. Merge components if 'components' in config: # Handle the merging of molecules and atoms if'molecules' in config['components']: if'molecules' not in merged_config['components']: merged_config['components']['molecules'] = {} for field, field_config in config['components']['molecules'].items(): if field in merged_config['components']['molecules']: # Merge params if 'params' in field_config: if 'params' not in merged_config['components']['molecules'][field]: merged_config['components']['molecules'][field]['params'] = {} merged_config['components']['molecules'][field]['params'].update(field_config['params'])else:merged_config['components']['molecules'][field]= field_configreturnmerged_configreturn config"..

[0031] S2. Initialize the prompt container used to store the content of each component loaded subsequently; S3. Based on the final configuration, determine whether atomic layer components exist; if atomic layer components exist, load the content of each atomic layer component one by one and store the loaded atomic layer component content into the prompt word container; if atomic layer components do not exist, keep the current prompt word container unchanged. S4. Determine if a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, first add the field extraction rule title, then iterate through each molecular field configuration, load the corresponding molecular template, render the molecular template, and store the rendering result in the prompt word container. If a molecular layer configuration does not exist, keep the current prompt word container unchanged. In this optional embodiment, rendering the molecular template includes the following steps: Receive the molecular name and parameter list of the molecular template; Process the molecule names, remove the template file extensions, and construct the template file path based on the processed molecule names; Check if the template file corresponding to the template file path exists; if the template file does not exist, return an error message; if the template file exists, read the complete content of the template file and use it as the template content to be rendered. Check if the parameter list is empty; if the parameter list is empty, return the original content of the template file as the rendering result; if the parameter list is not empty, replace the template content to be rendered and return the replaced template content as the rendering result.

[0032] In this optional embodiment, the replacement process includes the following steps: Iterate through each parameter in the parameter list; For each parameter encountered, find the placeholder corresponding to the parameter name in the template content to be rendered, and replace the placeholder with the actual value of the parameter.

[0033] It needs to be explained that, for example Figure 3 As shown, the template rendering process is as follows: 1. Start rendering: Start the template rendering process and prepare to process the molecular template.

[0034] 2. Input processing: Receive molecule name and parameters, process molecule name, remove any existing .j2 extensions, and construct template file path.

[0035] 3. File Check: Check if the template file exists; if the file does not exist, return an error message; if the file exists, read the contents of the template file.

[0036] 4. Parameter Processing: Check if there are any parameters that need to be processed; if there are no parameters, return the original template content directly; if there are parameters, iterate through the parameter list. 5. Variable substitution: Build a placeholder for each parameter (such as {{param_name}}) and replace the corresponding variable in the template content, repeating the process for all parameters.

[0037] 6. Return result: Returns the rendered template content, and the process ends.

[0038] The template rendering is implemented as follows: # Molecular layer template rendering def render_molecule(self, molecule_name, params=None): if params is None: params = {} # 1. Ensure the .j2 extension is not included if molecule_name.endswith('.j2'): molecule_name = molecule_name[:-3] # 2. Load the template file molecule_path = os.path.join(self.molecules_path, f"{molecule_name}.j2") if not os.path.exists(molecule_path): return f"[Molecular template does not exist: {molecule_path}]" try:with open(molecule_path, 'r', encoding='utf-8') as f: template_content =f.read() # 3. Replace the template variable for key, value in params.items(): placeholder = "{{ " + key + "}}" template_content = template_content.replace(placeholder,str(value)) return template_content except Exception as e:return f"[Error rendering molecular template: {str(e)}]"".

[0039] The complete example of the rendered prompt (generated_abc_bank_prompt.txt) is as follows: "{# Atomic layer template: role definition (role_definition.j2) # Function: Define the AI ​​assistant's persona and basic identity, establishing professional authority. # Use case: The beginning of all contract type prompts # Scope of impact: Affects the tone and professionalism of the entire prompt. # Edit history: #- 202X-07-15: Initial version, establishing the persona of a contract review expert. #- 202X-07-20: Added a description of 30 years of experience to enhance its authority. # Important Notes: #- The change will affect the beginning of the prompt word for all contract types Maintain a professional, concise, and authoritative style. #} You are a contract document review expert with 30 years of experience. Skilled at analyzing and retrieving contract text information to extract key information.

[0040] They are adept at summarizing and extracting key information from contract texts and finding information based on extracted keywords.

[0041] {# Atomic Layer Template: Skill 1 - Text Reading (skill_reading.j2)} # Purpose: To define the basic reading ability of AI, emphasizing careful reading of contract texts. # Use case: The first skill in the skill list # Scope of impact: All scenarios requiring text reading # Edit history: #- 202X-07-15: Initial version, establishing basic reading skills #- 202X-07-18: Added emphasis to "Read in detail" to ensure accuracy. # Important Notes: #- Modifications will affect skill descriptions for all contract types # Keep it concise and clear, avoid redundant descriptions #} ### Skill 1: Contract Text Reading - The ability to read the contract text in detail.

[0042] {# Atomic Layer Template: Skill 2 - Key Information Extraction (skill_extraction.j2)} # Purpose: Define the specialized skill for AI to extract key contract information # Use case: The second skill in the skill list, used to extract key fields. # Scope of impact: All scenarios requiring the extraction of key contract information # Edit history: #- 202X-07-15: Initial version, establishing key information extraction capabilities #- 202X-07-20: Refine the description, emphasizing the accuracy of "relevance of key fields". # Important Notes: #- The modification will affect the information extraction logic for all contract types. # Maintain professionalism and avoid overly broad descriptions. #} ### Skill 2: Extracting Key Information from Contract Text - Identify information related to key fields in the contract text.

[0043] # Atomic layer template: Workflow (workflow.j2) # Purpose: To define a standardized workflow for AI to process contract text. # Use Case: Workflow Description for All Contract Types # Scope of impact: Affects the order and logic of AI in processing contracts. # Edit history: #- 202X-07-15: Initial version, establishing a three-step workflow #- 202X-08-12: Optimized the description order to ensure clear logic. # Important Notes: #- The modification will affect the processing flow for all contract types. # - Keep it simple with these three steps: Read → Extract → Format #} ## Workflow: - Read the contract text carefully - Extract key information based on keywords Returns standard JSON format. # Atomic layer template: Constraint rules (constraints.j2) # Purpose: Define the constraints that AI must follow when extracting information. # Use Case: Description of constraint rules for all contract types # Scope of impact: Affects the standardization and consistency of AI output formats # Edit history: # - 202X-8-15: Initial version, establishing three basic constraints, refining constraint descriptions to ensure clarity and enforceability. # Important Notes: #- The modification will affect the output specifications for all contract types #- Maintain the clarity and enforceability of constraints #} ## Constraints - 1. Leave "-" for fields not mentioned. - 2. Disable XML / formatting tags - 3. Avoid divergent answers. # Atomic layer template: Example output (example_output.j2) # Purpose: Provides a standard JSON output format example to ensure output consistency. # Use case: Output format specifications for all contract types # Scope of impact: Affects the standardization of the final output JSON structure # Edit history: #- 202X-07-15: Initial version, establishing a 7-field standard output format #- 202X-07-28: Optimized sample data, using more realistic field values. # Important Notes: #- This modification will affect the output format of all contract types. # Maintain consistency in field order and format #} - Examples are as follows: { "loan_contract_number": "XXXX1234", "loan_contract_name": "XX Loan Contract", "loan_contract_amount": "200000", "loan_start_time": "2000-01-01", "loan_end_time": "2001-01-01", "loan_time_period": "-", "revolving_credit": "N" } ## Field Extraction Rules: ### loan_contract_number {# Molecular layer template: Contract number extraction rules (contract_number.j2)} # Purpose: Define the detailed extraction rules and steps for the contract number field. # Use case: Extracting data from the loan_contract_number field # Scope of impact: All contract types that require extracting contract numbers # Configuration parameters: #- strict_mode: Whether to enable strict mode and prevent extraction from headers and footers #- allow_name_search: Whether to allow searching for numbers near contract names # Edit history: #- 202X-07-10: Initial version, establishing basic number extraction logic #- 202X-07-25: Added illusion handling and multimodal error correction. #- 202X-08-01: Optimized number verification logic and added consistency checks. # Important Notes: #- This modification will affect the accuracy of number extraction for all contract types. # Maintain the clarity and enforceability of the rules #} ### loan_contract_number [Field Explanation: Please follow these steps to extract the contract number for this contract:] {% if strict_mode is defined and strict_mode %} 1. **Location Anchor Points**: - **Prohibit the extraction of similar numbering information from headers / footers.** - **Extracting page numbers and dates with identifiers such as 00001 and 202X is prohibited.** - First, locate the content in the main text that explicitly states "contract number" or "number". {% else %} 1. **Location Anchor Points**: - **Prohibit the extraction of similar numbering information from headers / footers.** - **Extracting page numbers and dates with identifiers such as 00001 and 202X is prohibited.** First, locate the text containing explicit phrases like "contract number" or "number". Then, look for similar phrases around the contract title. {% endif %} 2. **Determine the correct number:** - Because the text is provided in a multimodal manner, visual hallucinations may occur. - Multimodal processing will add the contract number before the suspected serial number. - If text resembling the contract number is found both before and after the contract number and contract name: First, verify that the two numbers match. - If they do not match, find a number consisting of multiple forms such as lender's abbreviation + numbers + date + sign as the contract number. {% if strict_mode is defined and strict_mode %} Page numbers like 001 and 002 are not contract numbers. {% endif %} 3. **Extract specific information**: - **Contract Number**: Search the text for paragraphs containing "Contract Number" or "number". - Extract the specific content immediately following it as the main contract number. - Extract the complete contract number, not just the digits. - Pay attention to the continuity of the numbers; extract the consecutive numbers between two newline characters, and do not omit any. {% if allow_name_search is defined and allow_name_search %} - You can find the number before or after the contract name text. {% endif %} - Note: Even if similar numbering information appears in the header or footer, the content in these locations should be ignored. ### loan_contract_name {# Molecular layer template: Contract name extraction rules (contract_name.j2)} # Purpose: Define detailed extraction rules and cleaning logic for the contract name field. # Use case: Extracting data from the loan_contract_name field # Scope of impact: All contract types for which contract names need to be extracted # Configuration parameters: #- search_header: Whether to search in the text header #- strict_extract: Whether to strictly extract names containing "loan agreement" #- clean_space: Whether to remove spaces in the name #- strict_end: Whether to require it to end with "contract" # Edit history: # - 202X-08-05: Initial version, established basic name extraction logic, added regular expression cleaning rules, and added strict extraction mode. # Important Notes: #- This modification will affect the accuracy of name extraction for all contract types. #- Cleaning rules need to balance accuracy and completeness #} ### loan_contract_name [Field Explanation: Please follow these steps to extract the contract name:] 1. {% if search_header is defined and search_header %} locates the beginning of the text, generally at the beginning of the text, or near the contract number / number. {% else %} locates the full name in the first page of the contract or the title clause. {% endif %} {% if strict_extract is defined and strict_extract %} First, check if the text contains the "XXX Loan Contract" text. If it appears, extract it; do not miss any! - The presence of the XXX loan contract can be considered as the contract number. {% endif %} 2. Extracting the name to the contract field will not continue extracting the contract name. - The extracted contract name must be complete. - Name characters without obvious spaces should be extracted together. - Extracted strictly according to the original text content - Pay special attention to extracting symbols such as "", "", and "—" in the name; do not omit them. - Extract strictly according to the original text content; do not extract as '...' 3. Perform the cleaning process, strictly following the requirements for extraction. Only delete the characters before and after the name; do not delete characters within the name itself. a. Use the regular expression `^[^\u4e00-\u9fa5]+` to delete non-Chinese characters (including letters and numbers) at the beginning of a string. b. Use the regular expression `[^\u4e00-\u9fa5《》·]+$` to delete non-Chinese characters at the end. {% if clean_space is defined and clean_space %} c. Remove spaces from the name {% endif %} {% if strict_end is defined and strict_end %} 4. Generally, it ends with "XXX Contract," be careful not to omit any details. - If no results are found, scan the first few sentences of the text again. - Check if the text ends with "XXX Loan Agreement" and contains newline characters (\n) before and after it. - If it exists, extract it. {% endif %}] ### loan_contract_amount {# Molecular layer template: Loan amount extraction rules (loan_amount.j2)} # Purpose: Defines the detailed extraction rules and amount conversion logic for the loan amount field. # Use case: Extracting data from the loan_contract_amount field # Scope of impact: All contract types that require loan withdrawals # Configuration parameters: #- priority_rule: Priority rule, specifies the priority of a particular monetary field. # Edit history: #- 202X-01-08: Initial version, establishing basic amount extraction logic #- 202X-07-20: Added Chinese capitalized amount conversion function #- 202X-02-03: Optimized amount verification and consistency checks # Important Notes: #- This modification will affect the accuracy of amount extraction for all contract types. #- The amount conversion logic needs to accurately handle Chinese capitalized amounts. #} loan_contract_amount [Field Explanation: Please extract the loan amount according to the following steps: 1. **Locate the anchor point**: Scan the clauses containing "borrow RMB", "borrowing amount in RMB", "credit limit" + "amount in both Chinese and Arabic numerals side by side" {% if priority_rule is defined %} - If the principal of the claim exists at the same time, then take the principal of the claim as the borrowing amount {% endif %} 2. **Extract the pair of Chinese and Arabic numerals**: Such as "(in Chinese) Two million yuan (in Arabic numerals) 2,000,000.00" 3. **Convert the Chinese amount**: - Only retain legal amount characters: "Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Hundred, Thousand, Ten Thousand, Hundred Million" - Analyze each character one by one in the order of Chinese amount expression (from high to low) - Digital mapping table: - Zero = 0, One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9 - Unit mapping table: - Ten = 10, Hundred = 100, Thousand = 1000, Ten Thousand = 10000, Hundred Million = 100000000 - Analysis rules: - When encountering "Ten", if the previous digit is "One", it is regarded as "10" - When encountering "One Hundred Thousand", it is regarded as 10 × 10000 = 100000 - When encountering "One Million", it is regarded as 100 × 10000 = 1000000 - Example: - "One Hundred Thousand yuan" →### loan_start_time [Field explanation: {% if field_type == 'start' %} Start date of the loan agreement {% else %} End date of the loan agreement {% endif %}.]

[0044] The numerical format is yyyy-mm-dd. If no specific date is specified, it will be extracted in the yyyy-mm format.

[0045] Extract strictly from the original text; do not add your own interpretations.

[0046] If the extracted value is from December 2012, then the time is 2012-12.

[0047] Do not add the date yourself.

[0048] {% if strict_date is defined and strict_date %} If a date is present, such as December 2, 2012, then the time would be 2012-12-02. Do not omit this.

[0049] {% endif %} Extraction steps: 1. First, locate the dates following the "Term" and "Loan Date" fields in the text. 2. If no keywords are found, locate the time in the text that may be the start date {% if field_type == 'start' %} {% else %} {% endif %}. {% if use_contract_date is defined and use_contract_date %} 3. If none of the above are found, then search the text for a phrase similar to "the loan term begins from the date the contract is signed". - If it exists, the loan_start_time field will be the contract signing date and time. 4. If the loan term is from the date of contract signing, check if the keywords "signing date" or "signing date" exist in the search text. - If the search result for the signing date is empty or the time is incomplete, continue searching downwards. - Until the complete contract date is retrieved or the end of the text is retrieved. - The signing date is usually found at the end of the contract text. Only if the signing date is not found at the end should you place it elsewhere. {% endif %} {% if no_self_calc is defined and no_self_calc %} 5. Unauthorized actions are prohibited. If the loan term is not explicitly stated in the contract, it shall be calculated from the date of signing the contract; therefore, the signing date cannot be used as the contract start date. {% endif %}] ### loan_end_time [Field explanation: {% if field_type == 'start' %} Start date of the loan agreement {% else %} End date of the loan agreement {% endif %}.]

[0050] The numerical format is yyyy-mm-dd. If no specific date is specified, it will be extracted in the yyyy-mm format.

[0051] Extract strictly from the original text; do not add your own interpretations.

[0052] If the extracted value is from December 2012, then the time is 2012-12.

[0053] Do not add the date yourself.

[0054] {% if strict_date is defined and strict_date %} If a date is present, such as December 2, 2012, then the time would be 2012-12-02. Do not omit this.

[0055] {% endif %} Extraction steps: 1. First, locate the dates following the "Term" and "Loan Date" fields in the text. 2. If no keywords are found, locate the time in the text that may be the start date {% if field_type == 'start' %} {% else %} {% endif %}. {% if use_contract_date is defined and use_contract_date %} 3. If none of the above are found, then search the text for a phrase similar to "the loan term begins from the date the contract is signed". - If it exists, the loan_start_time field will be the contract signing date and time. 4. If the loan term is from the date of contract signing, check if the keywords "signing date" or "signing date" exist in the search text. - If the search result for the signing date is empty or the time is incomplete, continue searching downwards. - Until the complete contract date is retrieved or the end of the text is retrieved. - The signing date is usually found at the end of the contract text. Only if the signing date is not found at the end should you place it elsewhere. {% endif %} {% if no_self_calc is defined and no_self_calc %} 5. Unauthorized actions are prohibited. If the loan term is not explicitly stated in the contract, it shall be calculated from the date of signing the contract; therefore, the signing date cannot be used as the contract start date. {% endif %}] ### loan_time_period [Field Explanation: Find the loan duration in the time clause of the contract, usually marked as "Term", "Loan Period", "Validity Period" or "Credit Limit Usage Period".]

[0056] The extracted data type is numbers.

[0057] {% if multi_rule is defined %} When the following conditions are simultaneously met: effective date of credit limit, maximum loan term, and credit limit duration, the credit limit duration shall be used as the loan duration. {% endif %} For example: 12 months, output: 12 Note: Only extract what is already in the contract; do not perform the calculations yourself. {% if day_conversion is defined and day_conversion %} If the loan term is found to be in days, then convert the days to months: - Loan term: 365 / 366 days, then the term is 12. Similarly, if the number of days doubles, the time limit also doubles. {% endif %}] ### revolving_credit [Field Explanation: Whether (Y / N) is a revolving credit:] {% if special_rule is defined %} Note: {{ special_rule}} {% endif %} {% if clause_priority is defined %} When multiple revolving credit criteria exist, the second criterion should be selected. {% endif %} Step 1: Scan the contract name: 1. Directly determine the name characteristics of revolving credit: containing the following keywords (highest priority): revolving, maximum amount / credit limit, credit limit + revolving related. 2. Directly identify the naming characteristics of non-revolving letters: containing the following keywords: single / one-time, non-revolving / fixed term. Step Two: Carefully Read the Key Terms (Core Judgments): 1. Positive keywords (if any one of these criteria is met, it is considered a loop): Credit line type: Revolving credit, revolving limit, revolving disbursement, revolving working capital loan Loan terms: Flexible borrowing and repayment, self-service and revolving, multiple withdrawals, repayment on a per-transaction basis, no contract signed for each transaction. Credit limit mechanism: Revolving credit within the maximum principal balance; repaid principal can be redisbursed; revolving use within the credit limit. 2. Reverse keywords (meeting any one of these criteria determines "not a loop"): Explicitly deny revolving credit: Non-revolving use, non-revolving withdrawal, one-time limit, no revolving, non-revolving credit. Fixed withdrawal restrictions: One-time withdrawal of the entire loan amount, withdrawals in installments by date (no credit limit restoration), single loan agreement. Step 3: Output field values: - If the contract is determined to be a revolving credit line, this field will output: Y - If the contract is determined to be non-revolving credit, then this field will output: N] - Examples are as follows: # Atomic layer template: Example output (example_output.j2) # Purpose: Provides a standard JSON output format example to ensure output consistency. # Use case: Output format specifications for all contract types # Scope of impact: Affects the standardization of the final output JSON structure # Edit history: #- 202X-07-15: Initial version, establishing a 7-field standard output format #- 202X-07-28: Optimized sample data, using more realistic field values. # Important Notes: #- This modification will affect the output format of all contract types. # Maintain consistency in field order and format #} - Examples are as follows: { "loan_contract_number": "XXXX1234", "loan_contract_name": "XX Loan Contract", "loan_contract_amount": "200000", "loan_start_time": "2000-01-01", "loan_end_time": "2001-01-01", "loan_time_period": "-", "revolving_credit": "N" }".

[0058] S5. Based on the content of all components in the prompt word container, and after security and compliance testing, generate a complete prompt word at the individual level.

[0059] In this optional embodiment, based on the content of all components in the prompt word container, and after security and compliance checks, generating a complete prompt word at the individual level includes the following steps: S51. At the individual level, combine all the component contents stored in the prompt word container to generate the prompt word to be detected; S52. Perform security and compliance checks on the prompts to be detected, including personal identity information desensitization and legal compliance checks. S53. If the security compliance test passes, the detected prompt word will be returned as the complete prompt word at the individual level; if the security compliance test fails, an error message will be returned.

[0060] In this optional embodiment, the personal identification information de-identification process includes: Regular expression matching is performed on the prompts to be detected to obtain personal identification information; The personal identification information is replaced, encrypted, or obscured by at least one of the following methods:

[0061] In this optional embodiment, the legal compliance check includes: Based on relevant laws, regulations, rules, and industry-specific compliance standards, content checks are performed on the keywords to be detected; these content checks include checks on prohibited content, sensitive topics, and data usage. The compliance risk level is assessed based on the content inspection results, a compliance inspection report is generated, and risk mitigation recommendations are provided.

[0062] It should be explained that safety compliance testing mainly includes: 1. Built-in PII (Personal Identification Information) desensitization function.

[0063] 2. Integrate legal compliance checks to ensure that prompts comply with regulatory requirements.

[0064] 3. Supports multimodal data processing and addresses the hallucination problem.

[0065] The PII desensitization process is as follows: 1. Recognition stage: Regular expression matching is performed on the prompt words to be detected to obtain personal identification information, such as ID card number, phone number, bank card number, name, etc.; or PII information in the image is processed for multimodal recognition, such as ID card information in scanned documents.

[0066] 2. Desensitization Stage: At least one of the following processes is applied to the Personal Identification Information (PII): replacement, encryption, or obfuscation. Replacement involves replacing the identified PII information with a placeholder or mask; encryption involves encrypting and storing sensitive information; obfuscation involves partially obscuring some of the PII information, such as displaying a phone number as "138****1234".

[0067] PII data masking / desensitization is an irreversible or controlled reversible transformation of personally identifiable information (PII) to eliminate or reduce its ability to directly or indirectly identify individuals while preserving the data format and business usability, in order to meet privacy compliance and data security requirements.

[0068] The legal compliance check process is as follows: 1. Rule Loading: Load relevant legal and regulatory rules, such as data protection laws and financial regulatory provisions; load industry-specific compliance standards, such as anti-money laundering regulations for the financial industry.

[0069] 2. Content Inspection: A content inspection is performed on the prompts to be detected. This content inspection includes prohibited content inspection, sensitive topic inspection, and data usage inspection. Prohibited content inspection checks whether the prompts contain content prohibited by laws and regulations; sensitive topic inspection checks whether the prompts involve sensitive topics; and data usage inspection checks whether the data usage complies with regulatory requirements.

[0070] 3. Risk Assessment: Assess the compliance risk level based on the content inspection results, generate a compliance inspection report, and provide risk mitigation suggestions.

[0071] The timing of security compliance checks during the prompt word assembly process is as follows: 1. Execute the prompt after it is assembled, before returning it to the user; 2. As part of the prompt word assembler, it is called in the assemble_prompt method; 3. If the check passes, return the complete prompt; if the check fails, return an error message.

[0072] In financial contract review scenarios, the security and compliance module plays a particularly important role in ensuring that personally identifiable information in the contract is properly anonymized, that prompts comply with the regulatory requirements of the financial industry, and that legal risks caused by inappropriate prompts are avoided.

[0073] In this optional embodiment, the organ layer configuration is used to define the combination of atomic layer components and molecular layer configurations, and supports a configuration inheritance mechanism to reduce redundant configurations; The atomic layer component is used to provide basic functions, including role definition, skill extraction, workflow, and constraints. The molecular layer configuration is used to implement the extraction logic and rules for specific fields based on the atomic layer components; The individual layer is used to combine all the component contents stored in the prompt word container to generate the final complete prompt word.

[0074] It should be explained that, as shown in Table 1, this invention adopts a four-layer hierarchical architecture of atom-molecule-organ-individual to achieve modularity, hierarchy and scalability of prompt words.

[0075] Table 1: Layered Architecture Specifically, role_definition.j2 is defined as follows: "{# Atomic layer template: role definition (role_definition.j2) # Function: Define the AI ​​assistant's persona and basic identity, establishing professional authority. # Use case: The beginning of all contract type prompts # Scope of impact: Affects the tone and professionalism of the entire prompt. # Edit history: # - 202X-07-15: Initial version, establishing the persona of a contract review expert. # - 202X-07-20: Added description of 30 years of experience to enhance authority. # Important Notes: #- The change will affect the beginning of the prompt word for all contract types Maintain a professional, concise, and authoritative style. #} You are a contract document review expert with 30 years of experience. Skilled at analyzing and retrieving contract text information to extract key information.

[0076] Skilled at summarizing and extracting key information from contract texts, and finding information based on extracted keywords.

[0077] The workflow.j2 file contains the following definition: "{# Atomic layer template: Workflow (workflow.j2) # Purpose: To define a standardized workflow for AI to process contract text. # Use Case: Workflow Description for All Contract Types # Scope of impact: Affects the order and logic of AI in processing contracts. # Edit history: # - 202X-07-15: Initial version, establishing a three-step workflow # - 202X-08-12: Optimized the description order to ensure clear logic. # Important Notes: #- The modification will affect the processing flow for all contract types. # - Keep it simple with these three steps: Read → Extract → Format #} ## Workflow: - Read the contract text carefully - Extract key information based on keywords - - Returns to standard JSON format The contents of the contract_number_extract.j2 file are defined as follows: "{# Contract Number Extraction Rules v1.0 #}" 1. Positioning anchor points: - Search scope: Only the main body of the contract (excluding headers / footers) - Keywords: "contract number", "number" 2. Visual hallucination processing: - Ignore page number: 00001 / 2025 - Conflict resolution: If multiple numbers appear in the main text: a) Prioritize the content following the "Contract Number" b) Select the one that best matches the numbering format (including alphanumeric combinations). 3. Extraction Specifications: - Extract complete numbered text - Example: Enter: "Contract No.: NJ2025-001" Output: "NJ2025-001" - Returns '-' if not found.

[0078] The contents of the common_contract.yaml file are as follows: # Organ layer configuration: base contract (common_contract.yaml) # Purpose: Defines the basic configuration for all contract types, serving as an inheritance template for other contracts. # Use case: As the basic configuration for all specific contract types # Inheritance relationship: No inheritance, serving as the root configuration # Scope of impact: All specific contract types that inherit this configuration # Configuration structure: #- atoms: List of basic atomic components #- molecules: Molecular layer template configuration, including template file and parameters # Field description: #- contract_type: Contract type identifier #- extends: The basic configuration for inheritance (null indicates no inheritance) #- description: Configuration description #- components.atoms: List of atomic layer components #- components.molecules: Molecular layer configuration, each field contains template and params # Important Notes: #- This modification will affect all contract types that inherit this configuration. #- The newly added fields need to be validated for compatibility in the specific contract type. contract_type: base extends: null Description: "Basic contract configuration, including rules for extracting all common fields." components: atoms: - role_definition - skill_reading - skill_extraction - workflow - constraints - example_output molecules: loan_contract_number: template: contract_number.j2 params: strict_mode: true loan_contract_name: template: contract_name.j2 params: clean_space: false search_header: false loan_contract_amount: template: loan_amount.j2 params: {} loan_start_time: template: date_extract.j2 params: field_type: start use_contract_date: true loan_end_time: template: date_extract.j2 params: field_type: end loan_time_period: template: time_period.j2 params: day_conversion: true multi_rule: "额度存续期" revolving_credit: template: revolving_credit.j2 params: {}”

[0079] The contents of the ABC_bank.yaml file are as follows: # Organ layer configuration: ABC Bank Contract (ABC_bank.yaml) # Purpose: ABC Bank-specific contract configuration, inheriting and overriding general configurations. # Use case: Handling ABC Bank's unique contract formats and rules # Inheritance relationship: Inherited from common_contract.yaml # Scope of impact: Applicable only to ABC Bank contract types # Overlay mechanism: #- molecule_overrides: Overrides the molecular layer parameters in the base configuration. # Special Configuration: #- loan_contract_name: Enable clean_space to remove spaces #- loan_contract_amount: Prioritize using "principal amount" as the amount. #- revolving_credit: The second clause is preferred as the standard for revolving credit. # Important Notes: #- The modification only affects ABC Bank contract types #- Ensure that the overridden parameters are compatible with the basic configuration. contract_type: ny_bank extends: common_contract Description: "ABC Bank Contract-Specific Configuration" molecule_overrides: loan_contract_name: params: clean_space: true loan_contract_amount: params: priority_rule: "Principal Amount of Debt" revolving_credit: params: clause_priority: "Second clause".

[0080] like Figure 4 The diagram shown is a schematic diagram of the principle architecture of the present invention. The present invention adopts a four-layer architecture, which consists of an atomic layer, a molecular layer, an organ layer and an individual layer from the bottom layer to the top layer. Each layer has a clear responsibility and function.

[0081] The PromptAssembler is the core component, responsible for coordinating the work of various components. The atomic layer provides basic functional modules such as role definition, skill extraction, workflow, and constraints. The molecular layer implements specific field extraction rules based on the atomic layer components. The organ layer defines the combination of atomic and molecular components through configuration files and supports inheritance mechanisms (for example, the contract configuration of company A can be inherited from the basic contract configuration, greatly reducing redundant configuration). After loading the organ layer configuration, the PromptAssembler processes the inheritance relationship, loads the atomic components, and uses the template rendering engine to perform variable replacement and personalized rendering on the molecular template, finally generating complete prompts at the individual layer.

[0082] like Figure 1 The diagram shows the prompt word assembly process, which is as follows: 1. Start Assembly: Initiate the prompt assembly process to prepare for generating complete prompts.

[0083] 2. Configuration Loading: Load the specified organ layer configuration file and check if there is an inheritance relationship; if there is an inheritance relationship, recursively load the parent configuration file, merge all configuration parameters, and generate the final configuration.

[0084] 3. Initialization: Create a prompt word container to store the content of each component.

[0085] 4. Atomic Component Processing: Load the atomic layer components specified in the configuration, and check if there are any atomic components that need to be loaded; if so, load the content of each atomic component one by one and add it to the prompt word container; if not, proceed directly to the next step.

[0086] 5. Molecular component processing: Check if molecular layer configuration exists in the configuration; if it exists, add field extraction rule title, traverse each molecular field configuration, load the corresponding molecular template, render the molecular template (replace variables), add the rendering result to the prompt word container, and repeat the processing of all molecular fields; if not, proceed directly to the assembly completion stage.

[0087] 6. Assembly complete: Combine all component contents into a complete prompt word.

[0088] 7. Return Result: Returns the complete generated prompt word, and the process ends.

[0089] The core assembly logic is as follows: # Core assembly logic def assemble_prompt(self, organ_name): # 1. Load organ layer configuration and handle inheritance relationship config = self.load_organ_config(organ_name) # 2. Initialize prompt word container prompt_parts = [] # 3. Load atomic layer components atoms = config.get("components",{}).get("atoms", []) for atom_name in atoms: atom_content = self.load_atom(atom_name) if atom_content: prompt_parts.append(atom_content) prompt_parts.append("") # 4. Add molecular layer field extraction content molecules = config.get("components", {}).get("molecules", {}) if molecules: prompt_parts.append("## Field extraction rules:") prompt_parts.append("") for field_name, field_config inmolecules.items():template_name = field_config.get("template")params =field_config.get("params", {})if template_name:# 5. Rendered molecular layer template rendered_content = self.render_molecule(template_name, params)prompt_parts.append(f"### {field_name}")prompt_parts.append(rendered_content)prompt_parts.append("")# 6. Return the complete prompt word return "\n".join(prompt_parts) ”.

[0090] According to another embodiment of the present invention, a system for constructing large model prompt words is provided, characterized in that the system includes: a configuration loading module, a container initialization module, an atom loading module, a molecular rendering module, and a secure generation module; The configuration loading module is used to load organ-level configurations and determine whether there is an inheritance relationship in the organ-level configuration. If there is an inheritance relationship, the parent configuration file is loaded recursively, and all configuration parameters are merged to generate the final configuration. If there is no inheritance relationship, the current configuration parameters are merged as the final configuration. The container initialization module is used to initialize the prompt word container that stores the content of each component loaded subsequently; The atomic loading module is used to determine whether atomic layer components exist based on the final configuration. If atomic layer components exist, the content of each atomic layer component is loaded one by one, and the loaded atomic layer component content is stored in the prompt word container. If atomic layer components do not exist, the current prompt word container remains unchanged. The molecular rendering module is used to determine whether a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, the field extraction rule title is added first, then each molecular field configuration is traversed, the corresponding molecular template is loaded, the molecular template is rendered, and the rendering result is stored in the prompt word container. If no molecular layer configuration exists, the current prompt word container remains unchanged. The security generation module is used to generate complete prompts at the individual level by combining all the component contents in the prompt word container, after passing security and compliance checks.

[0091] In summary, by utilizing the technical solutions described above, this invention significantly reduces the maintenance cost of prompt words through modular design and configuration inheritance mechanisms, reducing maintenance time by approximately 78%. When adding new contract types, only the basic configuration needs to be inherited and necessary fields covered, shortening the new business integration time by 83%. Shared atomic and molecular components ensure a high degree of consistency in the style and rules of prompt words for different contract types, while facilitating unit testing and integration testing, increasing test coverage by 163%. The combination of dynamic assembly and configuration inheritance greatly accelerates the speed of prompt word updates, reducing the error rate by 72%. Furthermore, built-in functions for desensitizing personal identity information and checking legal compliance ensure that the generated prompt words comply with regulatory requirements and support multimodal data processing such as text and images, effectively guaranteeing accuracy in complex scenarios.

[0092] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for constructing a large model of prompt words, characterized in that, The method includes: S1. Load the organ layer configuration and determine whether there is an inheritance relationship in the organ layer configuration; if there is an inheritance relationship, recursively load the parent configuration file and merge all configuration parameters to generate the final configuration; if there is no inheritance relationship, merge the current configuration parameters as the final configuration. S2. Initialize the prompt container used to store the content of each component loaded subsequently; S3. Based on the final configuration, determine whether atomic layer components exist; if atomic layer components exist, load the content of each atomic layer component one by one and store the loaded atomic layer component content into the prompt word container; if atomic layer components do not exist, keep the current prompt word container unchanged. S4. Determine if a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, first add the field extraction rule title, then iterate through each molecular field configuration, load the corresponding molecular template, render the molecular template, and store the rendering result in the prompt word container. If a molecular layer configuration does not exist, keep the current prompt word container unchanged. S5. Based on the content of all components in the prompt word container, and after security and compliance testing, generate a complete prompt word at the individual level.

2. The method for constructing a large model prompt word project according to claim 1, characterized in that, The organ layer configuration is used to define the combination of atomic layer components and molecular layer configurations, and supports a configuration inheritance mechanism to reduce redundant configurations. The atomic layer component is used to provide basic functions, including role definition, skill extraction, workflow, and constraints. The molecular layer configuration is used to implement the extraction logic and rules for specific fields based on the atomic layer components; The individual layer is used to combine all the component contents stored in the prompt word container to generate the final complete prompt word.

3. The method for constructing a large model prompt word project according to claim 1, characterized in that, The process involves loading the organ layer configuration and determining whether there is an inheritance relationship within that configuration. If an inheritance relationship exists, the parent configuration file is recursively loaded, and all configuration parameters are merged to generate the final configuration. If there is no inheritance relationship, merging the current configuration parameters into the final configuration includes the following steps: S11. Read the current organ layer configuration and check if the organ layer configuration exists. If the organ layer configuration does not exist, the output file will not exist. If the organ layer configuration exists, parse the YAML configuration content of the organ layer configuration to obtain the current configuration. S12. Check if the current configuration contains the `extends` field. If it does not contain the `extends` field, use the current configuration as the initial merge configuration. If it contains the `extends` field, recursively load the merge result of the parent configuration file and configure a copy according to the parent configuration file path specified by the `extends` field, and use it as the initial merge configuration. S13. Check if the current configuration contains the components field; if it does not contain the components field, use the initial merge configuration as the final configuration and return it; if it contains the components field, further check if the components field contains the molecules field. S14. If the components do not contain the molecules field, the initial merged configuration is used as the final configuration and returned. If the components contain the molecules field, each molecular field configuration in the current configuration is traversed and molecular field merging is performed. The processing result is updated to the initial merged configuration, and the merged configuration is finally obtained as the final configuration.

4. The method for constructing a large model prompt word project according to claim 3, characterized in that, The molecular field merging process includes the following steps: Iterate through each molecular field configuration in the molecules field under the currently configured components field; For each molecule field configuration encountered during the traversal, determine whether the molecule field already exists in the initial merge configuration; If the molecule field does not exist in the initial merge configuration, then add the molecule field configuration to the initial merge configuration; If the molecule field already exists in the initial merge configuration, then it is further determined whether the molecule field configuration contains the params field; If the params field is included, the params parameter in the sub-field configuration will be merged into the existing field configuration with the same name in the initial merge configuration, and the params parameter of the sub-configuration will override the parameter with the same name in the parent configuration. If the params field is not included, the original configuration of this subfield in the initial merge configuration will remain unchanged.

5. The method for constructing a large model prompt word project according to claim 1, characterized in that, The rendering of the molecular template includes the following steps: Receive the molecular name and parameter list of the molecular template; Process the molecule names, remove the template file extensions, and construct the template file path based on the processed molecule names; Check if the template file corresponding to the template file path exists; if the template file does not exist, return an error message; if the template file exists, read the complete content of the template file and use it as the template content to be rendered. Check if the parameter list is empty; if the parameter list is empty, return the original content of the template file as the rendering result; if the parameter list is not empty, replace the template content to be rendered and return the replaced template content as the rendering result.

6. The method for constructing a large model prompt word project according to claim 5, characterized in that, The replacement process includes the following steps: Iterate through each parameter in the parameter list; For each parameter encountered, find the placeholder corresponding to the parameter name in the template content to be rendered, and replace the placeholder with the actual value of the parameter.

7. The method for constructing a large model prompt word project according to claim 1, characterized in that, The process of generating a complete prompt word at the individual level, based on all components within the prompt word container and after passing security and compliance checks, includes the following steps: S51. At the individual level, combine all the component contents stored in the prompt word container to generate the prompt word to be detected; S52. Perform security and compliance checks on the prompts to be detected, including personal identity information desensitization and legal compliance checks. S53. If the security compliance test passes, the detected prompt word will be returned as the complete prompt word at the individual level; if the security compliance test fails, an error message will be returned.

8. The method for constructing a large model prompt word project according to claim 7, characterized in that, The personal identity information desensitization process includes: Regular expression matching is performed on the prompts to be detected to obtain personal identification information; The personal identification information is replaced, encrypted, or obscured by at least one of the following methods:

9. The method for constructing a large model prompt word project according to claim 7, characterized in that, The legal compliance check includes: Based on relevant laws, regulations, rules, and industry-specific compliance standards, content checks are performed on the keywords to be detected; these content checks include checks on prohibited content, sensitive topics, and data usage. The compliance risk level is assessed based on the content inspection results, a compliance inspection report is generated, and risk mitigation recommendations are provided.

10. A system for constructing large model prompt words, used to implement the method for constructing large model prompt words according to any one of claims 1-9, characterized in that, The system includes: a configuration loading module, a container initialization module, an atom loading module, a molecular rendering module, and a secure generation module; The configuration loading module is used to load organ-level configurations and determine whether there is an inheritance relationship in the organ-level configuration. If there is an inheritance relationship, the parent configuration file is loaded recursively, and all configuration parameters are merged to generate the final configuration. If there is no inheritance relationship, the current configuration parameters are merged as the final configuration. The container initialization module is used to initialize the prompt word container that stores the content of each component loaded subsequently; The atomic loading module is used to determine whether atomic layer components exist based on the final configuration. If atomic layer components exist, the content of each atomic layer component is loaded one by one, and the loaded atomic layer component content is stored in the prompt word container. If atomic layer components do not exist, the current prompt word container remains unchanged. The molecular rendering module is used to determine whether a molecular layer configuration exists in the final configuration. If a molecular layer configuration exists, the field extraction rule title is added first, then each molecular field configuration is traversed, the corresponding molecular template is loaded, the molecular template is rendered, and the rendering result is stored in the prompt word container. If no molecular layer configuration exists, the current prompt word container remains unchanged. The security generation module is used to generate complete prompts at the individual level by combining all the component contents in the prompt word container, after passing security and compliance checks.