---
title: 'SelectCopy: Controlled Copying in Deep Models'
url: https://www.emergentmind.com/topics/selectcopy
type: topic
---

# SelectCopy: Controlled Copying in Deep Models

Searching arXiv for the core paper and adjacent copying-mechanism work to ground the article in current arXiv metadata.
{"query":"1603.06393 CopyNet copying mechanism sequence-to-sequence learning", "max_results": 5}
“SelectCopy” (*Editor’s term*) denotes a family of computational mechanisms that arbitrate between copying an existing structure and producing an output by generation, transformation, inference, or recomputation. In neural sequence modeling, the copied unit is typically a token or span from an input sequence; in vision it may be an object label, an image region, a text-placement box, or a block of intermediate features; in data fusion it is a shared value that signals source dependence; in software security it is the reachable object graph allowed to remain shared after cloning; and in quantum algorithms it is a table entry coherently loaded into a register. The common technical problem is not copying alone, but controlled copying under structural, probabilistic, or semantic constraints [1603.06393] [1903.06763] [2108.09376] [1204.4322] [2605.20334].

## 1. Scope and recurring decision structure

Across the literature, selective copying is defined by three recurrent questions: what may be copied, when copying should dominate over generation or fresh computation, and how copied content interacts with a broader model state. In CopyNet, the alternatives are generation from a fixed vocabulary and copying from source positions under a single shared softmax normalizer; in span-copy editing, the alternatives are single-token generation and whole-span copy actions; in image captioning for novel objects, the alternatives are standard language-model emission and copying object names supplied by external visual classifiers [1603.06393] [2006.04771] [1708.05271].

Outside text generation, the same structure reappears with different objects. Copyspace detection treats text placement on images as selecting rectangular regions that satisfy compositional and legibility constraints rather than generating text itself. Context-aware copy-paste selects source content and target placements by caption-based semantic matching, object detection, mask extraction, and compositing constraints. BlockCopy selects spatial blocks to recompute and copies cached features elsewhere. Enterprise document extraction treats repetitive, template-based documents as a “copy-heavy” regime in which structure-aware routing minimizes generative decoding. Deep-Web truth finding treats a shared rare false value as evidence that one source copied another [2012.08933] [2407.08151] [2108.09376] [2510.10138] [1503.00309].

A plausible implication is that selective copying is best understood as an arbitration layer between reuse and reconstruction. The arbitration variable may be explicit, as in pointer-generator gates or reinforcement-trained execution policies, or implicit, as in CopyNet’s shared-normalizer competition and QROM’s circuit-level replacement of “SelectSwap” by “SelectCopy” [2112.10360] [1603.06393] [2605.20334].

## 2. CopyNet and token-level copying in sequence-to-sequence learning

The canonical neural formulation is CopyNet, which augments the standard attention-based encoder–decoder architecture with an explicit copying pathway. Given input sequence $x=(x_1,\dots,x_n)$ and output sequence $y=(y_1,\dots,y_m)$, a bidirectional RNN encoder produces hidden states $\mathbf{h}_i$, and an RNN decoder with state $\mathbf{s}_t$ attends to the encoder to compute $\mathbf{c}_t$. At step $t$, the decoder scores two competing emission modes: generation over a fixed vocabulary $V\cup\{\text{unk}\}$ and copying over source positions $1,\dots,n$. The key design is a single shared partition function $Z_t$ across both modes, so the selector is implicit rather than an explicit sigmoid gate [1603.06393].

For candidate token $y$, the emission probability is
$$
P(y_t = y \mid y_{<t}, x)
=
\mathbb{I}[y\in V\cup\{\text{unk}\}]
\frac{\exp(\psi_{\text{gen}(y)})}{Z_t}
+
\sum_{i:\,x_i=y}
\frac{\exp(\psi_{\text{copy}(i)})}{Z_t}.
$$
Because probability mass for duplicate source symbols is summed over positions, collisions are handled automatically: if a token is both in the fixed vocabulary and in the source, both terms contribute. The emergent mode probabilities $p_{\text{gen}}(t)$ and $p_{\text{copy}}(t)$ are the normalized masses of the two groups and satisfy $p_{\text{gen}}(t)+p_{\text{copy}}(t)=1$ [1603.06393].

