A large language model-oriented instruction optimization method, device, equipment and medium

By generating a directed acyclic graph through semantic parsing and logical reconstruction, optimizing resource utilization, and self-correcting in a sandbox environment, the problems of resource waste and execution instability in the construction of large language model skills are solved, and efficient and stable instruction optimization is achieved.

CN123157261APending Publication Date: 2026-11-24BEIJING YOUHANG INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611073966.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-17
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing technologies for building skills or intelligent agents based on large language models suffer from high resource consumption, high logic execution failure rates, and poor system stability. This is mainly due to the retention of redundant text and the lack of deep semantic logic parsing, which leads to increased token consumption, increased computational complexity, and frequent execution errors.

Method used

By extracting key elements through semantic parsing, constructing a directed acyclic graph for logical reconstruction and resource optimization, generating optimized logical flow data, and simulating execution and self-correction in a sandbox environment, a closed-loop self-healing mechanism is formed, generating standardized skill configuration files that can be parsed by machines.

Benefits of technology

It effectively reduces token consumption and API call costs, improves the stability and success rate of complex tasks, optimizes resource utilization, and enhances the system's automatic correction capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157261A_ABST
    Figure CN123157261A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, device, and medium for instruction optimization for large language models. The method includes: receiving unstructured natural language text input by a user; performing semantic parsing on the natural language text and extracting key elements; logically reconstructing based on the extracted key elements to construct a directed acyclic graph (DAG) representing the execution order between task nodes; optimizing and scheduling the task logic flow in the DAG to generate optimized logic flow data; mapping the optimized logic flow data to a predefined skill template library to generate a machine-parseable standardized skill configuration file; and sending the skill configuration file into a sandbox environment for simulated execution and self-correction until successful simulation, outputting the final skill configuration file. This invention can automatically convert natural language descriptions from ordinary users into structurally rigorous, low-resource-consumption, and directly executable instruction configuration files, thereby lowering the development threshold for AI applications and improving operational efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to an instruction optimization method, apparatus, device, and medium for large language models. Background Technology

[0002] With the rapid development of large language model technology, the construction of agents and skills based on large language models has become an important direction for artificial intelligence applications. Users can express their desired functional requirements to the system through natural language descriptions, and the system then transforms these descriptions into instruction configurations that can be understood and executed by the large language model. Currently, the construction of skills or agents based on large language models mainly relies on manually written prompt words or the use of simple keyword-based template matching tools. Developers need to manually transform user requirements into structured prompt word templates, or match and fill in user input using preset keyword rules to generate corresponding skill configurations.

[0003] However, existing technical solutions have significant drawbacks. First, regarding resource consumption, current template matching techniques typically retain the user's input natural language text as part of the context. Since user descriptions often contain a large amount of redundant information (such as subjective modifiers like "please help me," "best," and "thank you"), this invalid text is directly fed into the large model for inference. According to the principles of the Transformer architecture, the length of the input sequence is positively correlated with computational complexity. Therefore, this "preservation" of redundant text directly leads to an unnecessary increase in token consumption, not only increasing API call costs but also crowding out the limited context window. This makes the model more prone to forgetting key instructions when processing long tasks, resulting in resource waste and high computational costs.

[0004] Secondly, in terms of logic execution, existing technologies mainly rely on flat keyword extraction, lacking logical parsing of the deep semantics of the text. When user descriptions contain implicit dependencies (such as "analyze after data download"), existing systems cannot recognize such timing constraints, resulting in generated instructions that are often parallel or disordered. This leads to data races or null pointer errors when executing complex multi-step tasks, causing a high failure rate in logic execution. Furthermore, existing generation methods are typically "one-off," meaning that instructions are directly delivered for execution after generation. The lack of pre-verification of instruction logic during the generation phase (such as parameter integrity checks and interface permission checks) means that errors are often only discovered during actual runtime, preventing automated self-correction and severely impacting system stability.

[0005] Therefore, the problems of resource waste, high logic execution failure rate and poor system stability in the existing technology are technical problems that urgently need to be solved in this field. Summary of the Invention

