Papers
Topics
Authors
Recent
Search
2000 character limit reached

Balanced Group Softmax (BAGS) for Long-Tail Detection

Updated 10 July 2026
  • BAGS is a method for long-tail object detection that groups object classes based on frequency and replaces the flat softmax with group-wise normalization.
  • The technique addresses classifier imbalance by calibrating competition within groups using background and 'others' nodes, ensuring balanced training signals for both head and tail classes.
  • Empirical studies on LVIS demonstrate that BAGS improves overall mAP and rare class performance compared to baseline softmax and other re-balancing methods.

Searching arXiv for the specified BAGS papers to ground the article in the cited research. Balanced Group Softmax (BAGS) is a modification of the standard Softmax-based classification head in object detectors, proposed for long-tail object detection where object categories exhibit extreme frequency imbalance. In the original formulation, BAGS replaces the single softmax over CC object classes plus background with group-wise training over disjoint frequency groups, together with a special background group and per-group “others” nodes. Its stated purpose is to balance the classifiers within detection frameworks, to ensure that head and tail classes are both sufficiently trained, and to address the classifier imbalance that arises when standard detectors are trained on highly skewed data such as LVIS (Li et al., 2020).

1. Long-tail detection and classifier imbalance

Modern two-stage detectors such as Faster R-CNN and Mask R-CNN typically use a single softmax classifier over CC object classes plus background. Under a long-tailed distribution, abundant head-class proposals repeatedly activate and reinforce their corresponding weight vectors, while tail-class weights remain near zero. Empirically, the norm wj\lVert w_j\rVert of the classifier weight vector for class jj grows roughly in proportion to the number of its training instances. As a result, inference strongly favors head classes and almost never predicts low-shot categories (Li et al., 2020).

In the standard setting, the class posterior takes the form

pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.

When the dataset is extremely skewed, this competition across all classes produces what the paper describes as “classifier imbalance in terms of parameter magnitude.” The underperformance is not framed as a generic class-imbalance problem alone, but as a detection-specific failure mode: direct adaptation of long-tail classification models to detection frameworks does not solve the problem because of the intrinsic difference between detection and classification (Li et al., 2020).

The original analysis also rejects two common remedies as sufficient on their own. Simple re-sampling risks overfitting and slows convergence, while loss re-weighting is described as brittle to hyper-parameters and as struggling to handle the dominant background class. This establishes BAGS as a response to imbalance at the classifier level rather than only at the data-sampling or scalar-loss level (Li et al., 2020).

2. Group formation and group-wise softmax

BAGS divides the CC object classes into NN disjoint groups G1,,GNG_1,\dots,G_N, each containing classes with similar instance counts, and introduces a special background group G0={background}G_0=\{\text{background}\}. Let N(j)\mathbb{N}(j) denote the total number of training instances of class CC0. With pre-defined thresholds

CC1

group CC2 contains all object classes CC3 satisfying

CC4

On LVIS, the original paper uses CC5 with CC6 (Li et al., 2020).

A distinctive element of BAGS is the “others” calibration. To reduce inter-group false positives and allow each group to veto improbable predictions, one “others” node is appended to each object group. If the detection head produces logits CC7 for CC8 plus CC9 “others” logits wj\lVert w_j\rVert0, then the index sets are defined as

wj\lVert w_j\rVert1

For each group wj\lVert w_j\rVert2, the posterior is

wj\lVert w_j\rVert3

This construction restricts direct softmax competition to classes of similar shot level, rather than forcing rare classes to compete against the full head-dominated vocabulary (Li et al., 2020).

A later exposition of the same idea defines a grouping function wj\lVert w_j\rVert4, where wj\lVert w_j\rVert5 if class wj\lVert w_j\rVert6 belongs to group wj\lVert w_j\rVert7, and partitions the Region-of-Interest logits into group-specific subvectors. In that presentation, each RoI activates only the background group and its own frequency group, and the BAGS loss is the sum of cross-entropy terms over those two active groups (Gaba, 2 Sep 2025).

3. Training objective, “others” sampling, and inference

For a proposal labeled as class wj\lVert w_j\rVert8, the original BAGS formulation assigns cross-entropy losses for exactly two groups: wj\lVert w_j\rVert9 and the object group jj0 containing jj1. The per-proposal loss is written as

jj2

