Methods and systems for generating code for large multi-agent models in the field of optics
By introducing optical expert agents into the code generation process in the optical field through a multi-agent large model architecture, and combining it with optical design software interfaces such as Zemax, the problem of insufficient understanding of professional terminology in optical code generation is solved, achieving efficient and accurate automatic code generation, and reducing development complexity and cost.
Patent Information
- Application Number
- CN202511678526.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-17
- Publication Date
- 2026-03-13
- Estimated Expiration
- 2045-11-17
AI Technical Summary
Existing multi-agent large models lack sufficient understanding of optical terminology in optical field code generation, and cannot correctly extract optical performance requirements and constraints, resulting in generated code errors or failure to meet actual requirements.
It adopts a multi-agent large model architecture, including a requirement understanding agent, an optical expert agent, an architecture design agent, a script generation module, and a testing and feedback module. The optical expert agent provides professional knowledge support, and combined with optical design software interfaces such as Zemax, it realizes code generation and multi-round testing feedback.
It improves the accuracy and efficiency of optical code generation, lowers the operational threshold, shortens the development cycle, reduces reliance on senior optical engineers, and significantly improves the correctness and reliability of the code.
Smart Images

Figure CN121143812B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of optical design technology, and in particular to a method and system for generating code for a large multi-agent model in the field of optics. Background Technology
[0002] Optical industrial software is widely used for modeling, simulation, and optimization design of optical systems. While powerful, it is complex and highly specialized. Taking Zemax as an example, it supports advanced functions such as ray tracing, aberration analysis, tolerance simulation, and global optimization, and is commonly used in designing optical components such as lenses and illumination systems. However, to build accurate models and perform optimizations in such software, engineers need a deep understanding of optical theory and extensive experience. Furthermore, software like Zemax typically provides scripts or secondary development interfaces, allowing users to write code to automate operations or customize optimization algorithms. However, this secondary development also requires developers to be proficient in programming and familiar with optical knowledge, making the development process complex and time-consuming. Against this backdrop, how to lower the barrier to entry for custom development of optical design software and improve the efficiency of modeling and optimization has become a key concern in the industry.
[0003] In recent years, with the development of artificial intelligence technology, automated code generation based on large language models (LLMs) has gradually emerged. On the one hand, large language models such as OpenAI's Codex and ChatGPT have demonstrated the ability to automatically generate source code from natural language descriptions, which can alleviate programming workload to some extent. On the other hand, more noteworthy is the emergence and rapid development of multi-agent collaborative code generation methods. Multi-agent refers to using multiple LLM instances to play different roles, cooperating with each other to complete complex tasks. This approach is inspired by human software team collaboration; by allowing different "agents" to perform their respective duties, development complexity can be effectively controlled, and code correctness and quality can be improved. For example, systems like MetaGPT allow LLMs to play roles such as product manager, architect, and engineer, simulating the collaborative process of a software company team; another example is the Self-Collaboration framework, which allows multiple ChatGPT instances to act as "experts" in different domains, cooperating to solve programming tasks. Simultaneously, frameworks like FlowGen have also emerged, introducing software engineering development processes into LLM interaction, significantly improving the stability and accuracy of code generation. These large-model-based automated programming techniques are constantly evolving and have shown great potential to improve development efficiency in the field of general software development.
[0004] Existing general-purpose LLM multi-agent software development frameworks can be used to generate code, but they still have many technical shortcomings in generating code specifically for industrial software in the optics vertical industry. These shortcomings are manifested in the following aspects:
[0005] The existing framework lacks a sufficient understanding of optical terminology and concepts, making it difficult to accurately interpret specific terms and their contexts in optical design and analysis. This deficiency may lead to generated code that misinterprets optical requirements or misuses optical concepts.
[0006] Existing frameworks fail to accurately extract optical performance requirements and constraints. In optical industrial software development, requirements typically include complex optical performance indicators and numerous constraints. Existing large multi-agent models often struggle to extract key requirements and translate them into development tasks, resulting in generated code that either fails to meet actual optical performance indicators or ignores key constraints. Summary of the Invention
[0007] This invention aims to address the technical problems in the prior art of insufficient understanding of optical terminology and inability to correctly extract optical performance requirements and constraints, and provides a method and system for generating code for a large multi-agent model in the field of optics.
[0008] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:
[0009] A code generation system for a large multi-agent model in the field of optics, comprising the following components connected in sequence:
[0010] Demand Understanding Agent: Used for deep understanding and organizing user needs; this demand understanding agent is driven by a large language model and uses agent model instances finely tuned with knowledge of the optical domain;
[0011] Optical expert agent: used to provide professional knowledge support and solution guidance in the field of optics; this optical expert agent is implemented by a large language model or a professional rule engine;
[0012] Architecture design agent: used to formulate the overall architecture and logic design of the script based on the requirements and the solutions provided by optical experts; this architecture design agent is responsible for planning the module division, function design and algorithm flow of the script code by a large language model or professional rule engine;
[0013] Script generation module: Used to generate specific executable script code based on the design framework provided by the architecture design agent; the implementation of this script generation module includes: calling the large model of the code generation class to convert the architecture description into target scripting language code;
[0014] Test and Feedback Module: This module is used to execute tests on the generated script code and collect feedback information. It calls the optical design software interface to run the generated script and automatically executes the expected optical operations or design processes in a simulation environment.
[0015] In the above technical solution, the system also includes:
[0016] The control and scheduling module is connected to the requirements understanding agent, the optical expert agent, the architecture design agent, the script generation module, and the test and feedback module. It is used to coordinate the workflow of the requirements understanding agent, the optical expert agent, the architecture design agent, the script generation module, and the test and feedback module, and to manage data and control the flow. The control and scheduling module is also used to activate each module sequentially according to the predetermined software development process, and to iterate and loop as necessary.
[0017] Output module: It is connected to the script generation module and the test and feedback module respectively, and is used to organize and output the final results to the user. The output module receives the final version code from the script generation module and the result report from the test and feedback module, and formats them into a form that is easy for the user to understand.
[0018] In the above technical solutions, examples of intelligent agent models are: GPT, DeepSeek, Claude, Gemini, ERNIE, ChatGLM, Mistral, or LLaMA.
[0019] In the above technical solution, the script generation module automatically generates scripts, including the ZOS-API interface of Zemax optical design software and the Code V, LightTools, and GODAS platforms.
[0020] A method for generating code for a large multi-agent model in the field of optics, applicable to the aforementioned system, includes the following steps:
[0021] Step 1: The requirements understanding agent receives structured requirements data from the input parsing module, guides the LLM to analyze and clarify the requirements through prompt templates, and generates a formalized requirements specification document or requirements list;
[0022] Step 2: The optical expert agent receives the requirements specification document and, in conjunction with the knowledge base in the field of optical design, demonstrates and supplements the feasibility of the requirements and the selection of key optical parameters.
[0023] Step 3: After obtaining the requirements document and key points of the optical solution, the architecture design agent outputs an architecture design specification or pseudocode framework.
[0024] Step 4: The script generation module receives the pseudocode or design scheme provided by the architecture design agent, and fills in the specific code implementation in the large model with prompts, including the optical calculation steps and the call to ZOS-API;
[0025] Step 5: During the test, the test and feedback module monitors the script's running status and output results: if the script throws an error or fails to meet the user's required indicators, it records the error log or deviation data.
[0026] In the above technical solution, in step 1: the demand understanding agent reasones about the input, lists the goals, functions and constraints of the optical design task, and forms the basis for subsequent steps.
[0027] In the above technical solution, in step 2: the optical expert agent calls the pre-built optical knowledge base interface to retrieve optical system design examples, formulas and empirical data, and generates optimization suggestions or preliminary optical solution ideas accordingly.
[0028] In the above technical solution, in step 3: the architecture design agent runs through a preset prompt template and gradually refines the script logic using chain-like reasoning; the architecture design product clearly defines the steps required by the script, the optical calculation methods called, and the overall approach to interacting with the optical design software.
[0029] In the above technical solution, step 4: during the generation process, a combination of prompts and self-optimization strategies are adopted to ensure consistent code style and compliance with optical field standards.
[0030] In the above technical solution, in step 5: the testing and feedback module automatically generates test scenarios in advance according to the requirements, runs the script and compares the results with the requirements; then, the module submits the execution feedback to the control and scheduling module to trigger the subsequent code correction process.
[0031] The present invention has the following beneficial effects:
[0032] The beneficial effects of the multi-agent large model code generation method and system in the optical field of the present invention specifically include:
[0033] 1) The accuracy of understanding the needs of the optics profession has been greatly improved;
[0034] Existing multi-agent frameworks such as FlowGen and MetaGPT are primarily geared towards general software development. Their agents often lack sufficient understanding of optical terminology and modeling parameters, frequently leading to ambiguities or misunderstandings in requirements. This invention introduces an "optical expert agent" and embeds it into the requirements analysis phase, enabling the system to possess reasoning capabilities based on specialized optical knowledge. This mechanism directly improves the accuracy of requirements analysis and avoids subsequent design errors caused by misunderstandings.
[0035] 2) It has a stronger ability to automatically generate scripts for optical software such as Zemax;
[0036] Most existing methods remain at the code logic level and lack structured adaptation capabilities to the APIs of optical design software such as Zemax. In contrast, this invention deeply integrates the output of the architecture design agent with the interface specifications of platforms such as Zemax.
[0037] 3) Supports multi-round test feedback and control scheduling to improve generation accuracy;
[0038] This invention constructs a complete control and scheduling mechanism, allowing test results to be fed back to agents at any stage, achieving a true "closed-loop process." The testing and feedback module automatically executes scripts by calling optical simulation software and judges the output parameters. If performance deviations or structural anomalies occur, a joint repair process involving an "optical expert agent + script generation module" can be triggered to continuously optimize design quality. This mechanism not only achieves an end-to-end feedback closed loop but also significantly improves the accuracy of the initial generation and the reliability of the final code.
[0039] 4) The overall development cycle is shortened, and optical modeling efficiency is higher;
[0040] In traditional processes, optical modeling involves requirements confirmation, manual solution development, handwritten code writing and debugging, typically taking weeks. This invention, through a modular multi-agent automated collaboration mechanism, compresses the work previously requiring multiple people into a single-input driven automated process, usually completing the generation and testing of a complete script within minutes. The parallel operation of multiple agents and structured control scheduling strategies further reduce waiting and human intervention time, significantly shortening the delivery cycle from design intent to executable script.
[0041] 5) More user-friendly for non-professional users, lowering the barrier to entry;
[0042] The method of this invention, through the intermediary assistance of a natural language input parsing module and an optical expert intelligent agent, allows users to describe design goals using non-technical language. The system can then automatically convert these into parameterized requirements and complete the entire subsequent process. This design enables users without an optical background to complete high-quality designs without needing to learn the Zemax scripting language or modeling commands, greatly expanding the system's applicable user base.
[0043] 6) Reduce reliance on senior optical engineers and lower development costs;
[0044] This invention embeds optical expert agents into a system, enabling the structured transfer of experiential knowledge into the agent's behavior. Many repetitive, high-barrier tasks can be completed automatically by the system, requiring engineer intervention only for critical innovations or complex problems. This not only reduces the burden on experts but also significantly lowers the barriers to optical development and reduces human resource costs for SMEs and R&D teams. Attached Figure Description
[0045] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0046] Figure 1 This is an overall framework diagram of the optical multi-agent large model code generation system of the present invention. Detailed Implementation
[0047] The inventive concept of this invention is as follows:
[0048] The present invention provides a method for generating code for large-scale optical models using multiple agents. This method aims to automatically generate script code that conforms to the interface specifications of optical software platforms such as Zemax, ensuring that the generated results can be directly used for professional optical modeling and simulation. By introducing "optical expert" agents at various stages of the R&D process, this invention embeds specialized optical knowledge into the entire process of requirement analysis, scheme design, and result verification, enhancing the understanding of optical semantics, constraints, and accuracy requirements, thereby significantly shortening the development cycle of optical modeling and optimization tasks.
[0049] The method for generating code for a large multi-agent model in the field of optics in this invention ensures that the generated code fully reflects and meets the performance requirements and constraints of the optical system by improving the ability to accurately understand the technical terms and concepts in the field of optics.
[0050] This invention relates to a multi-agent large-scale model code generation method in the field of optics. It is an automatic code generation method applied to the vertical field of optics, and its core utilizes a multi-agent large-scale language model architecture to collaboratively generate optical design software script code. This method leverages the collaborative work of multiple agents, not limited to the GPT series models, but also employing underlying models such as DeepSeek, Claude, Gemini, ERNIE (Baidu Wenxin large-scale model), ChatGLM (Chat Generative Language Model), Mistral, and LLaMA (Large Language Model Meta AI). The system of this invention is designed for professional tools such as Zemax optical design software, automatically generating scripts conforming to the ZOS-API (Zemax Optical Studio Application Programming Interface) specification, and through multiple rounds of feedback optimization, ultimately outputting optical script code that meets user requirements.
[0051] The present invention will now be described in detail with reference to the accompanying drawings.
[0052] The optical multi-agent large model code generation system of the present invention adopts a multi-agent large model architecture design, consisting of multiple functional modules. Each module works closely together based on agent technology or algorithm flow. The overall framework diagram is shown below. Figure 1 As shown, it includes:
[0053] 1) Demand Understanding Agent: Used for deep understanding and organizing user needs. This demand understanding agent is driven by a large language model and uses GPT model instances finely tuned with knowledge from the optical domain.
[0054] The requirements understanding agent receives structured requirements data from the input parsing module, guides the LLM to analyze and clarify the requirements using prompt templates, and generates a formalized requirements specification document. Figure 1 (Used as a requirements document) or requirements list.
[0055] In practice, the requirement understanding AI acts as a "requirement engineer" to reason about the input, listing the goals, functions, and constraints of the optical design task, thus forming the basis for subsequent steps.
[0056] 2) Optical Expert Agent: This agent provides professional knowledge support and solution guidance in the field of optics. It is also implemented using a large language model or specialized rule engine, and assumes the role of an "optical expert."
[0057] The optical expert agent receives the requirements specification document and, in conjunction with a knowledge base in the field of optical design, demonstrates and supplements the feasibility of the requirements and the selection of key optical parameters.
[0058] In practice, the optical expert agent can call the pre-built optical knowledge base interface to retrieve optical system design examples, formulas and empirical data, and generate optimization suggestions or preliminary optical solution ideas accordingly.
[0059] 3) Architecture Design Agent: This agent is used to develop the overall architecture and logical design of the script based on requirements and solutions provided by optical experts. The architecture design agent, composed of a large language model, acts as a "software architect," responsible for planning the module division, function design, and algorithm flow of the script code.
[0060] After obtaining the requirements document and key points of the optical solution, the architecture design agent outputs an architecture design specification or pseudocode framework.
[0061] In implementation, the architecture design agent runs through a pre-set prompt template (including role descriptions and design task instructions), using chain-like reasoning to progressively refine the script logic. The architecture design deliverables clearly define the main steps required by the script, the optical computation methods invoked, and the overall approach to interacting with the optical design software.
[0062] 4) Script Generation Module: This module generates executable script code based on the design framework provided by the architecture design agent. It can be viewed as a "developer" role, and its implementation includes calling the large model of the code generation class to convert the architecture description into target scripting language code.
[0063] The script generation module receives pseudocode or design schemes from the architecture design agent and, with prompts, fills in specific code implementations into a large language model, including optical computation steps and calls to the ZOS-API.
[0064] The generation process employs a combination of prompts and self-optimization strategies to ensure consistent code style and compliance with optical standards.
[0065] 5) Testing and Feedback Module: This module executes the generated script code for testing and collects feedback. It calls the optical design software interface to run the generated script, automatically performing the expected optical operations or design processes in a simulation environment; it can be considered the "tester" role.
[0066] During testing, the test and feedback module monitors the script's running status and output results: if the script throws an error or fails to meet user requirements, it records an error log or deviation data.
[0067] In implementation, the testing and feedback module can automatically generate test scenarios in advance based on the requirements specifications, run scripts, and compare the results with the requirements. Subsequently, this module submits the execution feedback to the control and scheduling module, triggering the subsequent code correction process.
[0068] The prompt template is “{“Role”: “You are a [role], responsible for [task]”, “Instruction”: “Please follow the context [role-related instructions]”, “Context”: “[context]”}”, as shown in Table 1, which contains all the template content.
[0069] Table 1 Template Fill Content
[0070]
[0071] In addition to the aforementioned multi-agent roles, the system of this invention also includes two other functional modules:
[0072] 1) Control and Scheduling Module: This module coordinates the workflows of all intelligent agent modules (requirements understanding agent, optics expert agent, architecture design agent, script generation module, and testing and feedback module) globally, managing data and control flow. This module acts as the "scheduler" within the team, activating each module sequentially according to the predetermined software development process and iterating as needed.
[0073] The control and scheduling module is implemented using a state machine or scheduling algorithm: after input parsing is complete, the requirements understanding agent, the optical expert agent, the architecture design agent, and the script generation module are invoked sequentially; after the testing and feedback module reports the results, it is determined whether to enter the repair loop. This control and scheduling module can also dynamically adjust the interaction order of the agents. For example, when test feedback indicates a functional error, the script generation module is prioritized for code correction; conversely, if feedback indicates a deviation in requirements understanding, the requirements understanding agent or the optical expert agent's correction scheme may be re-triggered.
[0074] The control and scheduling module adopts an asynchronous communication mechanism based on message queues to ensure that the intermediate results generated by each agent are correctly transmitted and to maintain data consistency and orderly task execution throughout the process.
[0075] 2) Output module: Used to organize and output the final results to the user.
[0076] The output module receives the final version code from the script generation module and the results report from the testing and feedback module, and formats it into a user-friendly format for output.
[0077] The output includes: the generated optical script source code, a summary of the script's execution results, and necessary usage instructions. The output module embeds the code into a template document, highlighting key parameters and performance metrics to help users directly obtain the desired results.
[0078] For network applications, the output module is also responsible for returning the results to the caller through the interface or API; for local applications, it saves the script file in the local file system and pops up a prompt message.
[0079] The above modules have clear division of labor and cooperate with each other to form the multi-agent large model code generation system of this invention. Among them, the intelligent agent module (requirement understanding intelligent agent, optical expert intelligent agent, architecture design intelligent agent, etc.) uses large model reasoning to generate intermediate products, the tool module (such as script generation module, testing and feedback module, etc.) is responsible for program execution and result verification, the control and scheduling module coordinates the process throughout, and finally the output module delivers the results to the user.
[0080] Without altering the aforementioned functional processes and data paths, in order to adapt to different computing power conditions, security compliance requirements, and enterprise IT environments, the system can be deployed in the following operating mode. Although the physical structure differs, the functional objectives and data processes are consistent with the technical path of this invention.
[0081] In one implementation (running locally), the control and scheduling module, the requirement understanding agent, the optical expert agent, the architecture design agent, the script generation module, the testing and feedback module, and the output module are all deployed on local workstations or data center servers. The optical design and simulation software runs under a local license. The optical domain knowledge base (including material / glass libraries, historical design specifications, and cases) is stored in a local database or file system. Each module exchanges data through a local message queue or inter-process communication. The testing and feedback module calls the optical software to execute scripts and collect results via a local API interface (Application Programming Interface) or COM interface (Serial Communication Interface). The output module generates script source code and test reports locally. In this approach, requirements, scripts, and test results do not leave the intranet, making it suitable for confidential or commercially confidential scenarios and facilitating integration with existing PLM (Product Lifecycle Management) / R&D management systems.
[0082] This invention provides a method for generating code for a large multi-agent model in the optical field. The system to which this method is applicable is the aforementioned system, and the method includes the following steps:
[0083] Step 1: The requirements understanding agent receives structured requirements data from the input parsing module, guides the LLM to analyze and clarify the requirements through prompt templates, and generates a formalized requirements specification document or requirements list;
[0084] Among them, the demand understanding agent reasones about the input, lists the goals, functions and constraints of the optical design task, and forms the basis for subsequent steps;
[0085] Step 2: The optical expert agent receives the requirements specification document and, in conjunction with the knowledge base in the field of optical design, demonstrates and supplements the feasibility of the requirements and the selection of key optical parameters.
[0086] Among them, the optical expert intelligent agent calls the pre-built optical knowledge base interface to retrieve optical system design examples, formulas and empirical data, and generates optimization suggestions or preliminary optical solution ideas accordingly.
[0087] Step 3: After obtaining the requirements document and key points of the optical solution, the architecture design agent outputs an architecture design specification or pseudocode framework.
[0088] The architecture design agent runs through a preset prompt template and uses chain-like reasoning to gradually refine the script logic; the architecture design output clearly defines the steps required by the script, the optical calculation methods called, and the overall approach to interacting with the optical design software.
[0089] Step 4: The script generation module receives the pseudocode or design scheme provided by the architecture design agent, and fills in the specific code implementation in the large model with prompts, including the optical calculation steps and the call to ZOS-API;
[0090] Among them: during the generation process, a combination of prompts and self-optimization strategies are adopted to ensure consistent code style and compliance with optical field standards;
[0091] Step 5: During the test, the test and feedback module monitors the script's running status and output results: if the script throws an error or fails to meet the user's required indicators, it records the error log or deviation data;
[0092] Specifically, the testing and feedback module automatically generates test scenarios in advance based on the requirements, runs scripts, and compares the results with the requirements; subsequently, this module submits the execution feedback to the control and scheduling module, triggering the subsequent code correction process.
[0093] In one implementation (running on the network), intelligent agents such as requirement understanding, optical experts, architecture design, and script generation run on a cloud-based inference cluster. Control and scheduling are performed by a cloud-native orchestration service. Users submit requirements and obtain results via the web or API. If the testing platform is also in the cloud, the test container pulls the simulation image, executes the script, and sends back metrics; object storage is used for intermediate product accumulation; multi-tenant isolation ensures project-level data boundaries. This approach has elastic scaling capabilities and is suitable for large-scale parallel tasks.
[0094] In another implementation (hybrid architecture—model cloud, knowledge base, and local testing), requirement analysis, optical verification, architecture design, and script generation are completed in the cloud. Retrieval of historical processes, material parameters, and license-sensitive information is initiated by the control scheduler to the local knowledge base, which returns the minimized reference result. After script generation, the local testing and feedback module calls Zemax / Code V / LightTools / GODAS (Global Optical Design and Analysis System) for execution, and the generated logs and indicator summaries are sent back to the cloud to trigger secondary repair iterations. The output module generates report views in the cloud and saves the scripts and test conditions locally. Unlike purely local or purely cloud-based approaches, this method obtains the elastic computing power of cloud inference while ensuring data sovereignty and license compliance.
[0095] The above operating method only adjusts the execution location and resource orchestration, without changing the step sequence and semantics of requirement understanding → optical demonstration / solution → architecture design → script generation → testing and feedback. The functional goals and data flow remain consistent.
[0096] Depending on the actual deployment, roles can be integrated or subdivided without altering the technical path and closed-loop control. As an alternative, the "optical expert agent" and the "architecture design agent" can be merged into an "optical system modeling agent," which simultaneously completes physical solution recommendation and code structure planning. In terms of process, the demonstration of key optical indicators and engineering constraints, along with the output of the overall script architecture / interface division, from the aforementioned steps are combined, while the script generation and test feedback steps remain unchanged. To ensure output consistency, the modeling agent loads both optical knowledge and software architecture constraints into the prompt template, outputting an integrated design document containing "indicators—methods—interfaces—module division"; control scheduling correspondingly reduces one cross-role interaction, improving throughput.
[0097] As an alternative, the "Testing and Feedback Module" can be subdivided into a "Script Execution Agent" and a "Performance Analysis Agent." The former is responsible for executing scripts in the target environment and collecting logs / raw results, while the latter makes judgments, aggregates, and sends back improvement suggestions based on requirements and optical metrics (such as MTF (modulation transfer function), aberration budget, and tolerance). The process refines the testing steps into two sub-steps: execution and analysis. These two sub-modules are decoupled through standardized result contracts (such as JSON metric messages (JavaScript Object Notation)) and support parallel multi-case / multi-field testing. The performance analysis performs statistical significance evaluation on batch results and then sends them back centrally. When a functional error occurs, the script generation module is notified first; when there is a deviation in requirement understanding, the process reverts to the requirement understanding or optical verification stage (or the aforementioned merged modeling agent).
[0098] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A code generation system for a large multi-agent model in the field of optics, characterized in that, Including those connected sequentially: Demand-understanding agent: used to deeply understand and organize user needs; This requirement understands that the agent is driven by a large language model, using agent model instances finely tuned with knowledge from the optical domain; Optical expert intelligent agents: used to provide professional knowledge support and solution guidance in the field of optics; This optical expert agent is implemented using a large language model or a specialized rule engine; Architecture design agent: Used to develop the overall architecture and logic design of scripts based on requirements and solutions provided by optical experts; The architecture design uses a large language model or a specialized rule engine to plan the module division, function design, and algorithm flow of the script code. Script generation module: Used to generate specific executable script code based on the design framework provided by the architecture design agent; The script generation module is implemented by calling the large model of the code generation class and converting the architecture description into target scripting language code. Test and Feedback Module: This module is used to perform execution tests on the generated script code and collect feedback information. It calls the optical design software interface to run the generated script and automatically executes the expected optical operations or design processes in a simulation environment. The testing and feedback module includes a script execution agent and a performance analysis agent. The script execution agent executes the script in the target environment and collects logs / raw results, while the performance analysis agent makes judgments, aggregates, and sends back improvement suggestions based on requirements and optical metrics. The script execution agent and the performance analysis agent are decoupled through a standardized result contract and support parallel multi-case / multi-field testing. The performance analysis agent performs statistical significance evaluation on batch results and then sends them back centrally. When a functional error occurs, the script generation module is notified first. When there is a deviation in the understanding of requirements, the process is backtracked to the requirement understanding or optical verification stage. The system also includes: The control and scheduling module is connected to the requirements understanding agent, the optical expert agent, the architecture design agent, the script generation module, and the testing and feedback module. It coordinates the workflows of these modules globally, managing data and control flow. This module also activates each module sequentially according to a predetermined software development process. It employs an asynchronous communication mechanism based on message queues to ensure the correct transmission of intermediate results generated by each agent and maintains data consistency and task order throughout the entire process. Output module: It is connected to the script generation module and the test and feedback module respectively, and is used to organize and output the final results to the user. The output module receives the final version code from the script generation module and the result report from the test and feedback module, and formats them into a form that is easy for the user to understand.
2. The code generation system for a large multi-agent model in the optical field according to claim 1, characterized in that, Examples of intelligent agent models include: GPT, DeepSeek, Claude, Gemini, ERNIE, ChatGLM, Mistral, or LLaMA.
3. The code generation system for a large multi-agent model in the optical field according to claim 1, characterized in that, The script generation module automatically generates scripts, including the ZOS-API interface of Zemax optical design software and the Code V, LightTools, and GODAS platforms.
4. A method for generating code for a large multi-agent model in the field of optics, wherein the system to which this method is applicable is the system described in claim 1, characterized in that, The method includes the following steps: Step 1: The requirements understanding agent receives structured requirements data from the input parsing module, guides the LLM to analyze and clarify the requirements through prompt templates, and generates a formalized requirements specification document or requirements list; Step 2: The optical expert agent receives the requirements specification document and, in conjunction with the knowledge base in the field of optical design, demonstrates and supplements the feasibility of the requirements and the selection of key optical parameters. The optical expert agent calls the pre-built optical knowledge base interface to retrieve optical system design examples, formulas and empirical data, and generates optimization suggestions or preliminary optical solution ideas accordingly. Step 3: After obtaining the requirements document and key points of the optical solution, the architecture design agent outputs an architecture design specification or pseudocode framework. Step 4: The script generation module receives the pseudocode or design scheme provided by the architecture design agent, and fills in the specific code implementation in the large model with prompts, including the optical calculation steps and the call to ZOS-API; Step 5: During the test, the test and feedback module monitors the script's running status and output results. If the script throws an error or fails to meet the user's required indicators, it records the error log or deviation data.
5. The method for generating code for a large multi-agent model in the optical field according to claim 4, characterized in that, In step 1: the demand understanding agent reasoned about the input, listed the goals, functions and constraints of the optical design task, and formed the basis for subsequent steps.
6. The method for generating code for a large multi-agent model in the optical field according to claim 4, characterized in that, In step 3: the architecture design agent runs through a preset prompt template and uses chain-like reasoning to gradually refine the script logic; The architecture design deliverables clearly define the steps required for the script, the optical calculation methods invoked, and the overall approach to interacting with the optical design software.
7. The method for generating code for a large multi-agent model in the optical field according to claim 4, characterized in that, In step 4: During the generation process, a combination of prompts and self-optimization strategies are adopted to ensure consistent code style and compliance with optical field standards.
8. The method for generating code for a large multi-agent model in the optical field according to claim 4, characterized in that, In step 5: the testing and feedback module automatically generates test scenarios in advance based on the requirements specification, runs the scripts, and compares the results with the requirements; Subsequently, the module submits the execution feedback to the control and scheduling module, triggering the subsequent code correction process.
Citation Information
Patent Citations
Code generation method and system based on heterogeneous multi-agent cooperation and electronic equipment
CN119829038A