Script generation method, script generation device, program product and electronic equipment

By constructing a set of functions and using a large language model to generate scripts, the problems of low efficiency in manual script writing and complexity in expert system script writing are solved, realizing automated, flexible and efficient script generation, which is suitable for a variety of scenarios.

CN121785579APending Publication Date: 2026-04-03GUANGZHOU BOGUAN TELECOMM TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In existing technologies, scripts rely on manual writing, which is inefficient and prone to errors. Fixed-framework script templates have poor flexibility, and the if-then rules of expert systems have a high barrier to entry and low scalability.

Method used

By acquiring a set of function constructions from sample scripts, scripts are generated using a large language model. Combining script description and constraint information, scripts are automatically generated to replace fixed templates and expert system rules.

Benefits of technology

It improves script generation efficiency and quality, lowers technical barriers and operation and maintenance costs, enhances the flexibility and applicability of script generation, and supports script generation in new scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121785579A_ABST
    Figure CN121785579A_ABST
Patent Text Reader

Abstract

The invention provides a script generation method, a script generation device, a program product and electronic equipment, and relates to the technical field of computers. The method comprises the following steps: acquiring a plurality of sample scripts; the sample script comprises one or more script lines, and each script line comprises a script instruction and a script parameter; constructing a function set according to script lines in the plurality of sample scripts; the function set comprises one or more standardized functions; the standardized function represents that corresponding script statements are executed according to input script parameters; determining prompt information based on the function set and the script description information; and inputting the prompt information into a large language model, and generating a first script according to output information of the large language model. According to the method, the problem that manual script writing is low in efficiency and prone to errors is solved, the script generation efficiency is improved, the script quality can be guaranteed, and the scheme has high applicability and expandability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a script generation method, script generation apparatus, program product, and electronic device. Background Technology

[0002] In computer software, scripting is a common method for implementing logic. Software developers or users write custom scripts to meet specific scenario requirements and implement corresponding logic and functions. For example, game plot scripts can automatically advance the game's storyline, and automated test scripts can automate software testing.

[0003] Currently, script generation mainly relies on manual script writing, which is inefficient and prone to errors. Therefore, there is an urgent need for an effective script generation method. Summary of the Invention

[0004] This disclosure provides a script generation method, script generation device, program product, and electronic device to at least partially solve the problem of scripts relying on manual writing.

[0005] According to a first aspect of this disclosure, a script generation method is provided, the method comprising: acquiring a plurality of sample scripts; the sample scripts including one or more script lines, the script lines including script instructions and script parameters; constructing a function set based on the script lines in the plurality of sample scripts; the function set including one or more standardized functions; the standardized functions representing the execution of corresponding script statements based on input script parameters; determining prompt information based on the function set and script description information; inputting the prompt information into a large language model, and generating a first script based on the output information of the large language model.

[0006] According to a second aspect of this disclosure, a script generation apparatus is provided, the apparatus comprising: a sample script acquisition module configured to acquire a plurality of sample scripts; the sample scripts including one or more script lines, the script lines including script instructions and script parameters; a function construction module configured to construct a function set based on the script lines in the plurality of sample scripts; the function set including one or more standardized functions; the standardized functions representing the execution of corresponding script statements based on input script parameters; a prompt information determination module configured to determine prompt information based on the function set and script description information; and a model processing module configured to input the prompt information into a large language model and generate a first script based on the output information of the large language model.

[0007] According to a third aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method of the first aspect described above and possible implementations thereof.

[0008] According to a fourth aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to implement the method of the first aspect and possible implementations thereof by executing the executable instructions.

[0009] The technical solution disclosed herein has the following beneficial effects: A function set is constructed based on the script lines in the sample script. Based on this function set and script description information, prompts are determined and input into a large language model. The first script is then generated based on the output of the large language model. Firstly, standardized functions are used to control the standardization of script statements, combined with script description information to provide targeted guidance. This fully utilizes the reasoning capabilities of the large language model to generate scripts, thus providing an automated script generation solution. This solves the problems of low efficiency and error-proneness in manual script writing, improving script generation efficiency and ensuring script quality. Secondly, automatic parsing and function extraction are implemented for the sample script. Standardized functions abstracted from script lines replace fixed script templates and frameworks, and replace the complex if-then rule writing in expert systems. This eliminates the need for professional personnel to edit and maintain script templates and frameworks, as well as the need for professional personnel to build and maintain rule bases, reducing the technical threshold and operational costs. Thirdly, users can input script description information according to their own needs. The large language model combines standardized functions based on the script description information to generate different types of scripts, which improves the flexibility and diversity of script generation. Furthermore, when it is necessary to apply it to new scenarios, the function set can be updated or expanded by updating the sample scripts, thereby supporting the generation of scripts for new scenarios without having to reconstruct the entire system. Therefore, the solution has high applicability and scalability. Attached Figure Description

