A multi-level prompt word generation method for complex tasks

By employing semantic parsing and dynamic decomposition strategies, complex tasks are broken down into multiple logically related subtasks, generating targeted prompt words and dynamically adjusting them. This solves the problems of information loss and low efficiency in traditional single-level prompt word methods, enabling efficient processing of complex tasks.

CN120893589BActive Publication Date: 2026-01-09ZHEJIANG UNIV HIGH-END EQUIP RES INST
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511438516.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2026-01-09
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

Traditional single-level prompting methods suffer from information loss or low processing efficiency when handling complex tasks, and are unable to cover all the details and logical relationships of complex tasks, thus limiting the application scope and efficiency of existing technologies in handling complex tasks.

Method used

By generating task triples through semantic parsing, complex tasks are dynamically decomposed into multiple logically related subtasks, targeted task prompts are constructed, and subtasks are executed through a large language model. The prompts are dynamically adjusted to adapt to task changes, and finally, a coherent result is generated.

Benefits of technology

It achieves efficient and accurate processing of complex tasks, is suitable for multi-step reasoning and cross-domain knowledge fusion tasks, and improves the model's performance in complex tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120893589B_ABST
    Figure CN120893589B_ABST
Patent Text Reader

Abstract

The application discloses a kind of multi-level prompt word generation methods for complex tasks, comprising: complex task analysis is carried out by semantic analysis, and task type, target element and constraint condition are identified;Complex task is decomposed into subtask with logical association based on dynamic decomposition strategy;Task prompt word is constructed based on subtask feature, including keyword, question sentence, instruction;The logical association network across subtask is established, and the logical association between subtask is clarified, including execution order, dependency relationship, condition constraint;According to task prompt word and execution order, subtask is executed, and the task prompt word of subsequent subtask is dynamically adjusted according to the result of previous subtask;According to the logical association between subtask, the key information of each subtask execution result is integrated, and is converted into coherent final result by natural language generation technology.The application realizes stable and can adapt to multi-level prompt word generation of different complex tasks.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of artificial intelligence, and in particular to a multi-level prompt generation method for complex tasks, which is suitable for multi-step reasoning tasks, cross-domain knowledge fusion tasks and other complex task scenarios. BACKGROUND

[0002] In modern engineering practice, the demand for handling complex tasks is increasing. These complex tasks usually involve multiple steps, cross-domain knowledge fusion and long text generation, which pose higher requirements on existing natural language processing technologies and artificial intelligence models. However, traditional single-level prompt methods have obvious limitations in handling these complex tasks. First, the prompt for complex tasks is often too long, exceeding the upper limit of the model's input length, resulting in information loss or low processing efficiency. Second, the logical relationship of complex tasks is complex, and a single prompt cannot cover all the details and logical relationships of the task, thereby affecting the execution effect of the task. These limitations limit the application range and efficiency of existing technologies in complex task processing, therefore, a method for generating multi-level prompts is needed to improve the performance of models in complex tasks. SUMMARY

[0003] In view of the deficiencies of the prior art, the present application proposes a multi-level prompt generation method for complex tasks to improve the processing efficiency and accuracy of complex tasks.

[0004] The specific technical solutions are as follows:

[0005] A multi-level prompt generation method for complex tasks, comprising the following steps:

[0006] S1: Analyze the complex task through semantic parsing, output the task triplets, the task triplets include: task type, target element, constraint condition;

[0007] S2: According to the task triplets, combine the dynamic decomposition strategy to decompose the complex task into multiple subtasks with logical association;

[0008] S3: Task prompt generation, based on the characteristics of the subtasks, construct a targeted task prompt for each subtask; the task prompt includes: key words, question sentence, instruction;

[0009] S4: Establish a logical association network across subtasks to obtain the logical association between each subtask, the logical association includes: execution order, dependency relationship, constraint condition;

[0010] S5: sub-task execution and prompt word updating, executing each sub-task according to the task prompt word and the execution sequence; and dynamically adjusting the task prompt word of the subsequent sub-task according to the result of the previous sub-task;

[0011] S6: performing semantic analysis on the execution result of each sub-task, extracting the key information of the execution result, integrating the extracted key information of each execution result according to the logical association between the sub-tasks, and converting into a coherent final result conforming to language habits through natural language generation technology.

[0012] Further, in S1, the analysis of the complex task specifically comprises: using natural language processing technology, performing semantic analysis on text data related to the complex task, extracting complexity features and key information of the complex task, determining the logical structure of the complex task, and identifying the main logical units in the complex task and the logical relationship between the main logical units;

[0013] The complex task includes: a multi-step reasoning task, a cross-domain knowledge fusion task, and a complex text generation task.

[0014] The text data related to the complex task includes: task description, user requirement document, and domain knowledge base.

[0015] The natural language processing technology includes: word segmentation, part-of-speech tagging, and dependency syntax analysis.

[0016] The key information of the complex task includes the task target and the corresponding operation steps.

[0017] Further, S2 is specifically implemented through the following sub-steps:

[0018] (S2.1) Perform task decomposition: according to the task triple, combine the dynamic decomposition strategy, and decompose the complex task into multiple sub-tasks with logical association; the description of each sub-task includes the task target and the constraint condition; the dynamic decomposition strategy is realized based on the decomposition controller of reinforcement learning, and the decomposition controller is modeled as a Markov decision process, which is used to adaptively determine the decomposition depth and granularity of the sub-task in the complex task decomposition process to optimize the effect of task decomposition;

[0019] (S2.2) Perform performance analysis on all sub-tasks obtained by the current decomposition, if the comprehensive performance score of the large language model on all sub-tasks obtained by the current decomposition reaches the preset performance threshold, stop task decomposition; otherwise, perform (S2.1) on each newly generated sub-task node.