[0006] The purpose of this application is to provide an instruction optimization method, apparatus, electronic device, and computer-readable storage medium for large language models, which can automatically convert natural language descriptions from ordinary users into instruction configuration files that are structurally rigorous, resource-efficient, and directly executable through computer programs, thereby reducing the threshold for AI application development and improving operational efficiency.

[0007] The first aspect of this application provides an instruction optimization method for large language models, including: Receive unstructured natural language text input from the user; Perform semantic analysis on the natural language text and extract key elements; Based on the extracted key elements, a logical reconstruction is performed to construct a directed acyclic graph representing the execution order between task nodes; Resource optimization and scheduling are performed on the task logic flow in the directed acyclic graph to generate optimized logic flow data; The optimized logical flow data is mapped to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine; The standardized skill configuration file is sent to a sandbox environment for simulation and self-correction until the simulation is successful, and the final skill configuration file is output.

[0008] In one possible implementation, the semantic parsing of the natural language text and the extraction of key elements includes: The natural language text is segmented, part-of-speech tagging is performed, and dependency parsing is conducted using a natural language processing model. Based on the results of the dependency parsing, the intent, triggering conditions, input parameter entities, output format constraints, and action verbs of the natural language text are extracted as the key elements.

[0009] In one possible implementation, the logical reconstruction based on the extracted key elements to construct a directed acyclic graph representing the execution order among task nodes includes: Identify the sequential dependencies, parallel relationships, or conditional branches among the extracted key elements; Transform the aforementioned sequential dependencies, parallel relationships, or conditional branches into a logical rule tree; Based on the aforementioned logical rule tree, a directed acyclic graph representing the execution order among task nodes is constructed.

[0010] In one possible implementation, the step of optimizing and scheduling the task logic flow in the directed acyclic graph to generate optimized logic flow data includes: Identify nodes in the task logic flow that have no dependencies and mark them for parallel scheduling; and / or, Identify recurring operation patterns in the task logic flow and abstract them into standard function calls.

[0011] In one possible implementation, the standardized skill configuration file is sent to a sandbox environment for simulated execution and self-correction until the simulation is successful, and the final skill configuration file is output, including: Simulate the execution of the standardized skill profile in an isolated sandbox environment and monitor the execution logs; When an exception is captured, a preset error pattern library is queried to generate a correction strategy corresponding to the exception. The key elements or logical flow data are adjusted according to the correction strategy, and the process returns to the step of generating standardized skill configuration files for regeneration until the simulation is successfully executed, forming a closed-loop self-healing mechanism.

[0012] In one possible implementation, the natural language processing model is a pre-trained large language model; the key elements also include temporal constraint information.

[0013] In one possible implementation, the standard function call refers to abstracting the recurring operation pattern into a unified standard function through function abstraction and reuse, and replacing the recurring operation pattern by calling the standard function in the task logic flow.

[0014] A second aspect of this application provides an instruction optimization apparatus for large language models, comprising: The semantic parsing module is used to receive unstructured natural language text input by the user; perform semantic parsing on the natural language text and extract key elements; The logic reconstruction module is used to perform logic reconstruction based on the extracted key elements and construct a directed acyclic graph representing the execution order between task nodes. The resource optimization module is used to optimize and schedule the task logic flow in the directed acyclic graph, and generate optimized logic flow data. The instruction generation module is used to map the optimized logic flow data to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine. The verification and correction module is used to send the standardized skill configuration file into the sandbox environment for simulation execution and self-correction until the simulation execution is successful and the final skill configuration file is output.

[0015] In one possible implementation, the semantic parsing module is specifically used for: The natural language text is segmented, part-of-speech tagging is performed, and dependency parsing is conducted using a natural language processing model. Based on the results of the dependency parsing, the intent, triggering conditions, input parameter entities, output format constraints, and action verbs of the natural language text are extracted as the key elements.