[0010] Figure 1 A flowchart illustrating a script generation method according to an embodiment of this disclosure is shown; Figure 2 A flowchart illustrating a set of construction functions in an embodiment of this disclosure is shown; Figure 3 A schematic diagram illustrating one embodiment of constructing a standardized function is shown in this disclosure; Figure 4 A schematic diagram illustrating a constraint information set according to an embodiment of this disclosure is shown; Figure 5 A flowchart illustrating a verification process according to an embodiment of this disclosure is shown; Figure 6 This diagram illustrates a method for generating and verifying scripts using a large language model, as described in an embodiment of this disclosure. Figure 7A flowchart illustrating a script generation method according to an embodiment of this disclosure is shown. Figure 8 A schematic diagram of a script generation apparatus according to an embodiment of the present disclosure is shown; Figure 9 A schematic diagram of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0011] Exemplary embodiments of this disclosure will be described more fully below with reference to the accompanying drawings.

[0012] The accompanying drawings are schematic illustrations of this disclosure and are not necessarily drawn to scale. Some block diagrams shown in the drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in hardware modules or integrated circuits, or in networks, processors, or microcontrollers. Implementations can be carried out in various forms and should not be construed as limited to the examples set forth herein. The features, structures, or characteristics described in this disclosure can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough description of embodiments of this disclosure. However, those skilled in the art will recognize that one or more specific details may be omitted when implementing the technical solutions of this disclosure, or other methods, components, apparatuses, steps, etc., may be used to replace one or more specific details.

[0013] Manually writing scripts is inefficient and error-prone. One related approach involves pre-configuring script templates and corresponding script frameworks. After the user enters key information, this information is mapped to the script framework to generate the script. However, this approach can only generate scripts with fixed frameworks, lacking flexibility and unable to handle complex logic. Furthermore, it requires regular maintenance of the script templates, leading to high costs. Another related approach involves building a rule base based on an expert system and generating scripts through if-then rule reasoning. The system matches the corresponding rules based on input conditions and executes the script content according to the rule chain. However, the rule writing process is complex and involves specialized knowledge, resulting in a high implementation threshold. Additionally, the rules cover a limited range of scenarios, making it difficult to handle new scenarios and limiting scalability.

[0014] In view of one or more of the above-mentioned problems, this disclosure provides a script generation method. Figure 1 An exemplary flow of the method is shown, including the following steps: S110, Obtain multiple sample scripts; each sample script includes one or more script lines, and each script line includes script instructions and script parameters. S120, Construct a function set based on script lines from multiple sample scripts; the function set includes one or more standardized functions; the standardized function represents the execution of the corresponding script statement based on the input script parameters; S130, determine the prompt information based on the function set and script description information; S140: Input the prompt information into the large language model and generate the first script based on the output information of the large language model.

[0015] based on Figure 1 The proposed method constructs a function set based on script lines in a sample script, determines prompts based on the function set and script description information, inputs the prompts into a large language model, and generates a first script based on the output of the large language model. Firstly, it uses standardized functions to control the standardization of script statements, combined with script description information to provide targeted guidance, fully utilizing the reasoning capabilities of the large language model to generate scripts. This provides an automated script generation solution, solving the problems of low efficiency and error-proneness in manual script writing, improving script generation efficiency, and ensuring script quality. Secondly, it automatically parses and extracts functions from the sample script, replacing fixed script templates and frameworks with standardized functions abstracted from script lines, and replacing the complex if-then rule writing in expert systems. This eliminates the need for professional personnel to edit and maintain script templates and frameworks, as well as the need for professional personnel to build and maintain rule bases, reducing the technical threshold and operational costs. Thirdly, users can input script description information according to their own needs. The large language model combines standardized functions based on the script description information to generate different types of scripts, which improves the flexibility and diversity of script generation. Furthermore, when it is necessary to apply it to new scenarios, the function set can be updated or expanded by updating the sample scripts, thereby supporting the generation of scripts for new scenarios without having to reconstruct the entire system. Therefore, the solution has high applicability and scalability.

[0016] The following describes, in conjunction with one or more embodiments and related accompanying drawings, Figure 1 Each step is explained in detail.

[0017] refer to Figure 1 In step S110, multiple sample scripts are obtained; each sample script includes one or more script lines, and each script line includes script instructions and script parameters.

[0018] Sample scripts are executable script files that can be written manually and contain complete logic. For example, in a game story script generation scenario, sample scripts include pre-written script files used to drive specific storylines (such as task triggering, character dialogue, and scene transitions) during game development. Historical script files can be read from the game project's script library as sample scripts. Each script consists of several lines, each line including script instructions to implement a specific function (such as "create game character" or "play animation") and script parameters required to execute that instruction (such as position coordinates in the game scene, character name, and animation name).

[0019] For example, the following is a sample script: 0 SCRIPT_START SceneID=1174 X=106 Y=83 HideAnimation=0 Hook=xxx1 0 NPC CREATE ID=6 Shape=2123 Direction=2 X=120 Y=92 Name=Character Name Desc=0 SceneID=1174 Hook=xxx2 ... This indicates that the scene is initialized at frame 0, and an NPC (non-player character) is created.

