Order Matters: Competition-Guided Query Ordering for RNN-Based Object Detection

Shengjian Wu, Li Sun, Yu Shangguan, Qingli LiNeurIPS 2026

TL;DR

Modern Transformer-based object detectors ditch clumsy post-processing filters in favor of predicting objects all at once, yet they still suffer from "double vision"—multiple internal queries fighting over the exact same object. Taking inspiration from classical sequential filtering, DETRNN lines up competing object queries in single-file order and marches a Recurrent Neural Network (RNN) down the line to settle the dispute. It’s a clean, plug-and-play upgrade that stabilizes training and boosts accuracy across state-of-the-art detectors without slowing them down.

What Problem Does This Paper Address?

For decades, object detectors predicted thousands of overlapping bounding boxes and relied on a rigid, hand-tuned post-processing step called Non-Maximum Suppression (NMS) to clean up the mess: rank boxes by confidence, keep the best one, and ruthlessly delete any overlapping neighbors.

Then came DETR (Detection Transformer), which reframed detection as an end-to-end set prediction problem. Using a fixed pool of learnable "object queries" and one-to-one bipartite matching during training, DETR eliminated NMS altogether.

Except there's a catch. Inside a DETR decoder, queries talk to each other via self-attention, which is completely parallel and order-agnostic. Imagine a crowded room where everyone shouts at once to claim an object—nobody knows who called dibs first. Because there is no explicit pecking order, multiple queries often converge on the exact same object with nearly identical confidence scores. Only one gets rewarded during training while the runners-up get penalized, creating noisy gradients, sluggish convergence, and lingering duplicate predictions.

Figure 1: A comparison of de-duplication mechanisms. Classical NMS de-duplicates by removing highly overlapping proposals with a fixed IoU threshold (a). DETR predicts end-to-end, but its order-agnostic decoder can still yield duplicated results (b). DETRNN internalizes de-duplication into the decoder: CGQO builds a competition-aware query order, and a Bi-RNN refines queries sequentially to softly suppress redundant predictions (dashed boxes) without discarding outputs (c).

Methods

Instead of tweaking attention masks or pruning queries, the authors ask a delightfully direct question: what if we bring the sequential logic of NMS inside the learnable decoder? Because RNNs naturally process ordered streams, they are built for sequential suppression—provided the sequence actually means something.

DETRNN replaces the standard self-attention sub-layer in the final decoder stage(s) with a two-step plug-and-play module (leaving cross-attention and feed-forward networks untouched):

  1. Competition-Guided Query Ordering (CGQO): Taking prior predictions (from the encoder or previous decoder layer), CGQO sorts queries without throwing any away. It picks the highest-confidence query as a "pivot," then measures every other query's similarity to it—blending geometric box overlap (IoU) and semantic class-score cosine similarity. Queries exceeding a density-adaptive threshold (which tightens in crowded regions and relaxes in sparse ones) are grouped right behind the pivot. Those queries are set aside, a new top pivot is chosen from the remainder, and the cycle repeats until the unordered set becomes a structured line of "leaders followed immediately by their closest rivals."
  2. Bidirectional RNN Refinement: A Bidirectional RNN (instantiated primarily with modern state-space blocks like Mamba) scans forward and backward along this newly ordered sequence. Because rivals sit right next to strong candidates in the stream, the RNN can effortlessly pass suppression signals down the line to softly quiet duplicates.
Figure 2: Overview of DETRNN. Given prior predictions from encoder proposals or preceding decoder outputs, Competition-Guided Query Ordering (CGQO) first constructs an explicit competition order among queries. Specifically, queries are ranked by confidence; the top-scoring query is selected as a pivot, and other queries are grouped and reordered by their similarity to the pivot (highly similar competitors are placed nearby). This pivot-and-grouping process is repeated until all queries are ordered, yielding a competition-aware sequence. Bidirectional RNN then replaces decoder self-attention and refines queries sequentially along this order, enabling learnable competition resolution inside the decoder. Unlike NMS, CGQO does not discard queries; it only provides ordering cues that the decoder can internalize for de-duplication.

Datasets

