---
title: Euclidean Prompt Evolution in OP-SAM
url: https://www.emergentmind.com/topics/euclidean-prompt-evolution-epe
type: topic
---

# Euclidean Prompt Evolution in OP-SAM

Searching arXiv for the cited papers to ground the article.
arxiv_search.query{"search_query":"id:2507.16337 OR ti:\"One Polyp Identifies All: One-Shot Polyp Segmentation with SAM via Cascaded Priors and Iterative Prompt Evolution\"","max_results":5,"sort_by":"submittedDate","sort_order":"descending"}
arxiv_search.query returned 1 result:
- 2507.16337 — "One Polyp Identifies All: One-Shot Polyp Segmentation with SAM via Cascaded Priors and Iterative Prompt Evolution"
arxiv_search.query{"search_query":"id:2601.18847 OR ti:\"MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution\"","max_results":5,"sort_by":"submittedDate","sort_order":"descending"}
arxiv_search.query returned 1 result:
- 2601.18847 — "MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution"
arxiv_search.query{"search_query":"id:2503.23503 OR ti:\"Evolutionary Prompt Optimization Discovers Emergent Multimodal Reasoning Strategies in Vision-Language Models\"","max_results":5,"sort_by":"submittedDate","sort_order":"descending"}
arxiv_search.query returned 1 result:
- 2503.23503 — "Evolutionary Prompt Optimization Discovers Emergent Multimodal Reasoning Strategies in Vision-Language Models"
arxiv_search.query{"search_query":"id:2309.16797 OR ti:\"Promptbreeder: Self-Referential Self-Improvement Via Prompt Evolution\"","max_results":5,"sort_by":"submittedDate","sort_order":"descending"}
arxiv_search.query returned 1 result:
- 2309.16797 — "Promptbreeder: Self-Referential Self-Improvement Via Prompt Evolution"
Euclidean Prompt Evolution (EPE) is an iterative, training-free prompting algorithm that turns the fused semantic prior \(\mathbf{p}_{avg}\) from Correlation-based Prior Generation (CPG) and Scale-cascaded Prior Fusion (SPF) into a sequence of optimal point prompts for SAM2 in OP-SAM’s one-shot polyp segmentation framework [2507.16337]. Within OP-SAM, EPE is the last major component: it translates a dense probability prior into a feedback-driven interactive prompting process in image coordinate space, using Euclidean Distance Transform (EDT), coverage against a tight prior, SAM2’s predicted IoU, and occasional negative prompts to refine segmentation without human clicks. Across five datasets, OP-SAM reports strong one-shot segmentation performance; on Kvasir, it achieves 76.93% IoU, surpassing the state of the art by 11.44% [2507.16337].

## 1. Conceptual role in OP-SAM

OP-SAM has three key stages. First, CPG uses DINOv2 features and cross/self-correlation to transfer the support mask semantics to a query image, producing a dense probability prior \(\mathbf{p}_{ori}\) and its scaled variants. Second, SPF fuses \(\mathbf{p}_{ori}, \mathbf{p}_{xl}, \mathbf{p}_{xs}\) into a single robust prior \(\mathbf{p}_{avg}\) using a reverse-transfer and confidence-IoU scheme. Third, EPE takes that fused prior and converts it into a sequence of geometric prompts for SAM2 [2507.16337].

This division of labor is explicit. CPG answers “Where is the polyp likely to be?”, SPF answers “Given size variations, which prior is trustworthy?”, and EPE answers “How do we interactively prompt SAM2 with this prior to get a high-quality mask?” [2507.16337]. EPE is therefore not a prior-generation module and not a learning algorithm over model parameters. It is a fixed inference-time procedure that operationalizes the prior as a small number of high-impact prompts.

The design motivation is also explicit. Simply dumping many points from \(\mathbf{p}_{avg}\) into SAM2 can under-prompt or over-prompt the model; EPE instead models the interactive nature of SAM by adding one or a few carefully chosen prompts, observing the mask, evaluating it against the prior, and then deciding where and how to add the next prompt [2507.16337]. In that sense, EPE is a prompting policy over image coordinates rather than a prompt-template optimizer over text.

## 2. Formal definition and algorithmic structure

EPE starts from a final prior \(\mathbf{p}\) and several hyperparameters: the tight prior threshold \(\vartheta_t\), the loose prior threshold \(\vartheta_l\), the score threshold for success \(\theta\), and the negative-area threshold \(\eta\). Binary priors are defined by
\[
\hat{\mathbf{p}}_{t}, \hat{\mathbf{p}}_{l} \leftarrow \mathbf{p} > \vartheta_t,\; \mathbf{p} > \vartheta_l .
\]
Here \(\hat{\mathbf{p}}_t\) denotes a high-confidence polyp region, whereas \(\hat{\mathbf{p}}_l\) denotes a larger, lower-confidence region [2507.16337].