A distinctive feature is the selective read $\zeta(y_{t-1})$, which feeds the decoder not only the embedding of the previously emitted token but also a position-weighted summary of source locations where that token occurred. The decoder update uses
$$
\mathbf{s}_t=\mathrm{RNN}\big(\mathbf{s}_{t-1},\; [E(y_{t-1});\zeta(y_{t-1})],\; \mathbf{c}_t\big).
$$
This mechanism does not explicitly score spans, but it biases the state toward copying contiguous subsequences: after copying from location $\ell$, the next step is biased toward $x_{\ell+1}$. The model therefore combines semantically driven attention $\mathbf{c}_t$ with location-aware selective read $\zeta(\cdot)$, permitting both multi-token contiguous copying and jumps to new source regions [1603.06393].

CopyNet is trained end-to-end by maximum likelihood over the mixture distribution,
$$
\mathcal{L}=-\sum_{(x,y)}\sum_{t=1}^{|y|}\log P(y_t\mid y_{<t},x),
$$
with no supervision for which mode to use. Because copy-mode operates over source symbols, the model can emit OOV or rare words whenever they appear in the input, while generate-mode falls back to $\text{unk}$ for true OOVs. In the reported experiments, CopyNet achieved 93.7–98.3% exact-match accuracy on synthetic transformation rules requiring copying $x$ or $xx$, improved Chinese short-text summarization on LCSTS from approximately $26.8/16.1/24.1$ to approximately $35.0/22.3/32.0$ in ROUGE-1/2/L for word-based modeling, and raised dialogue accuracy on DS-II from $13.5\%/15.9\%$ to $50.5\%/64.8\%$ for Top-1/Top-10. The paper also notes two limitations: the mechanism copies surface forms and is therefore not directly applicable to cross-lingual tasks without modification, and it does not include ablations isolating the selective read from the shared-normalizer mixing [1603.06393].

## 3. Supervised gates, span actions, and novel-object captioning

Later work refined token-level copying in two directions: by supervising the copy/generate decision and by enlarging the copied unit from a token to a span. In the enhanced supervised-copy method, a Transformer encoder plus LSTM decoder pointer-generator model retains the standard mixture
$$
p(y_t = w)=p_{\text{gen}}P_{\text{vocab}}(w)+(1-p_{\text{gen}})\sum_{i:x_i=w}\alpha_{t,i},
$$
but adds explicit supervision to both attention and the gate. The timestep loss is
$$
loss^t = loss^t_{\text{vocab}} + loss^t_{\text{attn}} + loss^t_{p_{\text{gen}}},
$$
where $loss^t_{\text{attn}}=-\log\big(\sum_{i:x_i=w_t^*}\alpha_{t,i}\big)$ for copy-candidates and $loss^t_{p_{\text{gen}}}$ is defined either by Force-copy or by Force-copy-unk. Force-copy drives $p_{\text{gen}}$ low whenever the gold token appears in the source; Force-copy-unk does so only when the token is both in the source and OOV with respect to the target vocabulary. On CNN/DailyMail, Force-copy-unk reached ROUGE-1/2/L of $39.31/17.13/36.25$ versus $38.66/16.97/35.61$ for the re-implemented PGNet baseline, increased copy precision from $47.80\%$ to $48.84\%$, and raised novel $n$-gram rates from $0.25/5.37/11.45/16.85$ to $0.28/6.62/13.60/19.54$. On RotoWire, FCU achieved RG precision $95.40$ with $27.37$ unique extracted relations. The paper also reports that Force-copy tends to over-copy, whereas Force-copy-unk uses vocabulary size as a control knob over copy versus abstractness [2112.10360].

A more radical extension is to make the action space itself span-aware. “Copy that! Editing Sequences by Copying Spans” introduces generate actions $a=\{t\}$ and copy-span actions $a=\{i\}\{j\}$ that emit the contiguous subsequence $x_i\dots x_{j-1}$ in one step. Because many action sequences can produce the same output, training marginalizes over all valid derivations with a backward dynamic program:
$$
p\big(y[k:] \mid y[:k]\big)
=
\sum_{\substack{a,\ |a|=\ell\\ \llbracket a \rrbracket = y[k:k+\ell]}}
q(a\mid y[:k])\,
p\big(y[k+\ell:] \mid y[:k+\ell]\big).
$$
Span scores are computed from boundary encoder representations via
$$
s_{k,[i:j]}=\big(W\cdot(e_i\Vert e_{j-1})\big)\cdot h_k^\top.
$$
This formulation reduces the number of decisions on edit-heavy tasks where most of the input is unchanged. Reported gains include WikiAtomicEdits accuracy $78.1\%$ versus $67.8\%$ for a token-copy baseline, GitHubEdits $67.4\%$ versus $64.4\%$, C\# Fixers one-shot $24.2\%$ versus $18.8\%$, and code-repair accuracy $17.7\%$ versus $14.8\%$ on BFP-small [2006.04771].