[0016] In one possible implementation, the logical refactoring module is specifically used for: Identify the sequential dependencies, parallel relationships, or conditional branches among the extracted key elements; Transform the aforementioned sequential dependencies, parallel relationships, or conditional branches into a logical rule tree; Based on the aforementioned logical rule tree, a directed acyclic graph representing the execution order among task nodes is constructed.

[0017] In one possible implementation, the resource optimization module is specifically used for: Identify nodes in the task logic flow that have no dependencies and mark them for parallel scheduling; and / or, Identify recurring operation patterns in the task logic flow and abstract them into standard function calls.

[0018] In one possible implementation, the verification correction module is specifically used for: Simulate the execution of the standardized skill profile in an isolated sandbox environment and monitor the execution logs; When an exception is captured, a preset error pattern library is queried to generate a correction strategy corresponding to the exception. The key elements or logical flow data are adjusted according to the correction strategy, and the process returns to the step of generating standardized skill configuration files for regeneration until the simulation is successfully executed, forming a closed-loop self-healing mechanism.

[0019] In one possible implementation, the natural language processing model is a pre-trained large language model; the key elements also include temporal constraint information.

[0020] In one possible implementation, the standard function call refers to abstracting the recurring operation pattern into a unified standard function through function abstraction and reuse, and replacing the recurring operation pattern by calling the standard function in the task logic flow.

[0021] A third aspect of this application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the instruction optimization method for large language models described in the first aspect of this application.

[0022] The fourth aspect of this application provides a computer-readable storage medium storing computer-readable instructions thereon, which can be executed by a processor to implement the instruction optimization method for large language models described in the first aspect of this application.

[0023] This application provides a method, apparatus, electronic device, and storage medium for instruction optimization for large language models. The method receives unstructured natural language text input by a user; performs semantic parsing on the natural language text and extracts key elements; performs logical reconstruction based on the extracted key elements to construct a directed acyclic graph (DAG) representing the execution order between task nodes; optimizes and schedules the task logic flow in the DAG to generate optimized logic flow data; maps the optimized logic flow data to a predefined skill template library to generate a machine-parseable standardized skill configuration file; and sends the standardized skill configuration file into a sandbox environment for simulated execution and self-correction until successful simulation, outputting the final skill configuration file. This invention can automatically convert natural language descriptions into optimized machine-executable instructions, effectively reducing token consumption and API call costs, and improving the stability and success rate of complex task execution. Attached Figure Description

[0024] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 A flowchart of an instruction optimization method for large language models provided in this application is shown; Figure 2 A schematic diagram of the logical refactoring and dependency graph construction provided in this application is shown; Figure 3 The flowchart of the sandbox simulation and self-correction provided in this application is shown; Figure 4 A schematic diagram of the structure of an instruction optimization device for large language models provided in this application is shown; Figure 5 A schematic diagram of the structure of an electronic device provided in this application is shown. Detailed Implementation

[0025] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0026] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.

[0027] Furthermore, the terms "first" and "second," etc., are used to distinguish different objects, not to describe a specific order. Additionally, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to those processes, methods, products, or apparatuses.

[0028] This application provides an instruction optimization method and apparatus for large language models, an electronic device, and a computer-readable storage medium, which will be described below with reference to the accompanying drawings.

[0029] Figure 1 This illustration shows a flowchart of an instruction optimization method for large language models provided in an embodiment of this application. This application is mainly used in intelligent agent development platforms, low-code / no-code AI application builders, and automated workflow engines. It automatically converts natural language descriptions from ordinary users into instruction configuration files that are structurally rigorous, resource-efficient, and directly executable through computer programs, thereby reducing the threshold for AI application development and improving operational efficiency.

[0030] like Figure 1 As shown, the method specifically includes the following steps: S101, Receive unstructured natural language text input by the user.

[0031] Specifically, users can submit task requests in natural language to the system through graphical user interfaces, command-line interfaces, or application programming interfaces (APIs). The unstructured natural language text refers to unformatted text content entered by users in everyday spoken or written language, such as "I want to download the latest stock data every morning and generate a report to send to my email," or "Please download A first, then B, and finally merge them."

