Abstract
Large language models (LLMs) have achieved success in acting as agents, which interact with environments through tools such as search engines. However, LLMs are optimized for language generation instead of tool use during training or alignment, limiting their effectiveness as agents. To resolve this problem, previous work has first collected interaction trajectories between LLMs and environments, using only trajectories that successfully finished the task to fine-tune smaller models, making fine-tuning data scarce and acquiring it both difficult and costly. Discarding failed trajectories also leads to significant wastage of data and resources and limits the possible optimization paths during fine-tuning. In this paper, we argue that unsuccessful trajectories offer valuable insights, and LLMs can learn from these trajectories through appropriate quality control and fine-tuning strategies. By simply adding a prefix or suffix that tells the model whether to generate a successful trajectory during training, we improve model performance by a large margin on mathematical reasoning, multi-hop question answering, and strategic question answering tasks. We further analyze the inference results and find that our method provides a better trade-off between valuable information and errors in unsuccessful trajectories. To our knowledge, we are the first to demonstrate the value of negative trajectories and their application in agent-tunning scenarios. Our findings offer guidance for developing better agent-tuning methods and low-resource data usage techniques.
Introduction
Large Language Models (LLMs) are increasingly deployed as agents capable of using external tools like search engines and calculators to solve complex tasks. However, a significant gap exists: these models are primarily optimized for text generation rather than agentic tool-use. The standard approach to bridge this gap, known as "AgentTuning," involves fine-tuning smaller models on interaction trajectories generated by powerful models like GPT-4.
A major inefficiency in current AgentTuning is the reliance solely on successful trajectories. In complex reasoning tasks, up to 60% of generated attempts may fail. Discarding these "negative" examples results in massive data wastage and deprives the model of the opportunity to learn from mistakes. Furthermore, acquiring successful trajectories is computationally expensive and difficult. This research introduces Negative-Aware Training (NAT), a method that leverages these failed attempts to improve model performance and data efficiency.
Methodology: Negative-Aware Training (NAT)
The core of the NAT framework is the integration of both successful (positive) and unsuccessful (negative) trajectories into the fine-tuning process. The method consists of three primary stages:
- Data Collection: Using a teacher model (e.g., GPT-3.5), multiple trajectories are generated for seed questions. Each trajectory is labeled as Positive (correct final answer) or Negative (incorrect answer) based on ground truth.
- Negative-Aware Reformatting: To prevent the model from being confused by incorrect logic, the authors introduce a specific suffix to the task query. During training, positive examples are prompted with: "Please generate a solution that correctly answers the question." Negative examples are prompted with: "Please generate a solution that incorrectly answers the question."
- Fine-tuning and Inference: The smaller LLM (e.g., LLaMA-2) is fine-tuned on this reformatted dataset. At inference time, the model is prompted with the "correctly" suffix to guide it toward successful reasoning paths.
Experimental Results
The researchers evaluated NAT across benchmarks for mathematical reasoning (GSM8K, SVAMP), multi-hop QA (HotpotQA), and strategic reasoning (StrategyQA). The results demonstrate that NAT provides a significant performance boost over vanilla fine-tuning (using only positives) and Negative-Unaware Training (NUT, which mixes negatives without labels).
The Contrastive Learning Effect
Explicitly labeling negatives provides a contrastive signal that helps the model distinguish between valid reasoning and common pitfalls. As shown in the experimental data, simply adding negative examples without labels (NUT) can sometimes degrade performance due to the noise introduced by incorrect steps. In contrast, NAT consistently improves accuracy as more negative data is introduced.
Low-Resource Efficiency
NAT is particularly effective when successful training data is scarce. For a 7B model trained with only 2,000 positive examples, the addition of negative trajectories via NAT improved GSM8K accuracy from 35.63% to 46.93%. Analysis suggests that NAT primarily enhances the model's internal "thoughts"—its planning and logical consistency—rather than just its ability to follow tool syntax.
Conclusion
This study demonstrates that failure is a valuable teacher for LLM agents. By incorporating labeled negative trajectories, NAT reduces data wastage and significantly improves reasoning capabilities, especially in low-resource settings. Future work may explore automated quality assessment for trajectories where ground truth is unavailable and the scalability of NAT to larger model architectures.
Summary updated