Image captioning for novel objects instantiates a related but multimodal variant. LSTM-C combines a standard LSTM language model with a copying distribution over an external object lexicon $W_c$, using detector or classifier confidences $\delta(w)$ in the copy logits
$$
s_t^c(w)=[\phi(w^\top M_c)]\,h^t \cdot \delta(w).
$$
The final probability over $W=W_g\cup W_c$ mixes generation and copying with a fixed scalar $\lambda$, set to $0.2$ in most experiments. Unlike pointer-generator networks, there is no dynamic $\lambda_t$; copy selection arises from the relative logits and the fixed trade-off. On held-out MSCOCO, LSTM-C with One-hot+GloVe achieved METEOR $23.0$ and average F1 $55.66$, compared with METEOR $20.7$ and F1 $51.85$ for NOC. On ImageNet with external text from BNC+Wikipedia, it reached Novel $89.11$, F1 $33.64$, and Accuracy $31.11$, outperforming NOC’s $87.69$, $31.23$, and $21.96$ [1708.05271].

## 4. Image layout, copy-paste, and compositing

In vision, selective copying often concerns where content should be placed and how copied content should be harmonized. Copyspace detection formulates the placement of text over an image as an object-detection problem over expert-labeled rectangular regions. The dataset contains 20,000 license-free Unsplash images labeled by a team of experts and stratified into four difficulty classes. The paper evaluates YOLOv4, YOLOv5 variants, and Faster R-CNN using mAP@0.5, mAP@0.5:0.95, and average IoU. YOLOv5x at $640\times 640$ reached mAP@0.5 $34.2$, mAP@0.5:0.95 $27.2$, and IoU $64.4$; YOLOv5s reached $30.1/23.3/88.0$; Faster R-CNN reached $26.4/16.3/82.1$. Performance degrades sharply with complexity: for YOLOv5x, mAP@0.5 falls from $76.2$ in Class 1 to $9.0$ in Class 4. The paper explicitly cautions that “good predictions are sometimes disjoint from annotations,” so IoU and mAP undercount aesthetically valid placements [2012.08933].

Context-aware image augmentation addresses a different problem: selecting semantically compatible source content and pasting it into a target image without manual annotation. The CACP pipeline uses BLIP to caption a source image, BERT cosine similarity to rank category names, YOLO-365 to localize candidate objects in gallery images, Grad-CAM to derive point prompts, and SAM to extract masks. The paper reports that Grad-CAM-assisted prompts improve mask quality from bbox $0.734$ to $0.927$ with one CAM point and to $0.934$ with three CAM points. On downstream tasks, CACP outperforms random copy-paste and standard augmentation: on Cats vs Dogs, accuracy rises to $0.969$ with CACP and $0.974$ with CACP+aug; on CamVid, mIoU rises to $0.929$ and $0.938$; on CityPersons detection, mAP@0.5 rises to $0.577$ and $0.591$. The reported GPU cost per image pair is approximately $1137$ ms for BLIP, $12$ ms for YOLO, and $498$ ms for SAM, for a total of approximately $1647$ ms [2407.08151].

“Smart, Deep Copy-Paste” treats harmonization itself as the central copying problem. It receives a source image $S$, a target image $T$, and mask $M$, forms the naive composite
$$
C=M\circ S + (1-M)\circ T,
$$
and predicts a residual $\delta=G((C,M))$ so that the final result is
$$
R=M\circ(S+\delta)+(1-M)\circ T.
$$
Training is self-supervised: from a single image $I$, the method constructs transformed source content using a geometric homography $T_{\text{geometric}}$ and a locally varying photometric transform $T_{\text{shading}}$, then reconstructs the original image with an $L_1$ loss plus conditional WGAN-GP. The reported hyperparameters are $\alpha=10^{-4}$ and $\gamma=10^{-3}$ in the total objective, with ADAM $\beta_1=0.0$, $\beta_2=0.9$, learning rate $2\times 10^{-4}$, batch size $5$, and $250$k iterations. The method is demonstrated on $21$k face images at $512\times512$ and on Cityscapes, and the paper attributes its behavior to learning to correct shading and moderate geometric inconsistency rather than to explicit flow or homography prediction [1903.06763].

## 5. Spatially selective computation and copy-heavy document extraction