[0032] S102. Perform semantic analysis on the natural language text and extract key elements.

[0033] In a preferred embodiment of this invention, step S102 can be implemented as follows: The natural language text is segmented, tagged with parts of speech, and subjected to dependency parsing using a natural language processing model. Preferably, the natural language processing model is a pre-trained large language model (such as BERT, GPT, etc.) or a statistical model specifically designed for syntactic analysis (such as Stanford Parser, LTP, etc.).

[0034] Based on the results of dependency parsing, the intent, triggering conditions, input parameter entities, output format constraints, and action verbs of the natural language text are extracted as key elements. These key elements may also include temporal constraint information (such as the temporal order implied by expressions like "after..." or "after..."). Through dependency parsing, dependency relationships between words in a sentence (such as subject-verb, verb-object, and adverbial modification relationships) can be identified, thereby accurately locating the subject performing the action, the object of the action, and the modifying constraints.

[0035] Preferably, during the process of removing key elements, stop words, emotional words, and redundant modifiers (such as "Can you help me?", "Ah", "It would be best", "Thank you", etc.) from the natural language text are removed simultaneously to reduce the amount of data in subsequent processing.

[0036] S103. Based on the extracted key elements, perform logical reconstruction to construct a directed acyclic graph representing the execution order between task nodes.

[0037] In a preferred embodiment of this invention, step S103 can be implemented as follows: Identify the sequential dependencies, parallel relationships, or conditional branches among the extracted key elements. For example, when the key elements contain time-series information such as "execute B after A is completed" or "analyze after data download is complete," the sequential dependency between A and B is identified; when there are multiple independent tasks, parallel relationships are identified; and when there are conditional statements, conditional branch relationships are identified. Figure 2 This illustration shows a schematic diagram of the logical refactoring and dependency graph construction provided in this application.

[0038] The aforementioned sequential dependencies, parallel relationships, or conditional branches are transformed into a logical rule tree. This logical rule tree represents the hierarchical relationships between tasks in a tree structure, with the root node representing the overall task objective, child nodes representing subtasks, and edges between nodes representing execution order or conditional branches.

[0039] Based on the aforementioned logical rule tree, a directed acyclic graph (DAG) is constructed to represent the execution order among task nodes. Each node in the DAG represents a task or operation, and directed edges represent dependencies between tasks. Furthermore, there are no directed cycles in the graph, ensuring that tasks can be completed within a finite number of steps.

[0040] S104. Perform resource optimization and scheduling on the task logic flow in the directed acyclic graph to generate optimized logic flow data.

[0041] In a preferred embodiment of this invention, step S104 can be implemented as follows: Nodes without dependencies in the task logic flow are identified and marked for parallel scheduling. Specifically, the complexity index of the current logic flow is calculated, and nodes with zero in-degree in the directed acyclic graph and no dependent paths between them are marked as nodes that can be executed in parallel.

[0042] Identify recurring operation patterns in the task logic flow and abstract them into standard function calls. These standard function calls refer to abstracting the recurring operation patterns into a unified standard function through function abstraction and reuse, and then replacing the recurring operation patterns by calling this standard function in the task logic flow. For example, when there are multiple "crawl webpages" operations, they are abstracted into a generic function `func_web_crawler(url)`, and only this function and its parameters are referenced in the configuration file, rather than repeatedly describing the crawler logic.

[0043] Based on the processing results of the above two steps, optimized logical flow data is generated. The optimized logical flow data includes parallel scheduling flags and standard function calls, and compared with the original logical flow, it has significant optimizations in terms of token usage and execution time.

[0044] S105. Map the optimized logical flow data to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine.

[0045] Specifically, based on the type and parameters of each node in the optimized logical flow data, matching templates are selected from a predefined skill template library for filling and combination. The predefined skill template library contains standard configuration templates for various common operations (such as HTTP request templates, database query templates, file read / write templates, email sending templates, etc.). The generated standard skill configuration file format includes, but is not limited to, JSON or YAML format, which can be directly parsed and executed by large language models or execution engines.

