---
title: Region-Aware Cluster Discrimination (RICE)
url: https://www.emergentmind.com/topics/region-aware-cluster-discrimination-rice
type: topic
---

# Region-Aware Cluster Discrimination (RICE)

Region-Aware Cluster Discrimination (RICE) is a framework for large-scale visual representation learning that explicitly incorporates region-level semantics, addressing key limitations of global feature alignment in dense prediction tasks such as object grounding, optical character recognition (OCR), and segmentation. Unlike prior vision-language models that primarily rely on contrastive objectives at the image level, RICE introduces a regional clustering paradigm and a unified loss that strengthens both object and OCR capabilities within a single, scalable classification framework [2507.20025].

## 1. Billion-Scale Region Dataset Construction

The RICE framework is enabled by the construction of a billion-scale region dataset, sourced from LAION-2B, COYO-700M, and SAM1B. All source images are required to have a minimum edge of at least 336 pixels. Object regions are generated using the SAM model (Kirillov et al., ICCV 2023) applied to LAION and COYO, while SAM1B provides human-annotated regions. Fine-grained segmentation masks whose bounding boxes have both sides less than 128 pixels are discarded. This process yields approximately 2 billion object region proposals from about 400 million images.

For annotation, each object region $r_{ij}$ is embedded using a 512-dimensional CLIP model, $f_{ij} = \text{CLIP}(r_{ij})$. A large-scale hierarchical k-means clustering (implemented with Faiss on GPU) produces K=1,000,000 cluster centers $C = \{c_1, ..., c_K\}$. Each region receives a single pseudo-label via nearest neighbor assignment: $y_{ij}^{object} = \arg\min_k \|f_{ij} - c_k\|_2$.

OCR regions are generated by running PaddleOCR on LAION-2B and COYO-700M, retaining only text detections with confidence at least 0.7. This generates about 400 million OCR regions from approximately 50 million images. Each region’s recognized text $t_{ij}$ is tokenized using a byte pair encoding (BPE) tokenizer to produce multi-token labels $y_{ij}^{ocr} = \text{tokenize}(t_{ij})$.

The resulting datasets are organized as two parallel corpora: (1) region image $\rightarrow$ single object cluster label and (2) region image $\rightarrow$ multi-token OCR label, with a combined scale of 2 billion object regions and 0.4 billion OCR regions.

## 2. Region Transformer Layer and Embedding Extraction

RICE introduces a Region Transformer layer atop a Vision Transformer (ViT) backbone to produce region-specific embeddings. The model first applies $L_1$ standard ViT self-attention layers to image patch tokens (including $z_{cls}$ for the global image and $\{z_1, ..., z_N\}$ for spatial patches), yielding global embeddings $\{e_{cls}, e_1, ..., e_N\}$. Subsequently, $L_2$ Region Transformer layers are applied, designed to extract $L$ region-specific embeddings $r_1, ..., r_L$.

The core mechanism is masked region attention. For each image, up to $N$ regions are sampled, each with a binary visibility mask $M^j \in \{0, -\infty\}^{N \times N}$ that restricts attention to token indices within the corresponding region. Embedding extraction across a batch proceeds by gathering region queries ($Q_{batch}$), keys ($K_{batch}$), and values ($V_{batch}$), and applying:

$$
R_{batch} = \operatorname{Softmax}\left(\frac{Q_{batch} K_{batch}^T}{\sqrt{d_k}} + M\right) V_{batch}
$$

This yields one $D$-dimensional embedding per region. Both global and regional representations can be extracted within a single forward pass. 

## 3. Unified Region Cluster Discrimination Loss

RICE unifies region-based object recognition and OCR via a margin-based cluster-center discriminative loss. All embeddings and cluster centers are $L_2$ normalized; a global scale $s=64$ and additive angular margin $m=0.3$ are applied for positive pairs. Negative sampling is performed by randomly selecting $k = \lfloor \rho K \rfloor$ negative centers ($\rho = 0.1$ by default).

- **Object Region Loss:** Given predicted region embedding $\hat{y}_{ij}$ and its true cluster center $c_{y_{ij}^{object}}$,
  $$
  L_{object} =
  \log\left(1 + \exp\left(- \operatorname{sim}(\hat{y}_{ij}, c_{y_{ij}^{object}}) + m \right) \cdot s\right)
  +
  \log\left(1 + \sum_{n \in \Omega_n^{object}} \exp(\operatorname{sim}(\hat{y}_{ij}, c_n) \cdot s)\right)
  $$
  where $\operatorname{sim}(u, v) = u^T v$ and $\Omega_n^{object}$ is the set of negative cluster centers.

- **OCR Region Loss:** For OCR regions with $M$ positive tokens (embedding set $\{t_p\}$),
  $$
  L_{ocr} = \log \left(1 + \sum_{p \in \Omega_p^{ocr}} \exp(-\operatorname{sim}(\hat{y}_{ij}, t_p) \cdot s) \right)
  +
  \log \left(1 + \sum_{n \in \Omega_n^{ocr}} \exp(\operatorname{sim}(\hat{y}_{ij}, t_n) \cdot s) \right)
  $$
  $\Omega_p^{ocr}$ contains token centers for the detected tokens, $\Omega_n^{ocr}$ are negative token centers.