No new benchmarks are introduced; the authors evaluate on two standard, complementary detection datasets:

  • MS-COCO 2017: The go-to general object detection benchmark (117K training images, 5K validation images).
  • CrowdHuman: A stress-test benchmark for heavily occluded, densely packed human detection (4.4K validation images), where traditional NMS thresholds notoriously struggle.

Key Insights and Ideas

  • Neither ordering nor recurrence works alone—magic happens at their intersection: Putting CGQO before standard self-attention yields zero gain (self-attention is permutation-equivariant; it doesn't care about order). Conversely, feeding unordered queries into a Bi-RNN barely moves the needle (+0.0 to +0.2 AP), and random ordering actively hurts (-0.4 AP). An RNN needs a meaningful sequence to shine.
  • Architecture-agnostic recurrence: Swapping Mamba out for RWKV, xLSTM, or TTT yields nearly identical accuracy gains (48.4–48.7 AP vs. 47.6 baseline). The secret sauce isn't a specific trendy sequence model; it's framing de-duplication as ordered sequential refinement.
  • Single-layer de-duplication superpower: Standard DETRs need 6 stacked decoder layers to gradually iron out duplicates. In a brutal 1-decoder stress test, baselines suffered massive duplicate penalties, whereas DETRNN jumped by +3.7 to +5.7 AP—beating the baselines even after giving them post-processing NMS.
  • Less is more in stage placement: Inserting DETRNN into just the last 1 or 2 decoder layers beats putting it in all 6 layers on both speed and accuracy, as object recall largely saturates in earlier stages.

Key Results

Across four diverse ResNet-50 baselines on COCO (12-epoch 1x schedule, 900 queries), DETRNN delivers consistent AP boosts with virtually identical FLOPs and FPS:

  • Def-DETR++: 47.6 $\rightarrow$ 48.7 AP (+1.1)
  • DINO: 49.0 $\rightarrow$ 50.0 AP (+1.0)
  • MS-DETR: 50.0 $\rightarrow$ 50.5 AP (+0.5)
  • LoRA-DETR: 52.5 $\rightarrow$ 53.0 AP (+0.5), while increasing speed from 16 to 19 FPS by replacing complex query interactions.

Gains hold up under longer 2x schedules, scale to Swin-L backbones (pushing LoRA-DETRNN to 58.5 AP), and outperform specialized competition-aware decoders (EASE-DETR, Relation-DETR, DDQ) in both accuracy and throughput. On CrowdHuman, where aggressive NMS accidentally deletes true people (-0.3 AP at IoU 0.7), DETRNN cleanly adds +0.8 to +1.1 AP without touching a post-processing threshold.

Training dynamics and competition indicators showing faster AP convergence, lower residual NMS gains, and wider Top1-Top2 score gaps

Limitations and Future Work

In the main text, the authors note only that "A brief discussion of limitations is provided in Appendix P," which is not included in this 11-page main manuscript. Consequently, explicit limitations and proposed future directions are not discussed in the provided pages.

Summary updated

Abstract

DETR-style detectors use one-to-one bipartite matching during training to assign object queries to ground-truth objects, enabling end-to-end set prediction without non-maximum suppression (NMS). However, without an explicit de-duplication procedure, multiple queries can still produce highly similar hypotheses for the same object, making training unstable and predictions less decisive. Inspired by the sequential ordering of NMS, we propose DETRNN, a plug-and-play module that turns unordered object queries into a competition-aware sequence for recurrent refinement. DETRNN builds an explicit confidence-and-similarity based order from prior predictions, then refines queries with an RNN along this order to model competition inside the decoder. This ordered recurrent refinement reduces redundant predictions, stabilizes optimization, and improves final detection accuracy. Experiments on multiple DETR-style detectors show consistent gains with comparable efficiency. Code repository: https://github.com/nigelwoo2008-coder/DETRNN.
BibTeX
@inproceedings{wu2026order,
  author = {Shengjian Wu and Li Sun and Yu Shangguan and Qingli Li},
  title = {{Order Matters: Competition-Guided Query Ordering for RNN-Based Object Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=PoXySrgd0e},
}
Figure