Intelligent agent normal form context engineering and visualization adjusting and optimizing method, device, equipment and medium
By employing a dual-agent division of labor between producers and supervisors, paradigm templates, and context engineering, combined with visual contribution analysis, the system solves the problems of task decomposition and memory in agent systems, improves output accuracy and system stability, and is suitable for high-risk scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAFU SECURITIES CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-05-05
AI Technical Summary
Existing parameterless tuning methods in intelligent agent systems suffer from insufficient task decomposition capabilities, long-term memory loss, inconsistent data distribution, and illusion problems, leading to unstable system performance and difficulty in meeting the requirements of quantitative, targeted, and visual tuning.
By employing a dual-agent division of labor between producers and supervisors, combined with paradigm templates and context engineering, and through visual contribution analysis and integrated gradient algorithms, task decomposition, context memory, and targeted intervention are achieved to optimize input text and improve output accuracy and reliability.
It achieves the accuracy and completeness of the intelligent agent's output to reach the preset threshold, reduces the illusion rate, improves the system's performance stability and decision credibility, and adapts to the business needs of high-risk scenarios.
Smart Images

Figure CN121981108A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, and medium for intelligent agent paradigm context engineering and visualization optimization. Background Technology
[0002] An intelligent agent is a software system or application that integrates perception, planning, decision-making, and execution capabilities, with a large model as its core inference engine. It is mainly divided into two forms: single-agent and multi-agent. The single-agent form is currently the most common and basic, capable of independently completing the entire process from receiving tasks, planning workflows, calling tools, to generating output. A multi-agent system, on the other hand, consists of multiple agents with a certain degree of autonomy, working together to solve complex problems that a single agent would struggle to handle.
[0003] In the financial industry, multi-agent collaboration has become a mainstream development trend. Developers can leverage single agents that have been tested and validated in specific tasks to build multi-agent systems. This approach not only improves development efficiency but also enhances system reliability. Currently, most successfully implemented multi-agent systems employ orchestrated agents or semi-structured orchestration patterns to balance system reliability and flexibility.
[0004] Currently, without changing the parameters of the basic large model (i.e., without parameter tuning), the main tuning methods used to build intelligent agents (AIAgent) include Prompt engineering optimization, RAG (retrieval enhancement generation), and workflow structure optimization.
[0005] However, these parameter-free tuning methods have significant shortcomings, specifically in the following two aspects: First, there are flaws in long-chain task planning. On the one hand, the ability to break down tasks is insufficient, making it difficult to effectively decompose complex tasks such as construction project management into executable sub-tasks; on the other hand, there is a problem of long-term memory loss, where contextual information is easily forgotten when dealing with tasks that last for hours or even days, leading to a loss of continuity in task processing.
[0006] Secondly, data bias is difficult to quantitatively optimize. Firstly, there is a problem of distribution inconsistency, where the distribution of pre-training data does not match the distribution of the fine-tuning trajectory, leading to system performance instability. Secondly, there is a problem of illusion, where agents based on Large Language Models (LLM) may generate inaccurate or fictitious information. This problem can seriously affect the reliability of decision-making in high-risk scenarios such as healthcare and finance.
[0007] In summary, existing parameterless tuning methods cannot meet the tuning needs of intelligent agents in terms of quantization, orientation, and visualization. Summary of the Invention
[0008] The technical problem to be solved by this invention is to provide a method, device, equipment and medium for intelligent agent paradigm context engineering and visualization optimization, so as to realize the upgrade of intelligent agents from "executable" to "accurate, reliable and interpretable", which is especially suitable for the implementation of intelligent agents in high-risk and complex scenarios with quantitative requirements for optimization effect.
[0009] In a first aspect, the present invention provides a method for intelligent agent paradigm context engineering and visual tuning, comprising the following steps: S1. Deploy the set hardware and software environments, configure the target large model based on the transformer architecture and expose the API interface. The API interface supports input tokenization, embedded layer data output and result return. Configure the paradigm template, baseline samples and initial parameters of each component, connect to the data source and build a business-related knowledge base. S2. Instantiate the producer agent and the supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the output results of the producer agent. S3. Instantiate the context engineering agent, configure the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. S4. Instantiate the visualization contribution calculation component and the visualization contribution display component. The visualization contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads. It calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visualization contribution display component is configured with highlight color and contribution display precision parameters to realize contribution visualization and key token annotation. S5. Define task parameters and generate initial input text. The producer agent executes the task to obtain the initial output. The supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, the feedback information is recorded and the input text is optimized through the context engineering agent. The verification-optimization process is repeated until the output passes the verification or reaches the preset number of reviews, and the iteratively optimized output result is obtained. S6. Select the last round of optimization input text in the iterative optimization process, determine the target output token, and calculate the IG value of each token in the input text to the target output token through the visual contribution calculation component to obtain the contribution calculation result containing the token text, token ID and IG value; S7. Visualize the contribution calculation results using the contribution display component, and select the top 20% of positive contribution tokens as the key impact token set. Based on the key impact token set, perform targeted intervention on the optimized input text, input the intervened input text into the producer agent to execute the task, and verify whether the output results meet the preset standards. S8. Record the effective component configurations, parameter settings, and intervention schemes from S2 to S7, generate a configuration manual, and store it in the knowledge base; instantiate the monitoring term management tool, add the key impact token set to the monitoring term, configure the term update frequency and monitoring alarm threshold, and establish a real-time monitoring mechanism for input text; set a regular iteration update cycle.
[0010] Secondly, the present invention provides an intelligent agent paradigm context engineering and visualization optimization device, comprising: The pre-deployment module deploys the set hardware and software environments, configures the target large model based on the transformer architecture and exposes API interfaces, which support input tokenization, embedded layer data output and result return; configures the paradigm template, baseline samples and initial parameters of each component, connects to the data source and builds a business-related knowledge base; The dual-agent instantiation module instantiates a producer agent and a supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the producer agent's output results. The context optimization agent instantiation module instantiates the context engineering agent and configures the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. The contribution analysis component instantiation module instantiates a visual contribution calculation component and a visual contribution display component. The visual contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads, and calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visual contribution display component is configured with highlight colors and contribution display precision parameters to realize contribution visualization and key token annotation. The dual-agent iterative optimization module defines task parameters and generates initial input text. The producer agent executes the task to obtain the initial output, and the supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, feedback information is recorded and the input text is optimized through the context engineering agent. The verification-optimization process is repeated until the output passes the verification or reaches the preset number of verifications, resulting in the iteratively optimized output. The quantitative contribution analysis module selects the input text from the last round of optimization in the iterative optimization process, determines the target output token, and calculates the IG value of each token in the input text to the target output token through the visual contribution calculation component, thus obtaining the contribution calculation result containing the token text, token ID, and IG value. The targeted optimization and effect verification module visualizes the contribution calculation results through a visual contribution display component, selects the top 20% of positive contribution tokens as the key impact token set, and performs targeted intervention on the optimization input text based on the key impact token set. The intervened input text is then input into the producer agent to execute tasks, and the output results are verified to meet the preset standards. The optimization effect solidification and monitoring module records the effective component configurations, parameter settings, and intervention schemes from the dual-agent instantiation module to the targeted optimization and effect verification module, generates a configuration manual, and stores it in the knowledge base; the instantiation monitoring vocabulary management tool adds the key impact token set to the monitoring vocabulary, configures the vocabulary update frequency and monitoring alarm threshold, and establishes a real-time monitoring mechanism for input text; and sets a regular iteration update cycle.
[0011] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.
[0012] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0013] One or more technical solutions provided by this invention have at least the following technical effects or advantages: 1. This invention uses a dual-agent division of labor, namely "producer + supervisor". The producer is responsible for forward decomposition and execution, while the supervisor verifies and corrects in reverse. Combined with paradigm templates, complex tasks (such as cross-time project management and multi-dimensional data analysis) are decomposed into structured sub-tasks, thus solving the problem of "insufficient decomposition granularity". 2. The "persistent memory + context partitioning" strategy of the context engineering agent of this invention can store historical instructions, intermediate results and feedback information of multiple rounds of tasks, avoid context breakage of tasks across hours / days, and ensure the continuity of task execution.
[0014] 3. This invention improves system performance stability by using a multi-round "verification-feedback-optimization" closed loop of the supervisor agent, combined with contextual accurate information retrieval (supplementing matching data from the knowledge base); 4. The visualization contribution analysis of this invention can accurately locate the "key impact tokens" (such as vague words and incorrect association information) that cause hallucinations. Through targeted editing / replacement intervention, it can reduce the probability of distorted output from the source of input, and is especially suitable for the reliability requirements of high-risk scenarios such as finance and medical care.
[0015] 5. This case uses the Integrated Gradient Algorithm (IG) to calculate the contribution of the input token to the output (IG value), transforming the "correlation between input and output" from a vague qualitative to a precise quantitative (retaining positive and negative signs and specific values), avoiding the "trial and error based on experience" of traditional optimization; by using quantitative indicators such as contribution ranking and the proportion of key tokens (top 20%), the optimization priority is clarified, making iterative optimization based on data and reducing the dispersion of the optimization effect.
[0016] 6. This invention does not require modification of large model parameters (no parameter tuning). It locates the core input factors affecting the target output through the "key impact token set" and makes targeted editing, filtering or replacement, avoiding the inefficiency of traditional tuning's "comprehensive adjustment and blind optimization". It supports "on-demand tuning": it can reduce the probability of specific output tokens (such as incorrect conclusions and redundant statements) or strengthen positive outputs (such as accurate data and compliant conclusions), adapting to the personalized needs of different business scenarios.
[0017] 7. The visualization contribution display component of this invention presents the token contribution distribution in a visual chart format, highlights key influencing factors, and allows non-technical personnel to understand "how input affects output"; it records contextual strategy combinations, parameter configurations, intervention operations and effect changes to form a complete optimization chain, which facilitates problem investigation and strategy reuse.
[0018] 8. This invention supports mainstream large models based on the Transformer architecture (such as GPT, Llama, BERT) without the need for customized development of the large model itself; the data source interface is compatible with common formats such as MySQL, API, and Excel; the knowledge base can reuse existing business data, reducing data migration and adaptation costs.
[0019] 9. The process of dual-agent iterative optimization, automatic context optimization, and automatic early warning of key tokens in this invention can be automated, reducing the cost of manual operation and maintenance; it supports manual intervention in key links (such as confirmation of targeted intervention schemes and review of monitoring word lists), avoiding the risks that may be brought about by full automation, and is especially suitable for scenarios with high compliance requirements.
[0020] 10. After multiple rounds of verification and targeted optimization, the accuracy and completeness of the intelligent agent's output can reach preset thresholds (such as accuracy ≥95% and completeness ≥90%), reducing the cost of manual verification; the illusion rate is significantly reduced (target ≤3%), which can improve the credibility and compliance of decision-making in key scenarios such as financial data analysis.
[0021] 11. The periodic update mechanism of the monitoring vocabulary and optimization configuration of this invention can adapt to business changes (such as adding new task types or policy adjustments), allowing the intelligent agent to continuously evolve; the component-based design supports horizontal expansion (such as adding multimodal producer intelligent agents or expanding the knowledge base capacity), meeting the needs of large-scale business development.
[0022] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0023] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0024] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the device in Embodiment 2 of the present invention. Detailed Implementation
[0025] The overall concept of the technical solution in this application is as follows: This invention proposes a method for optimizing intelligent agents, which is achieved through the following key points: A. Paradigm Context Engineering Improves Chain Task Planning Defects: Two roles, producer and supervisor, are established to decompose the agent's task step structure. Simultaneously, context engineering techniques such as persistent memory, precise information retrieval, context slimming, and context partitioning are applied between each step. Furthermore, organizational paradigms using terms like who, what, why, how, and how much enhance the quality of input content for large-scale model execution steps.
[0026] B. Visualizing Contribution Improvement and Targeted Optimization Monitoring for Model Generation: This involves quantitatively analyzing the input and output content of large models based on the transformer architecture using data from the model's embedding layer. The analysis reveals the contribution of each token in the input content to the corresponding token in the output. This provides quantitative data support for targeted optimization of the large model's execution steps.
[0027] By employing the above methods, a quantifiable and iterative direction for optimizing the performance of the agent is provided, thereby reducing the dispersion of the agent's optimization performance. Specific implementation methods
[0028] (2-1) Overall Architecture It consists of the following modules: 2-1-1. Producer intelligent agent: responsible for completing positive work goals, such as extracting data, compiling statistics, and analyzing attributions.
[0029] 2-1-2. Supervisory agent: Responsible for reverse verification of the producer agent's results, identifying deficiencies in the producer agent's work results and proposing improvement requirements.
[0030] 2-1-3. Context Engineering Agent: Responsible for performing context engineering and paradigm engineering operations on the content generated by the large model. By setting parameters, the caller can select persistent memory, precise information retrieval, context slimming, and context partitioning operation methods. Multiple operation methods can be selected. Then, the caller selects a paradigm template and performs targeted optimization on the quality of the generated content.
[0031] 2-1-4. Paradigm Template Management Component: This component manages Promt paradigm templates, which are called by the context engineering agent to ensure that the generated content is displayed according to the paradigm template. For example, the 3W2H template (who, what, why, how, and how much) restricts the generated content to be organized according to the template paradigm of who, what, why, how, and to what extent.
[0032] 2-1-5. Visualized Contribution Calculation Component: Employs gradient ensemble data analysis to calculate the direct contribution (IG value) between the input and output tokens of the large model. This component provides the caller with parameter settings for the number of sampling attempts.
[0033] 2-1-6. Visual Contribution Display Component: During the generation phase, a target token (denoted as A) is selected from the model's output sequence. The contribution value of each input token to the prediction result of that target token is calculated and displayed. The contribution value retains the positive or negative sign to distinguish between positive promotion and negative inhibition of the prediction. Simultaneously, the input tokens with the largest and smallest absolute contribution values are highlighted to emphasize their crucial influence in generating the target token.
[0034] Specifically: 2-1-6-1: Contribution Calculation. Calculate the IG contribution of all input tokens.
[0035] 2-1-6-2: Contribution Filtering. This filters input tokens with positive values, i.e., input tokens that contribute to violating output rules. 2-1-6-3: Contribution Ranking. Sort the tokens with positive contributions from largest to smallest absolute value of contribution, and select the top 20% of tokens as the "key impact token set".
[0036] 2-1-6-4: Contribution visualization and intervention.
[0037] In the contribution display component, the tokens in the "key impact token set" are highlighted, and their contribution values and context positions are marked. In conjunction with the context engineering agent, the fragments containing these tokens are precisely edited, filtered, or replaced, or added to the "monitoring vocabulary" for subsequent task alerts.
[0038] (2-2) Method and Steps When building or tuning an agent, Step 1: Design the intelligent agents into two main categories: producer intelligent agents and supervisor intelligent agents.
[0039] Step 2: Set the number of times the supervisor agent reviews the producer agent's results and urges improvement.
[0040] Step 3: The producer agent generates content (denoted as C) in the forward direction. The supervisor agent checks the effect of C and requires the producer agent to improve it before re-outputting. The "check-improve" process is repeated multiple times according to the parameters set by the caller. Among them, the supervisor agent calls the context engineering agent to optimize the content generated by the multiple rounds of checks and the generated content through context engineering, and submits the optimized content as the input content for the next round to the producer agent for production.
[0041] Step 4: Developers can choose to call the visualization contribution calculation component in the large model execution step. The visualization contribution display component analyzes the contribution of the input token to the output token.
[0042] Step 5: If you want to reduce the probability or impact of a certain output token, you can find the input token with the largest absolute value of its contribution. Manually adjust and optimize this input token by replacing it and observe the changes in the output results.
[0043] Compared with existing calculation methods, the present invention has the following significant advantages: (1) It provides an engineering approach for parameterless optimization of intelligent agents. Technical features: By utilizing paradigm context engineering, the intelligent agent can be decomposed into internal sub-intelligent agents and the workflow design can be more reasonable. The quality of the content generated at each step can be controlled to facilitate the use of subsequent steps, and the memory loss problem in long-chain workflows can be solved.
[0044] Results: By employing an engineering approach, intelligent agents can be optimized more quickly according to business needs.
[0045] (2) Provide a visualization method for parameter-free optimization of intelligent agents Technical features: Contribution visualization provides quantitative data (absolute values) to facilitate analysis of the impact of specific input tokens on the generated results; furthermore, it uses positive and negative values to indicate the direction of the impact. This provides a quantifiable and directional optimization method for adjusting token granularity.
[0046] Effects: When fine-tuning or locating the generated results, there is intuitive and monitorable data and direction, which improves the efficiency of fine-grained optimization of the generated content by the agent. Scenarios include: (1) when discovering illegal content, quickly locate the few input tokens that contribute the most to the illegal content, and use context engineering for precise control or timely notification; (2) when the generated content is effective, conduct attribution analysis and summarize more good paradigm context engineering ideas and knowledge. Example 1
[0047] like Figure 1 As shown, this embodiment provides a method for intelligent agent paradigm context engineering and visual tuning, characterized by the following steps: S1. Deploy the set hardware and software environments, configure the target large model based on the transformer architecture and expose the API interface. The API interface supports input tokenization, embedding layer data output and result return. Configure the paradigm template, baseline samples and initial parameters of each component, connect to the data source and build a business-related knowledge base. Tokenization refers to the process of segmenting the input natural language text into the smallest semantic unit (i.e., token) that the model can process through the large model's tokenizer, and assigning a unique digital ID to each token. The core purpose is to convert human-understandable text into a numerical sequence that the large model can recognize and calculate, which is the basis for subsequent embedding layer data processing and contribution analysis (such as the IG value calculation in step S6). Token granularity: It can flexibly correspond to words, sub-words, characters or punctuation marks (e.g., "unhappy" can be split into two sub-word tokens "un" and "happy"). The mainstream sub-word segmentation algorithms such as BPE and WordPiece are used to balance generalization ability and dictionary size.
[0048] S2. Instantiate the producer agent and the supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the output results of the producer agent. S3. Instantiate the context engineering agent, configure the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. S4. Instantiate the visualization contribution calculation component and the visualization contribution display component. The visualization contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads. It calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visualization contribution display component is configured with highlight color and contribution display precision parameters to realize contribution visualization and key token annotation. S5. Define task parameters and generate initial input text. The producer agent executes the task to obtain the initial output. The supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, the feedback information is recorded and the input text is optimized through the context engineering agent. The verification-optimization process is repeated until the output passes the verification or reaches the preset number of reviews, and the iteratively optimized output result is obtained. The iterative execution-verification-optimization process refers to a cyclical process revolving around "the producer agent executes the task → the supervisor agent verifies the output → the context engineering agent optimizes the input," as detailed below: Execution: Input the current input text (the initial input text for the first time, and the optimized input text for subsequent times) into the producer agent, which will then perform business tasks such as data extraction and analysis and output the results; Verification: The supervisory agent verifies the accuracy of the output results based on preset standard data (such as real data in an authoritative database), and also verifies whether all required fields are included to verify completeness; Optimization: If the output fails the accuracy / completeness verification, record the feedback information of the supervisor agent, and the context engineering agent optimizes the input text based on the feedback information and historical context. Repeat: Input the optimized input text back into the producer agent and repeat the above "execution-verification-optimization" steps until the output result passes verification or reaches the maximum number of times the supervisor agent presets for review. S6. Select the last round of optimization input text in the iterative optimization process, determine the target output token, and calculate the IG value of each token in the input text to the target output token through the visual contribution calculation component to obtain the contribution calculation result containing the token text, token ID and IG value; S7. Visualize the contribution calculation results using the contribution display component, and select the top 20% of positive contribution tokens as the key impact token set. Based on the key impact token set, perform targeted intervention on the optimized input text, input the intervened input text into the producer agent to execute the task, and verify whether the output results meet the preset standards. S8. Record the effective component configurations, parameter settings, and intervention schemes from S2 to S7, generate a configuration manual, and store it in the knowledge base; instantiate the monitoring term management tool, add the key impact token set to the monitoring term, configure the term update frequency and monitoring alarm threshold, and establish a real-time monitoring mechanism for input text; set a regular iteration update cycle.
[0049] In this embodiment, preferably, the configuration rules for the baseline samples in S1 are as follows: the baseline sample for text input is the token sequence corresponding to an empty string; the baseline sample for numeric input is the token value corresponding to the mean of the data of that type; and the mixed input is split according to data type and then the baseline configuration rules for text and numeric types are adopted respectively.
[0050] In this embodiment, preferably, the verification of the accuracy and completeness of the initial output by the supervisor agent based on standard data and required fields in S5 specifically involves: using the SentenceTransformer model to encode the output result and standard data respectively, calculating the cosine similarity between the two, and determining that the accuracy meets the standard if the similarity is ≥ the accuracy verification threshold; the completeness verification is achieved by checking whether the output result contains all required fields, and determining that the completeness meets the standard if the proportion of missing fields is ≤ 1 - the completeness verification threshold.
[0051] In this embodiment, preferably, the context engineering agent in S5 optimizes the input text as follows: if a persistent memory strategy is configured, the historical context is stored in Redis and integrated into the current input text; if a context partitioning strategy is configured, the input text is classified and reorganized according to the task objective, execution steps, intermediate results, and constraints; redundant information in the input text is filtered based on a redundancy filtering threshold; and finally, a paradigm template is applied to reorganize the format of the input text.
[0052] In this embodiment, preferably, the specific process by which the visualization contribution calculation component calculates the IG value in S6 is as follows: The input text is converted into a token sequence using a large model's tokenizer tool, and the ID and text information of the input token are obtained. Based on the baseline samples configured in S1, a baseline token sequence corresponding to the input token sequence is generated; Sample m times along the path from the baseline token sequence to the input token sequence, where m is the configured number of sampling times, and calculate the gradient corresponding to the interpolated input obtained for each sampling. Calculate the average of m sampling gradients, obtain the IG value of a single token using the gradient integral formula, and integrate the information of all tokens to obtain the contribution calculation result.
[0053] In this embodiment, preferably, the specific process of the targeted intervention in S7 is as follows: using the tokenizer tool to locate the position of the key influence token in the input text, replacing the vague key token with preset precise expression words; after the replacement is completed, using the tokenizer tool to restore the intervened token sequence into text, and obtaining the intervened input text.
[0054] In this embodiment, preferably, the implementation process of the real-time monitoring mechanism in S8 is as follows: the monitoring word list management tool detects in real time whether the token in the input text contains a key token in the monitoring word list; if a key token is detected, an alarm is triggered and an alarm message is output. After the alarm is triggered, a manual review process or an automatic intervention process can be selected. The automatic intervention process is to call the targeted intervention method in step S7 to process the input text.
[0055] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example 2
[0056] like Figure 2 As shown, this embodiment provides an intelligent agent paradigm context engineering and visualization optimization device, including: The pre-deployment module deploys the set hardware and software environments, configures the target large model based on the transformer architecture and exposes API interfaces, which support input tokenization, embedded layer data output and result return; configures the paradigm template, baseline samples and initial parameters of each component, connects to the data source and builds a business-related knowledge base; The dual-agent instantiation module instantiates a producer agent and a supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the producer agent's output results. The context optimization agent instantiation module instantiates the context engineering agent and configures the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. The contribution analysis component instantiation module instantiates a visual contribution calculation component and a visual contribution display component. The visual contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads, and calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visual contribution display component is configured with highlight colors and contribution display precision parameters to realize contribution visualization and key token annotation. The dual-agent iterative optimization module defines task parameters and generates initial input text. The producer agent executes the task to obtain the initial output, and the supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, feedback information is recorded and the input text is optimized through the context engineering agent. The verification-optimization process is repeated until the output passes the verification or reaches the preset number of verifications, resulting in the iteratively optimized output. The quantitative contribution analysis module selects the input text from the last round of optimization in the iterative optimization process, determines the target output token, and calculates the IG value of each token in the input text to the target output token through the visual contribution calculation component, thus obtaining the contribution calculation result containing the token text, token ID, and IG value. The targeted optimization and effect verification module visualizes the contribution calculation results through a visual contribution display component, selects the top 20% of positive contribution tokens as the key impact token set, and performs targeted intervention on the optimization input text based on the key impact token set. The intervened input text is then input into the producer agent to execute tasks, and the output results are verified to meet the preset standards. The optimization effect solidification and monitoring module records the effective component configurations, parameter settings, and intervention schemes from the dual-agent instantiation module to the targeted optimization and effect verification module, generates a configuration manual, and stores it in the knowledge base; the instantiation monitoring vocabulary management tool adds the key impact token set to the monitoring vocabulary, configures the vocabulary update frequency and monitoring alarm threshold, and establishes a real-time monitoring mechanism for input text; and sets a regular iteration update cycle.
[0057] In this embodiment, preferably, the configuration rules for the baseline samples in the pre-preparation module are as follows: the baseline sample for text input is the token sequence corresponding to an empty string; the baseline sample for numeric input is the token value corresponding to the mean of the data of that type; and the mixed input is split according to data type and then the baseline configuration rules for text and numeric types are adopted respectively.
[0058] In this embodiment, preferably, the step of the supervisor agent verifying the accuracy and completeness of the initial output based on standard data and required fields in the dual-agent iterative optimization module specifically involves: using the SentenceTransformer model to encode the output result and standard data respectively, calculating the cosine similarity between the two, and determining that the accuracy meets the standard if the similarity is ≥ the accuracy verification threshold; the completeness verification is achieved by checking whether the output result contains all required fields, and determining that the completeness meets the standard if the proportion of missing fields is ≤ 1 - the completeness verification threshold.
[0059] In this embodiment, preferably, the context engineering agent in the dual-agent iterative optimization module optimizes the input text as follows: if a persistent memory strategy is configured, historical contexts are stored in Redis and integrated into the current input text; if a context partitioning strategy is configured, the input text is classified and reorganized according to task objectives, execution steps, intermediate results, and constraints; redundant information in the input text is filtered based on a redundancy filtering threshold; and finally, a paradigm template is applied to reorganize the format of the input text.
[0060] In this embodiment, preferably, the specific process by which the visualization contribution calculation component in the quantitative contribution analysis module calculates the IG value is as follows: The input text is converted into a token sequence using a large model's tokenizer tool, and the ID and text information of the input token are obtained. Based on the baseline samples configured in the pre-preparation module, a baseline token sequence corresponding to the input token sequence is generated; Sample m times along the path from the baseline token sequence to the input token sequence, where m is the configured number of sampling times, and calculate the gradient corresponding to the interpolated input obtained for each sampling. Calculate the average of m sampling gradients, obtain the IG value of a single token using the gradient integral formula, and integrate the information of all tokens to obtain the contribution calculation result.
[0061] In this embodiment, preferably, the specific process of targeted intervention in the targeted optimization and effect verification module is as follows: using the tokenizer tool to locate the position of key influencing tokens in the input text, replacing vague key tokens with preset precise expression words; after the replacement is completed, using the tokenizer tool to restore the intervened token sequence to text, thus obtaining the intervened input text.
[0062] In this embodiment, preferably, the implementation process of the real-time monitoring mechanism in the optimization effect solidification and monitoring module is as follows: the token in the input text is detected in real time by the monitoring word list management tool to see if it contains a key token in the monitoring word list; if a key token is detected, an alarm is triggered and an alarm message is output. After the alarm is triggered, a manual review process or an automatic intervention process can be selected. The automatic intervention process is to call the targeted intervention method of the targeted optimization and effect verification module to process the input text.
[0063] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.
[0064] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. Example 3
[0065] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the implementation methods in Embodiment 1.
[0066] Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application.
[0067] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4. Example 4
[0068] This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can implement any of the implementation methods in Embodiment 1.
[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0070] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0071] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0072] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0073] 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 method for context engineering and visual tuning of intelligent agent paradigms, characterized in that, Includes the following steps: S1. Deploy the set hardware and software environments, configure the target large model based on the transformer architecture and expose the API interface. The API interface supports input tokenization, embedded layer data output and result return. Configure the paradigm template, baseline samples and initial parameters of each component, connect to the data source and build a business-related knowledge base. S2. Instantiate the producer agent and the supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the output results of the producer agent. S3. Instantiate the context engineering agent, configure the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. S4. Instantiate the visualization contribution calculation component and the visualization contribution display component. The visualization contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads. It calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visualization contribution display component is configured with highlight color and contribution display precision parameters to realize contribution visualization and key token annotation. S5. Define task parameters and generate initial input text. The producer agent executes the task to obtain the initial output. The supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, record the feedback information and optimize the input text through the context engineering agent. Repeat the verification-optimization process until the output passes the verification or reaches the preset number of reviews, and obtain the iteratively optimized output result. S6. Select the last round of optimization input text in the iterative optimization process, determine the target output token, and calculate the IG value of each token in the input text to the target output token through the visual contribution calculation component to obtain the contribution calculation result containing the token text, token ID and IG value; S7. Visualize the contribution calculation results using the contribution display component, and select the top 20% of positive contribution tokens as the key impact token set. Based on the key impact token set, perform targeted intervention on the optimized input text, input the intervened input text into the producer agent to execute the task, and verify whether the output results meet the preset standards. S8. Record the effective component configurations, parameter settings, and intervention schemes from S2 to S7, generate a configuration manual, and store it in the knowledge base; instantiate the monitoring term management tool, add the key impact token set to the monitoring term, configure the term update frequency and monitoring alarm threshold, and establish a real-time monitoring mechanism for input text; set a regular iteration update cycle.
2. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The baseline sample configuration rules described in S1 are as follows: the baseline sample for text input is the token sequence corresponding to the empty string; the baseline sample for numeric input is the token value corresponding to the mean of the data in that class; and the mixed input is split according to data type and then the baseline configuration rules for text and numeric inputs are adopted respectively.
3. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The verification of the accuracy and completeness of the initial output by the supervisory agent based on standard data and required fields in S5 is specifically as follows: the SentenceTransformer model is used to encode the output results and standard data respectively, and the cosine similarity between the two is calculated. If the similarity is greater than or equal to the accuracy verification threshold, the accuracy is determined to be up to standard. The completeness verification is achieved by checking whether the output results contain all required fields. If the proportion of missing fields is less than or equal to 1 - the completeness verification threshold, the completeness is determined to be up to standard.
4. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The context engineering agent in S5 optimizes the input text specifically as follows: if a persistent memory strategy is configured, historical contexts are stored in Redis and integrated into the current input text; if a context partitioning strategy is configured, the input text is classified and reorganized according to task objectives, execution steps, intermediate results, and constraints. Redundant information in the input text is filtered out based on a redundancy filtering threshold, and finally, a paradigm template is applied to reformat the input text.
5. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The specific process by which the visualization contribution calculation component described in S6 calculates the IG value is as follows: The input text is converted into a token sequence using a large model's tokenizer tool, and the ID and text information of the input token are obtained. Based on the baseline samples configured in S1, a baseline token sequence corresponding to the input token sequence is generated; Sample m times along the path from the baseline token sequence to the input token sequence, where m is the configured number of sampling times, and calculate the gradient corresponding to the interpolated input obtained for each sampling. Calculate the average of m sampling gradients, obtain the IG value of a single token using the gradient integral formula, and integrate the information of all tokens to obtain the contribution calculation result.
6. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The specific process of targeted intervention described in S7 is as follows: using the tokenizer tool to locate the position of key impact tokens in the input text, replacing vague key tokens with preset precise expressions; after the replacement is completed, using the tokenizer tool to restore the intervened token sequence to text, thus obtaining the intervened input text.
7. The intelligent agent paradigm context engineering and visualization optimization method according to claim 1, characterized in that, The implementation process of the real-time monitoring mechanism described in S8 is as follows: the monitoring word list management tool detects in real time whether the token in the input text contains a key token in the monitoring word list; if a key token is detected, an alarm is triggered and an alarm message is output. After the alarm is triggered, a manual review process or an automatic intervention process can be selected. The automatic intervention process is to call the targeted intervention method in step S7 to process the input text.
8. A device for intelligent agent paradigm context engineering and visual tuning, characterized in that: include: The pre-deployment module deploys the set hardware and software environments, configures the target large model based on the transformer architecture and exposes API interfaces, which support input tokenization, embedded layer data output and result return; configures the paradigm template, baseline samples and initial parameters of each component, connects to the data source and builds a business-related knowledge base; The dual-agent instantiation module instantiates a producer agent and a supervisor agent respectively. The producer agent is configured with task type, output format and timeout threshold parameters for forward execution of business tasks. The supervisor agent is configured with review count, accuracy verification threshold and integrity verification threshold parameters for reverse verification of the producer agent's output results. The context optimization agent instantiation module instantiates the context engineering agent and configures the context policy combination, paradigm template ID and redundancy filtering threshold parameters. The context policy combination includes at least one of persistent memory and context partitioning. The paradigm template ID corresponds to a preset template. The contribution analysis component instantiation module instantiates a visual contribution calculation component and a visual contribution display component. The visual contribution calculation component is configured with parameters such as the number of sampling times, calculation precision, and the number of parallel computing threads, and calculates the contribution value (IG) of the input token to the output result based on the integrated gradient algorithm. The visual contribution display component is configured with highlight colors and contribution display precision parameters to realize contribution visualization and key token annotation. The dual-agent iterative optimization module defines task parameters and generates initial input text. The producer agent executes the task to obtain the initial output, and the supervisor agent verifies the accuracy and completeness of the initial output based on standard data and required fields. If the verification fails, record the feedback information and optimize the input text through the context engineering agent. Repeat the verification-optimization process until the output passes the verification or reaches the preset number of reviews, and obtain the iteratively optimized output result. The quantitative contribution analysis module selects the input text from the last round of optimization in the iterative optimization process, determines the target output token, and calculates the IG value of each token in the input text to the target output token through the visual contribution calculation component, thus obtaining the contribution calculation result containing the token text, token ID, and IG value. The targeted optimization and effect verification module visualizes the contribution calculation results through a visual contribution display component, selects the top 20% of positive contribution tokens as the key impact token set, and performs targeted intervention on the optimization input text based on the key impact token set. The intervened input text is then input into the producer agent to execute tasks, and the output results are verified to meet the preset standards. The optimization effect solidification and monitoring module records the effective component configurations, parameter settings, and intervention schemes from the dual-agent instantiation module to the targeted optimization and effect verification module, generates a configuration manual, and stores it in the knowledge base; the instantiation monitoring vocabulary management tool adds the key impact token set to the monitoring vocabulary, configures the vocabulary update frequency and monitoring alarm threshold, and establishes a real-time monitoring mechanism for input text; and sets a regular iteration update cycle.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 7.