The joint classification loss for a batch is given by $L = \alpha \cdot L_{object} + \beta \cdot L_{ocr}$, with $\alpha = \beta = 1$. Both object and OCR tasks share the same cluster-center architecture, enabling fully unified training and parameter sharding through Partial-FC.

## 4. Vision and OCR Integration with Large-Scale Distributed Training

A balanced region selector ensures that each minibatch contains a mix of object and OCR regions, sampled up to $N$ regions per image. The model supports distributed data-parallel training across 64 GPUs (with a global batch of 32,000 images). Cluster center matrices ($1\mathrm{M} \times D$) are sharded across GPUs and only a sampled $\rho$-fraction of negatives are communicated per GPU, following the PartialFC approach.

The Faiss hierarchical k-means clustering process for the billion-scale region set can be completed offline within approximately 10 hours on 64 GPUs. RICE supports both ViT-B/16 and ViT-L/14 architectures, with resolution schedules spanning $224^2$ up to $560^2$, and all training conducted using AdamW optimizer.

## 5. Empirical Evaluation and Benchmark Results

### 5.1 Pretraining and Downstream Benchmarks

RICE is pretrained on 13 billion region samples (from LAION-2B, COYO-700M, SAM1B). Backbones include ViT-B/16 and ViT-L/14. The system is evaluated on:

- Vision-only dense benchmarks: COCO detection/segmentation, LVIS detection/segmentation, and Roboflow100.
- Multimodal Large Language Models (MLLMs): LLaVA-NeXT, LLaVA-OneVision, and LISA frameworks, covering benchmarks such as OCRBench, DocVQA, InfoVQA, TextVQA, ChartQA, LiveXivVQA, AI2D, MMBench, MME, POPE, and RealworldQA.
- Referring segmentation: refCOCO, refCOCO+, refCOCOg using LISA-style two-stage training.
- Video tracking probe: OSTrack on LaSOT, TrackingNet, GOT-10k, TNL2K, using two additional transformer blocks atop the frozen backbone.

### 5.2 Quantitative Improvements

| Task/Metric          | RICE ViT-L/14-336 | Baseline / SOTA | Relative Gain         |
|----------------------|------------------|-----------------|-----------------------|
| InfoVQA              |  +9.8 pts        | CLIP L/14-336   | ↑ notable            |
| DocVQA               |  +3.98 pts       | CLIP L/14-336   | ↑ notable            |
| OCRBench avg         |  +50 pts         | CLIP L/14-336   | ↑ large              |
| COCO Detection AP    |  38.9%           | SigLIP L/16     | +3.9 pts             |
| COCO Segmentation AP |  31.5%           | SigLIP L/16     | +3.4 pts             |
| LVIS Detection AP    |  26.5%           | SigLIP L/16     | +4.7 pts             |
| LVIS Segmentation AP |  21.4%           | SigLIP L/16     | +4.1 pts             |
| Roboflow100 avg      |  26.5%           | Baseline        | +2.4 pts             |
| refCOCO/-/g mIoU     |  +2.0 pts        | CLIP            | ↑                    |
| LaSOT Succ/Prec      | 60.24/63.16      | MLCD: 58.05/60.75| ↑                    |

Ablation studies indicate optimal settings: number of regions $N=10$ per image, cluster count $K=1$M–2M (COCO/LVIS), negative ratio $\rho=0.05$–$0.1$, and approximately 10 OCR tokens per region.

Qualitative attention visualizations (PCA-projected) show temporally consistent behavior on video tracking.

## 6. Limitations and Prospects

RICE’s dependence on the SAM model exposes it to error propagation from segmentation masks. OCR region quality is limited by PaddleOCR’s handling of stylized or complex text. The current region clustering is static and not updated during training; integrating learnable or online cluster centers represents an avenue for future research. Extending the approach to support spatio-temporal region proposals for video or 3D point-cloud regions is a natural direction for expansion.

## 7. Code, Pretrained Models, and Reproducibility

Code, pretraining and finetuning scripts, model weights, and reproducibility recipes are publicly released at [https://github.com/deepglint/MVT](https://github.com/deepglint/MVT). The repository includes:

- `make_regions.py` for region curation (SAM and PaddleOCR pipeline)
- `train_rice.py` with ViT and Region Transformer integration and PartialFC loss
- Downstream task configurations for Detectron2, LLaVA-NeXT, LISA, and OSTrack

All required hyperparameters, library versions (Python, PyTorch, Faiss), and dependencies (SAM and PaddleOCR via Docker) are specified, ensuring direct replication of reported results.

RICE represents a synthesis of billion-scale region clustering with an efficient transformer-based regional embedding framework, advancing both vision and vision-language tasks through unified object and OCR recognition losses, while remaining scalable and computationally tractable at the largest data and compute regimes to date [2507.20025].

Source: https://www.emergentmind.com/topics/region-aware-cluster-discrimination-rice