---
title: Memory Demonstration Templates in Research
url: https://www.emergentmind.com/topics/memory-demonstration-templates-mdt
type: topic
---

# Memory Demonstration Templates in Research

Memory Demonstration Templates (MDT) is an acronym used in multiple research settings to denote templated mechanisms that incorporate “memory” as a reusable structural resource rather than as an ad hoc feature. In few-shot continual learning named entity recognition (FS-CLNER), MDT denotes replay-based demonstration prompts appended to each training instance so that old-class evidence remains available during prompt tuning and knowledge distillation [2508.07248]. Closely related demonstration templates for low-resource NER append entity- or instance-level exemplars to the input sequence for in-context learning without converting NER into span-wise cloze prediction [2110.08454]. In accelerator design, MDT denotes the demonstrative instantiation of a domain-specific memory template specialized by a compiler flow [2104.01448]. A further guide-style usage organizes the description of a memory-assisted quantum communication experiment based on a solid-state spin memory and asynchronous Bell-state measurements [1909.01323].

## 1. Scope of the term

The acronym appears in distinct technical domains, and its meaning is field-dependent rather than standardized.

| Context | MDT meaning | Core elements |
|---|---|---|
| FS-CLNER | Memory Demonstration Templates | Replay prompts, anchors, KD |
| Low-resource NER | Demonstration templates used as memory-like exemplars | [SEP]-appended demos, CRF decoding |
| Accelerator design | Demonstrative instantiation of a domain-specific memory template | PLMs, caches, DMA, compiler specialization |
| Quantum communication | Guide-style template for a memory-enhanced communication experiment | SiV spin memory, asynchronous BSM |

In the FS-CLNER setting, MDT is defined as a lightweight, replay-based demonstration prompt added to every training instance during incremental tasks. In low-resource NER, the relevant construct is a demonstration sequence $D$ appended to the input sentence $x$ so that the model computes token representations from $[x;D]$ and then decodes only the original sentence tokens. In the compiler setting, MDT operationalizes a reusable memory macro-architecture that can be specialized through compilation passes. In the quantum setting, the supplied MDT guide functions as a structured template for reporting a memory-enhanced protocol rather than as a prompt or compiler abstraction [2508.07248] [2110.08454] [2104.01448] [1909.01323].

A common misconception is to treat MDT as a single method. The record instead shows acronym reuse across quantum networking, compiler infrastructure, and prompt-based NER. This suggests that MDT functions as a cross-domain shorthand for templated memory augmentation, but the instantiated mechanisms, objectives, and evaluation criteria differ substantially.

## 2. MDT in few-shot continual learning named entity recognition

In FS-CLNER, the task is a sequence of $T$ NER tasks with non-overlapping entity type sets, with datasets $\{D^1,\dots,D^T\}$ and entity type sets $\{E^1,\dots,E^T\}$ satisfying $E^i \cap E^j = \varnothing$ for $i \ne j$. $D^1$ is a base dataset, while $D^t$ for $t>1$ are few-shot; after finishing task $t$, the model must recognize all types seen so far $\{E^i\}_{i=1}^t$. The motivation for MDT is the “Few-Shot Distillation Dilemma”: standard knowledge distillation depends on teacher outputs for old-class entities present in current-task inputs, but few-shot new-task data rarely contains old-class mentions, so the distillation signal becomes weak precisely when catastrophic forgetting is most likely [2508.07248].