[0020] Further, the state space S of the decomposition controller is composed of the feature vector S n of the current task node n, which includes: complexity indicator Cn , performance indicator P n , resource indicator R n ; the complexity indicator C n includes: text length L, domain crossing degree D, number of logical units U; the performance indicator P n includes: BLEU score between large language model output and reference answer, fact consistency score F; the resource indicator R n includes: total amount of consumed word pieces T used , total amount of remaining generatable word pieces T left ;

[0021] In the workspace A of the decomposition controller, the discrete action a includes: a decomposition action and a stop action; the decomposition action is used to split the current task node n into m subtask nodes of finer granularity, m≥2; when the decomposition action is triggered, the decomposition controller also outputs a split dimension identifier, which includes: split by domain, split by step, and split by data subset; the stop action is used to terminate further decomposition of the current task node, and each subtask obtained by decomposing the current task is output as S2;

[0022] The reward function r(S n , a) of the decomposition controller is used to quantify the immediate benefit of executing the discrete action a in the state S n ; if the discrete action is a stop action, and the comprehensive performance score prediction value of the large language model executing the current subtask meets the preset performance threshold, then r=+1; if the discrete action is a decomposition action, and the comprehensive performance score prediction value of all subtask nodes is higher than the performance score of the parent node, then r=+0.5; if the discrete action is a decomposition action, and it causes a logical break between any two subtask nodes, then r=-1; in other cases, r=0.

[0023] Further, the decomposition controller contains a policy network, whose network parameters are θ; the policy network is trained using a proximal policy optimization algorithm, and the training includes two stages: an offline pre-training stage and an online fine-tuning stage;

[0024] In the offline pre-training stage, a training set is constructed using historical complex tasks and their manually annotated decomposition results, and a policy objective function J(θ) is used as a training optimization indicator; the policy objective function is a performance metric in the sense of long-term cumulative discounted reward expectation, and the maximum value of each calculation is retained; the proximal policy optimization algorithm is used to iteratively update the network parameters θ, so that the value of the policy objective function increases, until a preset convergence threshold or a maximum number of iterations is reached, completing the training in this stage;

[0025] During the online fine-tuning phase, the real-time reward is adjusted according to the user's real-time feedback during the actual task execution, that is, the user's real-time feedback signal is superimposed on the initial reward, and the superimposition mode includes direct superimposition, weighted superimposition and truncated superimposition; and the policy network is incrementally updated through importance sampling.

[0026] Further, performance analysis is performed on all sub-tasks obtained by current decomposition, and a performance prediction simulator trained offline is used to realize the performance prediction simulator, which takes a feature vector S n as input, and predicts the comprehensive performance score of the large language model after executing the corresponding sub-task through the built-in regression model; the regression model is trained based on historical execution data of complex tasks, and the execution data contains the corresponding relationship between the state feature vector of the sub-task and the real execution performance score;

[0027] The decomposition controller compares the predicted comprehensive performance score output by the performance prediction simulator with a preset performance threshold, and if the preset performance threshold is reached, the task decomposition is stopped, and the real-time reward remains unchanged; otherwise, each newly generated sub-task node is executed (S2.1), and the reward is calculated according to the reward function based on the predicted comprehensive performance score.

[0028] Further, the S3 is realized by the following sub-steps:

[0029] (S3.1) Extracting domain core terms as keywords of the corresponding sub-task from each sub-task text through a weighted statistical method for information retrieval and text mining;

[0030] (S3.2) Taking the description of the sub-task and the keywords as input of the large language model, and generating a natural and fluent question sentence that meets the task requirements according to the sub-task constraint condition; the description of the sub-task includes the task objective and the constraint condition;

[0031] (S3.3) converting the question sentence into a structured instruction in the form of <action verb, target object, modification condition> through an operation instruction encoder; the operation instruction encoder adopts a hybrid system based on rules and models;

[0032] The rule-based system generates structured instructions using predefined rules and templates;

[0033] The model-based system generates structured instructions using a large language model, and the large language model generates structured instructions according to the input task description, keywords and question sentence.

[0034] Further, the weighted statistical method for information retrieval and text mining adopts the term frequency-inverse document frequency algorithm.

[0035] Further, in the S4, the logical association between the sub-tasks is obtained by combining the semantic analysis result obtained in the S1 in the form of conjunctions, logical operators and conditional statements.

[0036] The conjunctions are used to represent the execution order relationship between the sub-tasks; the logical operators are used to represent the logical relationship between the sub-tasks; and the conditional statements are used to represent the execution conditions of the sub-tasks.

[0037] Further, the S5 is implemented by the following sub-steps:

[0038] (S5.1) According to the task prompt words and the execution order, the sub-tasks in the current batch are executed by a large language model to generate corresponding execution results;

[0039] (S5.2) According to the execution results of the current sub-tasks, the task prompt words of all the sub-tasks that have a logical association with the current sub-tasks are updated in an incremental manner;

[0040] (S5.3) Repeat (S5.1)-(S5.2) until all the sub-tasks are executed.

[0041] The beneficial effects of the present application are:

[0042] The present application decomposes a complex task into multiple sub-tasks with logical association by using a dynamic decomposition strategy and multi-level prompt word generation. Meanwhile, the present application dynamically adjusts the prompt words of the subsequent sub-tasks according to the results of the previous sub-tasks, so that the large language model can better adapt to the changes of the complex task. In addition, by using the semantic fusion technology, the present application can effectively integrate the results of the sub-tasks to generate a coherent final result. The present application is suitable for various complex task scenarios such as multi-step reasoning tasks and cross-domain knowledge fusion tasks, and realizes stable and adaptive multi-level prompt word generation for different complex tasks. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1 is a flowchart of the multi-level prompt word generation method for complex tasks in the embodiments of the present application.

[0044] Figure 2 is a flowchart of the decomposition of complex tasks in the embodiments of the present application. DETAILED DESCRIPTION