[0020] Continue to refer to Figure 1 In step S120, a function set is constructed based on the script lines in multiple sample scripts; the function set includes one or more standardized functions; the standardized function represents the execution of the corresponding script statement based on the input script parameters.

[0021] The function set is a group of reusable standardized functions formed by analyzing and abstracting sample scripts. Each standardized function encapsulates one or more script instructions with a fixed pattern and their parameter generation logic. Given specific parameter values, the standardized function can output one or more lines of script statements that conform to the script syntax specification. It can parse each line of script in the sample script, identify the script instructions and their corresponding script parameter names, categorize script instructions of the same type, perform structured processing, form a correspondence between script parameters and script statements, and represent this correspondence in the form of standardized functions.

[0022] In one implementation, reference Figure 2 As shown, the above-mentioned function set is constructed based on script lines from multiple sample scripts, including the following steps: S210, extract instruction patterns from script lines in multiple sample scripts; the instruction pattern includes a tuple consisting of script instructions and script parameters corresponding to the script instructions. S220 constructs standardized functions based on instruction patterns and forms a function set based on the constructed standardized functions.

[0023] The instruction pattern is a structured extraction of the core logic of a script line. It extracts the specific parameter values ​​from the script line while retaining the skeleton of the instruction, which serves as the instruction pattern. An instruction pattern is a binary structure consisting of a script instruction type and a set of associated script parameter names. For example, for each script line, lexical analysis is performed first, such as word segmentation using spaces or other symbols as delimiters. Following the script line writing rules, the first word is the frame number, the second word is the script instruction, and the following are script parameters in the format (parameter name = parameter value). When extracting the instruction pattern, the frame number and specific parameter values ​​are ignored; only the script instructions and script parameters are extracted and represented as a binary instruction pattern. By traversing all sample scripts, a large number of instruction patterns can be obtained.

[0024] For example, the acquired set of sample scripts can be denoted as S={ , , ..., }, where each sample script It includes one or more script lines. Lexical and syntactic analysis is performed on each script line in the sample script to extract instruction patterns, represented as follows: Pattern(S) = {(comman , param ), (comman , param ), ...,(comman , param )} Where Pattern(S) represents the set of instruction patterns extracted from the sample script set S, (command) i ,params i ) represents a command pattern, where command is the script command type and params is the set of script parameters.

[0025] Further analysis of the instruction pattern set is conducted, such as merging instruction patterns with the same script instruction type and the same script parameter set. For each script instruction type, corresponding script statements are generated, and a standardized function is defined, thus forming a function set.

[0026] In one implementation, the above-described construction of a standardized function based on the instruction pattern includes the following steps: The script statement containing script instructions and script parameters is determined based on the instruction pattern; Generate function names and construct standardized functions based on function names, script parameters, and script statements.

[0027] Specifically, based on the script instructions and parameters in the instruction mode, script statements are determined using the instruction expression and parameter definition methods of the scripting language. These script statements express the execution of script instructions according to the script parameters. For example, a script statement can be a script line template with parameter placeholders. Semantically relevant function names can be generated based on the script instruction type, the meaning of the script parameters, and the meaning of the script statements. For instance, script instructions can be used as function names, or words with semantically similar meanings to script statements can be searched in a dictionary as function names. Standardized functions are then constructed based on the function names, script parameters, and script statements.