[0046] S106. The standardized skill configuration file is sent to the sandbox environment for simulation execution and self-correction until the simulation execution is successful, and the final skill configuration file is output.

[0047] For ease of understanding, Figure 3 A flowchart of the sandbox simulation and self-correction provided in this application is shown.

[0048] As a preferred embodiment of this example, step S106 can be implemented as follows: The standardized skill profile is simulated and executed in an isolated sandbox environment, and execution logs are monitored. The sandbox environment is a lightweight execution environment isolated from the production environment, capable of simulating the real execution process without affecting external systems.

[0049] When an exception is detected, a pre-defined error mode library is queried to generate a corresponding correction strategy. The error mode library pre-stores common exception types (such as missing parameters, insufficient interface permissions, data type mismatch, etc.) and their corresponding correction strategies.

[0050] Adjust key elements or logic flow data according to the correction strategy, and return to step S105 to regenerate the standardized skill configuration file until the simulation is successfully executed, forming a closed-loop self-healing process.

[0051] When the simulation is successfully executed, the final skill configuration file is output for use in the production environment.

[0052] The method described in this embodiment will be explained in detail below with reference to actual application scenarios.

[0053] Scenario 1: Daily Competitive Data Analysis Skills The user wants to build a "daily competitor data analysis" skill. The user inputs the following natural language text: "Could you please create a script for me? Every day at 5 PM, it should scrape the homepages of those competitor websites, capture their latest prices, compare them with our own prices, and finally compile the differences into an Excel spreadsheet and send it to me. Thank you!" Step S101 execution process: The system receives the unstructured natural language text input by the user.

[0054] Step S102 execution process: The system uses a natural language processing model to perform word segmentation, part-of-speech tagging, and dependency parsing on the text. The system removes redundant words such as "Can you help me?", "Ah", and "Thank you." The core elements are extracted as follows: Intent: Data collection and comparative analysis Trigger condition: 5 PM daily (timed trigger) Action verbs: crawl, scrape, compare, summarize, send Input parameters: competitor's official website homepage, your own price Output format constraints: Excel spreadsheet Timing constraints: Crawling → Comparison → Summarization → Sending (in sequence) Step S103 execution process: The system identifies that the "crawl" action targets multiple competitors (implying multiple target URLs). These crawling tasks are independent of each other and have no dependencies. The system constructs a DAG graph: Node A (crawl competitor 1), Node B (crawl competitor 2), and Node C (crawl competitor 3) are marked as parallel nodes; Node D (comparing prices) depends on the outputs of A, B, and C; Node E (generating Excel) depends on D; Node F (sending emails) depends on E.

[0055] Step S104 execution process: The system abstracts the general action of "crawl web pages" into the standard function `func_web_crawler(url, selector)`, and only references this function in the configuration file, instead of repeatedly describing the crawler logic; at the same time, the "comparing prices" operation is abstracted into `func_price_compare(data1, data2)`. The system marks nodes A, B, and C as parallel scheduling. After optimization, there are 3 parallel markings and 2 function abstractions in the generated logical stream data, which is estimated to save about 30% of token space and shorten the execution time by about 60%.

[0056] Step S105 execution process: The system maps the optimized logical flow data to the skill template library and generates a standardized skill configuration file in JSON format, which includes timed trigger configuration, parallel execution instructions, function call references and output format configuration.

[0057] Step S106 execution process: The system sends the generated configuration file into the sandbox environment for simulation. During the simulation, the system detects that the user has not provided a data source interface for "self-price", and captures a "data source missing" exception. The system queries the error pattern library and generates a correction strategy: "Detected a missing 'self-price' data source configuration. Please add the API_KEY or data path to the configuration file." The system feeds back the correction strategy to the user. After the user adds the data source configuration, the system returns to step S105 to regenerate the configuration file and performs the sandbox simulation again until the simulation is successful, and outputs the final skill configuration file.