The prompt list is initialized as \(\mathbf{L}\leftarrow\emptyset\). The core subroutine, EucSeg, takes a binary prior region \(\hat{\mathbf{p}}_{in}\) and the current prompt list \(\mathbf{L}\). It computes an EDT map on \(\hat{\mathbf{p}}_{in}\), locates the coordinate with maximum distance from background, appends that coordinate to \(\mathbf{L}\), runs SAM2 on the query image with \(\mathbf{L}\), and returns the predicted mask \(\mathbf{M}\), the prior coverage \(cov\), and SAM’s own mask IoU prediction \(iou\) [2507.16337]. In concise form, the prompt coordinate is
\[
\sigma_{coor} = \arg\max_{(x,y)} \mathrm{EDT}(\hat{\mathbf{p}}_{in}).
\]

The iterative loop begins with EucSeg on the tight prior:
\[
\mathbf{M}_0, cov_0, iou_0 = \text{EucSeg}(\hat{\mathbf{p}}_{t}, \mathbf{L}),
\]
and checks
\[
done \leftarrow (cov_0 \geq \theta)\ \text{and}\ (iou_0 \geq \theta).
\]
If coverage is low, the next prompt is restricted to the remaining tight prior,
\[
\hat{\mathbf{p}}_i = (\neg \mathbf{M}_{i-1}) \cap \hat{\mathbf{p}}_{t},
\]
whereas if coverage is sufficient but IoU is low, the next prompt is drawn from the remaining loose prior,
\[
\hat{\mathbf{p}}_i = (\neg \mathbf{M}_{i-1}) \cap \hat{\mathbf{p}}_{l}.
\]
The stated interpretation is that low coverage indicates failure to cover enough of the confident prior, while sufficient coverage but low IoU suggests that the tight prior is incomplete and that refinement should expand outward [2507.16337].

When the predicted mask includes a large area outside the loose prior, EPE performs a noise check:
\[
\mathrm{count}(\mathbf{M}_i \cap \neg \hat{\mathbf{p}}_{l}) \geq \eta .
\]
If this condition holds, the noisy outside region is treated as a negative prior,
\[
\hat{\mathbf{p}}_i = \mathbf{M}_i \cap \neg \hat{\mathbf{p}}_{l},
\]
and EucSeg is run again to add a negative prompt [2507.16337]. The final query mask is the union of all accepted masks,
\[
\mathbf{M}_q = \bigcup_{j=0}^{i-1} \mathbf{M}_j .
\]

The procedure is non-learned and non-differentiable. It does not use backpropagation or parameter updates. Stopping is quality-based, via \(cov_i \geq \theta\) and \(iou_i \geq \theta\), and also budget-based: the text states that the loop is exited when more than five rounds of prompting have been performed [2507.16337].

## 3. Euclidean geometry and prompt selection

The term “Euclidean” in EPE refers to Euclidean geometry in image coordinate space. Prompts live in a 2D pixel grid, EDT measures the Euclidean distance from each foreground pixel to the nearest background boundary, and the chosen prompt is the pixel maximally distant from background within the current prior region [2507.16337]. The relevant space is therefore not a text embedding space and not an LLM latent space; it is the geometric support of the image prior.

This choice gives the prompt a specific geometric interpretation. The EDT maximum is the medial point of the region, farthest from boundaries, and corresponds to the largest inscribed circle. The paper contrasts this with the bounding-box center (BBC), which may fall into background when the shape is elongated or irregular. In the provided example with a spike-like artefact in the prior, BBC falls into background, whereas the EDT center remains on the central polyp body [2507.16337].

The rationale for Euclidean distance is twofold. First, it is robust to shape: irregular, elongated, or spiky polyps can invalidate simpler geometric surrogates such as box centers. Second, it prioritizes core regions: points far from the boundary are the most confident internal locations. The prompting trajectory therefore starts from the interior and grows outward, which is more stable under noisy boundaries and lesion-scale variation [2507.16337].

This geometry is directly coupled to SAM2’s interactive prompting regime. EPE emulates human interaction by repeatedly identifying unexplained regions of the prior, clicking in those regions, and re-running segmentation. The process is explicitly designed to maintain prompt economy: only a few high-impact points are added, instead of flooding SAM2 with hundreds of points [2507.16337]. A plausible implication is that EPE should be understood as a geometric control heuristic for interactive segmentation rather than as a generic prompt-search framework.

## 4. Iterative refinement, evaluation, and negative prompting

EPE’s update policy is driven by two signals returned after each SAM2 call: coverage of the tight prior and SAM2’s predicted IoU. Coverage is computed with respect to \(\hat{\mathbf{p}}_t\), and IoU is the model’s internal confidence estimate. The algorithm then alternates between two refinement modes: filling the missing confident core and growing outward into the loose prior [2507.16337].

If \(cov_{i-1} < \theta\), the next prompt is selected from the uncovered portion of the tight prior. This expresses the hypothesis that the current segmentation has not yet captured enough of the most reliable prior mass. If coverage is high but IoU is low, the algorithm shifts to the uncovered portion of the loose prior, treating the current failure as one of incomplete spatial extent rather than core omission [2507.16337]. The prompting policy is therefore adaptive: the same prior can lead to different prompt trajectories depending on the observed mask.