[0028] For example, the format of a normalized function is: F( , , ..., → script_line. Among them, This indicates the script parameters required as input to the standardized function, with `script_line` representing the corresponding generated script statements. Function definitions include, but are not limited to: function name, script parameter list, parameter types, value ranges, parameter constraints, and output format specifications. (See reference) Figure 3 As shown, the original script instructions are obtained from the sample script, the instruction patterns are extracted, the script parameters are generalized, and a standardized function is constructed. For example, the standardized function for scene initialization is: InitScene(scene_id: int, pos_x:int, pos_y: int) → "SCRIPT_START SceneID={scene_id} X={pos_x} Y={pos_y}".

[0029] based on Figure 2 The proposed method provides a scheme for automatically constructing function sets. It uses instruction patterns as an intermediate representation of script logic, transforming messy raw script text into structured, standardized instruction patterns, and then abstracting them into standardized functions. This achieves a structured representation of script logic and reduces the workload of manual summarization and function design.

[0030] It should be noted that this disclosure can construct standardized functions for each instruction pattern, or it can construct standardized functions for only some of the instruction patterns.

[0031] In one implementation, the above-described construction of a standardized function based on the instruction pattern includes the following steps: Statistical analysis of instruction patterns is performed, and high-frequency instruction patterns are determined from the statistical results. Standardized functions are constructed based on high-frequency instruction patterns.

[0032] Cluster analysis can be used to statistically analyze command patterns, such as merging command patterns with the same meaning (e.g., script command types with different parameters) into the same command pattern. Frequency-related indicators for each command pattern in sample scripts can be calculated, including but not limited to: the number of times the command pattern appears in all sample scripts, the coverage ratio (i.e., the proportion of sample scripts containing a certain command pattern out of all sample scripts), etc. High-frequency command patterns refer to command patterns that appear frequently among all command patterns. The criteria for determining high-frequency command patterns can be determined based on factors such as the number of sample scripts, the number of script lines, and the number of command patterns. For example, a threshold for the number of occurrences or a threshold for the proportion can be set, classifying command patterns that appear at the threshold as high-frequency command patterns, or command patterns that cover a certain proportion of the sample as high-frequency command patterns. High-frequency command patterns typically correspond to commonly used functions in specific scenarios or projects (e.g., scene initialization and NPC creation command patterns are commonly used in game projects).

[0033] By focusing on high-frequency instruction patterns to build standardized functions, the function set can cover most script requirements of specific scenarios or projects, improve the reusability of standardized functions and the efficiency of script generation, reduce function redundancy, and lower the understanding and calling costs of large language models.

[0034] In one implementation, constraint information for the script parameters can also be determined. This constraint information restricts the values ​​of the script parameters, such as the range of values ​​for the script parameters. This constraint information can also be considered as the function constraint information of a standardized function.

[0035] In one implementation, the constraint information includes a value range. The determination of the constraint information for the script parameters includes the following steps: Iterate through the sample scripts to obtain sample values ​​of the script parameters; The range of values ​​for the script parameters is determined based on the sample values ​​of the script parameters.

[0036] When parsing each sample script, not only are instruction patterns extracted, but the specific values ​​of each script parameter are also recorded. For example, for the parameter SceneID, after traversing all sample scripts, the sample values ​​obtained are: {1174, 1174, 1175, 1174, 1200, 1175, …}. For the parameter X, in the context of SceneID=1174, the sample values ​​obtained are: {106, 83, 150, 20, 180, …}. Statistical analysis is performed on the collected sample values ​​to determine the value range. For example, for discrete script parameters (such as SceneID), the set of all appearing sample values ​​can be directly used as its value range, such as the value range of SceneID being {1174, 1175, 1200}. For continuous script parameters (such as X and Y coordinates): the range of values ​​can be determined in interval form based on the maximum and minimum values ​​in the sample values. For example, for the X coordinate under SceneID=1174, the minimum value of the sample value is 20 and the maximum value is 180, so its range can be determined as [20, 180]. Alternatively, a certain margin can be left, and the upper and lower limits of the range can be extended to a certain extent, such as determining it as [0, 200].

[0037] By employing the above methods, it is unnecessary to manually count all possible valid values ​​for script parameters. Driven by sample values ​​from the sample script, the constraint information is automatically constructed, reducing manual costs and improving processing efficiency. Furthermore, since the constraint information originates from real script information, it better reflects the actual situation of the project and ensures that the parameter values ​​in the newly generated script are within a verified range.

[0038] In one implementation, the script to be generated (such as the first script) is a game script, and the game contains virtual elements (such as game scenes, virtual characters, virtual items, etc.). For specific virtual elements, the constraint information of the script parameters associated with those virtual elements can be determined. For example, for an NPC in the game, the range of values ​​for the NPC's X-coordinate and Y-coordinate can be determined.

[0039] For example, available resources (corresponding to script parameters) are extracted from the script execution environment to construct a set of constraint information. The set of constraint information associated with the game's story script is represented as follows: C = {C_scene, C_character, C_action, C_temporal} Among them, reference Figure 4As shown, C represents the constraint information set, and C_scene, C_character, C_action, and C_temporal are subsets. C_scene represents the set of available scenes and their coordinate range; C_character represents the set of available characters and their attributes; C_action represents the available action types and their parameter ranges; and C_temporal represents the time constraint rules. Constraint information can be stored as key-value pairs, where the key is a virtual element and the value is the range of values ​​for the script parameters associated with that virtual element, as shown below: C_scene = {scene_i : (x_rang ,y_rang ),scene_i : (x_rang ,y_rang ), ...} The constraint information mechanism in this disclosure supports dynamic updates. For example, when the user's requirements for the value range of script parameters change, new constraint information can be set manually or the constraint information can be updated by changing relevant configurations (such as updating parameter configuration information in the game project), so that the subsequently generated scripts meet the new constraint information, which is convenient for adapting to environmental changes.

[0040] Continue to refer to Figure 1 In step S130, the prompt information is determined based on the function set and script description information.

[0041] The script description information can be natural language input by the user describing the script content or requirements. For example, in a game's storyline, the script description information could be: generate a script, initialize it at coordinates (100, 80) in scene 1174, and then create an NPC named "Guide" with a costume ID of 2123 and a position coordinate (120, 92). Combining the function set with the script description information forms a structured prompt message to guide the large language model. For example, a prompt template can be pre-built, including modules for the function set and script description information. Filling the prompt template with the function set and script description information forms the prompt message.

[0042] In one implementation, given the constraint information of the script parameters, the prompt information can be determined based on the function set, constraint information, and script description information. That is, when constructing the prompt information, in addition to the function set and script description information, constraint information of the script parameters can also be added. This provides the large language model with more comprehensive information, enabling the large language model to execute the script generation task under the constraints of the constraint information, ensuring that the parameter values ​​in the generated script conform to the constraint information.

[0043] In one implementation, function sets and constraint information can be populated into a prompt template and then merged with script description information to form a prompt message. The merging operation combines the information in the prompt template with the script description information to create a complete and coherent prompt text. For example, the script description information can be added before or after the prompt template. Alternatively, a module for script description information can be set within the prompt template, and the script description information can be populated within that module. By using prompt templates, standardization and maintainability of prompt message construction are achieved. Adaptation can be achieved for different projects or script types by adjusting the prompt template (adjusting different modules within the template), which facilitates the generation of uniformly formatted and standardized prompt messages, making them easier for large language models to recognize.

[0044] In one implementation, the prompt information includes, but is not limited to, the following: script description information, function set, constraint information, generation rules, task information, and role definition information.

[0045] The generation rules are the rules or output format requirements for the set of functions to be called. For example, generation rules could be: "Only the functions to be called and the parameter list need to be provided, output in list format," or "Only the functions to be called and the parameter list need to be provided, output in {function:parameter} format," and so on. Users can set generation rules according to the specific project requirements. Task information describes the script generation task. Role definition information refers to the task role played by the large language model, such as a script generation assistant. The above information can be filled into the prompt template to generate prompt information.

[0046] For example, a prompt template P can be constructed as follows: P = {R_role, F_functions, C_constraints, R_rules, T_task} Among them, R_role is the role definition information, used to clarify the task role played by the large language model; F_functions is the function set and its description; C_constraints is the constraint information; R_rules is the generation rules (including format requirements); T_task is the task information, used to specifically describe the script generation task. The script description information input by the user is denoted as "User_Requirement", and the process of generating the prompt information is as follows: Input = P ⊕ User_Requirement Here, Input represents the prompt information (i.e., the input information of the large language model), and ⊕ represents the fusion operation of the prompt template and the script description information.

[0047] Continue to refer to Figure 1 In step S140, the prompt information is input into the large language model, and the first script is generated based on the output information of the large language model.

[0048] Among them, the Large Language Model (LLM) is capable of performing script generation tasks. A pre-trained LLM can be used directly, or a pre-trained LLM can be fine-tuned using a specific dataset to obtain a LLM capable of handling script generation tasks.

[0049] The first script is the final generated script. The prompt information is input into the large language model, which performs inference and can either directly output the script or output script-related information. The output information of the large language model can be used directly as the first script, or the output information can be further processed to obtain the final first script.

[0050] In one implementation, multiple different large language models can be set up, which may have the same architecture but different parameters, or different architectures. The prompt information is output to each large language model separately, and the output information of each large language model is obtained. These output information are then combined through voting or weighted fusion to obtain the final first script. This improves the stability of script generation.

[0051] In one implementation, the output information of the large language model includes a second script. Generating the first script based on the output information of the large language model includes the following steps: Verify the second script; If the verification passes, the second script will be used as the first script; If the verification fails, obtain the verification feedback information, regenerate the script based on the verification feedback information, and if the regenerated script passes the verification, use the regenerated script as the first script.

[0052] The large language model can directly output a script, denoted as the second script. The second script is then validated, such as by checking its syntax and constraints to ensure it meets requirements. For example, validation can be performed in one or more of the following ways: syntax checking; constraint validation. Syntax checking verifies whether the script format conforms to predefined specifications, such as whether function call formats are correct, whether the number of parameters matches, and whether parameter types are compatible. Constraint validation verifies whether the script content adheres to constraint information and business or environmental constraints, such as whether parameter values ​​are within the allowed range and whether the logical order of instructions is correct.

[0053] If the verification passes, it means the second script is compliant in terms of syntax and constraints, and it will be used as the first script. If the verification fails, the verification feedback information can be determined based on the reason for the failure (such as the type of failure). The verification feedback information can be added to the prompt message, and this prompt message can be input into the large language model to regenerate the script. If the regenerated script passes the verification, it will be used as the first script.

[0054] In one implementation, script correction can be achieved based on reinforcement learning. Specifically, after the large language model outputs a second script based on the prompt information, the second script is validated, and the validation result is used as feedback information. The script generation strategy is then optimized based on the feedback information (the script generation strategy can be added to the prompt information or used as an implicit strategy executed by the large language model), thereby enabling the large language model to adaptively correct the script and improve the quality of script generation.

[0055] By using the above methods, we ensured that the final output script was compliant in terms of syntax and constraints, and implemented a closed-loop mechanism for script generation and correction, thereby improving the reliability of the script and reducing the cost of manual script debugging.

[0056] Figure 5 The flowchart illustrates the verification process. A syntax checker and a constraint checker can be set. After the large language model outputs the second script, the second script is first input into the syntax checker to verify aspects such as function call format, parameter types, and correct syntax structure. If the verification fails, verification feedback information (including the reason for failure) is determined, and the script can be regenerated based on the feedback information. If the verification passes, the second script is then input into the constraint checker to verify aspects such as the existence of scene IDs, the validity of role IDs, coordinate ranges, and temporal logic. If the verification fails, verification feedback information (including the reason for failure) is determined, and the script can be regenerated based on the feedback information. If the verification passes, the second script is used as the final output of the first script.

[0057] Figure 6 The diagram illustrates the process of generating and validating a script using a large language model. The user inputs a script description, such as "generate character movement script." The system constructs a prompt template P, fills it with information such as the function set, and merges the prompt template P and the script description to form a prompt message. The system inputs this prompt message into the large language model, which returns a generated second script. This second script is then input into a validator (which may include a syntax checker and a constraint checker) for syntax and constraint validation. If the validation passes, a structured second script is output.

[0058] Figure 7 The flowchart illustrating the script generation method includes the following steps: S701, Obtain the sample script set.

[0059] S702 performs lexical and syntactic analysis on the script lines of the sample script to extract instruction patterns.

[0060] S703 performs cluster analysis on instruction patterns.

[0061] S704 identifies high-frequency command modes.

[0062] S705 generalizes script parameters for high-frequency instruction modes.

[0063] S706 generates standardized functions corresponding to high-frequency instruction modes.

[0064] S707 allows for the construction of function sets and the creation of APIs (Application Programming Interfaces) to facilitate the calling of standardized functions by large language models and other applications.

[0065] S708 scans the script execution environment and analyzes resource references (such as virtual elements).

[0066] S709, Determine constraint information based on the analysis results of resource references.

[0067] S710, construct the constraint information set.

[0068] S711, Build a prompt template.

[0069] S712, the prompt template of the filled information is merged with the script description information entered by the user to obtain the prompt information.

[0070] S713 inputs the prompt information into the large language model for reasoning and outputs a structured second script.

[0071] S714, verify the second script. If the verification fails, execute S715; if the verification passes, execute S716.

[0072] S715 determines the verification feedback information and can feed it back to the large language model to regenerate the script.

[0073] S716 outputs the second script as the first script.

[0074] In one implementation, the script generation task can be decomposed into multiple subtasks. Each subtask is executed separately to obtain a corresponding sub-script. These sub-scripts are then combined to form the final first script. For example, script description information is decomposed into multiple sub-information pieces, each describing a part of the complete script. Each sub-information piece is combined with a set of functions, etc., to form prompt sub-information. Each prompt sub-information is input into a large language model. Based on the output information of the large language model, the corresponding sub-script is obtained. All sub-scripts are combined and verified. If the verification passes, the final first script is obtained.

[0075] This disclosure also provides a script generation apparatus. (See reference...) Figure 8 As shown, the script generation device 800 includes the following modules: The sample script acquisition module 810 is configured to acquire multiple sample scripts; the sample scripts include one or more script lines, and the script lines include script instructions and script parameters. The function construction module 820 is configured to construct a function set based on script lines in the plurality of sample scripts; the function set includes one or more standardized functions; the standardized functions represent the execution of corresponding script statements based on input script parameters; The prompt message determination module 830 is configured to determine the prompt message based on the function set and script description information; The model processing module 840 is configured to input the prompt information into a large language model and generate a first script based on the output information of the large language model.

[0076] In one implementation, constructing a function set based on script lines in the plurality of sample scripts includes: extracting instruction patterns from script lines in the plurality of sample scripts; the instruction pattern includes a tuple formed by the script instruction and the script parameters corresponding to the script instruction; constructing standardized functions based on the instruction patterns; and forming the function set based on the constructed standardized functions.

[0077] In one implementation, constructing a standardized function based on the instruction pattern includes: performing statistics on the instruction patterns, determining high-frequency instruction patterns from the instruction patterns based on the statistical results, and constructing a standardized function based on the high-frequency instruction patterns.

[0078] In one implementation, constructing a standardized function based on the instruction pattern includes: determining a script statement containing the script instruction and the script parameter based on the instruction pattern; generating a function name; and constructing the standardized function based on the function name, the script parameter, and the script statement.

[0079] In one embodiment, the device is further configured to: determine constraint information of the script parameters; the step of determining prompt information based on the function set and script description information includes: determining the prompt information based on the function set, the constraint information, and the script description information.

[0080] In one implementation, determining the prompt information based on the function set, the constraint information, and the script description information includes: filling the prompt template with the function set and the constraint information, and merging it with the script description information to form the prompt information.

[0081] In one implementation, the constraint information includes a value range; determining the constraint information for the script parameter includes: traversing the sample script to obtain sample values ​​of the script parameter; and determining the value range of the script parameter based on the sample values ​​of the script parameter.

[0082] In one implementation, the output information of the large language model includes a second script; generating a first script based on the output information of the large language model includes: verifying the second script; if the verification passes, using the second script as the first script; if the verification fails, obtaining verification feedback information, regenerating the script based on the verification feedback information, and using the regenerated script as the first script if the regenerated script passes verification.

[0083] In one implementation, the verification of the second script includes: performing a syntax check on the second script, and / or performing constraint verification on the second script.

[0084] The specific details of each part of the above-mentioned device have been described in detail in the method section of the implementation plan. For any undisclosed details, please refer to the implementation plan of the method section, and therefore will not be repeated here.

[0085] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0086] This disclosure also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the above-described method.