Selective copying can also reduce computation by copying intermediate representations rather than output symbols. BlockCopy partitions feature maps into spatial blocks and trains a lightweight policy network to decide, for each block and frame, whether to execute or copy. For selected blocks, block-sparse convolutions with halo padding recompute features; for non-selected blocks, the previous frame’s features are reused directly. The policy observes the current frame $I_t$, previous frame state $H_{t-1}$, previous output $O_{t-1}$, and previous execution grid $A_{t-1}$, and is trained online with REINFORCE using a reward
$$
R_b(a_b)=R_{\text{IG}}(a_b)+\gamma R_{\text{cost}}(a_b),
$$
with $\gamma=5$ and momentum $\mu=0.9$ in the smoothed cost term. On CityPersons with CSP and target $\tau=0.3$, GMACS drop from $1128$ to $393$, runtime from $0.330$ s/frame to $0.151$ s/frame, and miss rate on the Reasonable split changes from $11.0\%$ to $11.4\%$. For Mask R-CNN on Cityscapes, BlockCopy with $\tau=0.3$ roughly halves FLOPs, increases FPS from $6.7$ to $11.0$, and drops validation AP by about $0.9$ [2108.09376].

Enterprise-scale document extraction reframes “copy-heavy” as a structure-aware routing problem over repetitive documents. The hybrid OCR–LLM framework evaluates direct, replacement, and table-based extraction over PNG, DOCX, XLSX, and PDF using PaddleOCR, EasyOCR, Docling, MinerU, MarkItDown, Qwen2.5-7B, and Qwen2.5-VL-7B. Table-based extraction minimizes generation by having the LLM emit only structure metadata such as header-to-column mappings and row ranges, after which a deterministic parser extracts contents. On structured documents, table-based methods reach F1 $=1.0$ with $0.97$ s average latency; on PNG images with PaddleOCR table-based extraction, F1 is $0.997$ at approximately $0.6$ s; the multimodal PNG baseline reaches F1 $0.999$ but requires approximately $33.9$ s; Docling-based PDF table extraction reaches F1 $1.0$ at approximately $1.6$ s; EasyOCR table extraction on PNG and MinerU replacement on PDF both yield F1 $=0.0$. The framework’s central claim is that repetitive structure permits “copy-first” extraction with minimal LLM decoding [2510.10138].

A shared principle emerges across BlockCopy and enterprise extraction: copying is operationally useful when the system can preserve alignment. BlockCopy preserves alignment through cached block coordinates and halo padding; table-based document extraction preserves alignment through row and column structure. A plausible implication is that selective copying remains stable when geometry or schema is explicit, and degrades when those coordinates are lost, as in OCR outputs that fail to preserve spatial structure [2108.09376] [2510.10138].

## 6. Source dependence, secure cloning, retrieval arbitration, and QROM

In structured data fusion, copying becomes a latent dependency relation among sources. “Scaling up Copy Detection” assumes single truth per item, $n>1$ false values per item, item independence, copy selectivity $s$, and prior copying probability $\alpha$ with $\beta=1-2\alpha$. For two sources $S_1,S_2$ and observations $\Phi$, the posterior probability of independence is
$$
Pr(S_1 \perp S_2 \mid \Phi)
=
\frac{1}{1+(\alpha/\beta)\big(\exp(C^\rightarrow)+\exp(C^\leftarrow)\big)}.
$$
Shared rare false values contribute strongly positive evidence for copying, while differing values contribute the constant negative term $\ln(1-s)$. The scalability contribution is an inverted index over shared values $D.v$, processed in decreasing order of their contribution upper bound $C(E)$, with pruning, early termination, incremental updates, and optional sampling. The reported speedup is two to three orders of magnitude over naive pairwise copy detection, while truth-finding quality remains essentially unchanged and copy-detection precision/recall stays high, with examples including precision at least $0.985$ and recall at least $0.947$ [1503.00309].

In secure object-oriented programming, copying is constrained by policy rather than by probability. “Secure the Clones” introduces type-based annotations such as `@Shallow`, `@Deep`, and `@Copy(X)` to specify the maximally allowed sharing between an object and its clone. The semantics require that any location reachable from the result by following only deep-annotated fields be disjoint from any value reachable from pre-existing caller variables. The analysis uses graph-shaped types $T=(\Gamma,\Delta,\Theta)$ with strong and weak nodes, proves monotonicity of stronger policies, and establishes soundness in Coq: if a program is well typed, all declared copy methods satisfy their copy policies. The paper also notes a limitation: subclasses may add new fields not constrained by the superclass policy, motivating possible “deep-all-except” extensions [1204.4322].

