A function call-based optical system generative design method and device
By constructing a structured training dataset and a secure tunneling mechanism, and fine-tuning a large language model to call professional optical design software, the problems of long optical design cycles and multi-objective constraints are solved, and efficient and innovative automated design of optical systems is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-03-24
AI Technical Summary
Existing optical design methods are time-consuming and costly, while deep learning methods have poor generalization ability, are difficult to handle multi-objective constraints, have limited innovation capabilities, and cannot quickly generate the initial structure of a high-performance optical system.
By constructing a structured training dataset, fine-tuning a large language model to understand optical requirements and generate an initial structure, and then using a secure tunnel to call professional optical design software for optimization, end-to-end automated design is achieved.
It enables the rapid generation of high-quality initial structures for optical systems, reduces manual iteration time, improves design efficiency, and generates solutions that meet multiple engineering constraints, possessing both innovation and physical accuracy.
Smart Images

Figure CN121365608B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of optical design and artificial intelligence technology, and in particular to a generative design method and apparatus for optical systems based on function calls. Background Technology
[0002] As a core component of high-tech applications such as imaging, illumination, and sensing, the design quality of optical systems directly determines the overall system performance. Optical design involves complex optical principles and parameter optimization processes, making it a crucial link in high-end manufacturing. Traditionally, this field relies on specialized software (such as Zemax and CODE V) for simulation and iteration, but the core process remains dominated by human experience, including steps such as initial structure selection, parameter optimization, and image quality evaluation. This process is not only time-consuming and costly but also severely restricts innovation efficiency, especially when faced with entirely new design requirements, making it difficult for experts to quickly identify high-performance initial structures.
[0003] With the advancement of artificial intelligence technology, deep learning has provided new insights into the automation of optical design. Existing research has attempted to apply neural networks to this field, for example, using deep neural networks (DNNs) to directly map performance metrics to optical structural parameters, or employing recurrent neural networks (RNNs) to infer lens design sequences. However, these methods still face fundamental challenges:
[0004] 1. Strong data dependence. Its performance is limited by high-quality, large-scale and well-annotated optical design datasets, and the scarcity of such data severely restricts the model's generalization ability.
[0005] 2. Insufficient handling of complex constraints. Most methods focus on optimizing a single or a few optical parameters (such as RMS spot size), making it difficult to coordinate multiple objective constraints that must be considered in practical engineering (such as modulation transfer function MTF, distortion, system size and manufacturability, etc.).
[0006] 3. Limited innovation capability. The model essentially performs interpolation or pattern combination on existing design datasets, lacking guidance from physical principles, making it difficult to proactively discover groundbreaking optical configurations that exceed the scope of the training data.
[0007] Therefore, there is an urgent need in this field for an innovative method that can deeply integrate optical design knowledge, accurately understand user intent, and intelligently call upon professional tools to generate high-quality initial structures for optical systems, in order to solve the core technical problems of long cycles in traditional methods and poor generalization and insufficient multi-target processing capabilities of deep learning methods. Summary of the Invention
[0008] To address the problems in existing technologies, this invention provides a generative design method and apparatus for optical systems based on function calls. This invention fine-tunes a large language model, enabling it to understand complex optical requirements and generate initial structures. Simultaneously, a secure tunnel connection is constructed, allowing the large language model to reliably call the application programming interface (API) of local professional optical design software for precise optimization. By integrating the cognitive capabilities of the large language model with the numerical optimization capabilities of professional optical design software, end-to-end automated design is achieved, from natural language requirements to high-performance optical system structures.
[0009] In this invention, the “generative” design refers to the ability to automatically generate entirely new optical structures from scratch based on user needs. Its core lies in achieving end-to-end automatic design from user natural language requirements to optical system structures optimized by professional software.
[0010] The technical solution adopted in this invention is as follows:
[0011] In a first aspect, the present invention discloses a generative design method for optical systems based on function calls, comprising the following steps:
[0012] (1) Construct a function call optimization service, expose the application programming interface service of the local optical design software to the public network through a secure tunnel, and configure a dual authentication mechanism including token authentication and application programming interface key authentication;
[0013] (2) Construct a structured training dataset, which includes the correspondence between user requirements, optical design code and function call requests; the user requirements include optical performance indicators and output format requirements, the optical design code is a structured representation of optical design parameters, and the function call requests include application programming interface call specifications;
[0014] (3) Based on the structured training dataset, the general large language model is fine-tuned using low-rank adaptive technology so that the model establishes a mapping relationship between user needs and optical design parameters, and automatically generates a function call request that conforms to the application programming interface call specification when a preset condition is detected;
[0015] (4) Load the fine-tuned large language model and configure the generation parameters and public network service access capabilities, receive the user's input of natural language optical system design requirements, and generate the initial structure of the optical system described by structured text and function call requests;
[0016] (5) After detecting the function call request, the optical design parameters of the initial structure of the optical system are transmitted to the local optical design software through the secure tunnel for optimization, and the optimized results are received, parsed, and integrated to generate an optical design report.
[0017] Furthermore, the secure tunnel described in step (1) is implemented using an FRP reverse proxy, including:
[0018] Deploy an FRP server and an API gateway on a cloud server. Configure the FRP server with authentication tokens and set the allowed port range for mapping. The API gateway performs application programming interface key authentication, JSON syntax authentication, and integrity authentication on the optical design parameters of the initial structure of the incoming optical system for all incoming function call requests.
[0019] Deploy the FRP client on the local device, establish a secure connection using an authentication token, and map the API service port of the local optical design software to the cloud server port.
[0020] Furthermore, the first layer of the dual authentication mechanism refers to verifying the connection permissions between the FRP client and the FRP server through an authentication token, and the second layer of authentication refers to verifying the request permissions of the API gateway through an application programming interface key.
[0021] Furthermore, the process of constructing a structured training dataset includes:
[0022] Convert mainstream optical design files into structured text, extract optical design parameters, and save them as optical design code;
[0023] Generate simulated natural language user requirements for each mainstream optical design file;
[0024] Based on user requirements and corresponding optical design code, generate function call request descriptions that meet the application programming interface call specifications;
[0025] User requirements, optical design code, and function call requests are organized into JSON format data pairs to form the final structured training dataset.
[0026] Furthermore, the optical design parameters include system-level parameters and surface-level parameters;
[0027] The system-level parameters include one or more of the following: field of view, F-number, effective focal length, RMS spot size, aperture type, aperture position, wavelength list, and field information.
[0028] The surface-level parameters include one or more of the following for each optical surface: serial number, type, radius of curvature, thickness, material, half-aperture, and conic constant.
[0029] Furthermore, the application programming interface call specification in the function call request includes the endpoint path, request method, request header parameters, request body structure, and expected response format; the request body structure defines the JSON format of the transmitted parameters, including a variable surface list and optimization objectives.
[0030] Furthermore, in step (3), the preset conditions include:
[0031] User requirements include numerical specifications such as effective focal length, F-number, or field of view.
[0032] The model uses optical design rules to infer and determine if optimization is needed, including exceeding the system's total length limit, insufficient edge thickness, or exceeding aberration limits.
[0033] Furthermore, the optimization process of the local optical design software includes setting variable surfaces, defining optimization operands, and executing local optimization or hammer optimization algorithms. The optimization operands target optimization objectives, including effective focal length, RMS spot size, or MTF value.
[0034] Furthermore, the optical design report includes optical design parameters before and after optimization, key data of the optimization process, and the key data of the optimization process includes one or more of the following: evaluation function value, improvement percentage, and RMS wavefront error estimate.
[0035] Secondly, the present invention discloses a generative design apparatus for optical systems based on function calls, used to implement the above-mentioned generative design method for optical systems based on function calls.
[0036] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0037] (1) This invention effectively solves the problem of single optimization objective in existing methods by constructing structured training data containing multi-dimensional optical indicators and format requirements, and by utilizing the powerful semantic understanding capabilities of large language models. The method can comprehensively analyze complex tasks described in natural language and containing multiple constraints, and the generated design schemes are more in line with actual engineering applications.
[0038] (2) This invention guides the model to learn the underlying design logic rather than simply imitating it by fine-tuning the model based on high-quality mainstream optical design documents. This enables the model to reason and fuse, and has the potential to generate innovative optical structures that go beyond the scope of the training data and are not intuitive.
[0039] (3) By introducing a function call mechanism, the advantages of large language models in cognition and generation are combined with the expertise of professional optical design software in accurate physical simulation and numerical optimization. This method allows large language models to focus on their strengths in structural reasoning and discovery, while leaving complex numerical calculations to professional tools, thus ensuring the physical accuracy and engineering feasibility of the generated scheme.
[0040] (3) This invention can quickly generate high-quality initial structures and even optimized solutions through an end-to-end intelligent design process, which significantly reduces manual trial and error and iteration time, enabling non-senior engineers to efficiently complete complex design tasks and accelerate product development cycle. Attached Figure Description
[0041] Figure 1 This is a flowchart of the generative design method for optical systems based on function calls according to the present invention;
[0042] Figure 2 This is a structural diagram of the generative design device for optical systems based on function calls according to the present invention;
[0043] Figure 3 It is an optical path diagram of the optical system structure generated using the method of the present invention;
[0044] Figure 4 It is an optical path diagram of an optical system structure generated using existing methods. Detailed Implementation
[0045] The present invention will be further described and illustrated below with reference to the accompanying drawings and embodiments. The embodiments described are merely examples of the present invention and are not intended to limit the scope of protection. The technical features of each embodiment of the present invention can be combined accordingly, provided that there is no conflict between them.
[0046] The accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0047] The flowchart shown in the attached diagram is merely an illustrative example and does not necessarily include all steps. For example, some steps may be broken down, while others may be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0048] This invention proposes a generative design method for optical systems based on function calls. By fine-tuning a large language model to understand optical design requirements, and by utilizing a safe and reliable function call mechanism, the generation capability of the large language model is integrated with the optimization capability of professional optical design software, thereby realizing automated and intelligent optical system design.
[0049] like Figure 1 As shown, the specific implementation steps include:
[0050] S1: Build a function call optimization service, expose the API service port of the local optical design software to the public network through secure tunneling technology, and configure a dual authentication mechanism including token authentication and API service port key authentication.
[0051] The following sections explain the construction process of the function call optimization service from three aspects: secure tunnel configuration, API gateway settings, and workflow.
[0052] (1.1) Safety Tunnel Configuration
[0053] Launch the optical design software on the local computing device and ensure its API service is callable. Configure a secure tunnel using FRP reverse proxy technology to securely expose the local API service to the public network. The implementation includes two key steps:
[0054] First, deploy the FRP server on a cloud server with a public IP address. In the configuration file, set a non-empty authentication token and define the allowed port range for mapping. For example, set the port range to 7000-7100. It is recommended that the token length be no less than 8 characters.
[0055] Secondly, deploy the FRP client on the local workstation, specify the corresponding authentication token in the configuration file, and map the API service port of the local optical design software to a designated port on the cloud server. Taking the optical design software Zemax OpticStudio on the local computing device as an example, its API service port is 1946, which is mapped to a designated port 7000 on the cloud server.
[0056] This configuration constitutes the first layer of authentication, allowing only clients holding the correct authentication token to establish a tunnel connection.
[0057] (1.2) API Gateway Settings
[0058] Deploy an API gateway on a cloud server, which serves as a unified entry point for optimized requests. This gateway requires all requests to include a valid API key in the request header, forming a second-layer authentication mechanism specifically for verifying the permissions of specific API requests. The API gateway can be written using the Python Flask or FastAPI framework, and those skilled in the art can implement it based on existing technologies.
[0059] (1.3) API Gateway Workflow
[0060] The receiving and verification phase is responsible for processing JSON requests from the large language model that contain initial structural parameters of the optical system. Verification includes checking the validity of the API key, the integrity of the JSON structure, and the completeness of the optical design parameters. For example, if the API key does not match or the JSON structure is incomplete, the gateway will refuse access. Verification of JSON structure integrity includes ensuring that each "{" is paired with a "}". Parameter integrity checks require verifying whether the request contains complete optical design parameters, such as the radius of curvature and thickness of each surface.
[0061] In the file generation and optimization phase: The incoming JSON parameters are parsed via a professional interface, and the corresponding optical design file is generated in the optical design software. Variable surfaces and operands are automatically set, and optimization algorithms are executed. For example, the Zemax software parses the incoming JSON parameters through the ZOS-API to generate the corresponding lens file. The lens's radius of curvature and thickness are set as variables, and the optimization operands are defined to target optimization objectives such as the effective focal length (EFL), the RMS spot size in the dot plot, and the MTF value. Local optimization or hammer-shaped optimization algorithms are then executed to optimize the lens.
[0062] Results extraction and return process: After optimization, extract the optimized system parameters and key indicators. For example, extract the evaluation function values before and after optimization, the percentage improvement and wavefront error, etc., and encapsulate them into a structured JSON response and return it to the caller.
[0063] S2: Construct a structured training dataset, which includes the correspondence between user requirements, optical design code, and function call requests.
[0064] This step involves building a high-quality training dataset, enabling the large language model to learn optical design knowledge and master function call capabilities.
[0065] (2.1) Data transformation and parameter extraction
[0066] Using Zemax macros or Python automation programs combined with ZOS-API, existing mainstream optical design files such as Zemax and CodeV can be batch converted into structured text. This process ensures that optical design knowledge is digitized and standardized, providing core materials for model training.
[0067] The extracted parameters must comprehensively cover all design requirements that users may raise, including but not limited to the following two categories:
[0068] 1. Overall System Parameters. Describes the global characteristics of the optical system, such as field of view (FOV), f-number (fnum), effective focal length (EFL), RMS spot size, aperture type, aperture stop position, wavelength list, and field information.
[0069] 2. Detailed Surface Parameters. Describes the specific properties of each optical element, including the optical surface number, type, remarks, radius of curvature, thickness, material, half-aperture, and conic constant.
[0070] Suppose an optical design document contains a three-element lens system. The overall system parameters define the macroscopic performance indicators: a field of view of 20 degrees, an f-number of 2.0, and an effective focal length of 20 mm. These parameters collectively ensure that the system has wide-angle imaging capabilities, a suitable aperture size, and specific focal length requirements. Surface parameters define the geometric and material properties of each optical element. In a simplified illustration, surface 1 is the object surface, with an infinite radius of curvature and thickness, and empty material, representing the starting point of the incident light path of the optical system. Surface 2 is the standard surface, with a radius of curvature of 15.632 units, a thickness of 2.5 units, and H-K9L optical glass. The parameters of each surface are fully defined with an ordinal number, type, radius of curvature, thickness, and material, forming the core structural foundation of the optical design. These extracted parameters are standardized and encapsulated in JSON format to form optical design code that can be directly used for model training.
[0071] (2.2) User requirement simulation generation
[0072] For each optical design code, the corresponding user's natural language requirements must be simulated and generated, ensuring the diversity and practicality of the scenarios, so that the model can learn the mapping relationship from requirement description to design parameters. This requirement should include the following core components:
[0073] 1. Optical system performance specifications: Clearly describe the design goals, such as "design a lens with a field of view of 20 degrees, an F number of 2.0, and a focal length of 20 mm".
[0074] 2. Output format requirements: Specify the data organization specifications, such as "Please output the optical design in JSON format, and divide it into two parts: overall system parameters and parameters of each surface".
[0075] 3. Optional supplementary information: Optical formulas, imaging quality requirements or design constraints may be included, such as "total length less than 50mm" or "should satisfy Snell's Law".
[0076] For example, for a wide-angle lens design, the simulated user requirements might be: "Please design a lens for security monitoring with a field of view of 100 degrees, an F-number of 2.8, and a focal length of 4 mm. The output should be in JSON format and include system and surface parameters. In addition, the total length should be kept within 30 mm, and the relative illumination at the edge of the field of view should be higher than 60%."
[0077] (2.3) Function call request description generation
[0078] This template generates a description of the function call request for each data pair, guiding the model on how to construct API requests when optimization is needed. The template includes the following elements:
[0079] This template generates a description of the function call request for each data pair, guiding the model on how to construct API requests when optimization is needed. The template includes the following elements:
[0080] Endpoint path: The access address of the API service;
[0081] Request method: HTTP method type, such as POST or GET;
[0082] Request header parameters: contain authentication information (such as API keys) and content type definitions.
[0083] Request body structure: Defines the JSON format of the transmitted parameters, such as including a list of variable surfaces and optimization targets.
[0084] Expected response format: Specifies the structure of the returned data, such as optimized parameters and evaluation metrics.
[0085] It should be noted that the description template must ensure that the request for model generation conforms to the API specifications of the optical design software.
[0086] In this embodiment, approximately 1000 high-quality data pairs are generated using the method described above. Each pair contains user requirements, optical design code, and function call requests. The final dataset needs to be formatted as JSON.
[0087] S3: Based on the structured training dataset, the general large language model is fine-tuned using low-rank adaptive techniques.
[0088] This step uses efficient parameter fine-tuning technology to transform the general large language model into a generative design model for a dedicated optical system.
[0089] (3.1) Base model selection and fine-tuning techniques
[0090] Choose a general-purpose large language model with strong code generation and understanding capabilities as the base. Taking Qwen3-8b as an example, use the structured training dataset constructed in step S2 to train the model to have the ability to understand optical design knowledge and automatically call functions, so as to ensure that it can handle optical design tasks.
[0091] In this embodiment, fine-tuning employs low-rank adaptive technology, a parameter-efficient method that adapts to a specific domain by introducing a small number of trainable parameters, reducing computational resource requirements while maintaining model performance. Low-rank adaptive technology is a well-known technique in this field.
[0092] (3.2) Fine-tuning the environment configuration
[0093] Fine-tuning can be performed in a local environment or on a cloud service platform. A local environment requires a high-performance server with multiple GPUs to ensure sufficient computing power; cloud service platforms such as SiliconCloud can provide diverse computing resources and simplify the deployment process.
[0094] Key fine-tuning parameters are set to balance computational efficiency and model performance. These key fine-tuning parameters include: a learning rate set to 1e^(-1 / 2). -4 The parameters include 3 iterations, a batch size of 8, a LoRA rank of 8, and a LoRA Alpha value of 16. These parameters work together to ensure that the model converges quickly within a limited number of training epochs and maintains generative stability.
[0095] (3.3) Fine-tuning the target
[0096] The core of fine-tuning lies in forcing the model to learn key behavioral patterns: after the model generates optical design parameters, it needs to automatically determine whether optimization is required based on preset conditions and generate structured function call requests, rather than directly ending the interaction. This capability is achieved through the "user needs - function call requests" correspondence in the training dataset, enabling the model to master the following logic:
[0097] Identify numerical metrics (such as effective focal length and F-number) in user requirements as explicit conditions to trigger optimization.
[0098] Reasoning and judgment based on optical design rules, such as exceeding the system's total length limit or insufficient edge thickness, serve as implicit conditions for triggering optimization.
[0099] Generate a function call request that conforms to the API specification, including elements such as endpoint path, request method, and request body structure. For the specific implementation process, please refer to step S2 above.
[0100] (3.4) Fine-tuning the output
[0101] After fine-tuning, a dedicated generative design language model for the optical system is obtained. This model possesses end-to-end design capabilities, can understand natural language requirements, generate initial optical structures, and intelligently trigger optimization processes. The model output is structured text, containing optical parameters (such as system-level and surface-level optical parameters) and function call instructions, laying the foundation for subsequent optimization and integration.
[0102] S4 deploys a dedicated optical system for generative design of large language models and configures generation parameters and public network service access capabilities.
[0103] The generative design language model of the optical system, which has been fine-tuned, is deployed to the actual inference environment, and the relevant configurations are completed to ensure its stable operation and service call capabilities.
[0104] (4.1) Model loading and environment configuration
[0105] The finely tuned generative design of the optical system is then loaded into the inference environment. The inference environment requires sufficient computing resources, including GPU memory and processor performance, to support efficient model execution. The environment configuration must ensure consistency with the training environment.
[0106] The model loading process requires verifying the model's integrity and availability, ensuring all parameters are loaded correctly and the model can respond to inference requests normally. This process lays the foundation for subsequent configuration of generation control parameters and service integration.
[0107] (4.2) Generate control parameter configuration
[0108] Generative control parameters are used to control the randomness in the model generation process. For example, the temperature parameter is set to 0.7, and Top-p is set to 0.9. Low temperatures (e.g., 0.1) make the model's output more deterministic, while high temperatures (e.g., 1) make the output more random and creative, producing novel and diverse results. Top-p (also known as core sampling) ensures output quality while controlling generation diversity—low Top-p (e.g., 0.3) makes the output more precise and conservative, while high Top-p (e.g., 0.9) makes the output more random and divergent.
[0109] (4.3) Configuration of public network service access capability
[0110] Configure the model's public network service access capability to ensure that the model can call the API service established in step S1 when needed, including the following key configurations:
[0111] Network interface configuration enables the model to access external API services, including setting the correct network endpoints, configuring request timeouts and retry mechanisms, to ensure the reliability of service calls.
[0112] The security authentication configuration needs to integrate the dual authentication mechanism established in step S1 to ensure that the model carries a valid authentication token and API key when calling API services, and can pass through the verification process of the security tunnel.
[0113] After generating optical design parameters, the deployed model automatically sends an optimization request to the API gateway via a secure tunnel. The request contains complete design parameters and authentication information (API key). Once the API gateway verifies the request, it performs optimization calculations and returns the results to the model for further processing.
[0114] S5: Process user requests and generate complete reports.
[0115] First, the system receives user-inputted natural language design requirements via a graphical interface or command-line interface. For example, a user might input: "Please design a three-element lens for a mobile phone camera with a focal length of 4mm and an f-number of 1.8, and output it in JSON format." This instruction must include clear optical performance specifications (such as focal length and f-number) and output format requirements to ensure the model can accurately understand the design goals. The user input interface design must balance ease of use and flexibility, supporting multiple natural language expressions to accommodate different user habits.
[0116] Secondly, after receiving the user's request, the large language model generates an initial structure of the optical system described by structured text, based on the optical design knowledge gained during the fine-tuning training steps. The generated content is typically organized in JSON format and includes system-level parameters (such as effective focal length and field of view) and surface-level parameters (such as radius of curvature, thickness, and material). Simultaneously, the model automatically determines whether to initiate an optimization request based on preset conditions. These triggering conditions fall into two categories: first, the user's request contains specific numerical indicators such as "effective focal length" and "F-number"; second, the model infers based on optical design rules, such as determining that the total system length exceeds limits or aberration indicators are not met. If the conditions are met, the model automatically embeds a formatted function call request in its output.
[0117] The system monitors function call requests in the model output in real time. Once an optimization instruction is detected, it automatically extracts the initial structural parameters and sends them to the local optical design software API through the secure tunnel established in step S1. After receiving the request, the API gateway performs parameter verification and optimization calculations, such as setting variable surfaces, defining optimization operands, and running local optimization algorithms through Zemax software. After optimization, the system receives the results returned by the API and parses out key data such as the optimized optical system structural parameters and the percentage improvement of the evaluation function.
[0118] Finally, the system integrates the initial structure, key data from the optimization process (such as the percentage improvement of the evaluation function), and the final optimized structural parameters to generate a complete optical design report that engineers can directly reference or import into software. The entire process achieves intelligent generation from natural language requirements to high-quality optical design solutions, significantly improving design efficiency through automation and ensuring the engineering practicality of the output.
[0119] To verify the effectiveness of this invention, a systematic experiment was conducted on a server configured with appropriate computing resources (e.g., a server instance equipped with an NVIDIA GPU). The experimental environment and parameter settings strictly followed the procedures of this invention, ensuring the reliability and repeatability of the tests.
[0120] 1) Experimental environment and parameter settings
[0121] Basic model: Qwen3-8b.
[0122] Fine-tuning platform: The LLaMA-Factory framework is used on the Ubuntu server, which supports efficient parameter fine-tuning techniques.
[0123] Function call environment: Configure Zemax2024R1 optical design software on a Windows 11 workstation, and as described in step S1, use FRP reverse proxy technology to establish a secure tunnel to the cloud server API gateway to ensure a reliable connection between the local software and the cloud service.
[0124] Fine-tuning the dataset: By parsing approximately 1000 Zemax design files (.zmx format), about 1000 pairs of "user requirements - optical design code and optimization requests" data were automatically generated and formatted as JSON files. The dataset covers a diverse range of optical system types and performance metrics.
[0125] Fine-tuning parameters: The learning rate was set to 0.0001, the number of training iterations to 3, the batch size to 8, the LoRA rank to 8, and the LoRA Alpha value to 16, etc. These parameters were optimized to achieve fast model convergence within a limited number of training epochs while maintaining output stability.
[0126] 2) Model Inference and Output Generation
[0127] Load the finely tuned model and input the user's optical design requirements, such as "generate an optical system with a field of view of 40 degrees, an F-number of 2.8, and an entrance pupil diameter of 10 mm." The model generates a response based on the learned knowledge, and the output includes the following three parts:
[0128] System-level parameters include system name, field of view (40 degrees), F number (2.8), aperture type (specified as entrance pupil diameter), entrance pupil diameter (10 mm), and a list of working wavelengths (including three typical wavelengths: 0.486 μm, 0.587 μm, and 0.656 μm).
[0129] Surface-level parameters: Each optical surface is described in a list format, including its type, radius of curvature, thickness, material, half-aperture, conic constant, and notes. The first surface is the object plane, and the last surface is the image plane, ensuring optical path integrity.
[0130] Function call instructions: The model automatically determines that optimization is needed and generates a structured function call request, including the endpoint path, request method, request header parameters, request body structure, and expected response format. This process demonstrates the model's ability to autonomously trigger optimization after generating design parameters.
[0131] 3) Optimize execution and result extraction
[0132] After detecting a function call request in the model output, the system automatically extracts the initial structural parameters and sends them to the local optical design software API. Upon receiving the request, the API executes the optimization algorithm and returns the optimization result. The system then parses the optimized optical system structural parameters, and the final generated optical design result is as follows: Figure 3 As shown, the optical design results obtained by the method of the present invention have a reasonable structure, high imaging quality, and high lens manufacturability.
[0133] As a comparison, this embodiment tests the performance of the untuned general-purpose large model Qwen3-MAX under the same task. To guide its output of structured results, detailed prompts were provided, requiring it to strictly adhere to a specified format when outputting a JSON structure containing system parameters, a surface list, and calling instructions. Furthermore, optical design rules were enforced, such as the object plane being the first plane and the image plane being the last plane. The model's optical design results are as follows: Figure 4 It is evident that serious problems exist: insufficient lens quantity, unreasonable edge thickness, and the inability of the generated light rays to converge properly, resulting in substandard image quality. In contrast, the method of this invention, after fine-tuning and incorporating function calls, can significantly enhance the capabilities of large language models in the field of optical design, generating physically sound and high-performance initial structures for optical systems, and improving design quality through automated optimization processes. This experiment verifies the effectiveness and advancement of this invention in improving design efficiency and ensuring engineering feasibility.
[0134] like Figure 2 As shown, this embodiment also provides a generative design device for optical systems based on function calls, including:
[0135] The function call and optimization module is used to build a function call optimization service. It exposes the application programming interface (API) service of the local optical design software to the public network through a secure tunnel and configures a dual authentication mechanism including token authentication and API key authentication. When a function call request is detected and verified, the optimization task is executed using the local optical design software.
[0136] The structured training dataset construction module is used to build a structured training dataset containing the correspondence between user requirements, optical design code, and function call requests;
[0137] The model fine-tuning module is used to fine-tune the general large language model based on the structured training dataset using low-rank adaptive techniques;
[0138] The Reasoning and Service module is used to load the fine-tuned large language model to perform reasoning tasks, generate the initial structure of the optical system described by structured text, and function call requests.
[0139] The requirements processing and output module is used to receive user requirements instructions and integrate and output the final optical design report.
[0140] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments, and the implementation methods of the modules will not be repeated here. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the present invention according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0141] Embodiments of the device of the present invention can be applied to any device with data processing capabilities, such as a computer or other similar device. The device embodiments can be implemented in software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor of any data processing device loading the corresponding computer program instructions from non-volatile memory into memory for execution.
[0142] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. Those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. A generative design method for optical systems based on function calls, characterized in that, Includes the following steps: (1) Construct a function call optimization service, expose the application programming interface service of the local optical design software to the public network through a secure tunnel, and configure a dual authentication mechanism including token authentication and application programming interface key authentication; (2) Construct a structured training dataset, which includes the correspondence between user requirements, optical design code and function call requests; the user requirements include optical performance indicators and output format requirements, the optical design code is a structured representation of optical design parameters, and the function call requests include application programming interface call specifications; (3) Based on the structured training dataset, the general large language model is fine-tuned using low-rank adaptive technology so that the model establishes a mapping relationship between user needs and optical design parameters, and automatically generates a function call request that conforms to the application programming interface call specification when a preset condition is detected; The preset conditions include: User requirements include numerical specifications such as effective focal length, F-number, or field of view. The model uses optical design rules to infer and determine if optimization is needed, including when the total system length exceeds the limit, the edge thickness is insufficient, or the aberration index exceeds the standard. (4) Load the fine-tuned large language model and configure the generation parameters and public network service access capabilities, receive the user's input of natural language optical system design requirements, and generate the initial structure of the optical system described by structured text and function call requests; (5) After detecting the function call request, the optical design parameters of the initial structure of the optical system are transmitted to the local optical design software through the secure tunnel for optimization, and the optimized results are received, parsed, and integrated to generate an optical design report.
2. The generative design method for optical systems based on function calls according to claim 1, characterized in that, The secure tunnel described in step (1) is implemented using an FRP reverse proxy, including: Deploy an FRP server and an API gateway on a cloud server. Configure the FRP server with authentication tokens and set the allowed port range for mapping. The API gateway performs application programming interface key authentication, JSON syntax authentication, and integrity authentication on the optical design parameters of the initial structure of the incoming optical system for all incoming function call requests. Deploy the FRP client on the local device, establish a secure connection using an authentication token, and map the API service port of the local optical design software to the cloud server port.
3. The generative design method for optical systems based on function calls according to claim 2, characterized in that, The first layer of the dual authentication mechanism refers to verifying the connection permissions between the FRP client and the FRP server through an authentication token, while the second layer refers to verifying the request permissions of the API gateway through an application programming interface key.
4. The generative design method for optical systems based on function calls according to claim 1, characterized in that, The process of constructing a structured training dataset includes: Convert mainstream optical design files into structured text, extract optical design parameters, and save them as optical design code; Generate simulated natural language user requirements for each mainstream optical design file; Based on user requirements and corresponding optical design code, generate function call request descriptions that meet the application programming interface call specifications; User requirements, optical design code, and function call requests are organized into JSON format data pairs to form the final structured training dataset.
5. The generative design method for optical systems based on function calls according to claim 1 or 4, characterized in that, The optical design parameters include system-level parameters and surface-level parameters; The system-level parameters include one or more of the following: field of view, F-number, effective focal length, RMS spot size, aperture type, aperture position, wavelength list, and field information. The surface-level parameters include one or more of the following for each optical surface: serial number, type, radius of curvature, thickness, material, half-aperture, and conic constant.
6. The generative design method for optical systems based on function calls according to claim 1, characterized in that, The application programming interface call specification in a function call request includes the endpoint path, request method, request header parameters, request body structure, and expected response format; the request body structure defines the JSON format of the transmitted parameters, including a variable surface list and optimization objectives.
7. The generative design method for optical systems based on function calls according to claim 1, characterized in that, The optimization process of local optical design software includes setting variable surfaces, defining optimization operands, and executing local optimization or hammer optimization algorithms. The optimization operands target optimization objectives such as effective focal length, RMS spot size, or MTF value.
8. The generative design method for optical systems based on function calls according to claim 1, characterized in that, The optical design report includes optical design parameters before and after optimization, key data of the optimization process, including one or more of the following: evaluation function value, improvement percentage, and RMS wavefront error estimate.
9. A generative design apparatus for optical systems based on function calls, used to implement the generative design method for optical systems based on function calls as described in claim 1, characterized in that, The device includes: The function call and optimization module is used to build a function call optimization service. It exposes the application programming interface (API) service of the local optical design software to the public network through a secure tunnel and configures a dual authentication mechanism including token authentication and API key authentication. When a function call request is detected and verified, the optimization task is executed using the local optical design software. The structured training dataset construction module is used to build a structured training dataset containing the correspondence between user requirements, optical design code, and function call requests; The model fine-tuning module is used to fine-tune the general large language model based on the structured training dataset using low-rank adaptive techniques; The Reasoning and Service module is used to load the fine-tuned large language model to perform reasoning tasks, generate the initial structure of the optical system described by structured text, and function call requests. The requirements processing and output module is used to receive user requirements instructions and integrate and output the final optical design report.
Citation Information
Patent Citations
Optical system design method and system based on knowledge base retrieval enhancement large model
CN120522893A
Multi-agent large model code generation method and system in optical field
CN121143812A