Negative prompts address over-segmentation. When the newly predicted mask extends substantially outside \(\hat{\mathbf{p}}_l\), EPE discards the previous mask contribution, constructs a negative prior from the noisy outside region, and prompts again on that region [2507.16337]. Negative points in SAM2 act as “don’t include this region,” allowing EPE to tighten the boundary after overshoot.

The implementation details given for OP-SAM specify \(\vartheta_t = 0.7\), \(\vartheta_l = 0.5\), and \(\theta = 0.85\), with \(\eta\) described as a pixel-count threshold tuned to detect significant over-segmentation. Each round adds at most one new positive or negative point, and the full procedure runs only at inference time [2507.16337]. This combination of deterministic geometric prompt generation and feedback-based mask acceptance is the mechanism that turns a weak, approximate one-shot prior into a stronger segmentation output.

## 5. Empirical impact and comparative behavior

The reported ablation on Kvasir isolates the contribution of EPE within OP-SAM. CPG only yields IoU \(= 67.12\) and Dice \(= 76.43\); CPG + SPF yields IoU \(= 69.05\) and Dice \(= 78.07\); CPG + SPF + EPE yields IoU \(= 76.93\) and Dice \(= 84.53\) [2507.16337]. The paper attributes a gain of \(+7.88\) IoU and \(+6.46\) Dice over the CPG+SPF baseline to EPE alone, with the baseline using random sampling of three prior points when EPE is not applied.

A direct prompting ablation further distinguishes Euclidean prompt selection from alternative strategies.

| Prompting strategy | IoU | Dice |
|---|---:|---:|
| Top first and last probability points | 60.49 | 69.13 |
| “1 top + 1 center + bbox” | 70.54 | 79.51 |
| Bounding-box center evolution | 58.04 | 64.85 |
| EPE center evolution (EDT) | 76.93 | 84.53 |

These results show that iteration alone is not sufficient: prompt placement is critical. Replacing EDT center evolution with bounding-box-center evolution causes a marked performance drop, which the paper interprets as confirmation of the need for Euclidean prompt selection [2507.16337].

The qualitative claims are consistent with the quantitative ablations. EPE is described as improving boundary adherence by starting from the core and growing outward, handling large size mismatches between support and query, and reducing noise through negative prompts that cut away over-segmented regions [2507.16337]. In the broader OP-SAM evaluation, the full framework is reported to achieve 76.93% IoU on Kvasir and to surpass the state of the art by 11.44% [2507.16337].

## 6. Terminological scope and relation to other prompt-evolution methods

The name “Euclidean Prompt Evolution” is specific in the current literature represented here. In "One Polyp Identifies All: One-Shot Polyp Segmentation with SAM via Cascaded Priors and Iterative Prompt Evolution" [2507.16337], EPE refers to an image-space, geometry-driven iterative prompting method for SAM2. It does not refer to prompt optimization over text instructions.

This distinction matters because other recent works use the vocabulary of prompt evolution in different senses. "MulVul: Retrieval-augmented Multi-Agent Code Vulnerability Detection via Cross-Model Prompt Evolution" [2601.18847] does not define anything called EPE. Its optimization mechanism is "Cross-Model Prompt Evolution," and it is entirely discrete and text-based: prompts remain raw text, selection is rank-based on scalar fitness, evaluation uses Router Recall@\(k\) or Detector F1, and there is no notion of prompt vectors, cosine distance, or Euclidean distance inside the evolution loop [2601.18847].

A similar distinction applies to "Evolutionary Prompt Optimization Discovers Emergent Multimodal Reasoning Strategies in Vision-Language Models" [2503.23503]. There, the objects of evolution are system-level text prompts for VLMs, optimized with a binary tournament evolutionary algorithm, a composite fitness
\[
F(p) = (1-\lambda)F_{\text{task}}(p) + \lambda F_{\text{aux}}(p),
\]
and LLM-driven mutation and hyper-mutation. The paper explicitly states that the framework is purely discrete and uses no explicit embeddings, Euclidean distances, or similarity metrics in the evolution itself [2503.23503].

"Promptbreeder: Self-Referential Self-Improvement Via Prompt Evolution" [2309.16797] is closer to geometric prompt search, but only partially. It is largely text-based and self-referential, evolving task-prompts and mutation-prompts in a binary-tournament genetic algorithm. Its one explicit metric-space component is the use of BERT embeddings and cosine similarity for diversity filtering in one mutation operator; Euclidean geometry is not the organizing principle of the method [2309.16797].

A common misconception is therefore to treat EPE as a generic label for any evolutionary prompt optimization. The literature here supports a narrower usage. EPE, in the strict sense, denotes the EDT-based, image-coordinate prompting mechanism in OP-SAM [2507.16337]. Cross-Model Prompt Evolution, evolutionary prompt optimization for VLMs, and Promptbreeder belong to a related but distinct family of prompt-evolution methods over natural-language prompts rather than Euclidean prompt coordinates [2601.18847; 2503.23503; 2309.16797]. A plausible implication is that the term “Euclidean” should be reserved for methods whose search dynamics are defined by explicit geometric structure, not merely by evolutionary iteration.

Source: https://www.emergentmind.com/topics/euclidean-prompt-evolution-epe