[0058] Scenario 2: Intelligent Customer Service Automated Response Skills The user wants to build an "intelligent customer service auto-response" skill. The user inputs the following natural language text: "I need an automated reply tool. When a user sends a message on WeChat, first check if the message mentions 'refund.' If it does, transfer the message to a human operator. If it doesn't, generate a reply using a large model and send it to the user. At the same time, store the conversation history in a database." Step S101 execution process: The system receives the unstructured natural language text input by the user.

[0059] Step S102 execution process: The system performs semantic analysis on the text and removes redundant words. The core elements are extracted as follows: Intent: Automated message response Triggering condition: The user sends a message on WeChat (event triggered). Action verbs: judge, transfer to human agent, generate reply, send, store Input parameter entities: user messages, WeChat message interface Output format constraints: reply message, database record Timing constraint information: Decision → Branch (transfer to manual or generate reply) → Send → Store Step S103 execution process: The system identifies the conditional branching relationship: determining whether the message contains "refund" is a conditional node, branch 1 is "transfer to human assistance", and branch 2 is "generate reply → send". The system constructs a DAG graph, containing conditional judgment nodes and two conditional branch paths. The system identifies that there is no dependency between "sending message" and "storing database", and they can be executed in parallel.

[0060] Step S104 execution process: The system abstracts "determining whether a message contains keywords" into the standard function `func_keyword_match(message, keyword_list)`, "generating a large model reply" into `func_llm_generate(prompt)`, "sending a message" into `func_send_message(channel, content)`, and "storing the database" into `func_save_to_db(data)`. The system marks "sending messages" and "storing the database" as parallel nodes. After optimization, repetitive operations in the logical flow data are replaced by function calls, significantly reducing token consumption.

[0061] Step S105 execution process: The system generates a YAML format configuration file containing conditional branches, function calls, and parallel execution instructions.

[0062] Step S106 Execution Process: The system simulates execution in a sandbox. During the simulation, the system detects incomplete permission configuration for the "WeChat Message Interface" and captures an "Insufficient Interface Permissions" exception. The system queries the error pattern library and generates a correction strategy: "Missing permission configuration for the WeChat Message Interface has been detected. Please check whether API_KEY and APP_SECRET have been configured correctly." After the user completes the permission configuration, the system regenerates the configuration file, the sandbox simulation executes successfully, and the final configuration file is output.

[0063] The beneficial effects of the instruction optimization method for large language models provided in this application are as follows: First, this invention uses dependency parsing to remove “emotional noise” from user text and transforms fuzzy natural language logic into a rigorous computer-executable logic flow (such as a DAG graph), achieving high-quality conversion from natural language to machine instructions. This effectively solves the problems of token consumption and increased costs caused by directly retaining redundant text in existing technologies.

[0064] Secondly, this invention introduces resource quantification indicators. When constructing task logic, it actively identifies independent task nodes that can be executed in parallel, reduces the overall execution time through parallel scheduling and reduces the token size through function abstraction and reuse, thus significantly improving the execution efficiency and resource utilization of skills.

[0065] Third, this invention introduces a closed-loop process of generation-simulation-correction for the first time. By pre-executing instructions in an isolated environment, configuration errors are automatically captured and repaired, significantly improving the success rate of the first launch of skills and solving the system stability problem caused by the lack of a closed-loop verification mechanism in the prior art.

[0066] In the above embodiments, a method for instruction optimization based on a large language model is provided. Correspondingly, this application also provides an instruction optimization apparatus for a large language model. The instruction optimization apparatus for a large language model provided in this application can implement the above-described instruction optimization method for a large language model. This instruction optimization apparatus for a large language model can be implemented through software, hardware, or a combination of both. For example, the instruction optimization apparatus for a large language model may include integrated or separate functional modules or units to perform the corresponding steps in the above methods. Please refer to... Figure 4 This illustration shows a schematic diagram of an instruction optimization apparatus for large language models provided in an embodiment of this application. Since the apparatus embodiment is basically similar to the method embodiment, the description is relatively simple; relevant details can be found in the description of the method embodiment. The apparatus embodiment described below is merely illustrative.

