reinforcement-learning grpo coding-agents data-augmentation multimodal-reasoning long-horizon-reasoning visual-question-answering context-aware-rl
Abstract
Large language models (LLMs) often fail when answering requires identifying a small but decisive piece of evidence within a long or complex context, such as a single line in a tool trace or a subtle detail in an image. We propose ContextRL, a context-aware reinforcement learning (RL) method that improves long-horizon reasoning and multimodal performance through an indirect auxiliary objective. Instead of supervising only the final answer, ContextRL presents the model with a query, an answer, and two highly similar contexts, and rewards it for selecting the context that supports the query--answer pair, thereby encouraging fine-grained grounding. We construct contrastive context data in two domains: for coding agents, trajectories serve as contexts, yielding 1k pairs built via condition filtering; for multimodal reasoning, images serve as contexts, yielding 7K pairs built via generative editing and similarity search. ContextRL achieves average gains of +2.2% over standard GRPO on 5 long-horizon benchmarks, and +1.8% across 12 diverse visual question answering benchmarks. To disentangle the effect of the proposed objective from that of additional data, we compare against data-augmentation baselines that repurpose the same contrastive contexts as standard query--context--answer examples. These baselines provide little to no improvement, showing that the gains arise from the proposed context-selection objective rather than from the contrastive data alone.
한국어 요약
한 줄 요약
ContextRL은 강화학습에 문맥 선택 목적을 추가하여 LLM의 장기적 추론과 멀티모달 성능을 개선하는 방법이다.
핵심 기여도
- ContextRL은 최종 답변이 아닌, 문맥 선택을 보상하는 방식으로 세부적인 문맥 정착(fine-grained grounding)을 유도함.
- 코드 에이전트에 1,000개의 트래젝토리 기반 대조 문맥 쌍을, 멀티모달 분야에 7,000개의 이미지 기반 쌍을 생성함.
- 5개의 장기적 벤치마크에서 GRPO 대비 평균 +2.2%, 12개의 VQA 벤치마크에서 +1.8% 성능 향상.
- 데이터 증강 기반 기준 모델은 거의 개선 없이 실패함.
핵심 아이디어
기존 강화학습은 최종 답변만을 최적화하지만, ContextRL은 모델이 답변을 지지하는 문맥을 선택하도록 보상하는 보조 목적을 추가함. 이는 모델이 복잡한 문맥 내에서 결정적인 증거를 식별하도록 유도한다. 특히, 두 개의 매우 유사한 문맥 중 하나를 선택하도록 훈련함으로써, 모델이 세부적인 문맥 정착 능력을 향상시킨다. 이 접근법은 기존의 데이터 증강 방식과 구별되며, 훈련 목적 자체가 성능 향상의 핵심임을 보여준다.
기술적 접근법
- **ContextRL**: 강화학습에 추가되는 보조 목적. 모델이 주어진 질문-답변 쌍을 지지하는 문맥을 선택하도록 보상함.
- **대조 문맥 생성**:
- 코드 에이전트: 트래젝토리 기반, 조건 필터링을 통해 1,000개 쌍 생성.
- 멀티모달: 이미지 기반, 생성 편집과 유사도 검색을 통해 7,000개 쌍 생성.
- **훈련 방식**: GRPO(Gradient-based Reinforcement Policy Optimization)에 대조 문맥을 로짓 수준의 대조 손실(logit-level contrastive loss)로 통합.
- **기준 모델**: Klear-AgentForge-8B, Qwen3-8B, Qwen2.5-VL-7B, Qwen3-VL-8B 등.
주요 결과
- **장기적 추론**: 5개 벤치마크에서 GRPO 대비 평균 +2.2% 향상. Qwen3-8B 기반으로 +3.2%, Klear-AgentForge-8B 기반으로 +1.5% 개선.
- **멀티모달**: 12개 VQA 벤치마크에서 GRPO 대비 평균 +1.8% 향상. Qwen2.5-VL-7B 기반 +2.0%, Qwen3-VL-8B 기반 +1.6% 개선.
- **데이터 증강 기준 모델**: SFT나 결과 기반 RL로 동일한 대조 데이터를 사용했으나, 성능 향상 없이 실패함.
의의 및 한계
ContextRL은 복잡한 문맥 내에서 결정적인 증거를 식별하는 능력을 향상시키는 간단한 보조 목적을 제시함. 이는 기존 강화학습에서 간과되었던 문맥 정착 문제를 해결하는 학술적 기여로, 특히 대규모 인간 라벨링 없이도 효과적임. 그러나 본 연구는 특정 벤치마크와 모델에 국한된 실험을 기반으로 하며, 다른 도메인이나 아키텍처에 대한 일반화 가능성은 명시되지 않음.
실용적 활용
ContextRL은 코드 생성 에이전트나 멀티모달 질문 답변 시스템과 같은 복잡한 정보 처리 환경에서 적용 가능하다. 특히, 정확한 문맥 기반 결정이 필요한 산업 분야(예: 의료, 법률, 자동화된 시스템 디버깅)에서 유용할 수 있다.