CN-122018868-A - Large-model-based complex instruction code generation method and system
Abstract
The invention discloses a complex instruction code generation method and system based on a large model, wherein the method firstly obtains the requirement of controlling intelligent household appliances input by a user, and then converts the requirement into a plurality of different pseudo codes by utilizing a finely-adjusted large model, wherein the capability of the intelligent household appliances is used as a prompt word in the finely-adjusted large model, and the control method is predefined according to the prompt word; and finally, generating executable instruction codes according to the optimal pseudo codes for controlling the intelligent household appliances. The invention can accurately understand the complex user demands and accurately generate the instruction codes.
Inventors
- WANG HAIKUAN
- XU JIANMING
Assignees
- 北京楠社科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260129
Claims (10)
- 1. A complex instruction code generation method based on a large model is characterized by comprising the following steps: Acquiring a requirement of controlling intelligent household appliances input by a user; Converting the requirements into a plurality of different pseudo codes by utilizing a fine-tuned large model, wherein the fine-tuned large model takes the capacity of intelligent household appliances as a prompt word, and predefining a control method according to the prompt word; screening the optimal pseudo code from a plurality of different pseudo codes; and generating executable instruction codes according to the optimal pseudo codes, and controlling the intelligent household appliances.
- 2. The method for generating complex instruction codes based on large models as recited in claim 1, wherein the method for generating executable instruction codes according to the optimal pseudo-code comprises extracting control methods in the optimal pseudo-code, and converting the control methods into method functions in the instruction codes to obtain the executable instruction codes.
- 3. The large model based complex instruction code generating method according to claim 2, wherein the method functions in the instruction code include a query method and a setting method.
- 4. The method for generating complex instruction codes based on big models according to claim 1, wherein the method for screening the optimal pseudo codes from the plurality of different pseudo codes comprises screening the pseudo codes by using a grammar checker to obtain first pseudo codes, if the number of the first pseudo codes is 0, converting the requirement into the plurality of different pseudo codes by reusing the trimmed big models, if the number of the first pseudo codes is 1, the first pseudo codes are the optimal pseudo codes, otherwise, screening the optimal pseudo codes according to the similarity between the first pseudo codes and the requirement.
- 5. The method for generating complex instruction codes based on large models as claimed in claim 4, wherein said method for screening optimal pseudo-codes based on the similarity of said first pseudo-code to said requirement comprises: And converting the first pseudo code into natural language by using the trimmed large model, calculating the similarity between the natural language and the requirement, and selecting the first pseudo code with the highest similarity as the optimal pseudo code.
- 6. The large model based complex instruction code generation method according to claim 5, wherein the method of calculating the similarity of the natural language to the demand comprises: Using a TF-IDF model to segment the natural language and the requirement to respectively obtain a first feature vector and a second feature vector, and calculating a cosine similarity token_sim between the first feature vector and the second feature vector; Embedding the natural language and the requirements by using a BGE model to respectively obtain a third feature vector and a fourth feature vector, and calculating cosine similarity semantic _sim between the third feature vector and the fourth feature vector; calculating similarity of the natural language to the demand , wherein, , Is a super parameter.
- 7. A large model based complex instruction code generation system, comprising: The demand acquisition unit is used for acquiring the demand which is input by a user and used for controlling the intelligent household appliance; the pseudo code generation unit is used for converting the requirements into a plurality of different pseudo codes by utilizing a fine-tuned large model, wherein the fine-tuned large model takes the capacity of the intelligent household appliance as a prompt word, and a control method is predefined according to the prompt word; An optimal pseudo code screening unit, configured to screen an optimal pseudo code from a plurality of different pseudo codes; And the instruction code generating unit is used for generating executable instruction codes according to the optimal pseudo codes and controlling the intelligent household appliances.
- 8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the computer program when loaded to the processor implements the large model based complex instruction code generation method according to any of claims 1-6.
- 9. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the large model based complex instruction code generation method according to any of claims 1-6.
- 10. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the large model based complex instruction code generation method according to any of claims 1-6.
Description
Large-model-based complex instruction code generation method and system Technical Field The invention relates to the field of intelligent home control, in particular to a method and a system for generating complex instruction codes based on a large model. Background The intelligent home has entered a high-speed development stage, various intelligent home appliances, security devices, environment adjusting devices and the like are interconnected and intercommunicated, and a user can intelligently control the home devices. The current intent understanding model can only understand simple instruction requirements entered by the user, such as turning on a bedroom light, or simple multiple instructions, such as turning on a bedroom light and then turning off a living room window covering light. However, for complex instruction requirements related to condition judgment, time waiting, circulation and the like, the requirements of the complex instructions cannot be understood and processed, so that a user cannot reach personalized instructions according to living scenes, the functional boundaries of intelligent home are limited, and the flexibility and convenience of intelligent control are reduced. Disclosure of Invention The invention aims to provide a large model-based complex instruction code generation method and system, which can understand the complex intention of a user and convert the complex intention into executable code. The technical scheme is that the complex instruction code generation method based on the large model comprises the following steps: Acquiring a requirement of controlling intelligent household appliances input by a user; Converting the requirements into a plurality of different pseudo codes by utilizing a fine-tuned large model, wherein the fine-tuned large model takes the capacity of intelligent household appliances as a prompt word, and predefining a control method according to the prompt word; screening the optimal pseudo code from a plurality of different pseudo codes; and generating executable instruction codes according to the optimal pseudo codes, and controlling the intelligent household appliances. Further, the method for generating the executable instruction code according to the optimal pseudo code comprises the steps of extracting a control method in the optimal pseudo code, and converting the control method into a method function in the instruction code to obtain the executable instruction code. Further, the method functions in the instruction code include a query method and a setting method. Further, the method for screening the optimal pseudo codes from the plurality of different pseudo codes comprises the steps of screening the pseudo codes by using a grammar checker to obtain first pseudo codes, converting the requirement into the plurality of different pseudo codes by reusing the trimmed large model if the number of the first pseudo codes is 0, enabling the first pseudo codes to be the optimal pseudo codes if the number of the first pseudo codes is 1, and otherwise screening the optimal pseudo codes according to the similarity between the first pseudo codes and the requirement. Further, the method for screening the optimal pseudo code according to the similarity between the first pseudo code and the requirement comprises the following steps: And converting the first pseudo code into natural language by using the trimmed large model, calculating the similarity between the natural language and the requirement, and selecting the first pseudo code with the highest similarity as the optimal pseudo code. Further, the method for calculating the similarity of the natural language and the requirement comprises the following steps: Using a TF-IDF model to segment the natural language and the requirement to respectively obtain a first feature vector and a second feature vector, and calculating a cosine similarity token_sim between the first feature vector and the second feature vector; Embedding the natural language and the requirements by using a BGE model to respectively obtain a third feature vector and a fourth feature vector, and calculating cosine similarity semantic _sim between the third feature vector and the fourth feature vector; calculating similarity of the natural language to the demand , wherein,,Is a super parameter. The invention relates to a complex instruction code generation system based on a large model, which comprises the following steps: The demand acquisition unit is used for acquiring the demand which is input by a user and used for controlling the intelligent household appliance; the pseudo code generation unit is used for converting the requirements into a plurality of different pseudo codes by utilizing a fine-tuned large model, wherein the fine-tuned large model takes the capacity of the intelligent household appliance as a prompt word, and a control method is predefined according to the prompt word; An optimal pseudo code screening unit, configured