[0067] like Figure 4 As shown, the instruction optimization device 10 for large language models includes: Semantic parsing module 101 is used to receive unstructured natural language text input by the user; perform semantic parsing on the natural language text and extract key elements; The logic reconstruction module 102 is used to perform logic reconstruction based on the extracted key elements and construct a directed acyclic graph representing the execution order between task nodes. Resource optimization module 103 is used to optimize and schedule the task logic flow in the directed acyclic graph and generate optimized logic flow data. The instruction generation module 104 is used to map the optimized logic flow data to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine. The verification and correction module 105 is used to send the standardized skill configuration file into the sandbox environment for simulation execution and self-correction until the simulation execution is successful and the final skill configuration file is output.

[0068] In one possible implementation, the semantic parsing module 101 is specifically used for: The natural language text is segmented, part-of-speech tagging is performed, and dependency parsing is conducted using a natural language processing model. Based on the results of the dependency parsing, the intent, triggering conditions, input parameter entities, output format constraints, and action verbs of the natural language text are extracted as the key elements.

[0069] In one possible implementation, the logic refactoring module 102 is specifically used for: Identify the sequential dependencies, parallel relationships, or conditional branches among the extracted key elements; Transform the aforementioned sequential dependencies, parallel relationships, or conditional branches into a logical rule tree; Based on the aforementioned logical rule tree, a directed acyclic graph representing the execution order among task nodes is constructed.

[0070] In one possible implementation, the resource optimization module 103 is specifically used for: Identify nodes in the task logic flow that have no dependencies and mark them for parallel scheduling; and / or, Identify recurring operation patterns in the task logic flow and abstract them into standard function calls.

[0071] In one possible implementation, the verification correction module 105 is specifically used for: Simulate the execution of the standardized skill profile in an isolated sandbox environment and monitor the execution logs; When an exception is captured, a preset error pattern library is queried to generate a correction strategy corresponding to the exception. The key elements or logical flow data are adjusted according to the correction strategy, and the process returns to the step of generating standardized skill configuration files for regeneration until the simulation is successfully executed, forming a closed-loop self-healing mechanism.

[0072] In one possible implementation, the natural language processing model is a pre-trained large language model; the key elements also include temporal constraint information.

[0073] In one possible implementation, the standard function call refers to abstracting the recurring operation pattern into a unified standard function through function abstraction and reuse, and replacing the recurring operation pattern by calling the standard function in the task logic flow.

[0074] The instruction optimization apparatus for large language models provided in this application embodiment and the instruction optimization method for large language models provided in this application embodiment are based on the same inventive concept and have the same beneficial effects as the methods they adopt, run or implement.

[0075] This application also provides an electronic device corresponding to the instruction optimization method for large language models provided in the foregoing embodiments. The electronic device may be a mobile phone, laptop computer, tablet computer, desktop computer, etc., to execute the above-mentioned instruction optimization method for large language models.

[0076] Please refer to Figure 5 This illustrates a schematic diagram of an electronic device provided by some embodiments of this application. For example... Figure 5 As shown, the electronic device 20 includes: a processor 200, a memory 201, a bus 202, and a communication interface 203. The processor 200, the communication interface 203, and the memory 201 are connected via the bus 202. The memory 201 stores a computer program that can run on the processor 200. When the processor 200 runs the computer program, it executes the instruction optimization method for large language models provided in any of the foregoing embodiments of this application.

[0077] The memory 201 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 203 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.

[0078] Bus 202 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. Memory 201 is used to store programs. After receiving an execution instruction, processor 200 executes the program. The instruction optimization method for large language models disclosed in any of the foregoing embodiments of this application can be applied to processor 200, or implemented by processor 200.

[0079] The processor 200 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 200 or by instructions in software form. The processor 200 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 201. The processor 200 reads the information in memory 201 and, in conjunction with its hardware, completes the steps of the above method.