[0045] The purpose and effect of the present application will become more apparent from the following detailed description of the preferred embodiments of the present application in conjunction with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0046] As Figure 1As shown, a multi-level prompt generation method for complex tasks includes the following steps:

[0047] S1: Complex task analysis.

[0048] This step is the basis of the entire method, aiming to identify the key elements of the task through in-depth analysis of the complex task, providing guidance for subsequent subtask decomposition and prompt generation. This is achieved through the following sub-steps:

[0049] (S1.1) Task text semantic parsing: Collect text data related to the complex task, use natural language processing techniques to parse the text data semantically, extract the complexity characteristics and key information of the complex task; on the other hand, through semantic parsing, determine the logical structure of the complex task, identify the main logical units in the complex task and the relationship between the main logical units, providing the basis for subsequent subtask decomposition.

[0050] Among them, the complex task includes: multi-step reasoning task, cross-domain knowledge fusion task, complex text generation task. The listed various complex tasks at least include one of the following situations: the written prompt is too long, exceeding the input length limit of the large language model; the output required by the task is too long, exceeding the long-term memory limit of the large language model; the large language model performs poorly, regardless of how the prompt is adjusted, the performance of the large language model cannot meet expectations.

[0051] Text data related to the complex task includes: task description, user requirement document, domain knowledge base, etc.

[0052] Natural language processing techniques include: word segmentation, part-of-speech tagging, dependency syntax analysis, etc.

[0053] The key information of the complex task includes: task target and corresponding operation steps.

[0054] (S1.2) Based on the results of semantic parsing, output task triples, task triples include: task type, target element, constraint condition.

[0055] Task triples serve as important guidance information for subsequent subtask decomposition and prompt generation, ensuring the logicality and goal orientation of the entire complex task processing process. Among them, the task type is the overall category of the complex task (i.e. multi-step reasoning task or cross-domain knowledge fusion task or complex text generation task); the target element specifies the specific goal that the complex task needs to achieve, such as generating a specific format of text, solving a specific problem, etc.; the constraint condition limits the rules or conditions that must be followed when completing the complex task, such as time limit, resource limit, etc.

[0056] In this embodiment, the complex task of "diagnosing the current fault cause of a certain type of CNC machine tool based on historical maintenance logs and fault description texts and generating a detailed maintenance report" is taken as an example. In the text data related to this complex task, the task description is: "analyze recent machine tool downtime reports (text description), compare with historical maintenance database (text record), determine the current most likely fault cause, and generate a detailed report containing fault location, cause analysis, maintenance steps and suggestions." Through semantic analysis, the key verbs "analyze", "compare", "determine" and "generate" and the nouns "downtime report", "fault cause" and "detailed report" are extracted. The final output task triple is:

[0057] Task type: multi-step reasoning task (involving text understanding, information retrieval, causal reasoning, report generation)

[0058] Target element: output a structured fault diagnosis and maintenance report.

[0059] Constraint condition: input is text information (current fault description, historical maintenance log), need to quote historical cases to support diagnosis conclusion, report format needs to be standardized.

[0060] S2: Complex task decomposition.

[0061] Complex task decomposition is the process of decomposing a complex task into multiple subtasks with logical association, which is a key step to improve task processing efficiency and accuracy. As shown in Figure 2 , S2 is implemented through the following sub-steps:

[0062] (S2.1) Perform task decomposition: according to the task triple, combine dynamic decomposition strategy to decompose the complex task into multiple subtasks. Each subtask has a clear target and constraint condition (task target and constraint condition are the subtask description corresponding to this subtask), and there is a logical association between subtasks. Among them, the dynamic decomposition strategy is realized by a decomposition controller based on reinforcement learning. The decomposition controller is modeled as a Markov Decision Process (MDP) to adaptively determine the decomposition depth and granularity of subtasks during complex task decomposition to optimize the effect of task decomposition.

[0063] MDP is used to describe the decision-making process of decision-makers in an uncertain environment. It consists of five core elements: state space (S), action space (A), state transition probability (P), reward function (r) and discount factor (γ); these elements together define the interaction process between the decision-maker and the environment.

[0064] Specifically, the state space S of the decomposition controller is composed of the feature vector S n of the current task node n, and the feature vector Sn Including the following three categories of quantifiable metrics: Complexity metric C n Performance index P n Resource indicator R n Complexity metric C n This includes text length L, domain overlap D (e.g., the number of disciplines involved), and the number of logical units U. Performance metrics P n This refers to the historical execution results on the preceding subtasks, including the BLEU score and factual consistency score F between the large language model output and the reference answer. Resource metric R n Includes: the total amount T of consumed tokens (the smallest unit or basic element for processing text). used The remaining total amount of tokens that can be generated, T left In one specific embodiment, S n It can be represented as: S n =[C n ,P n ,R n ]=[L,D,U,BLEU,F,T used ,T left ].

[0065] In the action space A of the decomposer controller, discrete action a includes: decompose action a1 and stop action a2. Decompose action a1 is used to split the current task node n into m finer-grained sub-task nodes {n1, n2, ..., n}. m}, where m≥2. The stop action a2 is used to terminate further decomposition of the current task node n, directly taking the last subtask node before the stop action as the final subtask that can be executed all at once by the large language model (i.e., the output of S2). In an optional implementation, when action a1 is triggered, the decomposition controller further outputs a split dimension identifier d, where d's value range includes "split by domain", "split by step", or "split by data subset".