Retrieval-augmented generation exposes another arbitration problem: whether a language model should copy from the prompt context or recall from parametric memory. “To Copy or Not to Copy” constructs an arbitration vector $\mathbf{v}_{\ell,k}$ as the residual-stream centroid difference between irrelevant contexts that elicit recall and relevant-but-false contexts that elicit copying. Intervening with
$$
\tilde{\mathbf{h}}_{\ell,t}
=
\mathbf{h}_{\ell,t}
+
\alpha \mathbf{v}_{\ell,k}
$$
steers behavior in two directions. Copy$\rightarrow$Recall uses $\alpha=+30.0$ at early-to-middle layers and succeeds only when injected at counterfactual object tokens; Recall$\rightarrow$Copy uses $\alpha=-3.0$ at middle-to-late layers and succeeds from object, subject, or last-token locations. On PopQA, Copy$\rightarrow$Recall recovers to $66\%$ EM for Gemma2-2B and $74\%$ for T5Gemma-2B, while Recall$\rightarrow$Copy raises copying EM to $34\%$ and $46\%$; similar asymmetries appear on PEQ. The mechanistic conclusion is that inducing copying is an easier “reactivation” process than restoring recall, which behaves as a fragile suppression process [2601.12075].

At the hardware level, selective copying becomes a circuit optimization. “Halving the cost of QROM” replaces the dirty-ancilla SelectSwap architecture with SelectCopy. For a table of $N$ entries, entry width $b$, and bucket parameter $\lambda$, the dirty-ancilla SelectSwap cost is
$$
2\frac{N}{\lambda}+4b(\lambda-1),
$$
whereas SelectCopy reduces this to
$$
2\frac{N}{\lambda}+2b(\lambda-1)+2\lambda-6.
$$
A further bit-packet construction yields
$$
C_\alpha
=
\left(1+\frac{1}{\alpha}\right)\frac{N}{\lambda}
+
\left(b+\frac{b}{\alpha}\right)(\alpha\lambda-1)
+
(\alpha+1)(\alpha\lambda-3),
$$
interpolating the leading prefactor on $N/\lambda$ from $2$ down to $1+1/b$. For $\alpha=b$ and regimes where $N\gg b^2\lambda^2$, the paper reports an effective reduction of approximately $50\%$ in the dominant term, matching clean-qubit QROM performance with dirty qubits for practical values of $b$ [2605.20334].

## 7. Evaluation, trade-offs, and unresolved questions

A persistent issue across selective-copy systems is that standard metrics often observe only one aspect of correctness. Copyspace detection uses mAP and IoU even though many valid placements may be disjoint from the annotation. CopyNet shows strong empirical results but does not isolate the contributions of selective read and shared-normalizer mixing. Force-copy improves factual extraction but can reduce abstractness, whereas Force-copy-unk improves ROUGE and novel $n$-grams but depends on vocabulary size. RAG arbitration succeeds at moderate scaling but large $|\alpha|$ values spike perplexity and degrade fluency [2012.08933] [1603.06393] [2112.10360] [2601.12075].

Another recurrent limitation is that copying usually preserves surface form rather than semantic equivalence. CopyNet copies source tokens verbatim and is therefore not directly suited to cross-lingual translation without modification. LSTM-C copies detector labels as single tokens and does not explicitly handle singular/plural variation or multi-word object names. Context-aware copy-paste can fail under domain shift, thin structures, or missed detections. Enterprise document extraction depends critically on structure preservation by OCR or parsers, with catastrophic failures when that assumption breaks. Secure object cloning currently constrains only the fields named in a policy, not arbitrary future fields introduced by subclasses [1603.06393] [1708.05271] [2407.08151] [2510.10138] [1204.4322].

These results suggest that selective copying is most effective when the copied unit has an explicit address: a source position, a span boundary pair, a detected object label, a table cell, a block coordinate, a policy-annotated field, or a bucketed QROM address. When alignment is explicit, copying reduces uncertainty, compute, or latency; when alignment is weak, the system must reintroduce semantics through attention, gating, constraints, or expert annotation. That pattern links CopyNet’s selective read, span-copy marginalization, BlockCopy’s execution masks, enterprise table extraction, Deep-Web copy evidence, and QROM SelectCopy into a single computational theme: copying is a structured decision, not merely a retrieval primitive [2006.04771] [2108.09376] [1503.00309] [2605.20334].

Source: https://www.emergentmind.com/topics/selectcopy