Abstract
Reinforcement Learning (RL) is a primary method for fine-tuning Large Language Model (LLM) agents to perform tasks in interactive environments. However, these agents often suffer from "prompt overfitting," where they learn to map specific text patterns to actions rather than understanding the underlying environment state. This paper quantifies this sensitivity and introduces a contrastive regularization loss that forces models to focus on semantic environment states. Our results demonstrate that this approach significantly boosts agent robustness, success rates, and zero-shot generalization across diverse textual benchmarks.
Introduction: The Challenge of Prompt Sensitivity
As LLMs are increasingly deployed as autonomous agents to navigate complex environments or solve household tasks, the issue of "grounding"—connecting linguistic instructions to physical or simulated rules—becomes paramount. While fine-tuning via Proximal Policy Optimization (PPO) is the standard solution, it introduces a significant vulnerability: prompt sensitivity.
Researchers found that if the information order in a prompt is changed or if natural language is replaced with structured tags (like XML), the agent's performance often plummets. This suggests the model is not learning the logic of the task but is instead performing a superficial mapping between specific text formats and actions. This "prompt overfitting" prevents LLM agents from being reliable in real-world scenarios where input formats are naturally variable.
Methodology
To address this, the authors propose a multi-pronged approach to quantify and mitigate overfitting:
- Sensitivity Analysis: Models were tested across four distinct prompt formulations ($P_0$ to $P_3$), ranging from rigid structured tags to conversational paraphrases.
- Contrastive Regularization: The core innovation is a contrastive loss added to the standard RL objective. This loss acts as a "semantic magnet," pulling internal representations of the same environment state together (regardless of prompt format) and pushing representations of different states apart.
- Architectural Enhancements: For decoder-only models, a special
<contrastive>token was introduced at the start of the prompt. This allows the model to use bidirectional attention for that token, capturing the full context to create a format-invariant representation.
Experimental Setup
The study utilized two primary textual RL environments:
- BabyAI-Text: A grid-world environment requiring navigation and object manipulation.
- TWC-Medium (TextWorld Commonsense): A complex environment requiring common sense to solve household chores (e.g., placing "dirty dishes" in a "dishwasher").
- Knowledge Probes: Specialized Question-Answering (QA) and Object-Counting (OC) tasks were derived from TWC to measure the depth of the agent's acquired world knowledge.
Key Results and Analysis
The contrastive training method yielded substantial improvements in both raw performance and generalization. In the TWC-Medium environment, a Flan-T5 78M model's Success Rate (SR) increased from 0.80 under standard RL to 0.94 with contrastive regularization.
Beyond raw success rates, the models demonstrated superior Zero-Shot Generalization. When tested on a completely novel prompt format ($P_4$) never seen during training, contrastive-trained models maintained high performance, whereas standard RL models saw significant degradation. Furthermore, these models performed significantly better on TWC QA tasks (improving accuracy from ~50% to 63%), suggesting that by ignoring prompt "noise," the models were forced to learn the actual logic of the environment.
Discussion and Future Work
Analysis of the model's latent space via UMAP visualizations confirmed that standard RL training reinforces prompt sensitivity, creating isolated "islands" of representations for each prompt style. The contrastive loss successfully merged these into a single "semantic continent."
Despite these gains, limitations remain. Fine-tuning LLMs with RL is computationally expensive, particularly for larger models like Llama 7B. Additionally, while this study focused on textual environments, future work must extend these contrastive techniques to multimodal agents that process both visual and textual inputs in partially observable real-world settings.
Summary updated