where jj3 and jj4 are one-hot labels in each group (Li et al., 2020).

Because the “others” category can encompass many classes, its training examples can dominate unless explicitly controlled. The original method therefore samples at most jj5 times the total number of regular in-group proposals for each group. On LVIS, if jj6, the method randomly picks up to jj7 proposals labeled “others” to train group jj8, with jj9 reported to work well (Li et al., 2020).

The training loop described in the original paper is operationally simple. For each image mini-batch, the detector generates region proposals, extracts RoI features pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.0, computes logits

pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.1

for pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.2 together with pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.3 for each group, determines the group containing the ground-truth label, samples “others” proposals subject to the cap, computes the background and group-specific cross-entropies, and backpropagates only the classification head, or optionally part of the backbone (Li et al., 2020).

Inference is likewise group-wise. For each proposal, BAGS computes all group posteriors, discards the “others” entries, and multiplies each foreground class probability by the background-group probability:

pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.4

Non-maximum suppression and box regression then proceed as usual. This preserves the overall two-stage detection pipeline while replacing only the classifier normalization structure (Li et al., 2020).

4. Theoretical rationale and diagnostic ablations

The theoretical motivation given for BAGS is that restricting competition in softmax to classes of similar shot level prevents head-class weight vectors from suppressing tail-class weights. The per-group normalization is said to equalize gradient magnitudes across groups, so that each class group receives balanced numbers of positive and negative signals irrespective of its global prevalence. The “others” nodes then maintain calibration against background and out-of-group classes, preserving overall precision (Li et al., 2020).

The ablation results clarify several failure modes and common misconceptions. Groups alone are not sufficient: without “others” calibration, grouping hurts head-class mAP and produces many false positives. Adding only the background group yields only a modest gain, whereas adding both background and “others” yields the full benefit. These observations indicate that BAGS is not merely a coarse binning of categories; its calibration mechanism is integral to its reported behavior (Li et al., 2020).

Group count and “others” sampling also matter. On LVIS, pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.5 is reported as best; fewer groups bias the system toward head classes, while more groups starve tail classes. Performance rises as the “others” sampling ratio increases up to approximately pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.6, after which over-sampling “others” degrades tail performance. This suggests that BAGS depends on balancing two forms of competition simultaneously: within-group class competition and between-group rejection (Li et al., 2020).

A later LVIS v1 study reinforces the importance of semantically meaningful frequency grouping. In that work, “Random BAGS (RAGS),” obtained by shuffling categories before binning, causes rare AP to collapse to pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.7. This result supports the original claim that the grouping should reflect instance-count structure rather than arbitrary partitioning (Gaba, 2 Sep 2025).

5. Empirical performance on LVIS

The original experiments are conducted on LVIS v0.5, a long-tail large-vocabulary benchmark with 1,230 object categories. The validation split is binned into four shot levels: rare (pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.8 instances), common (pj=exp(wjTx)i=0Cexp(wiTx).p_j=\frac{\exp(w_j^T x)}{\sum_{i=0}^{C}\exp(w_i^T x)}.9–CC0), frequent (CC1–CC2), and very frequent (CC3). Reported metrics include overall mAP, CC4, CC5, CC6, and per-bin CC7 (Li et al., 2020).

Setting Key result
Baseline softmax, Faster R50-FPN mAP CC8
Repeat-Factor Sampling mAP CC9
Class-balanced re-weighting mAP NN0
BAGS, Faster R50-FPN mAP NN1
Baseline, ResNeXt-101-FPN + Faster R-CNN NN2 with BAGS
Baseline, ResNeXt-101-FPN + Cascade R-CNN NN3 with BAGS

For the Faster R50-FPN detector, the baseline softmax yields mAP NN4, with NN5, NN6, NN7, and NN8. Repeat-Factor Sampling raises mAP to NN9 and gives G1,,GNG_1,\dots,G_N0, G1,,GNG_1,\dots,G_N1. Class-balanced re-weighting reaches mAP G1,,GNG_1,\dots,G_N2, with G1,,GNG_1,\dots,G_N3 and G1,,GNG_1,\dots,G_N4. BAGS reaches mAP G1,,GNG_1,\dots,G_N5, with G1,,GNG_1,\dots,G_N6, G1,,GNG_1,\dots,G_N7, G1,,GNG_1,\dots,G_N8, and G1,,GNG_1,\dots,G_N9. The same paper reports that Mask R-CNN instance segmentation similarly improves by approximately G0={background}G_0=\{\text{background}\}0–G0={background}G_0=\{\text{background}\}1 mAP, and states that BAGS beats all state-of-the-art methods transferred from long-tail image classification and establishes new state-of-the-art (Li et al., 2020).