[0066] Decompose the reward function r(S) of the controller n a) Used for quantization in feature vector S n The immediate benefit (i.e., reward) of the discrete action a actually performed in the state is defined as follows: if the discrete action a = a2 = STOP, and the large language model satisfies the preset performance threshold θ after executing the current task node n. stop If the discrete action a = a1 = DECOMPOSE, and all subtask nodes {n1, n2, ..., n} are... mIf the overall performance score of} is higher than the performance score of the parent node n, then r = +0.5; if the discrete action a = a1 = DECOMPOSE, and causes a logical break between any two child task nodes (e.g., child task node n) i The output cannot be passed to subtask node n j If used as valid input, i = 1, 2, ..., m, j = 1, 2, ..., m, and i ≠ j, then r = -1. In other cases (e.g., a = a1 = DECOMPOSE, no logical break occurs, but θ cannot be satisfied), then r = -1. stop If r=0, then r=0, and it is returned to the decomposition controller to calculate the policy objective function J(θ). J(θ) will retain the maximum value calculated each time. When r=0, the calculated J(θ) will obviously not be larger than the previous one. At this time, the policy network reselects the action of this node, such as modifying the number of subtasks decomposed.

[0067] Policy Network and Training Method: Decomposing the Controller into a Policy Network π θ (a|S n ), where θ represents the network parameters. Policy network π θ The Proximal Policy Optimization (PPO) algorithm is used for training, which consists of two stages: offline pre-training and online fine-tuning. ① In the offline pre-training stage, a training set is constructed using historical complex tasks and their manually labeled decomposition results, with the policy objective function... As a training optimization metric, the policy objective function J(θ) is defined as a performance measure under the long-term cumulative discount reward expectation, where the subscript t represents the t-th decision step, γ is a manually set discount factor (0 < γ ≤ 1), and r(t) represents the "instant reward" given to the decomposition controller by the environment at the t-th step; J(θ) retains the maximum value calculated each time. In this stage, the PPO algorithm iteratively updates the network parameters θ, increasing the value of the policy objective function J(θ) until it reaches the preset convergence threshold or the maximum number of iterations, thus completing this stage of training and ensuring that the expected total reward obtained by the task decomposition policy is maximized during long-term operation. ② The online fine-tuning stage is executed after each complete task decomposition; specifically, during actual task execution, the instant reward is adjusted based on real-time user feedback, and the policy network π is adjusted through importance sampling. θ Incremental updates are performed. In one optional implementation, the policy network π θ The MLP (Multilayer Perceptron) architecture is used, where the input dimension is equal to the state space dimension |S|. n The output dimension equals the action space dimension |A|.

[0068] A complete strategy network interacts with the user as follows:

[0069] ① Strategy network π θ Output a complete decomposition trajectory on the current task: , S T denotes the state at time step T, denotes the action instance executed at step T, i.e., the action actually executed by the strategy network at time step t; at the same time, the intermediate results and final answers of each step are presented to the user.

[0070] ② The user gives implicit or explicit feedback, which is represented by Δr. Explicit feedback includes: scoring, written comments. Implicit feedback includes: retry, cancel, etc.

[0071] ③ Only the user feedback signal Δr is superimposed on the reward of each step of the complete decomposition trajectory to obtain the final instant reward for PPO (or obtain the instant reward by weighted superposition, truncated superposition, etc.); The value of Δr is predetermined according to different user actions, generally not more than ±0.5.

[0072] ④ PPO uses (state S t at time step t, the action actually executed by the strategy network at time step t,

[0073] The online fine-tuning does not affect the execution result of the current task, and the decomposition of the decomposition controller itself can guarantee the completion degree of the task. The collection of user feedback is to make the parameters θ converge to a new local optimum, improve the decomposition efficiency of the new task in the future, and be closer to the user's preference.

[0074] In the decomposition controller, the definition of state transition probability P is: the probability of the environment transitioning to a new state s' after executing action a in state s, P(s'|s,a)=Pr{S t+1 =s'|S t =s,A t =a}, where Pr{} represents the probability of an event occurring, S t denotes the random state variable at time step t, A trepresents the random action variable performed at time t. When the training algorithm adopts a model-free reinforcement learning framework such as Proximal Policy Optimization (PPO), the parameter update of the policy network only depends on the (s, a, r, s') samples returned by the environment in real time, without the need for explicit storage or numerical calculation of the state transition probability P(s'|s,a). The state transition probability P(s'|s,a) is only conceptually described as a feedback mechanism of the environment to the policy network: when the action a is STOP, the system enters the terminal state, and the next state s' is a deterministic absorbing state, corresponding to a probability value of 1; when the action a is DECOMPOSE, the system generates a new set of subtask nodes according to the task content, decomposition strategy, estimated performance of subtasks, and resource consumption, resulting in a probability distribution over the state space S rather than a single deterministic value.

[0075] (S2.2) Perform performance analysis on all subtasks obtained by the current decomposition. If the simulated performance of the large language model on all subtasks obtained by the current decomposition reaches the preset performance threshold θ stop , then stop task decomposition, otherwise perform (S2.1) for each newly generated subtask node.

[0076] Perform performance analysis on subtasks, which is realized by a lightweight performance prediction simulator trained offline. The performance prediction simulator takes the feature vector S n of the state space as input and predicts the comprehensive performance score of the large language model after executing the corresponding task node through an embedded regression model (such as gradient boosting decision tree or small neural network); this regression model is trained based on historical complex task execution data, which contains a large number of corresponding relationships between state feature vectors of subtasks and their real execution performance scores (i.e. comprehensive performance scores such as accuracy, BLEU value or manual score). In the MDP modeling of the decomposition controller, when the potential benefits of a specific action (especially the STOP action) need to be evaluated, the performance prediction simulator is called in real time: after inputting the state vector of the current task node, the performance prediction simulator outputs the predicted comprehensive performance score (such as diagnostic accuracy, report standardization), and the decomposition controller judges whether the performance of this node can meet the preset performance threshold if the decomposition is stopped at this node, thereby providing immediate and quantitative calculation basis for the reward function; specifically, if the node performance meets the preset threshold, task decomposition is stopped and the reward remains unchanged; if it is not possible to meet the preset threshold, return to (S2.1) and perform reward calculation based on the performance score predicted in (S2.2) according to the reward function r. This mechanism enables the reinforcement learning agent to reliably estimate the consequences of decisions before incurring real computational costs, which is a key component for optimizing efficient and goal-oriented decomposition strategies.

