Exploiting Edited Large Language Models as General Scientific Optimizers (2025)

Abstract: Large language models (LLMs) have been widely adopted in mathematical optimization in scientific scenarios for their extensive knowledge and advanced reasoning capabilities. Existing methods mainly focus on utilizing LLMs to solve optimization problems in a prompt-based manner, which takes observational feedback as additional textual descriptions. However, due to LLM’s **high sensitivity to the prompts** and **tendency to get lost in lengthy prompts**, these methods struggle to effectively utilize the observational feedback from each optimization step, which severely hinders the applications for real-world scenarios. To address these challenges, we propose a conceptually simple and general bi-level optimization method, namely **G**eneral **S**cientific **O**ptimizers (GSO).Specifically, GSO first utilizes inner-level simulators as experimental platforms to evaluate the current solution and provide observational feedback. Then, LLMs serve as knowledgeable and versatile scientists, generating new solutions by refining potential errors from the feedback as the outer-level optimization.Finally, simulations together with the expert knowledge in LLMs are jointly updated with bi-level interactions via model editing.Extensive experiments show that GSO consistently outperforms existing state-of-the-art methods using *six* different LLM backbone on *seven* different tasks, demonstrating the effectiveness and a wide range of applications.

## introduction optimization is ubiquitous across a wide range of scientific domains, spanning mathematics, physics, chemistry, pharmacology, etc @xcite @xcite . various research endeavors innovate within its field, creating methods tailored to its specific challenges and nuances to automate and accelerate the process * equal contributions. standing out as versatile tools with vast knowledge repositories, large language models (llms) have recently risen to prominence in optimization across scientific domains for their expansive knowledge bases, advanced reasoning capabilities, and human-friendly natural language interface (ai4science and quantum, 2023). extensive research efforts have been devoted to boosting general mathematical optimization in scientific scenarios. canonical methods mainly focus on fine-tuning llms using domain-specific data to align natural language with scientific information, such as chemical structures @xcite or drug structures @xcite . however, these approaches are constrained to specific domains and require substantial amounts of data and extensive computation resources for broader applicability. recently, promptbased iterative optimization methods-which enhance the inherent capabilities of pre-trained llms by incorporating the optimization feedback to llms-have emerged as a promising approach for advancing scientific optimization @xcite . extensive researches have explored leveraging llms as optimizers or agents @xcite for tasks such as mathematical problem-solving @xcite , conducting chemical experiments @xcite , advancing physical scientific discovery @xcite , molecular discovery @xcite , and drug discovery @xcite . albeit with multiple benefits of the promptbased methods, they confront one significant challenge that severely hinders their general applications-struggling to effectively utilize observational feedback. this challenge primarily stems from two limitations inherent in existing prompt-based methods: (i) llms are shown to be sensitive to the prompt format @xcite @xcite . in particular, semantically similar prompts can yield drastically different performance @xcite @xcite , and the optimal prompt formats may be model-specific and task-specific, which severely limits the generalizability across different scientific tasks. (ii) llms may get lost in lengthy prompt @xcite . in multi-round iterative optimization, the input prompt can become increasingly lengthy to trace the optimization trajectory, which may distract the llms' reasoning and result in the lost in the middle issue @xcite . despite llms' ability to process long contexts, performances significantly decrease as the input grows longer, even for models explicitly designed for long contexts @xcite . to address this challenge, we propose a conceptually simple, flexible, and general method, namely general scientific optimizers (gso). specifically, gso is a bi-level optimization method involving inner-level optimization and outer-level optimization, together with bi-level interaction between them. for a given optimization task, gso will iteratively conduct the following process: (i) the inner-level optimization first employs simulators serving as an experimental platform to provide observational feedback for reasoning and refining; (ii) the outer-level optimization then utilizes knowledgeable llms as reasoning agents to generate hypotheses, reason with observational feedback, and refine the previous hypothetical solutions. it also devises a dynamic exploit-and-explore strategy to adaptively adjust the llm reasoning trajectory based on observational feedback; (iii) finally, the bi-level optimization jointly updates the simulations together with the knowledge embedded within llms via model editing. gso is a novel framework to boost general mathematical optimization in scientific scenarios. as shown in figure 1 , extensive experiments demonstrate the effectiveness and generalization of our gso, leading significant and consistent superiority using six different llm backbone on seven different tasks than existing state-of-the-art methods. ## preliminaries model editing model editing mainly focuses on altering the internal knowledge within llms. it aims to update a range of intricate learned concepts, such as logical reasoning, spatial awareness, and numerical understanding, to make tailored adjustments to the model's behavior. in this paper, we follow @xcite to update factual knowledge represented as (subject s, relation r, object o). an llm is expected to retrieve a memory corresponding to o when given a natural language prompt. editing a fact involves replacing the existing knowledge triple (s, r, o) with a new one (s, r, o * ). for simplicity, an edit is denoted as @xmath0, r, o, o * ). given a set of edits @xmath1, e 2 , . . .} and an original model f θ 0 , sequential model editing applies each edit consecutively, i.e., f(f θ n-1 , e n ) = f θn , where f θn refers to the model after n edits. ## related work model editing model editing involves modifying the memorized knowledge contained in llms. various kinds of complex learned beliefs such as logical, spatial, or numerical knowledge are expected to be edited. many studies explore the role of mlp layers in transformers, revealing that these layers store knowledge, which can be localized to specific neurons and edited @xcite ., simulator 𝒗 𝟏 𝒗 𝟐 𝒗 𝟒 𝒗 𝟑 current solution: 𝑣 1 → 𝑣 2 → 𝑣 3 → 𝑣 4 → 𝑣 1 𝒗 𝟏 𝒗 𝟐 𝒗 𝟒 𝒗 𝟑 inner-level optimization outer-level optimization bi-level interaction k-th iter 𝒗 𝟏 𝒗 𝟐 𝒗 𝟒 𝒗 𝟑 simulation: total distance is feedback: (𝑣 4 , 𝑣 1 ) has a larger distance than (𝑣 2 , 𝑣 4 ) propose hypothesis: 𝑣 1 → 𝑣 2 → 𝑣 4 → 𝑣 3 → 𝑣 1 bilevel interaction inner-level optimization outer-level optimization bi-level interaction … inner-level optimization outer-level optimization bi-level interaction … simulator to llm observations feedbacks llm model editing simulator llm to simulator llm simulator provide the distance of (𝑣 2 , 𝑣 4 ) find another edge pass 𝑣 1 interaction llm give me a trace that has a length lower than any of the above and traverses all points once. user the optimized trace is 𝒗 𝟏 → 𝒗 𝟐 → 𝒗 𝟒 → 𝒗 𝟑 → 𝒗 𝟏 ## conclusion in this paper, we propose a novel general scientific optimizers method, effectively enabling llms to utilize observational feedback from each optimization step. specifically, gso consists of a bi-level optimization framework: outer-level llms function as knowledgeable and versatile scientists, generating new hypotheses to optimize experimental hyperparameters; inner-level simulations function as experimental platforms to perform numerical simulations to these hypotheses and provide observational feedback; a bi-level interaction then update the simulators together with the expert knowledge within llms via model editing. gso effectively guides llms to derive a more precise and stable optimization direction, yielding superior optimization results. extensive experiments on six different open-source and seven different scientific tasks demonstrate the superiority of our gso, delivering consistent, robust, generalizable, and nearly monotonic improvement. we view our gso as a trailblazer, establishing a new paradigm for utilizing llms and simulations as bi-level optimization to further advancements in scientific optimizations. 3 we consider a few limitations and future directions.