Tuning computer vision models with task rewards

André Susano Pinto, Alexander Kolesnikov, Yuge Shi, Lucas Beyer, Xiaohua Zhai

Abstract: Misalignment between model predictions and intended usage can be detrimental for the deployment of computer vision models. The issue is exacerbated when the task involves complex structured outputs, as it becomes harder to design procedures which address this misalignment. In natural language processing, this is often addressed using reinforcement learning techniques that align models with a task reward. We adopt this approach and show its surprising effectiveness across multiple computer vision tasks, such as object detection, panoptic segmentation, colorization and image captioning. We believe this approach has the potential to be widely useful for better aligning models with a diverse range of computer vision tasks.

1. Introduction

In the field of computer vision, models are traditionally trained using Maximum Likelihood Estimation (MLE). This objective encourages models to imitate the ground truth data distribution. However, a persistent challenge remains: the "misalignment" between this training objective and the actual task risk—the specific metrics used to evaluate real-world performance, such as Mean Average Precision (mAP) or Panoptic Quality (PQ).

To bridge this gap, practitioners often resort to task-specific heuristics, including specialized post-processing (e.g., Non-Maximum Suppression) or complex, hand-crafted loss functions. While the Natural Language Processing (NLP) community has successfully utilized Reinforcement Learning from Human Feedback (RLHF) to align Large Language Models with human intent, similar reinforcement learning (RL) strategies have remained under-explored for non-textual computer vision tasks. This paper demonstrates that the alignment problem in vision can be effectively addressed by fine-tuning pretrained models using the REINFORCE algorithm with task-specific rewards.

2. Methodology

The proposed framework consists of a simple, two-stage pipeline designed to optimize models directly for their intended evaluation metrics.

2.1 MLE Pretraining

First, a standard probabilistic model—typically an encoder-decoder Transformer—is trained via MLE. The model is tasked with predicting outputs as a sequence of discrete tokens. This stage establishes a strong "starting policy" that understands the underlying data distribution and provides a foundation for subsequent refinement.

2.2 Reward Tuning

In the second stage, the model is fine-tuned using the REINFORCE algorithm (the log-derivative trick). Unlike standard backpropagation, which requires a differentiable loss function, reward tuning allows the model to optimize for non-differentiable rewards. The model samples predictions, calculates a numerical reward based on the target task metric, and adjusts its weights to increase the probability of high-reward outputs.

To ensure training stability and reduce the high variance typically associated with RL, the authors implement a comparative baseline. For every input, the system draws two samples: one to estimate the gradient and another to serve as a baseline reward for comparison.

3. Experimental Setup

The effectiveness of reward tuning was evaluated across several diverse computer vision benchmarks:

  • Object Detection: Evaluated on COCO and Objects365.
  • Panoptic Segmentation: Evaluated on the COCO dataset.
  • Image Captioning: Evaluated on the COCO dataset.
  • Image Colorization: Evaluated using the ImageNet dataset.

4. Results and Analysis

The application of reward tuning yielded substantial quantitative improvements across all evaluated tasks, demonstrating the versatility of the approach.

4.1 Quantitative Performance

  • Object Detection: On the COCO benchmark, mAP increased from 39.2 to 54.3, notably outperforming previous specialized generative models such as Pix2seq.
  • Panoptic Segmentation: The model achieved an improvement in Panoptic Quality (PQ) from 43.1 to 46.1.
  • Image Captioning: For a ViT-B model, the CIDEr score was boosted from 120.0 to 134.5.
  • Colorization: The "colorfulness" score increased from 0.41 to 1.79, resulting in significantly more vibrant and diverse visual outputs compared to the often muted results of MLE-only models.

4.2 Key Insights

Analysis of the results reveals that MLE-trained models often possess the latent capability to produce high-quality outputs but fail to assign them the highest probability. Reward tuning shifts the probability distribution, allowing the model to consistently select the "best" outputs it has already learned to generate. Furthermore, the approach proved highly general; the same RL algorithm was effective across pixels (segmentation), coordinates (detection), and text (captioning), suggesting that specialized loss functions may be unnecessary if a robust reward function is available.

5. Discussion and Limitations

While reward tuning offers a powerful path toward model alignment, it is not without challenges. The authors identify "reward hacking" as a primary concern, where a model might find unintended shortcuts to maximize a reward without truly improving at the task. Additionally, the computational cost of sampling from auto-regressive models during training is higher than standard teacher-forcing MLE.

Future research may focus on more efficient RL techniques, such as off-policy methods or the use of value networks to approximate rewards. There is also significant potential in designing rewards for subjective tasks where traditional metrics are insufficient, such as human-preferred image editing.

6. Conclusion

This work demonstrates that reinforcement learning is a highly effective tool for aligning computer vision models with complex task rewards. By moving beyond the limitations of MLE and directly optimizing for task-specific metrics, we can achieve significant performance gains across a wide array of visual recognition and generation tasks without the need for architectural changes.

Summary updated

BibTeX
@inproceedings{pinto2023tuning,
  author = {André Susano Pinto and Alexander Kolesnikov and Yuge Shi and Lucas Beyer and Xiaohua Zhai},
  title = {{Tuning computer vision models with task rewards}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=zzOooeAqtT},
}
Figure