InstructMPC: LLM-Enhanced Predictive Control
- InstructMPC is a framework that integrates human semantic inputs via large language models with model predictive control for enhanced disturbance forecasting.
- It employs a dual feedback loop architecture that fuses contextual data processing with online fine-tuning to optimize control actions.
- The system achieves robust performance for linear systems with a theoretical regret bound of O(√(T log T)), ensuring control efficiency in dynamic settings.
InstructMPC is a human–LLM–in-the-loop framework for context-aware Model Predictive Control (MPC), developed to address the limitations of traditional MPC in domains where semantic, operator-supplied, or otherwise unstructured contextual information is crucial for disturbance forecasting. It augments classic MPC architectures by integrating LLMs to interpret high-level natural language instructions and encode them into quantitative disturbance forecasts, which are then optimally fused into the control loop. InstructMPC combines closed-loop learning with rigorous theoretical guarantees, achieving an regret for linear systems under a tailored, decision-focused loss optimized by methods such as Direct Preference Optimization (DPO) (Wu et al., 8 Apr 2025, Wu et al., 5 Dec 2025).
1. Motivation and Limitations of Traditional MPC
Conventional finite-horizon MPC methods rely on mechanistic or statistical models to generate future disturbance forecasts for decision making. These methods typically do not provide any mechanism for incorporating high-level, semantic, or unstructured operator instructions—such as upcoming scheduled events, emergency interventions, textual descriptions of weather or system state, or expert “gut instincts”. In domains such as building energy management, autonomous robotics, or power system operation, the disturbances often have a strong semantic or context-driven component not captured by conventional time-series models, leading to suboptimal control policies if this information is ignored (Wu et al., 8 Apr 2025, Wu et al., 5 Dec 2025).
The inability to adapt dynamically to changes in environment, context, or operator preference further constrains the utility of standard MPC frameworks. Additionally, direct closed-loop fine-tuning of neural predictors within the control loop is non-trivial; since the control cost depends on realized disturbances observable only after actions are taken, naïve gradient-based adaptations generally fail to align prediction objectives with actual control performance.
2. System Architecture and Data Flow
InstructMPC introduces a dual feedback loop architecture that tightly couples semantic context, disturbance prediction, and control optimization. The primary system modules are:
- Contextual Data Collection: At each time step , the system observes plant state and receives context , which is a free-form natural language instruction (e.g., “start backup generator at 2 pm,” “expect sudden wind surge,” or “maintenance on substation B tonight”).
- LLM-Based Module: The context (or a sequence for multi-step prediction) is processed via a prompting template through a pretrained LLM (e.g., LLaMA-8B or similar backbones). The LLM produces a probability distribution over a finite set of disturbance scenarios (Wu et al., 8 Apr 2025).
- Contextual Disturbances Predictor (CDP) / Language-to-Distribution (L2D) Module: The LLM output is mapped via a neural decoding module (affine and differentiable in ) to generate the predicted disturbance sequence . Specifically, or, in embedding-based implementations (as in (Wu et al., 5 Dec 2025)), LLM-extracted discrete features are mapped to a continuous embedding , then decoded to disturbance estimates.
- MPC Integration: The planner solves a quadratic program using plant dynamics,
with cost
and applies only the first control input , receding over time.
- Feedback and Learning: Upon observing actual disturbances and the realized control cost, the parameters of the L2D/CDP are fine-tuned online via a tailored, control-aware surrogate loss, closing the loop.
3. Mathematical Framework and Optimization
The core predictive control task is formulated for linear systems as follows:
- Plant dynamics: , where is stabilizable.
- At time , the L2D/CDP provides a -step ahead forecast based on context.
- The MPC optimization solves
subject to .
- The control law admits a closed-form in the linear-quadratic setting.
Crucially, the L2D/CDP map is parameterized to be affine in and differentiable. This structure enables efficient fine-tuning and theoretical analysis of the online regret.
The fine-tuning procedure exploits a surrogate loss , where
and is the closed-loop dynamics matrix. Gradients are delayed by horizon due to delayed availability of true disturbances.
4. Online Fine-Tuning and Theoretical Regret Analysis
Parameter updates to are performed via delayed gradient descent on the surrogate loss, i.e.,
with step sizes decreasing appropriately with . Under model assumptions (affine and Lipschitz , bounded gradients), the main theoretical result is a regret bound:
where is the cumulative MPC cost and is the best fixed parameter in hindsight. The surrogate loss is constructed to guarantee that minimization drives down true regret, even in non-stationary settings and in the presence of learning delay.
For fine-tuning, the framework leverages DPO-style updates: observed disturbance sequences are compared to scenario forecasts, and parameters are updated to increase the likelihood of scenarios nearest the ground-truth.
5. Instantiations and Empirical Evaluations
InstructMPC has been implemented and tested across several representative control domains (Wu et al., 5 Dec 2025):
- Power-Grid Operation: InstructMPC, equipped with a CDP transformer, leverages operator input such as maintenance schedules, topology changes, or event-driven demand surges to improve disturbance prediction and control, outperforming history-driven or open-loop baselines.
- Power-Infrastructure Drone Inspection: For quadrotor path tracking under stochastic wind, the CDP module encodes known reference shifts and linear embeddings of wind readings, with a tailored control-aware loss yielding improved tracking tightness over classical MSE or MAE losses.
- Battery SoC Management: In a battery management scenario with schedule-driven loads and photovoltaic generation, LLM-based context extraction (e.g., ChatGPT classification of compute job descriptions) enables mapping shell commands to “effort level” embeddings, then to accurate disturbance forecasts via a linear decoder. InstructMPC achieves lower cost than metadata-driven regression or static forecasts.
The central empirical finding is that LLM-extracted, unstructured semantic context—encoded by InstructMPC into disturbance forecasts and maintained via closed-loop, task-aware learning—can significantly outperform classical predictors in dynamic, event-driven environments.
6. Modeling Assumptions and Practical Considerations
The framework is analyzed under the following modeling assumptions:
- Linear plant dynamics with stabilizable .
- Bounded disturbances , and (optionally) bounded parameter domain for .
- Affine and Lipschitz-continuous CDP decoder .
- Bounded surrogate loss gradients.
- Arbitrary, potentially non-stationary, evolution of context and disturbance ; regret bound holds agnostic to these sequences.
A plausible implication is that while InstructMPC’s theoretical guarantees are currently given for linear settings, the modular design and LLM-agnostic contextualization enable deployment across a range of high-impact applications where unstructured context is essential for optimal control performance.
7. Summary Table: Core Components of InstructMPC
| Component | Description | Reference |
|---|---|---|
| L2D / CDP Module | Neural net mapping context to disturbance forecast | (Wu et al., 8 Apr 2025, Wu et al., 5 Dec 2025) |
| Surrogate Loss | Control-aware quadratic form aligning predictions with realized cost | (Wu et al., 8 Apr 2025, Wu et al., 5 Dec 2025) |
| Fine-Tuning | Online gradient descent (delayed) on , parameter update for | (Wu et al., 8 Apr 2025, Wu et al., 5 Dec 2025) |
The L2D/CDP module bridges human semantic input and optimization, the surrogate loss aligns learning with control objectives, and the closed-loop fine-tuning ensures adaptability and theoretical performance in non-stationary environments.