MDT addresses this by injecting explicit old-class evidence into every incremental-task example. The core format is the entity-oriented template `"[Entity] belongs to [ANCHOR]."` and the corresponding target template `"[ANCHOR] belongs to [ANCHOR]."` Here $\xi$ is a representative entity word set for an old class, and $A(e)$ is the anchor word representing that entity type. For a current-task instance $(X_i^t,Y_i^t)$, the augmented input and target are
$$(X'_i)^t = [X_i^t, T_1, \dots, T_r],$$
$$(\tilde{X}'_i)^t = [\tilde{X}_i^t, \tilde{T}_1, \dots, \tilde{T}_r].$$
Per training instance, for each old class $e \in E^{<t}$, the method samples $r$ demonstrations by randomly choosing $\epsilon \in \xi(e)$ and emitting `"[ε] belongs to [A(e)]."` The experiments set the number of demonstrations per old class to $r=2$, and the examples provided use representative set size $K=6$.

The demonstrations are coupled to Anchor words-oriented Prompt Tuning (APT). For each entity type $e$, the anchor embedding is
$$E(A(e)) = \frac{1}{K}\sum_{\epsilon \in \xi(e)} E(\epsilon).$$
NER is then reformulated as masked language modeling over the base vocabulary plus dynamically added anchor tokens. For a token $x_i^{t,j}$ labeled $e_t^n$, the target sequence $\tilde{X}_i^t$ replaces that token by $A(e_t^n)$. With encoder output $H_i^t$, logits are computed by
$$z_i^{t,j} = W_{\mathrm{MLM}} h_i^{t,j} + b_{\mathrm{MLM}},$$
and the prompt-tuning loss is
$$L_{PT} = -\frac{1}{N_i}\sum_{n=1}^{N_i}\sum_{m=1}^{|V|+c_t} \mathbf{1}(\tilde{x}_i^{t,n}=m)\cdot \log P(\tilde{x}_i^{t,n}=m \mid X_i^t).$$
Knowledge distillation uses a teacher $M^{t-1}$ and student $M^t$ on the MDT-augmented input, with KL divergence
$$L_{KD} = \frac{1}{N_i}\sum_{n=1}^{N_i}\sum_{m=1}^{|V|+c_t} P_{M^{t-1}} \cdot \log\!\left(\frac{P_{M^{t-1}}}{P_{M^t}}\right),$$
and the total objective is
$$L_{tot} = \alpha L_{KD} + \beta L_{PT}.$$
At inference time, MDT is not used; decoding is single-pass and anchor-based:
$$P(y_i^{t,j}=e \mid X_i^t) = P(x_i^{t,j}=A(e) \mid X_i^t).$$

Empirically, the method reports competitive performance on FS-CLNER. On CoNLL2003, macro F1 for the proposed method is 68.21, 64.96, and 63.54 at steps 2, 3, and 4 in the 5-shot setting, with $\mathrm{Avg}_{\ge 2}=65.57$, and 70.03, 66.37, and 64.88 in the 10-shot setting, with $\mathrm{Avg}_{\ge 2}=67.09$. The ablation “w/o MDT” reduces $\mathrm{Avg}_{\ge 2}$ from 65.57 to 54.82 in 5-shot and from 67.09 to 60.89 in 10-shot. The paper also reports that anchor-oriented MDT outperforms entity-only MDT, indicating that explicit alignment with anchor words contributes materially to in-context guidance. The implementation uses `bert-base-cased`, the original MLM head, no CRF, anchor tokens added to the vocabulary, Adam with encoder learning rate $1\mathrm{e}{-4}$, 5 epochs and batch size 32 at the base stage, and 20 epochs with batch size 2 and the first 9 BERT layers frozen in few-shot stages.

## 3. Demonstration templates in low-resource NER

A closely related line of work studies demonstration-based learning for low-resource NER by augmenting the original input sentence with demonstrations rather than recasting NER as cloze-style span classification. Let $x=[x^{(1)},\dots,x^{(n)}]$ be a sentence, $y=[y^{(1)},\dots,y^{(n)}]$ BIOES tags, and $D$ the demonstration sequence. The model forms a single sequence with a separator token, computes $h=\mathrm{embed}([x;D])$, and estimates
$$p_\theta(\mathbf{y}\mid \mathbf{x},D)\equiv p_\theta(\mathbf{y}\mid \mathbf{h}).$$
Training minimizes the conditional negative log-likelihood, and CRF decoding preserves token-label dependencies that cloze-style formulations omit [2110.08454].

The work instantiates several exact template variants. Entity-oriented no-context demonstrations use `"e is l."` Context demonstrations use `"s. e is l."` Lexical demonstrations replace the entity span $e$ in $s$ by its label string $l$ and show only the modified sentence. Instance-oriented context demonstrations use `"s. e1 is l1. … en is ln."` and instance-oriented lexical demonstrations show $s$ with all entities replaced by their label strings. Additional variants include `context-all`, `lexical-all`, `structure`, and `structure-all`, with the structure format replacing entities by `"[ e | l ]"`. Multiple demo items are concatenated with `[SEP]`, and the model decodes only the original sentence tokens, not the demonstration tokens.

The selection strategy is a major part of the method. Entity-oriented demonstrations can be chosen by `random`, `popular`, or `search`. The `popular` strategy fixes one frequent entity per label for all inputs. The `search` strategy collects top-$k$ frequent entities per label and grid-searches over the $k^{|L|}$ combinations to maximize development F1, yielding a single global demonstration. Instance-oriented retrieval uses SBERT sentence similarity or BERTScore token-level similarity. The main empirical finding is a consistency principle: fixed demonstrations outperform variable per-instance demonstrations, context and lexical templates outperform no-context templates, and using demonstrations in training but omitting them at inference degrades performance below the fine-tuning baseline. Different label orders all improve over baseline, but no single order has a consistent advantage; the important condition is that order remain fixed across the dataset.

The reported gains are substantial in low-resource settings. On CoNLL03 with `bert-base-cased` and a CRF, the no-demo baseline is $52.72 \pm 2.44$ F1 in the 25-shot setting and $62.75 \pm 0.98$ in 50-shot. Best MDT variants reach up to $57.00 \pm 4.03$ at 25-shot and $65.11 \pm 2.71$ at 50-shot. On Ontonotes, the baseline is $38.97 \pm 4.62$ at 25-shot and $54.51 \pm 3.27$ at 50-shot, while best MDT variants reach up to $45.74 \pm 5.57$ and $59.00 \pm 3.27$. In domain adaptation, transferring only the embedder from a source model and then fine-tuning with demonstrations yields Ontonotes 50-shot $69.98 \pm 1.63$ versus a transfer baseline of $66.44 \pm 1.75$, and BC5CDR 50-shot $63.55 \pm 1.58$ versus $62.10 \pm 1.01$. The abstract summarizes the improvement as 4–17% on 25 train instances.

Conceptually, this line of work provides a precursor to the FS-CLNER version of MDT. Both approaches use appended natural-language exemplars as structured memory, but the low-resource NER setting keeps the focus on sequence labeling with a CRF and on train–test consistency of demonstrations, whereas the FS-CLNER setting explicitly couples templates to continual learning, anchor words, and teacher–student distillation.

## 4. MDT as compiler-specialized memory architecture

In compiler and accelerator research, MDT denotes the practical, demonstrative instantiation of a domain-specific memory template. The underlying template is a reusable memory macro-architecture for accelerators, intended to replace one-off hand-crafted memory subsystems with a structured hierarchy that can be specialized for each workload. The template includes on-chip private local memories with multi-bank and multi-port configurations, data reuse buffers, scratchpads, local caches or coherent shared caches with the CPU via a protocol such as OpenESP-like coherency, off-chip DRAM and non-volatile memories, DMA engines, intelligent prefetchers, multi-channel memory controllers, address generators, latency-insensitive interfaces for irregular accesses, and optional near-memory functions such as encryption or matrix transpose [2104.01448].

The specialization flow is multi-level and compiler-driven. LLVM/MLIR is used as the IR substrate, with custom MLIR passes that capture data organization, layouts, access patterns, and lifetimes. HDL generation leverages a memory generator, Mnemosyne, driven by compiler decisions, and the explanation notes a possible future interface to CIRCT. The accelerator logic is produced by HLS, with the example pathway interfacing LLVM IR to Xilinx Vitis HLS. The flow proceeds through data organization, layout, communication, local partitioning, and HLS phases. In data organization, the compiler decides which datasets stay on-chip versus off-chip and classifies accesses as regular or irregular. In layout, it applies tiling, partitioning, data-layout reorganization, and sharing of physical memories for disjoint lifetimes. In communication, it configures DMA, prefetch, burst sizes, queues, and multi-channel controllers. In local partitioning, it binds the multi-bank architecture, ports, interleaving, and buffer sizes. The HLS phase then consumes an IR already rewritten to reflect the memory decisions.

The target workloads are memory-dominated big data pipelines and machine learning kernels. Regular high-bandwidth kernels map to multi-banked PLMs plus DMA and prefetch; irregular kernels map to latency-insensitive interfaces and potentially coherent caches; mixed workloads combine both. The explanation also identifies template parameters that can be bound incrementally in the IR: banks, ports, sizes, channel counts, cache properties, DMA window size, prefetch schedule, replacement policy, SRAM macro choice, DRAM/NVM timing, bus widths, and protection mechanisms.

The paper’s limitations are explicit. It presents the approach and infrastructure direction but does not include numeric evaluations or formal optimization models. The longer explanation supplements the paper with standard formulations for latency, throughput, bandwidth, capacity, energy, and area, but states that these are consistent with the methodology rather than verbatim from the paper. It likewise describes a plausible pass-based specialization algorithm and a worked GEMM example as demonstrations of how MDT could be used, not as experimentally reported results. The main contribution is therefore architectural and methodological: a memory-first compilation flow that binds application and technology constraints to a reusable template before HLS.

## 5. Guide-style MDT in memory-enhanced quantum communication

A further usage of MDT appears as a guide for structuring the description of a memory-enhanced quantum communication experiment. The underlying experiment realizes memory-assisted MDI-QKD with a single silicon-vacancy electronic spin in diamond integrated in a nanophotonic cavity, where the spin acts as a quantum memory and spin–photon interface enabling asynchronous Bell-state measurements between independently arriving photonic time-bin qubits [1909.01323].

The hardware stack is specified in detail. The memory is a single SiV electronic spin in diamond hosted in a nanophotonic cavity integrated with a waveguide and operated in a dilution refrigerator at 100–300 mK. The optical transition is at approximately 737 nm. Reported cavity parameters are $Q \approx 2\times 10^4$, mode volume $\approx 0.5(\lambda/n)^3$, cavity linewidth $\kappa = 21.6 \pm 1.3\ \mathrm{GHz}$, atom linewidth $\gamma = 0.123 \pm 0.010\ \mathrm{GHz}$, single-photon Rabi frequency $g = 8.38 \pm 0.05\ \mathrm{GHz}$, and cooperativity
$$C=\frac{4g^2}{\kappa \gamma}=105 \pm 11.$$
Spin-dependent reflectivity is strongly asymmetric: $|\uparrow\rangle$ reflects about 94.4% of incident photons, whereas $|\downarrow\rangle$ reflects about 4.1%, with spin-averaged device reflectivity about 0.493. The overall heralding efficiency is $\eta = 0.423 \pm 0.004$. Time-bin qubits are separated by $\delta t = 142\ \mathrm{ns}$, the time-delay interferometer uses about 28 m of fiber with interferometric visibility greater than 99%, and X-basis heralding employs a 1.8 MHz frequency shift. Detection is performed with SNSPDs at a 1 K stage, with detector QE $\gtrsim 0.99$ at 737 nm and overall system detection efficiency about 85%.

The operational principle is an asynchronous Bell-state measurement. Alice’s photonic qubit is stored in the spin via a heralded spin–photon gate, Bob’s photon arrives later within the memory coherence time, a second heralding event occurs, and a final X-basis spin readout completes the measurement. For an input qubit $(|e\rangle + e^{i\phi}|l\rangle)/\sqrt{2}$, the first heralding with outcome $m_1=\pm 1$ teleports the state to
$$\frac{|\uparrow\rangle + m_1 e^{i\phi_1}|\downarrow\rangle}{\sqrt{2}},$$
the second heralding with outcome $m_2=\pm 1$ yields
$$\frac{|\uparrow\rangle + m_1m_2 e^{i(\phi_1+\phi_2)}|\downarrow\rangle}{\sqrt{2}},$$
and the final X-basis spin measurement with outcome $m_3=\pm 1$ yields the BSM parity $m_1m_2m_3$. The protocol buffers independently arriving photons and removes the requirement of simultaneity at Charlie, thereby breaking the linear-optics scaling of direct-transmission MDI-QKD. For unbiased bases, the direct-transmission limit is
$$R_{\max} = \frac{p_{A\to B}}{2},$$
with $p_{A\to B}=\langle n\rangle_p^2$, whereas ideal memory scaling satisfies $R_s \propto \sqrt{p_{A\to B}}$.

The reported performance establishes the experiment’s significance. Initialization fidelity is $0.998 \pm 0.001$, single-shot readout fidelity is $0.9998^{+0.0002}_{-0.0003}$ in 30 $\mu$s, and spin coherence satisfies $T_2 > 0.2$ ms, although practical memory time is about 10–20 $\mu$s per run because of microwave heating at large $N_\pi$. Spin–photon entanglement fidelity reaches $F \ge 0.944 \pm 0.008$ at $\langle n\rangle_m = 0.002$. The average QBER for unbiased random strings is $E = 0.116 \pm 0.002$, below the individual-attack limit $E_i \approx 0.146$–0.147, and an optimized pattern yields $E = 0.097 \pm 0.006$, within the unconditional security threshold $E_u = 0.110$. CHSH violations are reported as $S_+ = 2.21 \pm 0.04$ and $S_- = 2.19 \pm 0.04$. At effective channel loss around 88 dB, the sifted-key rate enhancement is $78.4 \pm 0.7$ over direct transmission, and the distilled secure key rate enhancement reaches $4.1 \pm 0.5$ for $N=124$, with the repeaterless bound $R_S \le 1.44\, p_{A\to B}$ exceeded at 99.2% confidence. The experiment thus serves as a structured demonstration of memory-enhanced quantum communication at megahertz clock rates.

## 6. Comparative themes, limitations, and research directions

Across these uses, MDT consistently denotes a templated mechanism that makes previously unavailable information explicitly accessible at the point of decision. In FS-CLNER, that information is old-class evidence injected into each training instance; in low-resource NER, it is a fixed or retrieved set of demonstrations that influences token representations; in accelerator design, it is a reusable memory hierarchy specialized to workload and technology constraints; in the quantum guide, it is an explicit schema for a protocol whose central resource is an intermediate quantum memory [2508.07248] [2110.08454] [2104.01448] [1909.01323]. This suggests a shared design pattern—memory exposed through templates—despite the absence of a shared formalism.

The limitations are likewise domain-specific. In FS-CLNER, representative words $\xi$ may become suboptimal under domain shift, poor representative sets can harm anchor embeddings and demonstrations, and the number of appended templates grows with the number of old classes, creating sequence-length pressure. In low-resource NER, fixed demos from a mismatched domain may misguide the model, instance retrieval can be noisy because sentence similarity is weak in low-resource regimes, and demonstrations must be present in both training and inference to avoid degradation. In the compiler setting, specialization depends on accurate SRAM, DRAM, and NVM models, extreme irregular workloads may still require manual intervention or cache-dominated designs, and the paper leaves quantitative evaluation and formal optimization open. In the quantum setting, heralding efficiency $\eta \approx 0.423$, multiphoton error from undetected third-photon scattering, microwave-induced heating, routing losses such as the use of a 99:1 beamsplitter, and the current use of a single laser rather than truly independent distant sources remain central bottlenecks.

The forward directions also differ, but each follows directly from the corresponding bottleneck. FS-CLNER proposes refreshing representative sets, capping or rotating class coverage across mini-batches, and extending the approach to other token-level or sequence-level continual learning tasks. Low-resource NER suggests dynamic memory updates, multi-domain banks, automatic template optimization, and hybrid retrieval strategies. The compiler framework points toward tighter integration with hardware IR ecosystems and more automated analyses. The quantum roadmap includes decoy-state protocols, biased bases, finite-key analysis, telecom conversion, low-loss network elements, nuclear-spin memories for longer storage, strain tuning for frequency alignment, and multi-node repeater protocols. Taken together, these trajectories reinforce that MDT is best understood not as a single theory but as a family of template-driven techniques for making memory a first-class operational resource.

Source: https://www.emergentmind.com/topics/memory-demonstration-templates-mdt