# PoolDPP-MAP cuts near-duplicate prompts by 89% in app.dejan.ai using Gemini embeddings and Decision 1

> Source: <https://dejan.ai/blog/pooldpp-map-diverse-sampling-gemini-embeddings-decision-1/>
> Published: 2026-11-24 13:45:07+00:00

**Recommendation:** When generating many prompts or titles in one call, oversample 3-5x, deduplicate exact matches, then select with K-DPP MAP over embedding similarity and quality scores to avoid paying for near-duplicate runs.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

# PoolDPP-MAP cuts near-duplicate prompts by 89% in app.dejan.ai using Gemini embeddings and Decision 1

Oversampling with PoolDPP-MAP, gemini-embedding-2, and gemini-decision-1 cut near-duplicate prompts from 38 to 4 across three input modes in app.dejan.ai while raising mean quality to 0.9418.

Across three input modes on `dejan.ai` (Project Context, Single Entity, and Website URL), oversampling candidate outputs and selecting a subset with a quality-weighted Determinantal Point Process (PoolDPP-MAP) reduced near-duplicate prompt pairs (cosine similarity above 0.80) from 38 to 4 while raising mean quality from 0.9011 to 0.9418 and lifting the lowest-scoring prompt from 0.5605 to 0.8865. The pipeline runs on closed-source models without generator log-probabilities by pairing `gemini-embedding-2` for semantic repulsion with `gemini-decision-1` for calibrated quality scoring, at a scoring and embedding cost of $0.001 per 100 candidates in 0.4 seconds. It is now live as an opt-in option in two `app.dejan.ai` tools: **Diverse mode** in Prompt Generator and **Diverse subjects** in Content Writer.

**Test it on your own topic or page:** Compare 20 standard single-shot prompts against 20 PoolDPP-selected prompts side by side, with live duplicate, semantic spread, and Decision 1 quality scores.

## What it does in app.dejan.ai

Language models generate each completion independently. Asking a model for 20 prompts or 5 article titles in one call produces outputs that cluster around the same high-probability phrasing. In citation tracking, near-duplicate prompts burn API runs testing the same intent multiple times; in content planning, overlapping subjects produce articles that compete against each other and against posts already on the site.

Two opt-in controls in `app.dejan.ai` address this directly:

1. **Prompt Generator (Diverse mode)** : Oversamples 5× candidate prompts for counts of 10 or 20 (3× for 50 or 100), deduplicates exact matches, embeds every unique prompt with`gemini-embedding-2` , scores buyer relevance in one`gemini-decision-1` call, and selects the final $K$ prompts with greedy K-DPP MAP ($\beta = 1.5$).
2. **Content Writer (Diverse subjects)** : Requests 4× candidate`{title, angle}` pairs (12 to 20 ideas) inside the existing single Subject pick call, projects those candidates onto the orthogonal complement of existing**Content Library** titles, scores editorial quality with`gemini-decision-1` , and ranks the shortlist by conditioned PoolDPP-MAP. When**Pick title** is checked, the top $N$ diverse subjects appear pre-selected at the top of the list.

### Side-by-side example: dejan.ai Project Context ($K = 20$)