[0087] In one implementation, the computer program product can be a tangible product, such as a computer-readable storage medium storing a computer program. The readable storage medium can be based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, and includes, but is not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory, hard disk drive (HDD), solid-state drive (SSD), etc. For example, the computer program product can be a non-volatile storage medium storing a computer program, such as read-only memory, NAND flash memory, etc.

[0088] In one implementation, the computer program product can be an intangible product. For example, the computer program product can be a virtual digital product, such as an executable file or installation package containing a computer program.

[0089] Computer program code can be written in one or more programming languages. Examples of programming languages ​​include C, Java, and C++. Program code can execute entirely on the user's computing device, partially on the user's computing device, or as a standalone software package. It can also execute partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, such as a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via an internet connection provided by a mobile network operator).

[0090] Computer programs can be carried or transmitted via signals such as electrical, magnetic, optical, electromagnetic, and infrared rays. Electronic devices can convert the signals carrying computer programs into digital signals, thereby running the computer programs. When a computer program runs on an electronic device, its code is used to cause the electronic device to execute (more specifically, to be executed by the processor of the electronic device) the method steps of various embodiments of this disclosure, such as... Figure 1 The steps are shown.

[0091] Implementing the above method steps through a computer program achieves the following technical effects: Firstly, a function set is constructed based on the script lines in the sample script; based on the function set and script description information, prompt information is determined; the prompt information is input into a large language model; and the first script is generated based on the output information of the large language model. Secondly, standardized functions are used to control the standardization of script statements, combined with script description information to provide targeted guidance, fully utilizing the reasoning capabilities of the large language model to generate scripts. This provides an automated script generation solution, solving the problems of low efficiency and error-proneness in manual script writing, improving script generation efficiency, and ensuring script quality. Thirdly, automatic parsing and function extraction are implemented for the sample script. Standardized functions abstracted from script lines replace fixed script templates and frameworks, and replace the complex if-then rule writing in expert systems. This eliminates the need for professional personnel to edit and maintain script templates and frameworks, as well as the need for professional personnel to build and maintain rule bases, reducing the technical threshold and operational costs. Thirdly, users can input script description information according to their own needs. The large language model combines standardized functions based on the script description information to generate different types of scripts, which improves the flexibility and diversity of script generation. Furthermore, when it is necessary to apply it to new scenarios, the function set can be updated or expanded by updating the sample scripts, thereby supporting the generation of scripts for new scenarios without having to reconstruct the entire system. Therefore, the solution has high applicability and scalability.

