Papers
Topics
Authors
Recent
Search
2000 character limit reached

Semantic Guided Adaptive Patching (SGAP)

Updated 26 May 2026
  • Semantic Guided Adaptive Patching (SGAP) is a strategy that uses semantic features to form variable-sized, context-aware patches in images and code.
  • It applies feature-driven over-segmentation and adaptive clustering to produce coherent regions, reducing fragmentation and improving performance.
  • SGAP integrates methods from high-resolution vision processing and automated program repair to boost accuracy, efficiency, and scalability.

Semantic Guided Adaptive Patching (SGAP) is a family of adaptive partitioning strategies that leverage semantic information to guide the partitioning of structured objects—such as images or code—into non-uniform, context-aware "patches." Unlike traditional fixed-grid or sliding window approaches that disregard underlying semantics and result in inefficient or fragmented decompositions, SGAP methods exploit semantic guidance, via feature embeddings, edge/saliency maps, or logic-based judgments, to generate variable-sized, semantically coherent regions. SGAP has been instantiated in image understanding for high-resolution vision models, as well as in automated program repair pipelines.

1. Motivation and Theoretical Foundations

SGAP addresses the shortcomings of rigid partitioning in domains where semantic boundaries are non-aligned with spatial regularity or syntactic structure. In high-resolution image processing, fixed grids can sever foreground objects, leading to fragmented representations that degrade performance on downstream reasoning, visual question answering, or segmentation. Analogously, in program repair, unguided or test-only-driven patching can result in large, semantically redundant or irrelevant changes.

The core theoretical insight is that semantic features—whether deep visual embeddings, low-level edge cues, or symbolic logic effects—encode meaningful relationships that should inform granularity and contiguity of the resulting partition. The SGAP framework imposes data- or feature-driven constraints on how and when patches are subdivided or merged, enabling the resulting tokens/patches to better align with the structural and semantic composition of the data (Li et al., 22 May 2026, Zhang et al., 2024, Zhang et al., 2023).

2. Methods: Image Processing and Vision Transformers

In vision applications, SGAP adapts the size and boundaries of image patches based on an explicit semantic prior.

2.1. Feature-Driven Over-Segmentation

Given a high-resolution image II and its dense feature map HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d} (extracted for example with a visual expert such as SAM 3), the image is first over-segmented into a set of atomic superpixels (“atoms”) using SLIC in the feature space. Each atom is a local group of pixels with similar deep features. These atoms are organized into a region adjacency graph to preserve spatial relationships.

2.2. Adaptive Clustering and Cost Metrics

Atoms are clustered into kk groups by agglomerative clustering, constrained to maintain adjacency. The choice of kk balances under-segmentation (patches spanning multiple semantics) and over-segmentation (fragmentation). The optimal kk is determined by minimizing a total cost:

L(k)=Lo(Bk)Ls(Ha,lk)L(k) = L_o(B_k) - L_s(H_a, l_k)

where Lo(Bk)L_o(B_k) is the total overlap penalty (e.g., sum of pairwise IoUs of bounding boxes over clusters), and Ls(Ha,lk)L_s(H_a, l_k) is the silhouette score, measuring cluster separation in the feature space.

2.3. Patch Selection via Visual Complexity

Each candidate patch, defined by the bounding box of its cluster, is further scored by a visual complexity metric:

cv(Ipatch)=max(0,11RiRcosim(hi,hˉ))c_v(I_{\text{patch}}) = \max\left(0, 1 - \frac{1}{|R|} \sum_{i \in R} \text{cosim}(h_i, \bar{h})\right)

where hih_i are feature vectors for atoms in HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}0 (the patch), HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}1 is their centroid. Only patches exceeding a threshold HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}2 are retained, ensuring that low-complexity (background) regions are pruned.

2.4. Recursive Tree Construction

SGAP can be recursively applied: each informative patch may itself be decomposed using the above pipeline, yielding a multi-layer semantic patch tree. This recursion is bounded by a maximum depth or by the absence of further informative splits (Li et al., 22 May 2026).

3. Algorithmic Realization: Image and Transformer Integration

SGAP's image variant may alternatively use edge or saliency maps for semantic guidance (Zhang et al., 2024). Given a semantic guidance map HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}3 (e.g., via Canny edge detection), a patch refinement process proceeds via adaptive quadtree splitting:

  • For each region HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}4, if the total "semantic energy" HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}5 exceeds a threshold HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}6, subdivide HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}7.
  • Stop subdividing either when HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}8 is sufficiently low or a maximum depth is reached.
  • Optionally, adjacent leaf patches of low complexity may be merged.