[0077] Cold start problem: At the beginning of the method execution, when there is a lack of historical data to train the performance prediction simulator, the decomposition controller adopts a phased startup strategy, including an initial stage and a second stage. In the initial stage, the decomposition controller relies on a set of predefined heuristic rules for decision-making, such as: "When the task text length is below the empirical threshold, the domain crossing degree is 1, and the number of logical units is 1, tend to choose the STOP action; otherwise, choose the DECOMPOSE action." In this stage, all sub-tasks need to be executed in reality, and the real performance scores after execution and the corresponding task state features are recorded together to build an initial training data set. With the accumulation of task execution times, when the data volume is sufficient to train a preliminary performance prediction simulator, the system switches to the second stage, i.e., starts and gradually optimizes the above-mentioned performance prediction simulator. Thereafter, the decomposition controller decision-making transitions from relying on rules to relying on performance prediction simulator prediction, entering a self-optimizing positive cycle, thus achieving a smooth transition.

[0078] The decomposition stage only uses the prediction model to give an estimate of the overall performance score, and only when the strategy network finally determines the optimal decomposition trajectory is the operation of actually executing the final decomposition trajectory prepared. This not only solves the data deficiency of cold start, but also reduces the average token consumption.

[0079] In this embodiment, the text fault diagnosis task of S1 is taken over, and how the decomposition controller makes decisions for the numerical control machine tool text diagnosis task is described in detail.

[0080] Initial state space S0 setting: the controller quantizes the root task node n (diagnose faults and generate reports) to generate quantitative indicators. Among them, the complexity indicator C n includes: text length L=75 (characters) quantified by character number; domain crossing degree D=3, specifically involving mechanical engineering, electrical engineering, and numerical control programming; logical unit number U=5, specifically including: fault description, history retrieval, reason inference, scheme generation, and report synthesis. Performance indicator P n In the initial state, since there is no historical execution result, BLEU=0, F=0. The initial value of the resource indicator R n is set as: T used =0, T left =8000 (assuming total budget). In summary, in the initial state, the feature vector S0=[75, 3, 5, 0, 0, 0, 8000].

[0081] Action selection and execution: the strategy network π θUpon receiving S0, the computed output selects action a = a1= DECOMPOSE. Meanwhile, the decomposition controller outputs the split dimension identifier d = "step-wise split", and the root task is split into five sub-task nodes {n1, n2, n3, n4, n5}: n1 (critical information extraction): extract critical fault phenomena, alarm codes, abnormal descriptions, etc. from the current shutdown report text; n2 (historical case retrieval and matching): based on the extracted critical information, retrieve and match the most similar historical fault case from the historical maintenance database; n3 (fault reason reasoning): compare the current fault phenomena with the historical case for causal analysis and infer the most likely fault reason; n4 (maintenance scheme generation): generate specific maintenance steps, required tools, and precautions according to the inferred fault reason; n5 (report synthesis): integrate all previous results to generate a structured and formatted diagnostic report.

[0082] Reward computation: The decomposition controller simulates the execution of this decomposition. First, due to the step-wise split, the logical chain between sub-tasks is clear (n1→n2→n3→n4→n5), and no logical break occurs. In addition, performance analysis of the sub-tasks shows that this step-by-step processing significantly improves the overall performance score compared to directly processing the original task. Therefore, according to the reward function, this decomposition action receives an immediate reward r = +0.5.

[0083] Iterative decomposition and stop action: The decomposition controller does not stop here, but continues to evaluate the state of each newly generated sub-task node to determine whether to further decompose. For example, the next state evaluation is performed on sub-task n3 (fault reason reasoning) : The state vector is: [31, 2, 1, 0, 0, 2500, 5500]. The policy network π θ After evaluation, it is considered that the decomposition granularity of this task is sufficient and the complexity is low enough, and the simulation accuracy of direct execution is higher than the preset performance threshold θ stop = 90%, so the output action a = STOP. If the subsequent real execution of this sub-task indeed meets the performance requirements, then this STOP action will receive a reward r = +1.

[0084] Finally, by repeatedly executing the above MDP process on multiple sub-task nodes, the decomposition controller adaptively constructs a decomposition tree. Among them, complex nodes (such as n) are decomposed, while simple nodes (such as n3) are retained as the final sub-task. The goal of the entire process is to maximize the long-term cumulative discounted reward (i.e. ), thereby ensuring that the decomposition result achieves the optimal balance in terms of logicality, performance, and resource consumption.

[0085] S3: Task prompt word generation.

[0086] For each subtask, a targeted task prompt word is constructed, including keywords, question patterns, structured instructions, and other elements, to ensure that the model can accurately understand and execute the subtask. This is achieved through the following sub-steps:

[0087] (S3.1) Determine the keywords for each subtask.

[0088] Keywords are used to define the core content of the subtask, helping the large language model focus on the key information of the task. By using a weighted statistical method for information retrieval and text mining, domain core terms are extracted from the task text as keywords.

[0089] In this embodiment, the weighted statistical method for information retrieval and text mining uses the Term Frequency-Inverse Document Frequency (TF-IDF) algorithm, which is used to evaluate the importance of a word to a document set or a document in a corpus. Through the TF-IDF algorithm, core terms in the task text can be extracted as keywords, which can represent the main content and domain characteristics of the task.

[0090] In this embodiment, the prompt word generation for "subtask n2 (historical case retrieval and matching)" is taken as an example. The keywords "historical maintenance database", "retrieve", "match", "similarity", and "fault phenomenon" are extracted from the subtask description.