[0092] This disclosure also provides an electronic device. The electronic device includes a processor and a memory. The memory stores executable instructions for the processor, such as computer programs. The processor executes these executable instructions to implement the method steps of various exemplary embodiments of this disclosure.

[0093] The following is for reference. Figure 9 The electronic device is illustrated by way of a general-purpose computing device. It should be understood that... Figure 9 The electronic device 900 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments disclosed herein.

[0094] like Figure 9 As shown, the electronic device 900 may include: a processor 910, a memory 920, a bus 930, an I / O (input / output) interface 940, and a network adapter 950.

[0095] The memory 920 may include volatile memory, such as RAM 921 and cache unit 922, and may also include non-volatile memory, such as ROM 923. The memory 920 may also include one or more program modules 924, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. For example, program module 924 may include the modules described above.

[0096] The processor 910 may include one or more processing units, such as an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor, and / or an NPU (Neural-Network Processing Unit).

[0097] The processor 910 can be used to execute executable instructions stored in the memory 920 to perform method steps of various embodiments of this disclosure, such as... Figure 1 The steps are shown.

[0098] By executing the above method steps through processor 910, the following technical effects are achieved: A function set is constructed based on the script lines in the sample script; prompt information is determined based on the function set and script description information; the prompt information is input into the large language model; and the first script is generated based on the output information of the large language model. Firstly, standardized functions are used to control the standardization of script statements, combined with script description information to provide targeted guidance, fully utilizing the reasoning ability of the large language model to generate scripts. This provides an automated script generation solution, solving the problems of low efficiency and error-proneness in manual script writing, improving script generation efficiency, and ensuring script quality. Secondly, automatic parsing and function extraction are implemented for the sample script. Standardized functions abstracted from script lines replace fixed script templates and frameworks, and replace the complex if-then rule writing in expert systems. This eliminates the need for professional personnel to edit and maintain script templates and frameworks, as well as the need for professional personnel to build and maintain rule bases, reducing the technical threshold and operational costs. Thirdly, users can input script description information according to their own needs. The large language model combines standardized functions based on the script description information to generate different types of scripts, which improves the flexibility and diversity of script generation. Furthermore, when it is necessary to apply it to new scenarios, the function set can be updated or expanded by updating the sample scripts, thereby supporting the generation of scripts for new scenarios without having to reconstruct the entire system. Therefore, the solution has high applicability and scalability.

