Abstract
Mastering a skill generally relies on both hands-on experience from doers and insightful, high-level guidance by mentors. Will this strategy also work well for solving complex non-convex optimization problems? Here, a common gradient-based optimizer acts like a disciplined doer, making locally optimal updates at each step. Large Language Models (LLMs) can also search for better solutions by inferring from natural language instructions, akin to a high-level mentor. In this paper, we show that these two participators are complementary to each other and can effectively collaborate as a combined optimization framework. The collaborative optimization is achieved by alternating between the gradient-based and LLM-based optimizers. We instruct LLMs to generate possibly improved solutions by taking parameter trajectories recorded during the previous stage of gradient-based optimization into account. Inferred results of LLMs are used as restarting points for the next stage of gradient optimization. We verify the effectiveness of this optimization framework on prompt tuning. By leveraging both the locally rigorous gradient-based optimizer and the high-level deductive LLM-based optimizer, the combined optimization method consistently yields improvements over competitive baselines on a variety of tasks.
Introduction
In deep learning, gradient descent is the primary tool for optimization. However, it is inherently "short-sighted," moving based on local mathematical slopes. This makes it prone to getting trapped in local optima—suboptimal solutions that appear ideal only within their immediate neighborhood. This limitation is particularly evident in prompt tuning, where the goal is to find optimal "trigger words" or embeddings to guide a pre-trained model. The embedding space for prompts is highly complex and non-convex; a poor initialization often prevents gradient descent from ever reaching a global optimum.
While Large Language Models (LLMs) have been explored as optimizers, they often lack the mathematical precision of gradients. This research proposes a hybrid approach: combining the local rigor of calculus with the global semantic reasoning of LLMs to create a more robust optimization framework.
The MaaO Framework
The proposed framework, LLM as an Optimizer (MaaO), operates as a collaborative loop between a "doer" (gradient descent) and a "mentor" (the LLM). The process follows five key stages:
- The Doer Phase: Standard gradient-based optimization is performed on prompt parameters for several iterations.
- Trajectory Recording: The system logs the prompts tested and their corresponding performance metrics (loss/accuracy).
- Token Space Projection: Because LLMs process text while gradient optimizers work with continuous vectors, optimized vectors are projected back into discrete, readable words using L2 distance.
- The Mentor Phase: The LLM receives the trajectory of prompts and scores. It is then prompted to deduce patterns and suggest new candidate prompts that might achieve lower loss.
- The Restart: These LLM-generated prompts are converted back into embeddings to serve as new "restarting points" for the next round of gradient descent.
By alternating these phases, the LLM enables the optimizer to "jump" out of local minima into more promising regions of the search space, which the gradient optimizer then explores with precision.
Experimental Results
The researchers evaluated the MaaO framework across Natural Language Understanding (NLU) and Vision-Language tasks. For NLU, the method was tested on the SuperGLUE benchmark using a RoBERTa-Large backbone. For vision tasks, prompt tuning was applied to CLIP across 10 diverse datasets, ranging from general objects (Caltech101) to satellite imagery (EuroSAT) and fine-grained categories (OxfordPets).
As shown in the experimental data, the combined approach consistently outperformed standard baselines. On SuperGLUE, the method achieved an average score of 61.81, compared to 59.52 for standard P-tuning. In vision tasks, the LLM-guided optimizer surpassed the popular CoOp baseline in nearly all few-shot scenarios (1, 4, 8, and 16-shot). Notably, on the EuroSAT dataset, average accuracy rose to 72.59% when using GPT-4 as the mentor.
Key Insights
- Semantic Intuition: Unlike gradient descent, which only follows numerical slopes, LLMs understand semantic relationships (e.g., recognizing that "a precise satellite view" is related to "a centered satellite photo"). This allows for "intelligent" jumps in the search space.
- Robustness to Initialization: Prompt tuning is notoriously sensitive to starting words. This framework significantly reduces variance, making the optimization process more reliable regardless of the initial prompt.
- Interpretability: A secondary benefit of this method is that the optimized prompts are often more human-readable and meaningful than the "gibberish" vectors typically produced by pure soft prompt tuning.
Conclusion and Future Work
The MaaO framework demonstrates that LLMs can effectively complement traditional optimization methods by acting as high-level mentors. While currently tailored for prompt tuning due to dimensionality constraints—it is difficult to describe millions of parameters in a text prompt—the results are promising. Future work will explore scaling this "mentor-doer" framework to higher-dimensional parameter spaces, such as those found in LoRA or full model fine-tuning, and applying it to other complex domains like reinforcement learning.
Summary updated