The significance of these results lies in their distributional profile. The largest gains occur in the low-shot bins, while the head categories remain competitive rather than collapsing. This is consistent with the paper’s claim that BAGS improves rare-class behavior without requiring extra sampling for the instances from tail classes (Li et al., 2020).

6. Later extensions in long-tailed detection

A later study on LVIS v1 uses a two-stage Faster R-CNN architecture with a ResNet-50 backbone and MMDetection defaults, and treats BAGS as the starting point for further improvements. In that setting, the baseline Softmax on the validation set gives overall mAP G0={background}G_0=\{\text{background}\}2, rare AP G0={background}G_0=\{\text{background}\}3, common G0={background}G_0=\{\text{background}\}4, and frequent G0={background}G_0=\{\text{background}\}5, while original BAGS with four bins gives overall mAP G0={background}G_0=\{\text{background}\}6, rare G0={background}G_0=\{\text{background}\}7, common G0={background}G_0=\{\text{background}\}8, and frequent G0={background}G_0=\{\text{background}\}9 (Gaba, 2 Sep 2025).

That work investigates several modifications. A five-bin variant, obtained by splitting the N(j)\mathbb{N}(j)0 range into N(j)\mathbb{N}(j)1 and N(j)\mathbb{N}(j)2, reaches mAP N(j)\mathbb{N}(j)3. “Clustered BAGS,” with thresholds chosen by k-means clustering on the instance-count histogram, gives mAP N(j)\mathbb{N}(j)4. “Focal-Loss BAGS,” which replaces the per-group cross-entropy by focal loss with N(j)\mathbb{N}(j)5, reports rare AP N(j)\mathbb{N}(j)6 and overall N(j)\mathbb{N}(j)7. “Class-Weighted BAGS,” using exact inverse-count weights normalized within each group, reaches mAP N(j)\mathbb{N}(j)8, rare N(j)\mathbb{N}(j)9, and common CC00. A hybrid strategy that uses class-weighted softmax in the rare and common bins and standard softmax in the head bins yields the best reported overall mAP, CC01, described as a new state of the art on LVIS in that paper (Gaba, 2 Sep 2025).

The same study also hypothesizes that tail-class features may form smaller, denser clusters within the feature space of head classes, making classification challenging for regression-based classifiers. To address this, it explores metric learning to obtain embeddings that are well-separated across classes and tightly clustered within each class, and uses a k-Nearest Neighbors approach at inference to improve classification performance, particularly for rare classes. These additions are presented as enhancements to the BAGS framework rather than as part of the original 2020 formulation (Gaba, 2 Sep 2025).

The grouped-softmax idea also appears in neural text generation under the name “FCC02-Softmax,” where the vocabulary is partitioned into frequency classes with roughly equal total corpus frequencies and the output distribution is factorized into a class probability and a within-class token probability. In that work, the posterior is written as

CC03

and training remains maximum likelihood, implemented through two softmax heads (Choi et al., 2020).

The paper explicitly states that all of FCC04-Softmax’s ingredients can be viewed as one instance of a more general BAGS mechanism. In that mapping, one pre-computes a partition of the vocabulary into balanced groups, replaces the flat softmax over the full vocabulary by a group softmax plus a per-group softmax, and optimizes the sum of the corresponding log-probabilities. The intended effect is analogous to the detection setting: more uniform training signals by confining competition to subsets with balanced frequency mass (Choi et al., 2020).

This does not imply that the detection and language-model variants are identical. The original BAGS for object detection is defined around frequency-grouped object classes, a dedicated background group, and “others” calibration inside a two-stage detector, whereas FCC05-Softmax is a factorized generation head over a token vocabulary. A plausible implication is that BAGS is best understood not as a single architecture, but as a design pattern for replacing flat softmax competition with frequency-aware grouped normalization when extreme imbalance distorts learning dynamics (Li et al., 2020).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Balanced Group Softmax (BAGS).