The invention discloses a
code generation method based on a model, which is used for improving the generation efficiency of codes and relates to the technical field of
artificial intelligence (AI). According to the application, for the given demand document, the
service process in the demand document is analyzed through the AI model, and the
service process in the demand document is presented by adopting a state
machine representation mode, so that an interactive interface for representing the
service process based on the state is realized, and an interactive action for representing the service process based on an event for triggering state conversion is realized. State
machine representation is further analyzed through the AI model, codes are automatically generated, the manual
code writing process is omitted, and the
code generation efficiency is improved. Moreover, according to the scheme, the
language understanding capability of the AI model is utilized, the complex
business process is firstly converted into the simple state
machine representation with a simple structure, and then the state machine representation is converted into the code, so that multi-step disassembly of the complex task is realized, and the AI model can more accurately understand the actual
business process in the
code generation process to generate the accurate code.