[0091] (S3.2) Generate question patterns.

[0092] Question patterns are used to guide the large language model to think about the subtask, and through the large language model, the subtask description and the keywords extracted in S3.1 are input into the large language model, and a natural and fluent guiding sentence (i.e., the question pattern) that meets the task requirements is generated according to the subtask context (i.e., the subtask constraint condition), adapting to different task requirements.

[0093] In this embodiment, the generated question pattern is: "Please retrieve the most similar past cases from the historical maintenance database based on the current fault phenomenon ({phenomenon description extracted from subtask n1}). Please list the top 3 matching cases by number, main phenomenon, and final cause."

[0094] (S3.3) Generate structured instructions.

[0095] Structured instructions are used to clearly show the operation steps and constraints of the subtask. By using an operation instruction encoder, the question pattern generated in S3.2 is converted into a structured instruction in the form of <action verb, target object, modification condition> to clearly show the operation steps and constraints of the subtask.

[0096] The operation instruction encoder adopts a hybrid system based on rules and models. The rule-based system uses predefined rules and templates to generate structured instructions, for example, according to the task type and the keywords determined in S3.1, a suitable template is selected to generate a structured instruction. The model-based system uses a machine learning model (such as a large language model) to generate a structured instruction, and the large language model generates a structured instruction according to the input task description, keywords, and question patterns. The hybrid system retains the explicitness of rules and utilizes the flexibility of models.

[0097] In this embodiment, the generated structured instruction is: <retrieve and match target objects, historical fault cases, output the top 3 case summaries with the highest similarity based on the current fault phenomenon>.

[0098] S4: Logical association establishment.

[0099] The logical association network across sub-tasks is established to ensure the logicality, coherence, and accuracy of the task processing process. The establishment of the logical association network across sub-tasks specifically includes: using conjunctions, logical operators, conditional statements, etc., in combination with the semantic parsing results obtained in S1, to clearly define the logical association between sub-tasks; the logical association includes: execution order, logical constraints (i.e. conditional constraints), dependency relationships, etc. According to the logical association between sub-tasks, a logical association network across sub-tasks is constructed, which provides a complete logical framework for task processing.

[0100] Among them, conjunctions are used to represent the execution order relationship between sub-tasks, such as "first", "then", "last", etc. Predefined templates such as: "first execute sub-task n1, then execute sub-task n2, and finally execute sub-task n3".

[0101] Logical operators are used to represent the logical relationship between sub-tasks, such as "and", "and", "or", "not", etc. Predefined templates can define rules such as "only when sub-task n1 and sub-task n2 are successfully completed, execute sub-task n3". For conditional statements, structures similar to "if the result of sub-task n1 meets condition X, then execute sub-task n2" can be used.

[0102] Conditional statements are used to represent the execution conditions of sub-tasks, such as "if … then …" etc.

[0103] In this embodiment, there is a strict order dependency and data flow between sub-tasks. The execution order must first execute sub-task n1, then execute sub-task n2, then execute sub-task n3, then execute sub-task n4, and finally execute sub-task n5.

[0104] The conditional statement takes the prompt word template of subtask n3 as an example: "Given: the current fault phenomenon is {X}, the most similar historical case retrieved is {Y}, and the cause is {Z}. Please perform: analyze the differences between the current fault and case Y, and infer the most likely cause."

[0105] The logical constraints and dependencies obtained are: the execution of subtask n2 depends on the output of subtask n1 (extracted key phenomena). The execution of subtask n3 depends on the output of subtask n1 and the output of subtask n2 (matched past cases). The execution of subtask n4 depends on the output of subtask n3 (inferred fault cause). The input of subtask n5 is the output of all previous subtasks.

[0106] S5: Subtask execution.

[0107] Subtask execution is the process of applying the generated task prompts to actual task processing, and is the core step to realize complex task processing. It is realized through the following sub-steps:

[0108] (S5.1) Execute subtasks.

[0109] According to the multi-level subtask prompts obtained in S3 and the cross-subtask logical association network obtained in S4, each batch of subtasks is executed in turn. For the current subtask, during execution, the large language model accurately understands and executes the requirements of the subtask according to the task prompt, generating the corresponding execution result.

[0110] In this embodiment, subtask n1 is used to extract key phenomena from the description "Machine tool frequently appears 430 alarm during machining process, accompanied by violent vibration", and the execution result is: "Fault phenomenon is 'Z-axis violent vibration', alarm code is '430'".

[0111] (S5.2) Dynamically update prompts.

[0112] According to the execution result of the current subtask, modify the task prompts of all subsequent subtasks that have logical association with it. Further, in the process of dynamically updating the prompts, an incremental updating method can be used. If the result of subtask n1 is "X=5", add the information "Given X=5" to the prompt of subtask n2 to ensure that subtask n2 can be accurately executed based on the latest information. This dynamic updating mechanism can make the prompts of subsequent subtasks fully reflect the execution results of the current subtask, thereby improving the adaptability and flexibility of the large language model to task changes.

[0113] In this embodiment, the task prompt of subtask n2 is dynamically embedded with the execution result of subtask n1, and the task prompt of subtask n2 is updated as: "Please retrieve the most similar past case from the historical maintenance database based on the current fault phenomenon (Z-axis severe vibration) and alarm code (430)."

[0114] Subsequently, the task prompt of subtask n3 will be updated as "Given the current fault phenomenon: Z-axis severe vibration, alarm code 430; the most similar historical case: #2023-045 (Z-axis 430 alarm with vibration), the recorded cause is'servo motor encoder feedback fault'. Please perform: analyze and infer the most likely cause." The execution result of subtask n3 is: "After comparison and analysis, the most likely cause of the current fault is: abnormal servo motor encoder feedback signal."