[0099] Bus 930 is used to connect different components of electronic device 900 and may include a data bus, an address bus, and a control bus. Electronic device 900 can communicate with one or more external devices 1000 (e.g., keyboard, mouse, external controller, etc.) via I / O interface 940. Electronic device 900 can communicate with one or more networks via network adapter 950. For example, network adapter 950 can provide mobile communication solutions such as 3G / 4G / 5G, or wireless communication solutions such as wireless LAN, Bluetooth, and near-field communication. Network adapter 950 can communicate with other modules of electronic device 900 via bus 930.

[0100] In one embodiment, the electronic device 900 further includes a display for displaying a graphical user interface.

[0101] although Figure 9 As not shown in the diagram, other hardware and / or software modules may also be configured in the electronic device 900, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (Redundant Arrays of Independent Disks) systems, tape drives, and data backup storage systems.

[0102] As can be seen from the above, the technical solutions disclosed herein can be implemented as methods, apparatus, systems, computer program products, storage media, electronic devices, etc. Those skilled in the art will understand that various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which may be referred to as "circuit," "module," or "system," respectively.

[0103] It should be understood that this disclosure is not limited to the specific methods, steps, or structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. Those skilled in the art will readily conceive of other embodiments based on the specific implementations provided in this disclosure. Therefore, the specific implementations provided in this disclosure are merely exemplary, and the scope and spirit of this disclosure are indicated by the claims, and should cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary technical means in the art not disclosed in this disclosure.

