Automatic generation method, device, electronic device and storage medium of TCL command
通过自动生成TCL命令的方法,用户只需输入设计需求,利用嵌入模型和大语言模型生成并校验命令,解决了现有技术中学习成本高、效率低、准确性差的问题,实现了快速、 The accurate TCL command is generated.
Patent Information
- Application Number
- CN202411516142.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-29
AI Technical Summary
In the prior art, when a user obtains the TCL commands of the EDA tool, the learning cost is high, the efficiency is low, and the accuracy is poor, making it difficult to quickly obtain the required commands.
By obtaining the design requirements of the user input, the embedded model is used to transform it into a demand vector, calculate the similarity of the fragment vector in the vector database, determine the candidate segment vector, and use the heavy sorting model to determine the most related target fragment vector. Combined with design requirements and target TCL command help information, enter to the TCL command large language model to generate and check the target TCL command to ensure that it meets the design needs.
It greatly reduces the learning cost of users, improves the generating efficiency of the TCL command, ensures that the accuracy of the generated command is high, and can quickly meet the user's design needs.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of integrated circuit design, and in particular to a method, device, electronic device and storage medium for automatically generating TCL commands. Background Art
[0002] EDA (Electronic Design Automation) tools usually integrate a large number of customized TCL commands to implement various links in integrated circuit design, such as circuit simulation, synthesis, layout, and verification. Users need to master the command options, syntax, and application scenarios through tool documentation manuals, and write executable scripts to complete specific tasks. However, there may be more than dozens of options for commands used in development, and in-depth professional knowledge is required to correctly understand the role of each option and the complex constraints between options. Writing executable TCL commands through manual practice and debugging reduces the efficiency of tool use.
[0003] For a new EDA tool, even experienced users with clear design requirements still need to re-familiarize themselves with the tool's command manual and find commands that correspond to their needs. The command structure of some tools is relatively complex, and the command option settings have their specific uses and rules, and there may be complex dependency constraints between options. For junior layout designers, how to combine these options to build correct and effective commands requires time-consuming attempts to ensure that the commands can be executed correctly and achieve the expected design effect.
[0004] In summary, how to enable users to quickly, conveniently and accurately obtain the TCL commands of the EDA tools they need and reduce the learning cost has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a method, device, electronic device and storage medium for automatically generating TCL commands, so as to alleviate the technical problems of high learning cost, low efficiency and poor accuracy faced by traditional technology users when obtaining the TCL commands of the EDA tools they need.
[0006] In a first aspect, an embodiment of the present invention provides a method for automatically generating a TCL command, comprising:
[0007] Obtaining design requirements input by a user, and converting the design requirements into a requirement vector using an embedding model;
[0008] Calculating the similarity between the requirement vector and each fragment vector in a vector database, and determining a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: a plurality of fragments of TCL command Help information, a fragment vector corresponding to each of the fragments, and metadata of the fragment vector;
[0009] Determine a target segment vector most relevant to the requirement vector from the candidate segment vectors by using a reordering model, and determine target TCL command Help information corresponding to the target segment vector;
[0010] Combining the design requirement and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning a large language model using a TCL command data set;
[0011] The target TCL command is verified to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirement.
[0012] Further, each of the fragment vectors is obtained by transforming a corresponding fragment of the TCL command Help information using an embedding model;
[0013] The metadata is used to represent the TCL command corresponding to the fragment vector and the position of the TCL command corresponding to the fragment vector in the TCL command manual.
[0014] Furthermore, the training process of the TCL command large language model includes:
[0015] Parsing a YAML file by flex-bison to obtain an abstract syntax tree, wherein the YAML file includes a DSL programming language, and the DSL programming language is used to describe TCL commands in a TCL command manual;
[0016] Randomly set a value for an option node in the abstract syntax tree, traverse the logic nodes in the abstract syntax tree, and generate a TCL command sample according to the constraint rules of the logic nodes;
[0017] Generating a description of the TCL command sample from the TCL command sample using a prompting project;
[0018] The TCL command sample and the description of the TCL command sample are used as a TCL command data set, wherein each TCL command data in the TCL command data set includes: an instruction, an input, and an output, the instruction is Help information of the TCL command sample, the input is the description of the TCL command sample, and the output is the TCL command sample;
[0019] The TCL command data set is used to perform fine-tuning training on the large language model to obtain the TCL command large language model.
[0020] Further, the target TCL command is verified, including:
[0021] Obtain a target abstract syntax tree of the target TCL command;
[0022] The target TCL command is verified for option node dependencies and their values according to the target abstract syntax tree to obtain the successfully verified target TCL command.
[0023] Furthermore, the method further comprises:
[0024] If the target TCL command verification fails, the TCL command large language model is used to rewrite the design requirement to obtain a new design requirement, and the new design requirement is used as the design requirement. The process returns to the step of converting the design requirement into a requirement vector using an embedded model until the target TCL command verification succeeds, or the number of verifications reaches a preset threshold.
[0025] Furthermore, the fine-tuning training process adopts supervised fine-tuning and low-rank adaptation fine-tuning methods.
[0026] Furthermore, the method further comprises:
[0027] If the target TCL command still fails to be verified when the number of verifications reaches the preset number threshold, an error prompt is returned.
[0028] In a second aspect, an embodiment of the present invention further provides a device for automatically generating a TCL command, comprising:
[0029] An acquisition and conversion unit, used for acquiring the design requirements input by the user, and converting the design requirements into a requirement vector by using an embedding model;
[0030] a calculating and determining unit, configured to calculate the similarity between the requirement vector and each fragment vector in a vector database, and determine a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: a plurality of fragments of TCL command Help information, a fragment vector corresponding to each of the fragments, and metadata of the fragment vector;
[0031] a determining unit, configured to determine a target segment vector most relevant to the requirement vector from among the candidate segment vectors by using a reordering model, and determine target TCL command Help information corresponding to the target segment vector;
[0032] A combination and input unit, used for combining the design requirement and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using a TCL command data set;
[0033] The verification unit is used to verify the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements.
[0034] In a third aspect, an embodiment of the present invention further 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 implements the steps of any one of the methods described in the first aspect when executing the computer program.
[0035] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to execute any method described in the first aspect above.
[0036] In an embodiment of the present invention, a method for automatically generating TCL commands is provided, comprising: obtaining design requirements input by a user, and converting the design requirements into a requirement vector by using an embedding model; calculating the similarity between the requirement vector and each fragment vector in a vector database, and determining a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: multiple fragments of TCL command Help information, a fragment vector corresponding to each fragment, and metadata of the fragment vector; using a reordering model to determine a target fragment vector most relevant to the requirement vector in the candidate fragment vector, and determining target TCL command Help information corresponding to the target fragment vector; combining the design requirements and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using a TCL command data set; verifying the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements. From the above description, it can be seen that in the automatic generation method of TCL commands of the present invention, the user only needs to input his own design requirements, and the method can automatically generate the target TCL commands that have been verified successfully, which greatly reduces the user's learning cost and improves the generation efficiency of TCL commands. In addition, when generating the target TCL commands that have been verified successfully, not only the user's design requirements are referred to, but also the target TCL command Help information is referred to. The target TCL command Help information is the TCL command Help information that is most relevant to the design requirements. Finally, the target TCL commands output by the TCL command large language model according to the design requirements and the target TCL command Help information are accurate and can meet the user's design requirements. In addition, the generated target TCL commands are also verified, and the verified target TCL commands are more accurate, which can help users quickly, conveniently and accurately obtain the TCL commands of the EDA tool (using the EDA tool), reducing the learning cost and alleviating the technical problems of high learning cost, low efficiency and poor accuracy of traditional technology users when obtaining the TCL commands of the EDA tools they need. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A flowchart of a method for automatically generating TCL commands provided by an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of generating a target TCL command provided by an embodiment of the present invention;
[0040] Figure 3 A schematic diagram of a TCL command data sample provided by an embodiment of the present invention;
[0041] Figure 4 A schematic diagram of an automatic generation device of TCL commands provided by an embodiment of the present invention;
[0042] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] In traditional technologies, when users obtain the TCL commands of the EDA tools they need, the learning cost is high, the efficiency is low, and the accuracy is poor.
[0045] Based on this, in the automatic generation method of TCL commands of the present invention, the user only needs to input his own design requirements, and the method can automatically generate the target TCL commands that have been verified successfully, which greatly reduces the user's learning cost and improves the generation efficiency of TCL commands. In addition, when generating the target TCL commands that have been verified successfully, not only the user's design requirements are referred to, but also the target TCL command Help information is referred to. The target TCL command Help information is the TCL command Help information that is most relevant to the design requirements. Finally, the target TCL commands output by the TCL command large language model according to the design requirements and the target TCL command Help information are accurate and can meet the user's design requirements. In addition, the generated target TCL commands are also verified, and the verified target TCL commands are more accurate, which can help users quickly, conveniently and accurately obtain the TCL commands of the EDA tool (using the EDA tool), reducing the learning cost.
[0046] To facilitate understanding of this embodiment, a method for automatically generating a TCL command disclosed in an embodiment of the present invention is first introduced in detail.
[0047] Embodiment 1:
[0048] According to an embodiment of the present invention, an embodiment of a method for automatically generating TCL commands is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0049] Figure 1 is a flow chart of a method for automatically generating TCL commands according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0050] Step S102, obtaining the design requirements input by the user, and converting the design requirements into a requirement vector using an embedding model;
[0051] In an embodiment of the present invention, with the advancement of artificial intelligence, especially the development of LLM (Large Language Model), with the help of AI capabilities, it is possible to understand user intentions based on natural language input and automatically generate reasonable TCL command examples, thereby simplifying user operations. However, the generation capability that relies solely on LLM is often limited by model training data, especially when facing proprietary commands in specific fields and optional commands may not be accurate enough. Therefore, it is necessary to obtain a large language model of TCL commands and use the large language model of TCL commands to output the target TCL commands.
[0052] However, the process of only using the TCL command large language model to output the target TCL command according to the user's design requirements is not accurate enough for the target TCL command, and has poor relevance to the user's design requirements. Therefore, combining the target TCL command Help information that is most relevant to the user's design requirements, and then using the TCL command large language model to output the target TCL command according to the user's design requirements and the target TCL command Help information, can significantly improve the accuracy and relevance of the generated results, help users use EDA tools quickly and accurately, reduce learning costs, and bring technological progress in the field of chip design.
[0053] During implementation, the design requirements input by the user are converted into a fixed-length requirement vector through the Embedding model.
[0054] Step S104, calculating the similarity between the demand vector and each segment vector in the vector database, and determining a candidate segment vector from each segment vector according to the similarity, wherein the vector database includes: multiple segments of TCL command Help information, a segment vector corresponding to each segment, and metadata of the segment vector;
[0055] Specifically, the similarity may be cosine similarity, and then the similarities are sorted from large to small, and then the first K similarities are selected according to the similarity sorting sequence, and the segment vectors corresponding to the first K similarities are used as candidate segment vectors.
[0056] The above-mentioned vector database includes multiple fragments of TCL command Help information, that is, the Help information of each TCL command in the TCL command manual is taken as a Chunk. The above-mentioned fragment is converted into a fragment vector of fixed length through the Embedding model, and metadata is added to the fragment vector, so as to obtain a vector database (i.e., Chroma database) containing multiple fragments of TCL command Help information, a fragment vector corresponding to each fragment and metadata of the fragment vector. The fragments of TCL command Help information, the fragment vectors and metadata in the vector database are related to each other.
[0057] Step S106, using the reordering model to determine the target segment vector most relevant to the requirement vector among the candidate segment vectors, and determining the target TCL command Help information corresponding to the target segment vector;
[0058] Specifically, after obtaining the similarity sorting sequence, the ReRank model is used to screen and sort again to determine the target segment vector most relevant to the requirement vector (that is, the user's design requirement), and then determine the target TCL command Help information corresponding to the target segment vector.
[0059] Step S108, combining the design requirement and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into the TCL command large language model to obtain the target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using the TCL command data set;
[0060] When implemented, Figure 2 As shown in the figure, the RAG (Retrieval-Augmented Generation) technology retrieves the most relevant target TCL command Help information from the tool command knowledge base (i.e., vector database) in combination with the design requirements input by the user, and inputs the design requirements and the target TCL command Help information (i.e., prompt information, Prompt Template) into the TCL command large language model to generate target TCL commands that are highly relevant to the user's design requirements.
[0061] Step S110 , verifying the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements.
[0062] In an embodiment of the present invention, a method for automatically generating TCL commands is provided, comprising: obtaining design requirements input by a user, and converting the design requirements into a requirement vector by using an embedding model; calculating the similarity between the requirement vector and each fragment vector in a vector database, and determining a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: multiple fragments of TCL command Help information, a fragment vector corresponding to each fragment, and metadata of the fragment vector; using a reordering model to determine a target fragment vector most relevant to the requirement vector in the candidate fragment vector, and determining target TCL command Help information corresponding to the target fragment vector; combining the design requirements and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using a TCL command data set; verifying the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements. From the above description, it can be seen that in the automatic generation method of TCL commands of the present invention, the user only needs to input his own design requirements, and the method can automatically generate the target TCL commands that have been verified successfully, which greatly reduces the user's learning cost and improves the generation efficiency of TCL commands. In addition, when generating the target TCL commands that have been verified successfully, not only the user's design requirements are referred to, but also the target TCL command Help information is referred to. The target TCL command Help information is the TCL command Help information that is most relevant to the design requirements. Finally, the target TCL commands output by the TCL command large language model according to the design requirements and the target TCL command Help information are accurate and can meet the user's design requirements. In addition, the generated target TCL commands are also verified, and the verified target TCL commands are more accurate, which can help users quickly, conveniently and accurately obtain the TCL commands of the EDA tool (using the EDA tool), reducing the learning cost and alleviating the technical problems of high learning cost, low efficiency and poor accuracy of traditional technology users when obtaining the TCL commands of the EDA tools they need.
[0063] The above content briefly introduces the automatic generation method of TCL commands of the present invention. The specific contents involved are described in detail below.
[0064] In an optional embodiment of the present invention, each fragment vector is obtained by transforming a fragment of the corresponding TCL command Help information using an embedding model;
[0065] The metadata is used to characterize the TCL command corresponding to the fragment vector and the position of the TCL command corresponding to the fragment vector in the TCL command manual.
[0066] In an optional embodiment of the present invention, the training process of the TCL command large language model includes the following steps:
[0067] (1) Parse the YAML file through flex-bison to obtain an abstract syntax tree, where the YAML file includes a DSL programming language, which is used to describe TCL commands in the TCL command manual;
[0068] (2) Randomly set the value of the option node in the abstract syntax tree, traverse the logical nodes in the abstract syntax tree, and generate TCL command samples according to the constraint rules of the logical nodes;
[0069] (3) Generate descriptions of TCL command samples using prompt engineering for TCL command samples;
[0070] (4) taking the TCL command sample and the description of the TCL command sample as a TCL command data set, wherein each TCL command data in the TCL command data set includes: an instruction, an input, and an output, the instruction is the TCL command sample Help information, the input is the description of the TCL command sample, and the output is the TCL command sample;
[0071] (5) The TCL command dataset is used to fine-tune the large language model to obtain the TCL command large language model.
[0072] Specifically, the general LLM (i.e., large language model) has significant advantages in the field of natural language processing, but in the TCL command generation task, the LLM may give TCL commands that do not conform to the format, and there is also an unstable output. Therefore, it is necessary to fine-tune the LLM with enterprise-private data. The method of constructing a fine-tuning dataset and fine-tuning the LLM is:
[0073] a. Use YAML files as configuration data of DSL programming language to describe built-in commands of EDA tools. Therefore, flex-bison is used to parse the YAML files, generate an abstract syntax tree, and obtain the constraint relationship between command options. The above abstract syntax tree includes: option nodes and logic nodes.
[0074] b. Randomly add different restriction constraints (i.e. randomly set values for option nodes in the abstract syntax tree), traverse the logical nodes on the AST (abstract syntax tree), and generate correct TCL command samples according to the constraint rules of the logical nodes;
[0075] c. Generate descriptions of TCL command samples through LLM (Large Language Model) and Prompt Engineering;
[0076] d. Construct an instruction fine-tuning dataset (i.e., a TCL command dataset). Each TCL command data includes: instruction, input, and output. The Help information of the TCL command sample is used as the instruction, the description of the TCL command sample is used as the input, and the TCL command sample is used as the output. The TCL command data sample is as follows: Figure 3 As shown;
[0077] e. Based on SFT (Supervised Fine-tuning) and LoRA (Low-Rank Adaptation), the TCL command dataset is used to fine-tune the LLM (i.e., large language model) to obtain the TCL command large language model.
[0078] In addition, after SFT fine-tuning, LLM can be aligned and tuned by PPO or DPO. When fine-tuning the LLM weight parameters, in addition to the LoRA fine-tuning method, QLoRA, AdaLoRA and other fine-tuning methods can also be used.
[0079] In an optional embodiment of the present invention, verifying the target TCL command specifically includes the following steps:
[0080] (1) Get the target abstract syntax tree of the target TCL command;
[0081] (2) Verify the option node dependencies and their values of the target TCL command according to the target abstract syntax tree to obtain a successfully verified target TCL command.
[0082] Specifically, Agent is a system that can make decisions and execute tasks autonomously. It can complete the workflow of target TCL command verification based on the input and output of the TCL command language model and the preset strategy. After obtaining the target TCL command, it calls the DslCheck API to verify option dependencies and parse option values based on AST (i.e., the target abstract syntax tree of the target TCL command) to obtain the successfully verified target TCL command.
[0083] In an optional embodiment of the present invention, the method further comprises the following steps:
[0084] If the target TCL command verification fails, the TCL command large language model is used to rewrite the design requirements to obtain new design requirements, and the new design requirements are used as the design requirements. The process returns to the step of converting the design requirements into requirement vectors using the embedded model until the target TCL command verification succeeds, or the number of verifications reaches a preset threshold.
[0085] Specifically, if the target TCL command is successfully verified, the command generation process ends. If the verification fails, the TCL command large language model is used to rewrite the design requirements to obtain new design requirements, and the new design requirements are used as design requirements. Return to the step of converting the design requirements into requirement vectors using the embedded model until the verification succeeds or reaches the preset number of times threshold. When the preset number of times threshold is reached and the verification still fails, the Error generated by the verification failure is returned (that is, if the verification times reach the preset number of times threshold, the target TCL command still fails to verify, and an error prompt is returned).
[0086] In the automatic generation method of TCL commands of the present invention, first, a correct TCL command sample is generated based on DSL, a description is generated for the TCL command sample through LLM, a TCL command data set is constructed to fine-tune the LLM, and a large language model of TCL commands is obtained; then, the enterprise TCL command manual is loaded into a vector database through Embedding technology, and the target TCL command is generated by RAG technology; finally, whether the generated target TCL command is legal is judged based on Agent.
[0087] In the automatic generation method of TCL commands of the present invention, first, a TCL command data set is automatically constructed based on DSL and LLM to provide enterprises with a real and reliable training data source. Secondly, LLM is fine-tuned based on SFT and LoRA to maximize the correctness of the target TCL commands generated by the TCL command large language model for EDA tools. Then, after the user enters the design requirements, the target TCL commands that can be successfully executed are generated in real time based on RAG to improve the user experience. Finally, the verification of the generated target TCL commands is realized based on Agent to further improve the accuracy of command generation.
[0088] Embodiment 2:
[0089] The embodiment of the present invention further provides an automatic generation device for TCL commands, which is mainly used to execute the automatic generation method for TCL commands provided in the first embodiment of the present invention. The automatic generation device for TCL commands provided in the embodiment of the present invention is specifically introduced below.
[0090] Figure 4 is a schematic diagram of an automatic generation device of TCL commands according to an embodiment of the present invention, such as Figure 4 As shown, the device mainly includes: an acquisition and conversion unit 10, a calculation and determination unit 20, a determination unit 30, a combination and input unit 40, and a verification unit 50, wherein:
[0091] An acquisition and conversion unit, used to acquire the design requirements input by the user and convert the design requirements into a requirement vector using an embedding model;
[0092] A calculation and determination unit, configured to calculate the similarity between the demand vector and each segment vector in a vector database, and determine a candidate segment vector in each segment vector according to the similarity, wherein the vector database includes: segments of a plurality of TCL command Help information, a segment vector corresponding to each segment, and metadata of the segment vector;
[0093] A determination unit, configured to determine a target segment vector most relevant to the requirement vector from the candidate segment vectors by using a reordering model, and determine target TCL command Help information corresponding to the target segment vector;
[0094] A combination and input unit, used for combining the design requirements and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into the TCL command large language model to obtain the target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using the TCL command data set;
[0095] The verification unit is used to verify the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements.
[0096] In an embodiment of the present invention, a device for automatically generating TCL commands is provided, comprising: obtaining design requirements input by a user, and converting the design requirements into a requirement vector by using an embedding model; calculating the similarity between the requirement vector and each fragment vector in a vector database, and determining a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: multiple fragments of TCL command Help information, a fragment vector corresponding to each fragment, and metadata of the fragment vector; using a reordering model to determine a target fragment vector most relevant to the requirement vector in the candidate fragment vector, and determining the target TCL command Help information corresponding to the target fragment vector; combining the design requirements and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using a TCL command data set; verifying the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirements. From the above description, it can be seen that in the automatic generation device of TCL commands of the present invention, the user only needs to input his own design requirements, and the method can automatically generate the target TCL commands that have been verified successfully, which greatly reduces the user's learning cost and improves the generation efficiency of TCL commands. In addition, when generating the target TCL commands that have been verified successfully, not only the user's design requirements are referred to, but also the target TCL command Help information is referred to. The target TCL command Help information is the TCL command Help information that is most relevant to the design requirements. Finally, the target TCL commands output by the TCL command large language model according to the design requirements and the target TCL command Help information are accurate and can meet the user's design requirements. In addition, the generated target TCL commands are also verified, and the verified target TCL commands are more accurate, which can help users quickly, conveniently and accurately obtain the TCL commands of the EDA tool (using the EDA tool), reducing the learning cost and alleviating the technical problems of high learning cost, low efficiency and poor accuracy of traditional technology users when obtaining the TCL commands of the EDA tool they need.
[0097] Optionally, each fragment vector is obtained by transforming a fragment of the corresponding TCL command Help information using an embedding model; the metadata is used to characterize the TCL command corresponding to the fragment vector and the position of the TCL command corresponding to the fragment vector in the TCL command manual.
[0098] Optionally, the device is also used to: parse a YAML file through flex-bison to obtain an abstract syntax tree, wherein the YAML file includes a DSL programming language, and the DSL programming language is used to describe TCL commands in a TCL command manual; randomly set values for option nodes in the abstract syntax tree, traverse the logical nodes in the abstract syntax tree, and generate TCL command samples according to constraint rules of the logical nodes; use a prompt project to generate a description of the TCL command sample from the TCL command sample; use the TCL command sample and the description of the TCL command sample as a TCL command data set, wherein each TCL command data in the TCL command data set includes: instructions, input and output, the instruction is the TCL command sample Help information, the input is the description of the TCL command sample, and the output is the TCL command sample; and use the TCL command data set to fine-tune the large language model to obtain a TCL command large language model.
[0099] Optionally, the verification unit is further used to: obtain a target abstract syntax tree of a target TCL command; verify the option node dependency and its value of the target TCL command according to the target abstract syntax tree to obtain a successfully verified target TCL command.
[0100] Optionally, the device is also used to: if the target TCL command verification fails, rewrite the design requirements using the TCL command large language model to obtain new design requirements, and use the new design requirements as the design requirements, and return to execute the step of converting the design requirements into requirement vectors using the embedded model until the target TCL command verification succeeds, or the number of verifications reaches a preset threshold.
[0101] Optionally, supervised fine-tuning and low-rank adaptation fine-tuning methods are used during fine-tuning training.
[0102] Optionally, the device is also used to: if the verification times reach a preset threshold and the target TCL command still fails to be verified, an error prompt is returned.
[0103] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0104] like Figure 5 As shown, an electronic device 600 provided in an embodiment of the present application includes: a processor 601, a memory 602 and a bus, wherein the memory 602 stores machine-readable instructions executable by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 through the bus, and the processor 601 executes the machine-readable instructions to perform the steps of the automatic generation method of the TCL command as described above.
[0105] Specifically, the memory 602 and the processor 601 can be general-purpose memories and processors, which are not specifically limited here. When the processor 601 runs the computer program stored in the memory 602, the automatic generation method of the TCL command can be executed.
[0106] The processor 601 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 601. The above processor 601 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the above method in combination with its hardware.
[0107] Corresponding to the above-mentioned method for automatically generating TCL commands, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the steps of the above-mentioned method for automatically generating TCL commands.
[0108] The automatic generation device of the TCL command provided in the embodiment of the present application can be specific hardware on the device or software or firmware installed on the device. The device provided in the embodiment of the present application, its implementation principle and the technical effect produced are the same as those in the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the device embodiment can refer to the corresponding contents in the aforementioned method embodiment. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment, and will not be repeated here.
[0109] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0110] For another example, the flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the device, method and computer program product according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0111] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0112] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0113] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the automatic generation method of TCL commands described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0114] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.
[0115] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solution of the present application, rather than to limit it. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solution recorded in the aforementioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solution deviate from the scope of the technical solution of the embodiment of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for automatically generating TCL commands, characterized in that: include: Obtaining design requirements input by a user, and converting the design requirements into a requirement vector using an embedding model; Calculating the similarity between the requirement vector and each fragment vector in a vector database, and determining a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: a plurality of fragments of TCL command Help information, a fragment vector corresponding to each of the fragments, and metadata of the fragment vector; Determine a target segment vector most relevant to the requirement vector from the candidate segment vectors by using a reordering model, and determine target TCL command Help information corresponding to the target segment vector; Combining the design requirement and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning a large language model using a TCL command data set; Verifying the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirement; Each of the fragment vectors is obtained by transforming a corresponding fragment of the TCL command Help information using an embedding model; The metadata is used to represent the TCL command corresponding to the fragment vector and the position of the TCL command corresponding to the fragment vector in the TCL command manual; The training process of the TCL command large language model includes: Parsing a YAML file by flex-bison to obtain an abstract syntax tree, wherein the YAML file includes a DSL programming language, and the DSL programming language is used to describe TCL commands in a TCL command manual; Randomly set a value for an option node in the abstract syntax tree, traverse the logic nodes in the abstract syntax tree, and generate a TCL command sample according to the constraint rules of the logic nodes; Generating a description of the TCL command sample from the TCL command sample using a prompting project; The TCL command sample and the description of the TCL command sample are used as a TCL command data set, wherein each TCL command data in the TCL command data set includes: an instruction, an input, and an output, the instruction is Help information of the TCL command sample, the input is the description of the TCL command sample, and the output is the TCL command sample; The TCL command data set is used to perform fine-tuning training on the large language model to obtain the TCL command large language model.
2. The method according to claim 1, characterized in that Verifying the target TCL command includes: Obtain a target abstract syntax tree of the target TCL command; The target TCL command is verified for option node dependencies and their values according to the target abstract syntax tree to obtain the successfully verified target TCL command.
3. The method according to claim 1, characterized in that The method further comprises: If the target TCL command verification fails, the TCL command large language model is used to rewrite the design requirement to obtain a new design requirement, and the new design requirement is used as the design requirement. The process returns to the step of converting the design requirement into a requirement vector using an embedded model until the target TCL command verification succeeds, or the number of verifications reaches a preset threshold.
4. The method according to claim 1, characterized in that: The fine-tuning training process adopts supervised fine-tuning and low-rank adaptation fine-tuning methods.
5. The method according to claim 3, characterized in that: The method further comprises: If the target TCL command still fails to be verified when the number of verifications reaches the preset number threshold, an error prompt is returned.
6. A device for automatically generating TCL commands, characterized in that: include: An acquisition and conversion unit, used for acquiring the design requirements input by the user, and converting the design requirements into a requirement vector by using an embedding model; a calculating and determining unit, configured to calculate the similarity between the requirement vector and each fragment vector in a vector database, and determine a candidate fragment vector in each fragment vector according to the similarity, wherein the vector database includes: a plurality of fragments of TCL command Help information, a fragment vector corresponding to each of the fragments, and metadata of the fragment vector; a determining unit, configured to determine a target segment vector most relevant to the requirement vector from among the candidate segment vectors by using a reordering model, and determine target TCL command Help information corresponding to the target segment vector; A combination and input unit, used for combining the design requirement and the target TCL command Help information to obtain prompt word information, and inputting the prompt word information into a TCL command large language model to obtain a target TCL command, wherein the TCL command large language model is obtained by fine-tuning the large language model using a TCL command data set; A verification unit, configured to verify the target TCL command to obtain a successfully verified target TCL command, wherein the successfully verified target TCL command meets the design requirement; Each of the fragment vectors is obtained by transforming a corresponding fragment of the TCL command Help information using an embedding model; The metadata is used to represent the TCL command corresponding to the fragment vector and the position of the TCL command corresponding to the fragment vector in the TCL command manual; The device is further used for: parsing a YAML file through flex-bison to obtain an abstract syntax tree, wherein the YAML file includes a DSL programming language, and the DSL programming language is used to describe TCL commands in a TCL command manual; randomly setting values for option nodes in the abstract syntax tree, traversing the logic nodes in the abstract syntax tree, and generating TCL command samples according to constraint rules of the logic nodes; using a prompt project to generate a description of the TCL command sample from the TCL command sample; using the TCL command sample and the description of the TCL command sample as a TCL command data set, wherein each TCL command data in the TCL command data set includes: instructions, input and output, the instruction is the TCL command sample Help information, the input is the description of the TCL command sample, and the output is the TCL command sample; and using the TCL command data set to fine-tune a large language model to obtain the TCL command large language model.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Model-based interaction method and device, electronic equipment and storage medium
CN117235222A
Electronic design automation script pre-checking method, system and equipment and storage medium
CN117850984A