[0115] The prompt of subtask n4 (maintenance plan generation) is dynamically updated as: "Given the current fault phenomenon: Z-axis severe vibration, alarm code 430; the most similar historical case: #2023-045 (Z-axis 430 alarm with vibration); inferred cause: abnormal servo motor encoder feedback signal. Please perform: based on the above information, generate a directly executable maintenance plan. Requirements: ① List the operation sequence in steps; ② Note the required tools or spare parts for each step; ③ Provide key notes and safety tips."

[0116] The execution result of subtask n4 is: "Maintenance plan: Z-axis servo motor encoder feedback signal abnormal, operation sequence: ① Power off: turn off the machine tool main power, hang the "under repair" warning sign; required tools: none. ② Visual inspection: check the appearance of the servo motor and encoder connection line for damage or looseness. Required tools: flashlight, hexagonal wrench. Notes: wear anti-static gloves. ③ Encoder signal detection: use an oscilloscope to measure the A / B / Z signal waveform of the encoder; the normal waveform should be a 5V TTL square wave, otherwise proceed to the next step. Required tools: oscilloscope, BNC probe, test line. ④ Encoder replacement or re-plug: if the waveform is missing or distorted, try re-plugging the encoder connector first; if it is still abnormal, replace the entire encoder of the same type. Required spare parts: same specification incremental encoder (model: 6FX2001-5FP12). Notes: record the original encoder zero point offset value, and re-calibrate after replacement. ⑤ Zero point calibration and function test: enter the machine tool parameter interface and execute the Z-axis zero point calibration program; low-speed zero return, confirm that there is no alarm and run empty for 5 minutes. Required tools: machine tool operation panel. ⑥ Delivery confirmation: confirm with the operator that the vibration is eliminated and the 430 alarm is gone; fill out the "on-site maintenance record sheet" and archive it."

[0117] The subtask n5 is a report synthesis. Since the subtask only performs integration and output, it does not contain new reasoning or retrieval operations, so its task prompt word adopts a fixed template and is no longer dynamically updated with the changes in the results of the preceding subtasks.

[0118] The large language model performs reasoning accordingly, thereby ensuring the coherence and accuracy of the diagnostic process, and finally generates a traceable diagnostic report.

[0119] (S5.3) Repeat (S5.1)-(S5.2) until all subtasks are completed.

[0120] S6: Semantic fusion.

[0121] Semantic fusion is a step of integrating the execution results of each subtask to generate a coherent final result. It is achieved through the following sub-steps:

[0122] (S6.1) Semantic analysis of the execution results of subtasks.

[0123] Natural language processing techniques are used to perform semantic analysis on the execution results of each subtask, extracting key information from the execution results to provide a basis for subsequent information integration.

[0124] (S6.2) Integration of key information.

[0125] According to the logical association between subtasks, the extracted key information of each execution result is integrated. In the integration process, the order relationship, dependency relationship and conditional constraints between subtasks are fully considered to ensure that the integrated information has logical coherence and consistency.

[0126] (S6.3) Generation of coherent final results.

[0127] Through natural language generation technology, the integrated information is converted into coherent final results. Natural language generation technology can generate natural and fluent text content that conforms to language habits based on the integrated information, serving as the final output of the task. In generating coherent final results, coherence checking algorithms in natural language processing technology, such as a coherence scoring system based on a graph model, can be used to ensure that the final results are logically coherent and clearly expressed.

[0128] Through the above steps, the application provides a multi-level prompt word generation method for complex tasks of a system, which is suitable for various complex task scenarios such as multi-step reasoning tasks, cross-domain knowledge fusion tasks, complex text generation tasks, and has high flexibility and scalability. Through the dynamic decomposition strategy, multi-level prompt word generation, cross-subtask logical association network establishment, dynamic prompt word updating and semantic fusion technology, the processing efficiency and accuracy of the complex task are significantly improved, and strong support is provided for the processing of the complex task.

[0129] Those skilled in the art can understand that the above description is only preferred examples of the application and is not used to limit the application, although the application is described in detail with reference to the foregoing examples, those skilled in the art can still modify the technical solutions recorded in the foregoing examples or make equivalent replacement for part of the technical features. Any modification, equivalent replacement, etc. made within the spirit and principles of the application shall be included in the protection scope of the application.

Claims

1. A method for generating multi-level prompt words for complex tasks, characterized in that, Includes the following steps: S1: Analyze complex tasks through semantic parsing and output task triples, which include: task type, target element, and constraints. S2: Based on the task triples and combined with the dynamic decomposition strategy, the complex task is decomposed into multiple logically related subtasks. S3: Task prompt word generation: Based on the characteristics of the sub-tasks, construct targeted task prompt words for each sub-task; the task prompt words include: keywords, question phrases, and instructions; S4: Establish a logical relationship network across subtasks to obtain the logical relationships between each subtask. The logical relationships include: execution order, dependency relationship, and constraint condition. S5: Subtask execution and prompt word update: Execute each subtask according to the task prompt words and execution order; and dynamically adjust the task prompt words of subsequent subtasks according to the result of the previous subtask. S6: Perform semantic parsing on the execution results of each subtask, extract key information from the execution results, integrate the key information from each execution result according to the logical relationship between the subtasks, and transform it into a coherent final result that conforms to language habits through natural language generation technology; S2 is specifically implemented through the following sub-steps: (S2.1) Perform task decomposition: Based on the task triples and combined with the dynamic decomposition strategy, the complex task is decomposed into multiple logically related subtasks; the description of each subtask includes the task objective and constraints; the dynamic decomposition strategy is implemented based on a reinforcement learning decomposition controller, which is modeled with a Markov decision process and is used to adaptively determine the decomposition depth and granularity of the subtasks during the decomposition of complex tasks in order to optimize the effect of task decomposition. (S2.2) Perform performance analysis on all subtasks obtained from the current decomposition. If the comprehensive performance score of the large language model on all subtasks obtained from the current decomposition reaches the preset performance threshold, then stop the task decomposition; otherwise, execute (S2.1) on each newly generated subtask node. The state space S of the decomposition controller is composed of the feature vector S of the current task node n. n Composition; In the workspace A of the decomposition controller, discrete action a includes: decomposition action and stopping action; The reward function r(S) of the decomposition controller n a) Used to quantify in state S n The immediate benefit of executing discrete action 'a' is calculated as follows: If the discrete action is a stopping action and the predicted comprehensive performance score of the large language model for the current subtask meets the preset performance threshold, then r = +1; if the discrete action is a decomposition action and the predicted comprehensive performance score of all subtask nodes is higher than the performance score of the parent node, then r = +0.5; if the discrete action is a decomposition action and causes a logical break between any two subtask nodes, then r = -1; otherwise, r = 0.

2. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, In S1, the analysis of complex tasks specifically involves: using natural language processing technology to perform semantic parsing on text data related to complex tasks, extracting complexity features and key information of complex tasks, determining the logical structure of complex tasks, and identifying the main logical units in complex tasks and the logical relationships between them. The complex tasks include: multi-step reasoning tasks, cross-domain knowledge fusion tasks, and complex text generation tasks; The text data related to the complex task includes: task description, user requirement document, and domain knowledge base; The natural language processing techniques include: word segmentation, part-of-speech tagging, and dependency parsing; The key information for the complex task includes the task objective and the corresponding operational steps.

3. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, The feature vector includes: complexity index C n Performance index P n Resource indicator R n The complexity index C n This includes: text length L, domain overlap D, and number of logical units U; the performance metric P n This includes: the BLEU score between the output of the large language model and the reference answer, the factual consistency score F; and the resource indicator R. n Includes: the total number of lexical units consumed, T used The remaining total number of generative units, T left ; The decomposition action is used to split the current task node n into m finer-grained sub-task nodes, where m ≥ 2. When the decomposition action is triggered, the decomposition controller also outputs a split dimension identifier, which includes: split by domain, split by step, and split by data subset. The stop action is used to terminate the further decomposition of the current task node and take each sub-task obtained from the decomposition of the current task as the output of S2.

4. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, The decomposition controller includes a policy network with network parameters θ; the policy network is trained using a proximal policy optimization algorithm, and the training includes two stages: an offline pre-training stage and an online fine-tuning stage. In the offline pre-training stage, a training set is constructed using historical complex tasks and their manually labeled decomposition results. The policy objective function J(θ) is used as the training optimization index. The policy objective function is a performance measure under the long-term cumulative discount reward expectation, and the maximum value of each calculation is retained. The network parameter θ is iteratively updated using a proximal policy optimization algorithm to increase the value of the policy objective function until a preset convergence threshold or maximum number of iterations is reached, thus completing this stage of training. During the online fine-tuning phase, in the actual task execution process, the instant reward is adjusted based on real-time user feedback, that is, the real-time user feedback signal is superimposed on the initial reward. The superposition methods include: direct superposition, weighted superposition, and truncated superposition; and the policy network is incrementally updated through importance sampling.

5. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, Performance analysis is performed on all subtasks obtained from the current decomposition, using an offline-trained performance prediction simulator. The performance prediction simulator uses feature vector S... n As input, the built-in regression model predicts the comprehensive performance score of the large language model after performing the corresponding sub-task; the regression model is trained based on the execution data of historical complex tasks, and the execution data includes the correspondence between the state feature vector of the sub-task and its actual execution performance score. The decomposition controller compares the comprehensive performance score predicted by the performance prediction simulator with a preset performance threshold. If the preset performance threshold is reached, the task decomposition stops and the immediate reward remains unchanged. Conversely, for each newly generated subtask node, (S2.1) is executed, and the reward is calculated based on the predicted comprehensive performance score according to the reward function.

6. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, S3 is specifically implemented through the following sub-steps: (S3.1) Using weighted statistical methods for information retrieval and text mining, core domain terms are extracted from the text of each subtask and used as keywords for the corresponding subtask; (S3.2) The description of the subtask and the keywords are used as input to the large language model, and a natural and fluent question sentence that meets the task requirements is generated according to the constraints of the subtask; the description of the subtask includes the task objective and constraints. (S3.3) The problem sentence is transformed into a structured instruction in the form of <action verb, target object, modifying condition> by an operation instruction encoder; the operation instruction encoder adopts a hybrid system based on rules and models; Rule-based systems use predefined rules and templates to generate structured instructions; Model-based systems use large language models to generate structured instructions. The large language model generates structured instructions based on the input task description, keywords, and question format.

7. The multi-level prompt word generation method for complex tasks according to claim 6, characterized in that, The weighted statistical method used for information retrieval and text mining employs the term frequency-inverse document frequency algorithm.

8. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, In S4, the logical relationships between the various subtasks are obtained by combining the semantic parsing results obtained in S1 with the form of connectives, logical operators, and conditional statements. The connector is used to indicate the execution order relationship between subtasks; the logical operator is used to indicate the logical relationship between subtasks. The conditional statement is used to indicate the execution conditions of the subtask.

9. The multi-level prompt word generation method for complex tasks according to claim 1, characterized in that, S5 is specifically implemented through the following sub-steps: (S5.1) Based on the task prompts and execution order, execute the sub-tasks of the current batch through the large language model and generate the corresponding execution results; (S5.2) Based on the execution result of the current subtask, update the task prompts of all subsequent subtasks that are logically related to the current subtask using an incremental update method; (S5.3) Repeat (S5.1)-(S5.2) until all subtasks have been completed.

Citation Information

Patent Citations

  • Cue word layered optimization method for complex problem decomposition

    CN120234399A