Claims

1. A script generation method, characterized in that, The method includes: Obtain multiple sample scripts; each sample script includes one or more script lines, and each script line includes script instructions and script parameters; A function set is constructed based on the script lines in the multiple sample scripts; the function set includes one or more standardized functions; the standardized functions represent the execution of corresponding script statements based on the input script parameters; The prompt information is determined based on the function set and script description information; The prompt information is input into the large language model, and a first script is generated based on the output information of the large language model.

2. The method according to claim 1, characterized in that, The step of constructing a function set based on script lines in the plurality of sample scripts includes: Extract instruction patterns from script lines in the plurality of sample scripts; the instruction pattern includes a tuple formed by the script instruction and the script parameters corresponding to the script instruction. Standardized functions are constructed based on the instruction pattern, and the function set is formed based on the constructed standardized functions.

3. The method according to claim 2, characterized in that, The construction of standardized functions based on the instruction pattern includes: The command patterns are statistically analyzed, and high-frequency command patterns are determined from the command patterns based on the statistical results. A standardized function is constructed based on the high-frequency instruction pattern.

4. The method according to claim 2, characterized in that, The construction of standardized functions based on the instruction pattern includes: The script statement containing the script instructions and the script parameters is determined based on the instruction pattern; Generate a function name, and construct the standardized function based on the function name, the script parameters, and the script statements.

5. The method according to claim 1, characterized in that, The method further includes: Determine the constraint information of the script parameters; The process of determining the prompt information based on the function set and script description information includes: The prompt information is determined based on the function set, the constraint information, and the script description information.

6. The method according to claim 5, characterized in that, Determining the prompt information based on the function set, the constraint information, and the script description information includes: The function set and the constraint information are filled into the prompt template and merged with the script description information to form the prompt information.

7. The method according to claim 5, characterized in that, The constraint information includes a value range; the constraint information for determining the script parameters includes: Iterate through the sample scripts to obtain sample values ​​of the script parameters; The value range of the script parameters is determined based on the sample values ​​of the script parameters.

8. The method according to any one of claims 1 to 7, characterized in that, The output information of the large language model includes a second script; the generation of the first script based on the output information of the large language model includes: Verify the second script; If the verification passes, the second script will be used as the first script; If the verification fails, obtain the verification feedback information, regenerate the script based on the verification feedback information, and if the regenerated script passes the verification, use the regenerated script as the first script.

9. The method according to claim 8, characterized in that, The verification of the second script includes: Perform syntax checking on the second script, and / or perform constraint validation on the second script.

10. A script generation apparatus, characterized in that, The device includes: The sample script acquisition module is configured to acquire multiple sample scripts; each sample script includes one or more script lines, and each script line includes script instructions and script parameters. A function construction module is configured to construct a function set based on script lines in the plurality of sample scripts; the function set includes one or more standardized functions; the standardized functions represent the execution of corresponding script statements based on input script parameters; The prompt message determination module is configured to determine the prompt message based on the function set and script description information; The model processing module is configured to input the prompt information into a large language model and generate a first script based on the output information of the large language model.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 9.

12. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to implement the method of any one of claims 1 to 9 by executing the executable instructions.