In a benchmark on property 82 (`dejan.ai`, 271 entities, `gemini-4-hydrogen`, non-branded mode), single-shot generation repeated variations of hiring or evaluating an AI SEO agency five times (items 1, 3, 9, 16, and 20). PoolDPP-MAP ($\beta = 1$) kept one agency-selection prompt and filled the remaining slots with distinct topics from the entity graph that single-shot generation omitted: [Selection Rate Optimization](https://dejan.ai/concepts/selection-rate-optimization/) (SRO), information gain, AI crawler E-E-A-T signals, LLM [hallucination](https://dejan.ai/concepts/hallucination/) auditing, and LLM search volume prediction.

| Slot | Traditional single-shot (20 prompts) | PoolDPP-MAP ($\beta = 1$, from pool of 100) | 
|---|---|---|
| 1 | What are the best AI SEO agencies in Australia for enterprise e-commerce brands looking to improve visibility in generative search? | What are the best AI SEO agencies in Australia for enterprise e-commerce brands? | 
| 2 | What should I look for when hiring a technical SEO agency to handle a large-scale website migration and AI search optimization? | What is selection rate optimization (SRO), and how does it differ from traditional click-through rate optimization? | 
| 3 | What is the difference between traditional SEO and Generative Engine Optimization (GEO), and how should we budget for an agency? | How can I measure information gain and information density in my existing content to make it more likely to be cited by AI? | 
| 4 | Can you recommend top-tier Australian digital marketing agencies that specialize in data-driven technical SEO rather than basic link building? | How do AI crawlers evaluate source authority and E-E-A-T signals compared to traditional search engine crawlers? | 
| 5 | What are the key criteria for evaluating an enterprise Answer Engine Optimization agency with a monthly retainer between $5,000 and $20,000? | What tools or methodologies exist for predicting LLM search volume and emerging purchase-intent prompts? | 
| 6 | What metrics should be included in an executive AI SEO reporting dashboard for a global e-commerce business? | How can we audit and fix brand association or veracity issues when an LLM hallucinates information about our company? | 

*Excerpt of 6 slots from the 20-prompt runs; zero brand leaks occurred in any method.*

## Benchmark results across three input modes

We benchmarked five selection methods on `dejan.ai` (property 82) at $K = 20$ across three input types: **Project Context** (271 database entities, locations, and objectives), **Single Entity** (`ai seo agency`), and **Website URL** (` https://dejan.ai` with live [grounding](https://dejan.ai/concepts/grounding/) via URL context). Every pool method selected 20 prompts from the same 100-prompt pool generated by `gemini-4-hydrogen`.

### 1. Project Context (271 entities)

| Method ($K = 20$) | Gram Log-Det | Mean Cos Dist | Max Pair Sim | Pairs > 0.80 | Mean Quality | Min Quality | 
|---|---|---|---|---|---|---|
| Traditional (single-shot) | -20.611 | 0.3345 | 0.8063 | 1 | 0.9192 | 0.8141 | 
| k-Means ($N = 100$) | -23.316 | 0.3111 | 0.8559 | 8 | 0.9434 | 0.9126 | 
| PoolDPP-MAP pure diversity ($\beta = 0$) | -17.770 | 0.3746 | 0.7287 | 0 | 0.8925 | 0.7103 | 
| **PoolDPP-MAP ($\beta = 1$)** | **-18.360** | **0.3673** | **0.7718** | **0** | **0.9242** | **0.8691** | 
| **PoolDPP-MAP ($\beta = 2$)** | **-18.880** | **0.3597** | **0.7922** | **0** | **0.9300** | **0.8844** | 

### 2. Single Entity (`ai seo agency`)

| Method ($K = 20$) | Gram Log-Det | Mean Cos Dist | Max Pair Sim | Pairs > 0.80 | Mean Quality | Min Quality | 
|---|---|---|---|---|---|---|
| Traditional (single-shot) | -28.541 | 0.2177 | 0.9012 | 60 | 0.9593 | 0.9293 | 
| k-Means ($N = 100$) | -28.033 | 0.2230 | 0.9247 | 40 | 0.9724 | 0.9427 | 
| PoolDPP-MAP pure diversity ($\beta = 0$) | -23.436 | 0.2687 | 0.8232 | 1 | 0.9455 | 0.8566 | 
| **PoolDPP-MAP ($\beta = 1$)** | **-23.522** | **0.2693** | **0.8220** | **5** | **0.9602** | **0.8723** | 
| **PoolDPP-MAP ($\beta = 2$)** | **-23.933** | **0.2636** | **0.8351** | **4** | **0.9677** | **0.9480** | 

### 3. Website URL (`https://dejan.ai`, live `url_context`)

| Method ($K = 20$) | Gram Log-Det | Mean Cos Dist | Max Pair Sim | Pairs > 0.80 | Mean Quality | Min Quality | 
|---|---|---|---|---|---|---|
| Traditional (single-shot) | -20.765 | 0.3328 | 0.8139 | 2 | 0.8962 | 0.4702 | 
| k-Means ($N = 100$) | -20.951 | 0.3409 | 0.8513 | 6 | 0.9567 | 0.8929 | 
| PoolDPP-MAP pure diversity ($\beta = 0$) | -17.078 | 0.3919 | 0.7304 | 0 | 0.8562 | 0.4277 | 
| **PoolDPP-MAP ($\beta = 1$)** | **-18.235** | **0.3703** | **0.7818** | **0** | **0.9392** | **0.8353** | 
| **PoolDPP-MAP ($\beta = 2$)** | **-19.127** | **0.3571** | **0.8095** | **1** | **0.9556** | **0.8929** | 

- **k-Means reduced diversity relative to PoolDPP-MAP.** Picking the highest-scoring item inside each k-Means cluster pulls adjacent cluster winners toward the same high-quality region, yielding 8 near-duplicate pairs on Project Context and 40 on Single Entity (where`Max Pair Sim` reached 0.9247).
- **Pure-diversity DPP ($\beta = 0$) pulled in low-quality outliers.** Without a quality term, the maximum-volume objective rewarded unusual phrasing regardless of usefulness, dropping`Min Quality` to 0.7103 on Project Context and 0.4277 on Website URL. Weighting the kernel with`gemini-decision-1` ($\beta = 1$ to $2$) raised`Min Quality` to 0.8353–0.9480 while keeping near-duplicate counts at 0 to 5.

## The original paper: PoolDPP (NeurIPS 2026)

Our implementation builds on [*A Model of Diverse Sampling from Language Models*](https://arxiv.org/pdf/2611.25003) (Manuel Prada-Corral, Yahya Emara, Timothy J. O'Donnell, Ryan Cotterell, and Tim Vieira, NeurIPS 2026; code at [rycolab/pool-dpp](https://github.com/rycolab/pool-dpp)).

The paper formalizes diverse generation as selecting a size-$K$ subset $S$ of complete strings from a **K-Determinantal Point Process (K-DPP)**. Each string $y$ is represented by a unit-norm [vector embedding](https://dejan.ai/concepts/vector-embedding/) $\phi(y) \in \mathbb{R}^D$ ($\|\phi(y)\|_2 = 1$) and a scalar quality score $\kappa(y) \ge 0$. The kernel matrix $L$ is:

The probability of selecting subset $S$ of size $K$ is proportional to the determinant of its principal submatrix $L_S$, which factorizes into a quality product and a geometric diversity volume:

$$\det(L_S) = \left(\prod_{y \in S} \kappa(y)\right) \det\!\left(\Phi_S^\top \Phi_S\right)$$
Geometrically, $\det(L_S)$ equals the squared volume of the $K$-dimensional parallelepiped spanned by the quality-scaled vectors $\{\sqrt{\kappa(y)}\,\phi(y)\}_{y \in S}$. When two strings are nearly identical, their vectors point in almost the same direction and the volume collapses toward zero regardless of individual quality.

Exact inference over all possible strings $\Sigma^*$ is intractable, so the paper proposes **PoolDPP**: draw a finite candidate pool of size $N$ from a tractable proposal distribution $q$, build the finite pool kernel, and run K-DPP inference on the pool. The paper defines two inference modes:

- **PoolDPP-Sampling** : Importance-weights each pool item by $w^{(n)} = \kappa(y^{(n)}) / q(y^{(n)})$ and draws an exact stochastic K-DPP sample via the $D \times D$ dual kernel at cost $O(D^2 N + D^3 + DNK)$. The authors prove an explicit finite-sample bound showing that the KL divergence to the intractable population K-DPP decays as $O(1/N)$, with Lean 4 machine-checked proofs in the repository.
- **PoolDPP-MAP** : Targets the single size-$K$ subset in the pool that maximizes $\det(L_S)$ via greedy orthogonal projection. Because MAP maximizes $\det(L_S)$ over the realized pool rather than approximating a distribution over $\Sigma^*$, it requires no proposal density $q(y)$ and no importance weights.

## Adapting PoolDPP to closed-source models

In the paper's experiments on open-weight models (Gemma-2-9B, Qwen3-8B, Llama-3.1-8B), quality is defined as globally annealed sequence likelihood $\kappa(y) = p(y)^{1/T}$, extracted via a patched vLLM build that logs token probabilities at temperature $T'$ and $T = 1$.

Closed-source models such as Gemini 4 do not expose generator log-probabilities. Without $q(y)$ or $p(y)$, importance-weighted PoolDPP-Sampling cannot be computed. PoolDPP-MAP needs only two external ingredients:

1. **Unit-norm semantic vectors $\phi(y)$** from`gemini-embedding-2` (3072 dimensions, already used by Image Optimizer in`app.dejan.ai` ).
2. **Calibrated scalar quality scores $\kappa(y)$** from`gemini-decision-1` (Google's Decisions API), which evaluates up to 1,000 typed questions against a shared context in a single HTTP request and returns calibrated probabilities $p_i \in (0, 1)$.

Replacing sequence log-probabilities with `gemini-decision-1` changes the quality signal in a useful way: sequence log-probability favors short, high-frequency strings, whereas `gemini-decision-1` scores each candidate directly against a task-specific rubric (buyer realism and specificity for Prompt Generator; editorial originality and site fit for Content Writer).

### Greedy K-DPP MAP in log space

In `modules/prompt_generator/pool_dpp.py`, we run the greedy MAP algorithm directly on the quality-scaled residuals without forming an $N \times N$ Gram matrix. Setting $\log s_i = \beta \log p_i$ (where $p_i$ is the `gemini-decision-1` probability clipped to $[10^{-6}, 1]$ and $\beta$ controls quality strength), each step selects:

Here $r_i$ is the component of $\phi(y_i)$ orthogonal to all previously selected vectors. After picking $i^*$, every remaining residual is updated in one rank-1 Gram-Schmidt step:

$$v = \frac{r_{i^*}}{\|r_{i^*}\|_2}, \qquad r_j \leftarrow r_j - (r_j^\top v)\,v$$
Selecting $K = 20$ items from $N = 100$ vectors in 3072 dimensions takes under 10 milliseconds on CPU in NumPy.

### Content Library repulsion via conditional orthogonal projection

For Content Writer (`modules/content_agent/subject_dpp.py`), preventing overlap within a single batch is only half the requirement; new articles must also stay clear of topics already in the property's Content Library.

Before running `greedy_map`, we fetch up to 100 recent own-content titles for the property (from `outreach_articles` in website mode and manual `content_entries`), embed them alongside the candidate `{title, angle}` pairs, and compute an orthonormal basis $Q$ for the library span via thin SVD (retaining singular values above $10^{-6}$). Projecting each candidate onto the orthogonal complement gives:

The projected vectors are passed into `greedy_map` **without re-normalization**. Because `greedy_map` folds $\log \|r_i^{(0)}\|_2$ into $\log s_i$, a candidate that closely mirrors an existing Library article starts with $\|r_i^{(0)}\|_2 \approx 0$ and receives a large negative log-volume penalty, while a candidate orthogonal to the Library starts with $\|r_i^{(0)}\|_2 \approx 1$ and pays no penalty. This is exact conditional K-DPP MAP inference given the existing Library.

## Parameter sweep: choosing defaults

To select default values for the pool multiplier ($N / K$) and quality weight ($\beta$), we ran a nested sweep across all three input modes on `dejan.ai` ($K = 20$), evaluating multipliers 1× through 5× and $\beta \in \{0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0\}$ on the same generated pools.

| Config ($K = 20$, 3-mode average) | Avg Log-Det | Avg Cos Dist | Total Pairs > 0.80 | Avg Quality | Worst Min Quality | 
|---|---|---|---|---|---|
| 1× baseline (single-shot) | -22.431 | 0.3068 | 38 | 0.9011 | 0.5605 | 
| 2×, $\beta = 1.0$ | -21.504 | 0.3162 | 12 | 0.9288 | 0.8253 | 
| 3×, $\beta = 1.0$ | -21.139 | 0.3217 | 14 | 0.9301 | 0.8253 | 
| 4×, $\beta = 1.5$ | -21.212 | 0.3205 | 8 | 0.9382 | 0.8253 | 
| 5×, $\beta = 1.0$ | -20.692 | 0.3279 | 5 | 0.9346 | 0.8453 | 
| **5×, $\beta = 1.5$ (production default)** | **-21.135** | **0.3214** | **4** | **0.9418** | **0.8865** | 
| 5×, $\beta = 2.0$ | -21.280 | 0.3210 | 7 | 0.9435 | 0.8865 | 
| 5×, $\beta = 4.0$ | -22.124 | 0.3099 | 18 | 0.9503 | 0.8999 | 

At $\beta \ge 3.0$ on 2× to 4× pools, quality weighting overpowered volume repulsion and pushed `Avg Log-Det` below the 1× baseline. Production defaults are set to $\beta = 1.5$ in both tools, with a 5× pool for Prompt Generator at $K \le 20$ (3× at $K \ge 50$) and a 4× pool (12 to 20 subjects) for Content Writer.

## Cost, latency, and implementation scope

Every extra stage in PoolDPP-MAP is metered through the existing `app.dejan.ai` credit ledger (own-key BYO properties ride their own Google API key and are not charged platform credits).

| Component | Model | List Rate | Typical Cost ($K = 20, N = 100$) | Measured Latency | 
|---|---|---|---|---|
| Candidate pool (Prompt Generator) | `gemini-4-hydrogen` | $1.50 / 1M in, $7.50 / 1M out | ~$0.03–$0.04 (5 batches, 2-way parallel) | 25–35 s | 
| Candidate pool (Content Writer) | Antigravity agent | ~$0.20 per Subject pick | ~$0.20 (same single picker call) | ~60 s | 
| Embeddings | `gemini-embedding-2` | $0.20 / 1M input tokens | ~$0.0005 (~2.5k tokens) | 3.3–4.3 s | 
| Quality scoring | `gemini-decision-1` | $0.10 / 1M input tokens, $0 out | ~$0.0005 (~5k tokens, 1 call) | 0.4 s | 
| Greedy K-DPP MAP + SVD | Local NumPy (CPU) | $0 | $0 | < 0.01 s | 

PoolDPP-MAP selects only from candidates present in the generated pool. On broad inputs (Project Context and Website URL), 5× sampling eliminated all pairs above 0.80 cosine similarity; on a narrow single entity (`ai seo agency`), 4 to 5 pairs above 0.80 remained because all five pool batches shared the same prompt template. All measurements above were collected on property 82 (`dejan.ai`) using `gemini-4-hydrogen`, `gemini-embedding-2`, and `gemini-decision-1` on 24 November 2026.