[0080] The electronic device provided in this application embodiment and the instruction optimization method for large language models provided in this application embodiment are based on the same inventive concept and have the same beneficial effects as the methods they adopt, run or implement.

[0081] This application also provides a computer-readable storage medium corresponding to the instruction optimization method for large language models provided in the foregoing embodiments. The computer-readable storage medium may be an optical disc, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it executes the instruction optimization method for large language models provided in any of the foregoing embodiments.

[0082] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.

[0083] The computer-readable storage medium provided in the above embodiments of this application and the instruction optimization method for large language models provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and they should all be covered within the scope of the claims and specification of this application.

Claims

1. A method for instruction optimization for large language models, characterized in that, include: Receive unstructured natural language text input from the user; Perform semantic analysis on the natural language text and extract key elements; Based on the extracted key elements, a logical reconstruction is performed to construct a directed acyclic graph representing the execution order between task nodes; Resource optimization and scheduling are performed on the task logic flow in the directed acyclic graph to generate optimized logic flow data; The optimized logical flow data is mapped to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine; The standardized skill configuration file is sent to a sandbox environment for simulation and self-correction until the simulation is successful, and the final skill configuration file is output.

2. The method according to claim 1, characterized in that, The process of semantically parsing the natural language text and extracting key elements includes: The natural language text is segmented, part-of-speech tagging is performed, and dependency parsing is conducted using a natural language processing model. Based on the results of the dependency parsing, the intent, triggering conditions, input parameter entities, output format constraints, and action verbs of the natural language text are extracted as the key elements.

3. The method according to claim 1, characterized in that, The logical reconstruction based on the extracted key elements to construct a directed acyclic graph representing the execution order between task nodes includes: Identify the sequential dependencies, parallel relationships, or conditional branches among the extracted key elements; Transform the aforementioned sequential dependencies, parallel relationships, or conditional branches into a logical rule tree; Based on the aforementioned logical rule tree, a directed acyclic graph representing the execution order among task nodes is constructed.

4. The method according to claim 1, characterized in that, The step of optimizing and scheduling the task logic flow in the directed acyclic graph to generate optimized logic flow data includes: Identify nodes in the task logic flow that have no dependencies and mark them for parallel scheduling; and / or, Identify recurring operation patterns in the task logic flow and abstract them into standard function calls.

5. The method according to claim 1, characterized in that, The process involves sending the standardized skill configuration file into a sandbox environment for simulated execution and self-correction until the simulation is successful, and then outputting the final skill configuration file, including: Simulate the execution of the standardized skill profile in an isolated sandbox environment and monitor the execution logs; When an exception is captured, a preset error pattern library is queried to generate a correction strategy corresponding to the exception. The key elements or logical flow data are adjusted according to the correction strategy, and the process returns to the step of generating standardized skill configuration files for regeneration until the simulation is successfully executed, forming a closed-loop self-healing mechanism.

6. The method according to claim 2, characterized in that, The natural language processing model is a pre-trained large language model; the key elements also include temporal constraint information.

7. The method according to claim 4, characterized in that, The standard function call refers to abstracting the recurring operation pattern into a unified standard function through function abstraction and reuse, and replacing the recurring operation pattern by calling the standard function in the task logic flow.

8. An instruction optimization device for large language models, characterized in that, include: The semantic parsing module is used to receive unstructured natural language text input by the user; Perform semantic analysis on the natural language text and extract key elements; The logic reconstruction module is used to perform logic reconstruction based on the extracted key elements and construct a directed acyclic graph representing the execution order between task nodes. The resource optimization module is used to optimize and schedule the task logic flow in the directed acyclic graph, and generate optimized logic flow data. The instruction generation module is used to map the optimized logic flow data to a predefined skill template library to generate a standardized skill configuration file that can be parsed by a machine. The verification and correction module is used to send the standardized skill configuration file into the sandbox environment for simulation execution and self-correction until the simulation execution is successful and the final skill configuration file is output.

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 the processor, when executing the computer program, implements the method as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that can be executed by a processor to implement the method as described in any one of claims 1 to 7.