Table of Contents
Fetching ...

MCP-Enabled LLM for Meta-optics Inverse Design: Leveraging Differentiable Solver without LLM Expertise

Yi Huang, Bowen Zheng, Yunxi Dong, Hong Tang, Huan Zhao, Rakibul Hasan Shawon, Sensong An, Hualiang Zhang

TL;DR

The work tackles the barrier of specialized expertise in differentiable metasurface inverse design by introducing a Model Context Protocol (MCP) that allows LLMs to autonomously orchestrate design workflows using verified templates and solver documentation. By evaluating two prompt strategies (P1 and P2) against a documentation-only baseline, the study shows that structured prompting with mandatory two-stage optimization markedly improves design quality, efficiency, and reliability for a Huygens meta-atom with TorchRDIT. Key findings include higher success rates, reduced token usage, and substantially fewer hallucination- and solver-related errors under P2, illustrating that tool-aware orchestration can democratize access to rigorous electromagnetic design. The results have practical impact by enabling researchers without deep programming expertise to leverage differentiable solvers for complex metasurface optimization, with potential extensions to other scientific tasks via solver-agnostic MCP templates.

Abstract

Automatic differentiation (AD) enables powerful metasurface inverse design but requires extensive theoretical and programming expertise. We present a Model Context Protocol (MCP) assisted framework that allows researchers to conduct inverse design with differentiable solvers through large language models (LLMs). Since LLMs inherently lack knowledge of specialized solvers, our proposed solution provides dynamic access to verified code templates and comprehensive documentation through dedicated servers. The LLM autonomously accesses these resources to generate complete inverse design codes without prescribed coordination rules. Evaluation on the Huygens meta-atom design task with the differentiable TorchRDIT solver shows that while both natural language and structured prompting strategies achieve high success rates, structured prompting significantly outperforms in design quality, workflow efficiency, computational cost, and error reduction. The minimalist server design, using only 5 APIs, demonstrates how MCP makes sophisticated computational tools accessible to researchers without programming expertise, offering a generalizable integration solution for other scientific tasks.

MCP-Enabled LLM for Meta-optics Inverse Design: Leveraging Differentiable Solver without LLM Expertise

TL;DR

The work tackles the barrier of specialized expertise in differentiable metasurface inverse design by introducing a Model Context Protocol (MCP) that allows LLMs to autonomously orchestrate design workflows using verified templates and solver documentation. By evaluating two prompt strategies (P1 and P2) against a documentation-only baseline, the study shows that structured prompting with mandatory two-stage optimization markedly improves design quality, efficiency, and reliability for a Huygens meta-atom with TorchRDIT. Key findings include higher success rates, reduced token usage, and substantially fewer hallucination- and solver-related errors under P2, illustrating that tool-aware orchestration can democratize access to rigorous electromagnetic design. The results have practical impact by enabling researchers without deep programming expertise to leverage differentiable solvers for complex metasurface optimization, with potential extensions to other scientific tasks via solver-agnostic MCP templates.

Abstract

Automatic differentiation (AD) enables powerful metasurface inverse design but requires extensive theoretical and programming expertise. We present a Model Context Protocol (MCP) assisted framework that allows researchers to conduct inverse design with differentiable solvers through large language models (LLMs). Since LLMs inherently lack knowledge of specialized solvers, our proposed solution provides dynamic access to verified code templates and comprehensive documentation through dedicated servers. The LLM autonomously accesses these resources to generate complete inverse design codes without prescribed coordination rules. Evaluation on the Huygens meta-atom design task with the differentiable TorchRDIT solver shows that while both natural language and structured prompting strategies achieve high success rates, structured prompting significantly outperforms in design quality, workflow efficiency, computational cost, and error reduction. The minimalist server design, using only 5 APIs, demonstrates how MCP makes sophisticated computational tools accessible to researchers without programming expertise, offering a generalizable integration solution for other scientific tasks.

Paper Structure

This paper contains 30 sections, 7 equations, 8 figures, 7 tables, 1 algorithm.

Figures (8)

  • Figure 1: The schematic of the proposed LLM-MCP framework. Users provide queries that relate to the context of the problem and its design goals. The analyzes queries with autonomous access to the provided resources until enough information is obtained. The generates executable Python code that implements the complete inverse design pipeline. A feedback loop enables interactive refinement based on execution results.
  • Figure 2: Workflow efficiency metrics and Design Efficiency Score (DES) analysis. (a) distributions with quartile-based performance zones. Excellent: Top 25% of values; Good Zone: 50th - 75th percentile; Acceptable: Bottom 50% of values. (b) Composite score versus session length. (c) Session length distributions. (d) Tool usage analysis versus session length.
  • Figure 3: Comprehensive tool usage pattern analysis across prompt strategies. (a) Top 6 tool usage analysis. (b) Tool diversity per trial. (c) Average tools per turn analysis. (d) Temporal tool usage patterns aggregated by turn number.
  • Figure 4: Token usage and cost analysis across prompting strategies. (a) Distribution of estimated total tokens consumed per trial showing P2's more efficient token usage (Cohen's d = 0.885, p < 0.001). (b) Total computational cost per trial in USD (input token: $3/MTok, output token: $15/MTok ), with P2 achieving 37% cost reduction. (c) Token type distribution across all trials, revealing similar proportions of tool usage (P1: 17.9%, P2: 23.0%) and tool results (P1: 67.2%, P2: 59.0%). (d) Temporal dynamics of token consumption per turn, showing front-loaded usage patterns with P2 maintaining lower consumption throughout the conversation.
  • Figure 5: Performance and design metrics between natural language (P1) and structured guidance (P2) prompt strategies. (a) Composite score distribution of all successful trials versus prompt strategies. The composite score classification is shown in Table \ref{['tab:score_classification']} in Supplementary Information. (b) Absolute counts shown with percentages of total errors (P1 = 106, P2 = 48). Scatter plots show (c) transmission efficiency, (d) phase error, and (e) composite score as functions of x_length and y_length for prompting strategies P1 (circles, n=47) and P2 (squares, n=50). Red dashed lines indicate design requirements. Panel (e) includes performance-based clustering with average scores annotated for each region.
  • ...and 3 more figures