Metasurface reinforcement learning inverse design method
By combining VQ-VAE and a large language model with reinforcement learning, the problem of aligning spectral and structural features in metasurface inverse design is solved, achieving efficient and accurate metasurface structure generation that meets the design requirements of complex spectral responses and physical laws.
Patent Information
- Application Number
- CN202611374663.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-27
AI Technical Summary
In existing metasurface reverse design methods, deep learning models face difficulties in aligning spectral and structural features, making it difficult to generate metasurface structures that conform to the spectral response of complex targets and satisfy physical laws. Furthermore, the computational cost is high, making it difficult to meet the design requirements of complex multi-target or broadband devices.
A vector quantization variational autoencoder (VQ-VAE) is used to discretize the metasurface structure image dataset into a one-dimensional structure encoding sequence. Combined with a large language model (LLM) and reinforcement learning strategies, a physical surrogate model is used for computational verification and rejection sampling to optimize the generation strategy and achieve accurate mapping between structure and spectrum.
This improves the spectral fidelity and physical processability of metasurface reverse design, enhances the accuracy and diversity of generated structures, and meets the spectral response and manufacturing constraints of complex targets.
Smart Images

Figure CN123179906A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of micro-nano optical device design and artificial intelligence technology, and in particular to a metasurface reverse design method that combines vector quantization variational autoencoder (VQ-VAE), large language model (LLM), and reinforcement learning (RL). Background Technology
[0002] Metasurfaces are two-dimensional planar devices composed of arrays of subwavelength-scale artificial microstructures, capable of flexibly and precisely controlling the amplitude, phase, polarization, and other characteristics of electromagnetic waves. With the development of micro-nano photonics, reverse engineering of metasurfaces—that is, inferring the geometry of metasurfaces based on specific electromagnetic response requirements (such as target transmission or reflection spectra)—has become a core research hotspot in this field.
[0003] Traditional metasurface reverse design methods mainly rely on the adjoint partial derivative method or heuristic optimization algorithms, such as GA (Genetic Algorithm) and PSO (Particle Swarm Optimization). However, the adjoint partial derivative method is highly dependent on the initial parameter settings and is prone to getting trapped in local optima; while heuristic algorithms, when faced with the huge design parameter space of metasurfaces, require massive full-wave electromagnetic simulations, such as FDTD (Finite Difference Time Domain), which has extremely high computational costs and is time-consuming, making it difficult to meet the efficient design requirements of complex multi-objective or broadband devices.
[0004] In recent years, data-driven methods based on deep learning have been introduced into metasurface inverse design. Researchers typically employ CNNs (Convolutional Neural Networks), GANs (Generative Adversarial Networks), or conventional VAEs (Variational Autoencoders) to establish the mapping relationship between spectra and metasurface structures. However, existing deep learning methods still suffer from the following significant drawbacks: (1) Difficulty in feature alignment: The highly complex topology of metasurfaces and the drastically changing broadband transmission spectrum are in completely different feature spaces. Traditional CNNs or conventional VAEs are difficult to establish an accurate nonlinear mapping between the two, which leads to a sharp decrease in the accuracy of the model when predicting the structure corresponding to the complex spectrum.
[0005] (2) Poor physical generalization ability, easily producing "non-physical" structures: Traditional generative models only fit the statistical distribution of training data and lack the perception of underlying physical laws. When generating structures, they often output invalid structures with blurred edges, which do not meet the requirements of manufacturing processes or completely violate Maxwell's equations.
[0006] The above background information is provided only to aid in understanding the concept and technical solution of this invention. It does not necessarily belong to the prior art of this patent application. In the absence of clear evidence that the above information was disclosed on the filing date of this patent application, the above background information should not be used to evaluate the novelty and inventiveness of this application. Summary of the Invention
[0007] This invention proposes a metasurface reinforcement learning inverse design method, which can overcome the problems faced by deep learning models in existing metasurface inverse design methods, such as the difficulty in aligning spectral and structural features and the easy generation of invalid structures that do not conform to the laws of electromagnetic physics. This enables efficient and accurate generation of metasurface structures that conform to the spectral response of complex targets and meet physical laws and manufacturing constraints.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention discloses a metasurface reinforcement learning inverse design method, comprising the following steps: Z1: Collect a two-dimensional metasurface structure image dataset, and train the two-dimensional metasurface structure image dataset using a vector quantization variational autoencoder model to map the images in the two-dimensional metasurface structure image dataset into a one-dimensional structure coding sequence. Z2: Obtain the target transmission spectrum sequence and input the target transmission spectrum sequence and the one-dimensional structure coding sequence into the large language model to generate at least two candidate structure coding sequences; Z3: Decode the candidate structure encoding sequence, and perform computational verification and rejection sampling through a physical proxy model to select candidate structures. Then, based on the selection results, optimize the generation strategy of the large language model through a reinforcement learning strategy.
[0009] Preferably, the vector quantization variational autoencoder model includes an encoder, a discrete codebook, and a decoder. The encoder is used to map images in the two-dimensional metasurface structure image dataset into continuous latent variable features. The discrete codebook is used to transform the continuous latent variable features into a one-dimensional structure encoding sequence through nearest neighbor matching. The decoder is used to reconstruct the image.
[0010] Preferably, the total loss function when training a two-dimensional metasurface structure image dataset using a vector quantization variational autoencoder model includes the basic reconstruction loss of the vector quantization variational autoencoder model, the physical surrogate model loss, and the latent variable spatial contrast constraint loss based on spectral similarity.
[0011] Preferably, step Z2 specifically includes: acquiring the target transmission spectrum sequence and constructing a large language model based on the LoRAMoE architecture; using the target transmission spectrum sequence and the one-dimensional structure encoding sequence to perform supervised fine-tuning on the large language model to generate candidate structure encoding sequences; wherein the LoRAMoE architecture is a LoRA-based hybrid expert system consisting of a router and a LoRA network, and the router adaptively allocates the weights of the expert network according to the input spectral features to process spectral features of different frequency bands.
[0012] Preferably, step Z3 specifically includes: Z31: Decode the candidate structure encoding sequence to obtain a two-dimensional metasurface structure image; Z32: Input the image of the two-dimensional metasurface structure into the physical proxy model to obtain the predicted spectrum; Z33: Based on the error between the predicted spectrum and the target transmission spectrum sequence, candidate structures that meet the sampling threshold are selected; Z34: Based on the screening results, optimize the generation strategy of the large language model through reinforcement learning.
[0013] Preferably, step Z34 includes: modeling the process of generating metasurface structure encoding from a large language model as a Markov decision process, and based on a policy gradient optimization algorithm, converting the error between the predicted spectrum and the target transmission spectrum sequence into a physical performance advantage function, and performing policy gradient optimization on the large language model.
[0014] Preferably, the update formula for the reinforcement learning strategy is:
[0015] In the formula, This represents the network parameters that need to be optimized for the large language model; This represents the gradient estimate of the objective policy function; This represents the batch dataset obtained from sampling; This represents the total number of trajectories in the batch dataset; This represents a complete metasurface generation trajectory; This represents the total step size required to generate a complete metasurface structure. Indicates the current generation stage. One time step; Indicates the first The state during the step; This indicates that the large language model is in the first... The action to be performed step by step; Indicates the current state Below, the parameters are The model takes action The probability distribution; This represents a function that indicates physical performance advantages.
[0016] Preferably, the total loss function of the reinforcement learning strategy includes candidate discrimination loss and physical consistency loss.
[0017] Preferably, the physical proxy model is a fast approximate spectral prediction model constructed using ResNet or other deep neural networks and trained under supervision using structure-spectral pairing data obtained from FDTD simulation.
[0018] In a second aspect, the present invention discloses a computer-readable storage medium having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the steps of the metasurface reinforcement learning inverse design method as described in the first aspect.
[0019] Compared with existing technologies, the advantages of this invention are as follows: This invention discretizes continuous and highly complex two-dimensional metasurface images into low-dimensional structural coding sequences using a vector quantization variational autoencoder, effectively eliminating structural ambiguity and ensuring perfect alignment of structural features with one-dimensional spectral sequences in terms of feature morphology. It introduces a large language model with powerful logical reasoning and sequence modeling capabilities and constructs a closed-loop feedback mechanism of rejection sampling and reinforcement learning. Through a physical proxy model, physical errors are used as reward signals to be passed back to the large language model for policy gradient updates, allowing the large language model to directly optimize under the constraints of physical laws. This breaks through the physical accuracy bottleneck of traditional data-driven methods and greatly improves the spectral fidelity and manufacturability of the generated metasurface structures. Through the combination of the above technical features, this invention achieves a significant improvement in the spectral fidelity of metasurface reverse design and the physical manufacturability of the generated structures, making it applicable to applications such as micro / nano optical device design, holographic imaging, and photoelectric sensing.
[0020] In a further embodiment, the present invention also has the following beneficial effects: (1) By introducing latent variable space contrast constraint loss based on spectral similarity, metasurface structure samples with similar transmission spectral responses are closer in the latent variable space, while samples with significantly different transmission spectral responses are farther apart in the latent variable space, which improves the stability and physical consistency of subsequent structure encoding generation, similar structure retrieval and spectral condition reverse design.
[0021] (2) By constructing a large language model based on the LoRAMoE architecture, the router adaptively calculates the gating weights according to the different frequency band characteristics of the input broadband transmission spectrum, thereby allocating different expert networks for processing, which improves the expressive ability of the large model to process the mapping of broadband multi-resonant spectrum to complex topology structure, and realizes adaptive expert allocation for different frequency band characteristics.
[0022] (3) By modeling the process of generating metasurface structure encoding from a large language model as a Markov decision process, and using the error signal fed back by the physical verifier to construct the advantage function, the large language model is optimized by policy gradient. This makes the model no longer limited to statistical fitting at the pure data level, but directly seeks optimization under the constraints of Maxwell's electromagnetic physics laws, thereby greatly improving the physical accuracy of the generated structure.
[0023] (4) By introducing a joint loss function of candidate discrimination loss and physical consistency loss, while ensuring that the predicted spectrum of the candidate structure is as close as possible to the target transmission spectrum, the difference between multiple candidate structures under the same target spectrum is improved, and multiple candidate results are prevented from collapsing into the same or highly similar structures, thereby improving the diversity and exploration capability of the candidate set.
[0024] Other beneficial effects of the embodiments of the present invention will be further described below. Attached Figure Description
[0025] Figure 1 This is a flowchart of the metasurface reinforcement learning reverse design method disclosed in a preferred embodiment of the present invention; Figure 2 This is a block diagram of a VQ-VAE discretization encoding and reconstruction network for a metasurface structure according to a specific embodiment of the present invention; Figure 3 This is a generative network block diagram based on the LoRAMoE architecture and forward physics feedback reinforcement learning, according to a specific embodiment of the present invention. Figure 4 This is an overall flowchart of a metasurface reinforcement learning inverse design method based on a large model and VQ-VAE, according to a specific embodiment of the present invention. Detailed Implementation
[0026] The embodiments of the present invention will be described in detail below. It should be emphasized that the following description is merely exemplary and not intended to limit the scope and application of the present invention.
[0027] To address the challenges of aligning spectral and structural features and generating invalid structures that violate electromagnetic physics in existing metasurface inverse design methods using deep learning models, this invention establishes a metasurface inverse design algorithm based on LLM (Large Language Model) and VQ-VAE (Vector Quantization Variational Autoencoder). The algorithm proposes a method to discretize the continuous physical structure of the metasurface into a one-dimensional encoded sequence and map it using a large model. Furthermore, the algorithm incorporates physical forward verification and reinforcement learning closed-loop feedback for the generated structure, significantly improving the spectral fidelity and physical fabricatability of the generated structure. This algorithm can be applied to micro / nano optical device design, holographic imaging, and photoelectric sensing.
[0028] like Figure 1 As shown, a preferred embodiment of the present invention discloses a metasurface reinforcement learning inverse design method based on a large model and VQ-VAE (Vector Quantized Variational Autoencoder). It discloses a generation mapping process from the target transmission spectrum to a complex two-dimensional metasurface structure and proposes an algorithm to improve the accuracy of the generated structure by introducing forward physics verification feedback, including: Z1: Collect a dataset of two-dimensional metasurface structure images and train a vector quantization variational autoencoder model on the dataset to map the images in the dataset into a one-dimensional structure encoding sequence. Specifically, this step involves constructing and training a discretization encoding and decoding model for metasurface structures based on a vector quantization variational autoencoder (VQ-VAE). The VQ-VAE model is then used to train the collected two-dimensional metasurface structure dataset, discretizing the two-dimensional metasurface image features into a one-dimensional structure encoding sequence. The VQ-VAE is specifically a vector quantization variational autoencoder.
[0029] The VQ-VAE model is used to extract the geometric structure and topological features of metasurfaces. The acquired two-dimensional metasurface structure image dataset is input into the VQ-VAE model for image reconstruction, and joint training is performed using spectral consistency constraints and spectral supervised contrast constraints. The VQ-VAE model includes an encoder, a discrete encoding book (also known as the embedding space), and a decoder. The encoder maps the two-dimensional metasurface image into continuous latent variable features, then transforms them into a one-dimensional token (structure encoding) sequence in the discrete encoding book through nearest neighbor matching. Finally, the decoder reconstructs the image. From a data perspective, discretization encoding can effectively eliminate the ambiguity of micro / nano physical structures, perfectly aligning them with one-dimensional spectral data in terms of feature morphology.
[0030] refer to Figure 2 This illustrates the process of extracting continuous latent variables from a two-dimensional metasurface image via an encoder, mapping it to a discrete codebook via nearest neighbor matching, reconstructing the image via a decoder, and serializing it to obtain a one-dimensional structure encoding sequence. In a specific example, a dataset of two-dimensional metasurface structure images is collected, and the input tensor is denoted as... Where B is the batch size (e.g., Batch size=32), H=64, W=64, and C=1 (a pixel value of 1 represents the presence of material in the structure layer, and 0 represents the absence of material; this is obtained by merging grayscale values from a 64×64×3 metasurface structure image). Input image x Feature extraction and downsampling are performed using a multi-layer convolutional neural network. Specifically, the encoder in this embodiment includes: a first layer with a Conv2D operator, a 4×4 convolutional kernel, a stride of 2, padding of 1, followed by a ReLU activation function, resulting in an output tensor size of (B, 32, 32, 128); a second layer with a Conv2D operator, a 4×4 convolutional kernel, a stride of 2, padding of 1, followed by a ReLU activation function, resulting in an output tensor size of (B, 16, 16, 256); subsequently, two cascaded residual blocks (ResNet Blocks) are connected, each containing two 3×3 Conv2D operators and a skip connection, without changing the tensor size. Encoder E processes the input metasurface structure image... x Mapped to continuous latent variable feature maps z e = E( x ).
[0031] Then, through nearest neighbor matching, the feature map is... Each feature vector in the dataset is mapped to a discrete codebook. ( k The nearest embedding vector in (1, 2, ..., K) (Where K is the size of the encoding file, and in this embodiment K is set to 1024;) (with embedding dimension D=256), thus obtaining a discrete structure encoding matrix. Decoder D will convert the matrix Reconstructed metasurface image .
[0032] To ensure the physical accuracy of the generated metasurface structures and their good spectral discriminability in the latent space, this specific embodiment introduces physical verification loss and contrast loss in addition to the conventional variational autoencoder loss in the training function. That is, the total loss function when training the two-dimensional metasurface structure image dataset using the VQ-VAE model includes the basic reconstruction loss of the VQ-VAE model, the physical surrogate model loss, and the latent variable space contrast constraint loss based on spectral similarity.
[0033] The total loss function L is defined as follows:
[0034] The basic reconstruction loss for VQ-VAE is defined as follows:
[0035] In the formula, Represents the reconstruction loss, used to constrain the pixel-level differences between the image generated by the decoder and the original image; This represents the codebook loss, used to update the vectors in the codebook that approximate the encoder output; This represents commitment loss, used to prevent drastic fluctuations in encoder output; hyperparameter To control its weight, this embodiment sets... ; This indicates the Stop Gradient operator, which acts as an identity function during forward propagation and has a zero gradient during backward propagation.
[0036] The physical surrogate model loss characterizes the error between the predicted spectrum of the reconstructed structure and the true target spectrum. It is defined as: .
[0037] In the formula, S represents the image of the original metasurface structure. x The corresponding true transmission spectrum; R(·) represents the pre-trained ResNet physical proxy model; This represents the metasurface image reconstructed by the decoder. The predicted spectrum is calculated after being input into the agent network.
[0038] In some embodiments, the physical proxy model employs a ResNet-34 network structure without ImageNet pre-trained weights. This network takes a two-dimensional metasurface structure image as input and the corresponding spectral response as output, approximating the forward physical mapping relationship obtained from FDTD simulations. Specifically, the input is a 64×64×3 metasurface structure image, and the output is a 40-dimensional spectral vector corresponding to 40 discretely sampled spectral response points within the target wavelength range. The last fully connected layer of the ResNet-34 is replaced with a linear layer with an output dimension of 40 to adapt to the spectral prediction task. This physical proxy model is trained under supervised supervision using structure-spectral data obtained from FDTD simulations. The training objective is to make the network's predicted spectrum as close as possible to the FDTD simulation spectral labels. The Huber loss function is used.
[0039] The loss item Effective constraints on electromagnetic physical properties were introduced during the feature reconstruction stage.
[0040] This is a latent variable space contrastive constraint loss based on spectral similarity, used to cluster and separate extracted features in the latent variable space according to the spectral response characteristics of the metasurface, thereby constraining the latent variable distribution learned by the VQ-VAE encoder. It is defined as follows:
[0041] In the formula, G is the total number of samples in the batch; and These represent the first and second digits within the batch. i The and the first j Continuous latent variable feature map of a metasurface sample; For spectral similarity labels, when the first i The and the first j When the Euclidean distance between the true transmission spectra of samples is less than a preset threshold for spectral similarity, they are considered spectrally similar. Conversely, if they are not similar, they are considered dissimilar and taken as... ; m The preset distance boundary hyperparameters are defined as follows. The preset threshold for spectral similarity and the distance boundary parameter can be determined based on statistical results from the training set or experiments on the validation set. In a specific embodiment, the preset threshold for spectral similarity is 0.35, and the distance boundary parameter is 1.0.
[0042] The aforementioned spectral similarity threshold of 0.35 was determined by statistically analyzing the Euclidean distance distribution between the spectral responses of all sample pairs in the training set, and selecting the 30th percentile (i.e., 30% of sample pairs have a distance below this value). Boundary hyperparameters mThe initial setting is achieved by calculating the mean difference between the distances of positive and negative samples to latent variables within a batch during the early stages of training and taking a multiple of that difference (e.g., 1.5 times), and then fine-tuning it based on the clustering results during training.
[0043] In this specific embodiment, the 40-dimensional true transmission spectrum is first normalized, then the spectral Euclidean distance distribution of sample pairs in the training set is calculated. Sample pairs with distances within a smaller quantile are defined as spectrally similar sample pairs, and a preset threshold for spectral similarity is determined accordingly. The preset distance boundary hyperparameter... m The method is set based on the statistical results of the latent variable distance during the training process, and the verification standard is "the average latent variable distance between positive samples is less than the average latent variable distance between negative samples".
[0044] Its function is to constrain the continuous latent variable characteristics of the VQ-VAE encoder output. This approach places metasurface structure samples with similar transmission spectral responses closer together in the latent variable space, while placing samples with significantly different transmission spectral responses further apart. The loss is a pair-level contrastive learning loss. By incorporating spectral response information to organize the latent variable space, the structure encoding learned by VQ-VAE not only reconstructs the metasurface image but also reflects the corresponding physical spectral properties of the metasurface structure. This helps improve the stability and physical consistency of subsequent structure encoding generation, similar structure retrieval, and spectral conditional inverse design.
[0045] By calculating the distance between latent variable feature maps of different samples within a batch, metasurface structures with similar transmission spectra are made to move closer to each other in the latent space, while metasurface structures with large differences in transmission spectra are moved further apart in the latent space.
[0046] The two-dimensional metasurface structure image dataset used in the above specific examples mainly consists of nanopillar metasurface structures. Each sample includes a two-dimensional metasurface structure image and its corresponding transmission / reflection spectral response. The corresponding real spectral labels are obtained through FDTD simulation; FDTD simulation is a data generation method used to obtain high-precision real spectral labels, which is also the method for constructing the dataset. Specifically, electromagnetic simulation is performed on a given nanopillar metasurface structure to obtain its spectral response in the target wavelength range, and this spectrum is used as a supervised training label. The data size is approximately 18,000 samples, of which approximately 16,000 are used for training and approximately 2,000 are used for validation or testing. The structural parameters of the nanopillar structures mainly included in the two-dimensional metasurface structure image dataset cover the following ranges: nanopillar radius from 40 nm to 120 nm, nanopillar height fixed at 230 nm (or from 200 nm to 250 nm), and period fixed at 300 nm (or from 280 nm to 320 nm). Each structural image sample corresponds to eight hundred transmittance (or reflectance) samples within a spectral range from 400 nm to 1200 nm. This parameter range ensures that the dataset covers a sufficiently diverse range of geometries to generate rich spectral responses. This dataset is used for training the VQ-VAE structural encoding model, the physical surrogate model, and for data construction in the subsequent large-scale model reverse engineering phase.
[0047] The latent variable space contrast constraint loss based on spectral similarity introduced during the training of the VQ-VAE model makes metasurface structure samples with similar transmission spectral responses closer together in the latent variable space, thereby improving the stability and physical consistency of subsequent structure encoding generation.
[0048] The Z1 step perfectly transforms complex two-dimensional metasurface structures into one-dimensional discrete token (structure encoding) sequences.
[0049] Z2: Obtain the target transmission spectrum sequence and input the target transmission spectrum sequence and one-dimensional structure coding sequence into the large language model to generate at least two candidate structure coding sequences; Furthermore, this step constructs a large language model based on the LoRAMoE architecture and performs SFT (Supervised Fine-Tuning). Specifically, the main parameters of the base large model (large language model) can be frozen or remain essentially unchanged, while multiple LoRA expert modules are inserted at the fine-tunable positions of its attention layer. For different input conditions, such as different target spectra, different metasurface structure types, or different design requirements, the routing network calculates the activation weights of each LoRA expert based on the current hidden state or input features, and selects one or more experts to participate in the calculation. This invention, after representing the metasurface structure as a discrete structure encoding sequence using VQ-VAE, utilizes the LoRAMoE fine-tuning mechanism to learn the mapping relationship between the target spectrum and the structure encoding.
[0050] In one specific embodiment, for example, a Qwen2.5 large language model based on the LoRAMoE (low-rank fine-tuning hybrid expert system) architecture is constructed, and SFT (Supervised Fine-Tuning) is performed on the large language model using the target transmission spectrum sequence and the one-dimensional structure encoding sequence. In other specific embodiments, the base model of the large language model can be replaced with other Transformer-like language models or multimodal models with sequence generation capabilities. In other words, the specific base model is only one example of implementing the present invention; the core technical contribution mainly lies in the overall combination method of VQ-VAE structure discretization representation, LoRAMoE conditional fine-tuning, and physical proxy model-assisted optimization.
[0051] Furthermore, step Z2 specifically includes: acquiring the target transmission spectrum sequence and constructing a large language model based on the LoRAMoE architecture; using the target transmission spectrum sequence and a one-dimensional structure encoding sequence to perform supervised fine-tuning of the large language model to generate at least two candidate structure encoding sequences; wherein the LoRAMoE architecture is a LoRA-based hybrid expert system consisting of a router and a LoRA network, the router adaptively assigns weights to the expert network according to the input spectral features to handle spectral features of different frequency bands. The router in the LoRAMoE architecture adaptively assigns expert network weights according to the input spectral features, which can handle spectral features of different frequency bands more finely and improve the model's ability to resolve complex spectra.
[0052] In a specific embodiment, step Z2 specifically includes introducing a LoRAMoE module into the multi-head attention mechanism or feedforward neural network bypass of the Qwen2.5 large model. The router in this module adaptively calculates gating weights based on the different frequency band characteristics of the input broadband transmission spectrum, thereby allocating different expert networks for processing. This architecture can significantly improve the expressive ability of large models to handle broadband multi-resonant spectra mapped to complex topological structures.
[0053] This specific embodiment uses the open-source Qwen2.5 large model as the base model to establish a conditional generation mapping from the target transmission spectrum to the structure encoding obtained in step Z1. To improve the large model's ability to capture transmission spectral features across different frequency bands, this invention innovatively introduces a LoRAMoE (hybrid expert low-rank adaptation) module into the bypass of the Qwen2.5 large model. For each expert, this module includes a low-rank dimensionality reduction matrix. (4096×16) and an upgraded matrix (16×4096). The LoRAMoE module consists of a router and multiple expert networks (i.e., independent LoRA fine-tuning branches). For the input feature vector... The output calculation formula is as follows:
[0054] In the formula, This is the final output vector of the LoRAMoE module; In this embodiment, the total number of expert networks is set to [number]. ; Indicates the first The calculation process of an expert and The first Low-rank reduced-dimensionality matrix and increased-dimensionality matrix (e.g., rank) of an expert ); The gating weights output by the router represent the gating weights for the current input features. The activation probability of each expert. The router implements this through the Softmax function: ,in Here is the learnable weight matrix for the router. It's a Softmax route.
[0055] By discretizing the target transmission spectrum into a numerical sequence as a prompt, the large model outputs the corresponding structure encoding sequence to complete the Supervised Soft Formapping (SFT). The input variables are the target transmission spectrum (a 40-dimensional discrete numerical sequence, downsampled from an 800-dimensional FDTD simulation spectrum) and the Prompt vector transformed from physical parameters (Plasma, Thickness, and MIM / DM types), which are input to the base large model. At the end of the model, an autoregressive approach is used to generate the sequence. Unlike the single-sample output method, this specific embodiment uses one-to-many extended data for training in the SFT stage. The number of reference structure encoding sequences corresponding to each target transmission spectrum does not exceed four, and each candidate sequence is 256 characters long, corresponding to four sets of metasurface discrete token sequences. These settings significantly improve the candidate coverage and optimization space in the subsequent reinforcement learning stages.
[0056] Z3: Decodes the candidate structure encoding sequence and performs computational verification and rejection sampling through a physical proxy model to filter out candidate structures. Then, based on the filtering results, it optimizes the generation strategy of the large language model through a reinforcement learning strategy.
[0057] This step utilizes reinforcement learning alignment optimization based on physical feedback. Specifically, a fine-tuned large model is used to generate and decode multiple candidate structure encoding sequences. A physical surrogate model is then used to perform computational verification and rejection-sampling on the candidate structures, filtering out high-quality candidate data. The generation process of the large language model is modeled as a Markov decision process, and a dominance function is established by combining physical verification feedback. Reinforcement learning algorithms are then used to optimize and align the large model's policy gradient for reverse engineering of high-precision metasurface devices.
[0058] The specific process of rejecting sampling mentioned above includes: (1) Given the target spectrum or design requirements, the fine-tuned large language model generates N candidate structure encoding sequences; (2) Input each candidate structure encoding sequence into the VQ-VAE decoder to recover the corresponding two-dimensional metasurface structure image; (3) Input the decoded metasurface structure image into the physical proxy model to predict its transmission / reflection spectrum; (4) Calculate the error between the predicted spectrum and the target spectrum, such as mean square error (MSE), mean absolute error (MAE), or a comprehensive evaluation index combining spectral correlation coefficient; (5) Sort all candidate structures according to the error from smallest to largest; (6) Retain the Top-K candidate structures with the smallest error and reject the remaining candidate structures. In the preferred embodiment, Top-K screening is used; in other embodiments, an error threshold can be further set to accept only candidate structures with errors lower than the preset threshold.
[0059] The optimization process specifically includes: based on the policy gradient optimization algorithm, the predicted spectral error calculated by the physical verifier is transformed into a physical performance advantage function, and policy gradient optimization is performed on the large language model. The closer the spectrum of the generated structure is to the target spectrum, the larger the advantage function value, and the model updates its parameters to increase the probability of that generation action. By utilizing the closed-loop feedback mechanism of reinforcement learning, the large language model is no longer limited to statistical fitting at the pure data level, but directly seeks optimization under the constraints of Maxwell's laws of electromagnetic physics, thereby greatly improving the physical accuracy of the generated structure.
[0060] Specifically, this invention models the process of generating metasurface structure codes from a large language model as a Markov Decision Process (MDP). It utilizes error signals from a physical surrogate model (e.g., ResNet) or FDTD to construct an advantage function, and then optimizes the policy gradient of the large language model. The ResNet physical surrogate model is trained using structure-spectrum data generated by FDTD and is used for rapid spectrum prediction. The FDTD simulator can directly perform electromagnetic simulations without training, offering high accuracy but slow computation. ResNet and FDTD are not the reward function itself, but rather the source of the reward signal calculation. In reinforcement learning, candidate metasurface structures are input into the physical surrogate model and / or the FDTD simulator to obtain the corresponding predicted or simulated spectra. A reward function or physical performance advantage function is constructed based on the error between the predicted or simulated spectra and the target transmission spectrum. In this embodiment, the physical surrogate model is constructed using ResNet or other deep neural networks and trained under supervision using structure-spectrum pairing data obtained from FDTD simulations, resulting in a fast approximate spectral prediction model.
[0061] The core policy update formula for reinforcement learning is as follows:
[0062] In the formula, This represents the network parameters that need to be optimized for a large model (including the LoRAMoE module); This represents the gradient estimate of the objective policy function, which guides the direction of model parameter updates; This represents the batch of trajectories obtained through sampling. This indicates the total number of trajectories in the batch dataset (e.g., Batch size = 64). This represents a complete metasurface generation trajectory. This represents the total step size required to generate a complete metasurface structure (i.e., the total length of the token sequence; in this specific embodiment, the metasurface resolution is set to 64×64; if the downsampling rate is 4, then the sequence length is...). ); Indicates the current generation stage. One time step; Indicates the first The state at each step includes the given target transmission spectrum information and the previous state. The metasurface structure encoding information has already been generated; Indicates the large model in the first... The action to be performed is the prediction of the output in the vocabulary. Each structure code (Token); Indicates the current state Below, the parameters are The model takes action The probability distribution; This represents the physical performance advantage function, which is calculated by a physical surrogate model or FDTD simulation. The closer the predicted spectrum of the metasurface structure generated by the current action sequence is to the target spectrum (the better the physical performance), then... The larger the positive value, the higher the probability of the model generating the action sequence; conversely, if an invalid or non-physical structure is generated, the model will generate a lower probability. A negative value penalizes the action. The physical meaning refers to the token selection action corresponding to a structure with better physical verification performance. Gain a positive advantage >0, the gradient formula will drive the parameters of a large model. Update the backpropagation in the direction that increases the probability of generating the action (and suppress its generation if it decreases the probability). This process is repeated multiple times.
[0063] In the reinforcement learning process described above, after supervised fine-tuning, N candidate structure encoding sequences are generated for the same target transmission spectrum. Each candidate structure encoding sequence is input into a VQ-VAE decoder to obtain the corresponding two-dimensional candidate metasurface structure. The predicted spectral response of each candidate metasurface structure is then calculated using a physical surrogate model and / or a full-wave electromagnetic simulator. Based on the matching error between the predicted spectral response and the target transmission spectrum, the N candidate structures are sorted, thresholded, or selected using a Top-K algorithm.
[0064] In an embodiment employing reinforcement learning optimization, a reward value is calculated based on the spectral matching degree of candidate structures, structural effectiveness, and structural differences between candidates, and the generation strategy of the large language model is updated based on the reward value.
[0065] The total loss in reinforcement learning is defined as:
[0066] In this embodiment, and Weights are used to control the candidate structure discrimination loss and physical consistency loss, respectively. Since metasurface reverse design first requires the generated structure to meet the target spectral response, this embodiment adopts a weight setting that prioritizes physical consistency. Preferably, let =1.0, =0.05. Wherein, This is used to ensure that the predicted spectrum of the candidate structure is as close as possible to the target transmission spectrum. This method aims to improve the diversity among multiple candidate structures under the same target spectrum without significantly compromising spectral matching accuracy, thus preventing multiple candidate results from collapsing into identical or highly similar structures. (Reinforcement learning loss weight coefficients) and The candidate diversity is maintained while prioritizing physical consistency by performing a grid search on a small validation set.
[0067] in, The discrimination loss of multi-candidate generation results is used to constrain multiple candidate structures corresponding to the same input spectrum to have sufficient differences in the latent space or sequence space, so as to avoid multiple candidate sequences collapsing into highly similar results, thereby improving the diversity and exploration capability of the candidate set; The physical consistency loss is used to constrain the minimization of the error between the predicted spectrum obtained after forward validation of the candidate structure by the ResNet physical proxy model or FDTD and the target transmission spectrum. This term corresponds to the core physical optimization objective in the original reinforcement learning.
[0068] The negative average dissimilarity between each pair of candidate sequences is defined as:
[0069] In the formula, This represents the number of candidate metasurface structure sequences generated for the same target transmission spectrum; in this embodiment, it can be set to... = 8; and These represent the numbers of the candidate structure sequences, and Greater than This is used to iterate through pairwise combinations of different candidate structures under the same target spectrum; They represent the first The and the first One candidate metasurface structure encoding sequence; This represents a measure of dissimilarity between two candidate structure encoding sequences. In a preferred embodiment, Normalized Hamming distance or Jaccard distance can be used to calculate the degree of difference between two discrete structured coding sequences.
[0070] The physical consistency loss is calculated using the following formula:
[0071] After multiple iterations, the final output of the large model is the network weights aligned and optimized by physical laws (implicit constraints of Maxwell's equations). This is achieved through physical consistency loss. middle, Indicates the first The predicted transmission spectra of candidate structures are obtained by decoding them using VQ-VAE and inputting them into a physical surrogate model or FDTD forward verification. This represents the target transmission spectrum input to the large model; Indicates the first The squared Euclidean distance between the predicted spectrum of each candidate structure and the transmission spectrum of the target structure is used to measure the physical response error of the candidate structure. The average spectral errors of each candidate structure are used to obtain the overall physical consistency loss of the candidate structure set under the same target spectrum.
[0072] It should be noted that there is an inevitable approximation error between the prediction of the physical surrogate model and the high-precision FDTD simulation. This error may lead to deviations in the reinforcement learning feedback signal. To alleviate this problem, the present invention adopts the following strategies: (1) Surrogate model training stage: Robust loss functions such as Huber loss are used, and regularization methods such as noise injection are used to improve the generalization ability of the surrogate model. (2) Reinforcement learning optimization stage: Periodically (e.g., every 5 rounds of training), some samples are extracted from the generated candidate structures for high-precision FDTD simulation verification, and the FDTD results are used to calibrate the prediction of the surrogate model, or directly used to calculate the advantage function to ensure the correctness of the optimization direction.
[0073] refer to Figure 3 The diagram illustrates the process of inputting transmission spectral features and one-dimensional structure encoding into the LoRAMoE hybrid expert module, followed by router selection of expert LoRA, parallel processing of multi-expert networks, multi-head attention fusion output, candidate structure decoding, predicted spectrum calculation, and physical error feedback to inversely update network weights.
[0074] refer to Figure 4 The diagram illustrates the relationship between target transmission spectrum, metasurface structure dataset, cue word construction, VQ-VAE discretization encoding, LoRAMoE-based large model supervised fine-tuning, rejection sampling and candidate generation, physical proxy model verification, advantage function establishment and policy update in a specific embodiment of the present invention.
[0075] This invention employs a physical surrogate model at different stages. Specifically: during the VQ-VAE training phase, the physical surrogate model calculates the spectral consistency loss after structure reconstruction, ensuring that the structure decoded by VQ-VAE closely approximates the original structure not only at the image level but also at the physical response level. During the reinforcement learning or generative optimization phase, the physical surrogate model is used to quickly evaluate the spectral performance of structures generated by large models and serves as the basis for reward calculation, candidate selection, or rejection sampling. In the final verification phase, for the selected high-quality candidate structures, FDTD simulation is further used for high-precision physical verification to avoid bias caused by surrogate model errors.
[0076] This invention overcomes the difficulties faced by deep learning models in existing metasurface reverse design methods, such as the difficulty in aligning spectral and structural features and the tendency to generate invalid structures that do not conform to the laws of electromagnetic physics. The reason for overcoming the shortcomings of existing technologies is as follows: First, this invention utilizes VQ-VAE to discretize the continuous and highly complex two-dimensional image of the metasurface into a low-dimensional token (structure encoding) sequence, effectively eliminating structural ambiguity and ensuring perfect alignment of structural features with the one-dimensional spectral sequence in terms of feature morphology. Second, this invention introduces LLM (Large Language Model) with powerful logical reasoning and sequence modeling capabilities, such as Qwen and GPT, and combines it with LoRAMoE (Low-Rank Adaptation Mixture of Experts), greatly improving the model's ability to process the mapping from broadband transmission spectra to complex topological structures, and achieving adaptive expert allocation for features in different frequency bands. Finally, to address the problem of "non-physical" structures, this invention innovatively constructs a closed-loop feedback mechanism of rejection sampling and reinforcement learning (RL). By introducing physical surrogate models (such as ResNet residual networks) or FDTD simulations, physical errors are used as reward signals and passed back to the large model for policy gradient updates. This allows the model to move beyond simple data fitting and optimize directly under the constraints of physical laws, thus breaking through the physical accuracy bottleneck of traditional data-driven methods and greatly improving the spectral fidelity and workability of generated metasurface structures.
[0077] Another preferred embodiment of the present invention discloses a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the metasurface reinforcement learning reverse design method as described in the preferred embodiment above.
[0078] Optionally, the aforementioned storage media may include, but are not limited to, USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks, and other media capable of storing computer programs.
[0079] This invention discloses a metasurface reinforcement learning inverse design method based on a large model and VQ-VAE, including a VQ-VAE-based metasurface structure discretization model and a spectrum-to-structure generation optimization algorithm based on a large model combined with reinforcement learning. The VQ-VAE-based metasurface structure discretization model includes the construction of a two-dimensional metasurface structure image dataset and the extraction of latent variable features; nearest neighbor matching mapping between continuous latent variable features and discrete encodings; and mutual conversion and reconstruction between two-dimensional metasurface structure images and one-dimensional discrete structure encodings. The spectrum-to-structure generation optimization algorithm based on a large model combined with reinforcement learning includes: supervised fine-tuning of a large language model based on the LoRAMoE architecture; rejection sampling of candidate metasurface structure encoding data; prediction spectrum calculation and error ranking based on a forward physics surrogate model; and the establishment and gradient optimization of a reinforcement learning advantage function combining a large model generation strategy and forward physics verification feedback.
[0080] In summary, this invention addresses the challenges of existing deep learning inverse design methods, such as difficulty in aligning complex structural features and the tendency to generate unmanufacturable non-physical structures. It proposes a large-scale model structure serialization generation framework based on VQ-VAE and introduces the LoRAMoE architecture to adaptively handle complex features of broadband spectra. Building upon this mapping model, a reinforcement learning closed-loop optimization algorithm combining rejection sampling and forward physics simulation feedback is proposed. This design fully leverages the feedback advantages of the physical surrogate model, overcoming the bottleneck of traditional data-driven methods lacking physically perceptual constraints. It significantly improves the prediction accuracy of broadband transmission spectra and greatly enhances the physical connectivity and fabrication yield of metasurface-generated structures. This technology can be applied to complex multi-object micro / nano optical device design, holographic imaging, optical interconnect computing, and high-frequency electromagnetic sensing.
[0081] The background section of this invention may include background information about the problems or circumstances surrounding the invention, rather than a description of prior art by others. Therefore, the content included in the background section is not an admission of prior art by the applicant.
[0082] The above description provides a further detailed explanation of the present invention in conjunction with specific / preferred embodiments, and it should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various substitutions or modifications can be made to these described embodiments without departing from the concept of the present invention, and all such substitutions or modifications should be considered within the scope of protection of the present invention. In the description of this specification, the reference to terms such as "an embodiment," "some embodiments," "preferred embodiment," "example," "specific example," or "some examples," etc., indicates that the specific features, structures, materials, or characteristics described in connection with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Furthermore, those skilled in the art can combine and integrate different embodiments or examples and features of different embodiments or examples described in this specification without contradiction. Although the embodiments of the present invention and their advantages have been described in detail, it should be understood that various changes, substitutions, and modifications can be made herein without departing from the scope defined by the appended claims.
Claims
1. A metasurface reinforcement learning inverse design method, characterized in that, Includes the following steps: Z1: Collect a two-dimensional metasurface structure image dataset, and train the two-dimensional metasurface structure image dataset using a vector quantization variational autoencoder model to map the images in the two-dimensional metasurface structure image dataset into a one-dimensional structure coding sequence. Z2: Obtain the target transmission spectrum sequence and input the target transmission spectrum sequence and the one-dimensional structure coding sequence into the large language model to generate at least two candidate structure coding sequences; Z3: Decode the candidate structure encoding sequence, and perform computational verification and rejection sampling through a physical proxy model to select candidate structures. Then, based on the selection results, optimize the generation strategy of the large language model through a reinforcement learning strategy.
2. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, The vector quantization variational autoencoder model includes an encoder, a discrete codebook, and a decoder. The encoder is used to map images in the two-dimensional metasurface structure image dataset into continuous latent variable features. The discrete codebook is used to transform the continuous latent variable features into a one-dimensional structure encoding sequence through nearest neighbor matching. The decoder is used to reconstruct the image.
3. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, The total loss function when training a two-dimensional metasurface structure image dataset using a vector quantization variational autoencoder model includes the basic reconstruction loss of the vector quantization variational autoencoder model, the physical surrogate model loss, and the latent variable spatial contrast constraint loss based on spectral similarity.
4. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, Step Z2 specifically includes: acquiring the target transmission spectrum sequence and constructing a large language model based on the LoRAMoE architecture; using the target transmission spectrum sequence and the one-dimensional structure encoding sequence to perform supervised fine-tuning on the large language model to generate candidate structure encoding sequences; wherein the LoRAMoE architecture is a LoRA-based hybrid expert system consisting of a router and a LoRA network, and the router adaptively allocates the weights of the expert network according to the input spectral features to process spectral features of different frequency bands.
5. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, Step Z3 specifically includes: Z31: Decode the candidate structure encoding sequence to obtain a two-dimensional metasurface structure image; Z32: Input the image of the two-dimensional metasurface structure into the physical proxy model to obtain the predicted spectrum; Z33: Based on the error between the predicted spectrum and the target transmission spectrum sequence, candidate structures that meet the sampling threshold are selected; Z34: Based on the screening results, optimize the generation strategy of the large language model through reinforcement learning.
6. The metasurface reinforcement learning reverse design method according to claim 5, characterized in that, Step Z34 includes: modeling the process of generating metasurface structure encoding from the large language model as a Markov decision process, and based on the policy gradient optimization algorithm, transforming the error between the predicted spectrum and the target transmission spectrum sequence into a physical performance advantage function, and performing policy gradient optimization on the large language model.
7. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, The update formula for the reinforcement learning strategy is: In the formula, This represents the network parameters that need to be optimized for the large language model; This represents the gradient estimate of the objective policy function; This represents the batch dataset obtained from sampling; This represents the total number of trajectories in the batch dataset; This represents a complete metasurface generation trajectory; This represents the total step size required to generate a complete metasurface structure. Indicates the current generation stage. One time step; Indicates the first The state during the step; This indicates that the large language model is in the first... The action to be performed step by step; Indicates the current state Below, the parameters are The model takes action The probability distribution; This represents a function that indicates physical performance advantages.
8. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, The total loss function of the reinforcement learning strategy includes candidate discrimination loss and physical consistency loss.
9. The metasurface reinforcement learning reverse design method according to claim 1, characterized in that, The physical proxy model is constructed using a deep neural network and trained under supervised supervision using structure-spectral pairing data obtained from FDTD simulation, resulting in a fast approximate spectral prediction model.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the metasurface reinforcement learning reverse design method as described in any one of claims 1 to 9.