After patching, each patch is resized, embedded, and sequentialized as a token for vision transformers. The SGAP process is a preprocessing step, preserving the underlying transformer architecture while reducing token length—leading to major efficiency and memory improvements without compromising segmentation or recognition quality (Zhang et al., 2024).

4. SGAP in Program Repair: Static Analysis Feedback

In automated program repair, SGAP takes a logically driven approach to guide the synthesis and validation of patches. Here, semantic guidance derives from static analysis in the form of Incorrectness Separation Logic (ISL) judgments (Zhang et al., 2023). The patch search is organized around a probabilistic context-free grammar (PCFG), where production probabilities are adaptively reweighted according to ISL-derived semantic feedback:

  • Each candidate patch is analyzed by an ISL-powered analyzer (Pulse), producing a semantic "footprint" composed of program states (HeRh×w×dH_e \in \mathbb{R}^{h\times w\times d}9).
  • Patches are clustered into equivalence classes based on the (symmetric-difference) distance between their semantic effects and those of the original buggy footprint.
  • Only a single representative from each equivalence class requires expensive validation, greatly improving overall scalability. For example, empirical studies observe kk0 patches generated across only kk1 equivalence classes, resulting in a substantial validation cost reduction.
  • This semantic-driven grouping enables the patch synthesis process to avoid functionally redundant or spurious candidates, directly targeting impactful corrections (Zhang et al., 2023).

5. Empirical Results and Comparative Performance

Quantitative evaluations in vision domains demonstrate significant improvements in both efficiency and downstream accuracy. For instance, in multimodal LLM-based HR image search, integrating SGAP with visual bottom-up search attains 76.8% accuracy with a throughput of 3.81 samples/minute on HR-Bench 4K, outpacing both rigid grids (73.5%/2.02) and generic top-down SGAP (72.3%/2.14). SGAP's selective pruning and alignment with semantic structure underwrite these gains (Li et al., 22 May 2026).

In high-resolution medical segmentation, SGAP-style patching yields up to kk2 sequence or wall-time speedup for Vision Transformer pipelines (e.g., PAIP, BTCV) while preserving or improving Dice and IoU scores compared to uniform patching or U-Net baselines (Zhang et al., 2024).

In program repair, SGAP substantially outperforms prior approaches in plausible and correct patch rates—for instance, 24/27 plausible and 19/27 correct memory bug repairs on a diverse set, versus 16/27 and 13/27 for the SAVER baseline (Zhang et al., 2023).

6. Analysis of Limitations and Extensions

SGAP's effectiveness is modulated by the quality and granularity of underlying semantic priors. In image settings, uniformly complex or noisy content can force near-uniform patching, diminishing efficiency gains. Patch boundaries may introduce stitching artifacts if semantic granularity varies sharply; minor overlaps or boundary-aware merging can provide mitigation (Zhang et al., 2024).

Potential extensions include multi-modal or learned semantic guidance maps, adaptively learned threshold selection via policy networks, and enhanced merging schemes that smooth superpixel boundaries.

In program repair, semantic equivalence class construction critically depends on the expressiveness and faithfulness of the static analysis domain; insufficient abstraction granularity or soundness issues could lead to missed plausible repairs or excessive validation.

7. Illustrative Examples and Impact

Empirical figures from (Li et al., 22 May 2026) show SGAP's practical benefits:

  • In a text-rich storefront, rigid grids bisect signs and text, confounding OCR. SGAP’s clustering isolates the visual sign as a cohesive patch, preserving textual content for downstream extraction.
  • On architectural scenes, SGAP avoids fragmenting structural elements (e.g., church spires and naves) commonly split by standard methods.
  • In images containing trucks or cluttered scenes, SGAP splits foreground (vehicle, salient objects) and background (sky, trees) into semantically aligned, non-overlapping patches, enhancing both accuracy and computational focus.

In sum, Semantic Guided Adaptive Patching constitutes a generalizable methodology for context-informed partitioning, yielding compact, semantically meaningful units across both visual and symbolic domains, with demonstrable benefits in accuracy, computational efficiency, and functional relevance (Li et al., 22 May 2026, Zhang et al., 2024, Zhang et al., 2023).

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 Semantic Guided Adaptive Patching (SGAP).