Your Institute @yourname Sep 22, 2026

A Paper with Multiple References (demo)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

A long paper sometimes needs more than one bibliography: a main text and an appendix written against a different literature, or two halves of a review whose sources barely overlap. The theme supports that by letting each list name its own file, so each list downloads only its own entries and numbers them from one. This note is written that way on purpose — the first half is about how a model is asked, the second about how it is adapted, and the two halves share no sources.

Part one: how a model is asked

The prompting literature divides along a simple question: what is added to the prompt. The survey of the field \cite{Yu2023-qr} organises it that way, and the empirical study of what actually matters inside a chain \cite{Wang2022-hh} narrows the answer, arguing that the order of the steps and the presence of the question count for more than the fluency of the demonstrations. Both are worth reading before trusting a single reported gain.

The first family changes the shape of the prompt itself. ChainLM \cite{Cheng2024-az} adds a verification stage so that the model checks the chain it has just written; contrastive prompting \cite{Chia2023-cz} supplies wrong chains alongside right ones so the difference is visible; and R³ prompting \cite{Tian2023-bk} reviews and rephrases the question before attempting it. The shared idea is that a chain is a scaffold the model can be handed, not only a trace it produces.

The second family removes the hand-written demonstrations altogether. Synthetic prompting \cite{Shao2023-lx} has the model write its own examples and keeps the ones that solve the task; active prompting \cite{Diao2024-at} selects the questions whose chains would teach the most, one round at a time; and explanation selection \cite{Ye2023-wa} chooses, from many candidate explanations, the one that helps on unlabeled data.

The third family changes what happens after sampling, and that is where the reported gains are both largest and least stable. Self-consistency \cite{Wang2022-ir} samples several chains and takes the majority answer; uncertainty-guided selection \cite{Kumar2024-bj} decides per question whether one chain or a vote is worth the budget; the comparison of zero-shot and few-shot settings \cite{Cheng2025-sl} finds that the ordering of methods can reverse with the prompt alone; and a study of hallucination cues \cite{Cheng2025-wj} shows a longer chain hiding, rather than revealing, that the model is unsure. Tool-augmented chains \cite{Inaba2023-cg} are a fourth case: the chain calls a program, which changes what an answer can be grounded in.

Read more »
Your Institute @yourname Sep 22, 2026

Autoregressive Generation (sequence diagram)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

A language model writes one token at a time. The prompt is processed once, then each new token is appended to the sequence and fed back in, so generation is a loop between the model and the sampler rather than a single call. The sequence diagram below shows the participants and the messages between them.

The loop samples from a distribution over the vocabulary, conditioned on everything generated so far: \(x_t \sim p(\cdot \mid x_{\lt t})\). The logits are usually divided by a temperature \(T\) before the softmax, and truncation (keeping only the most probable tokens) changes the support of that distribution rather than the model itself.

sequenceDiagram
    autonumber
    participant C as Client
    participant M as Model
    participant S as Sampler
    C->>M: prompt tokens x_1 .. x_n
    M->>M: prefill: keys and values cached
    loop until stop token or token budget
        M->>S: logits z_t for the next position
        S-->>M: sampled token x_t from softmax(z_t / T)
        M->>C: stream token x_t
        M->>M: append x_t and extend the cache
    end
    M->>C: end of stream

Reading the diagram. The prefill call is the only one that processes the whole prompt; every later step processes one position and reuses the cached keys and values, which is why the first token arrives slowly and the rest quickly. The sampler is drawn as a separate participant because it is where generation is controlled — temperature and truncation act there, not in the model. The loop’s exit condition matters just as much: a stop token ends it early, while a token budget ends it by force, and the two produce different kinds of output.

Your Institute @yourname Sep 22, 2026

Causal Multi-Head Attention in Python (intermediate)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

Attention is the one place in a transformer where tokens exchange information: every other block — the projections, the activations, the normalisations — treats positions independently. That makes attention mostly shape bookkeeping, and the shapes alone decide which products are legal.

The code below is a module-sized step up from the previous snippet: a helper that splits the projected sequence into heads, the tensor operations of scaled dot-product attention, an assertion that the head arithmetic divides evenly, and a property check at the bottom. The mask is what makes the block usable as a next-token predictor: position \(t\) may look at positions up to \(t\) and nothing later.

import numpy as np


def split_heads(x, n_heads, d_head):
    """(B, T, d_model) -> (B, H, T, d_head)."""
    B, T, _ = x.shape
    return x.reshape(B, T, n_heads, d_head).transpose(0, 2, 1, 3)


def causal_attention(X, Wq, Wk, Wv, n_heads):
    """Multi-head self-attention over a batch of sequences.

    X: (B, T, d_model)   Wq, Wk, Wv: (d_model, d_model)
    """
    B, T, d_model = X.shape
    assert d_model % n_heads == 0, "d_model must divide by n_heads"
    d_head = d_model // n_heads

    Q = split_heads(X @ Wq, n_heads, d_head)      # (B, H, T, d_head)
    K = split_heads(X @ Wk, n_heads, d_head)
    V = split_heads(X @ Wv, n_heads, d_head)

    scores = Q @ K.transpose(0, 1, 3, 2) / np.sqrt(d_head)  # (B,H,T,T)
    future = np.triu(np.ones((T, T), dtype=bool), k=1)
    scores = np.where(future, -np.inf, scores)

    weights = np.exp(scores - scores.max(axis=-1, keepdims=True))
    weights /= weights.sum(axis=-1, keepdims=True)  # rows sum to 1

    out = weights @ V  # (B, H, T, d_head)
    return out.transpose(0, 2, 1, 3).reshape(B, T, d_model)


if __name__ == "__main__":
    rng = np.random.default_rng(0)
    B, T, d_model, n_heads = 2, 5, 16, 4
    X = rng.normal(size=(B, T, d_model))
    W = rng.normal(size=(d_model, d_model)) / np.sqrt(d_model)

    P = causal_attention(X, W, W, W, n_heads)
    print("output shape", P.shape)

    # A position may not affect the ones before it: change the last token
    # and check that every earlier output is unchanged.
    X2 = X.copy()
    X2[:, -1] += 1.0
    P2 = causal_attention(X2, W, W, W, n_heads)
    same = np.allclose(P[:, :-1], P2[:, :-1])
    print("earlier positions unchanged:", same)

Run as printed, it reports the output shape (2, 5, 16) and earlier positions unchanged: True. The check perturbs the last token and confirms that no earlier output moves, which is the property the mask exists to guarantee. The scores matrix costs \(T^2\) entries per head, which is why long-context variants trade that term away.

Your Institute @yourname Sep 22, 2026

Attention with Two Tokens (example)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

The smallest interesting attention example has two positions and one head, which is enough for a full calculation with no matrix product larger than two by two.

Working it at this size makes the two roles visible: the score decides how much the output at position two borrows from position one, and the value vectors set what is borrowed. With a causal mask, the first row has nothing to attend to but itself.

Example. Let \(d_h = 2\) and take

$$ Q = K = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, \qquad V = \begin{pmatrix} 1 & 0 \\ 0 & 2 \end{pmatrix} . $$

The unnormalised scores are \(QK^{\top} = I\), so with \(\sqrt{d_h} = \sqrt{2}\) the scaled scores are the identity divided by \(1.414\): \(0.707\) on the diagonal and zero elsewhere. After the causal mask the upper-right entry is set to \(-\infty\), giving

$$ S_{\text{masked}} = \begin{pmatrix} 0.707 & -\infty \\ 0 & 0.707 \end{pmatrix}, \qquad A = \begin{pmatrix} 1 & 0 \\ 0.354 & 0.646 \end{pmatrix}, $$

where the second row of \(A\) splits its weight between the two positions because the two scores there are \(0\) and \(0.707\). The output is then

$$ A V = \begin{pmatrix} 1 & 0 \\ 0.354 & 1.293 \end{pmatrix} . $$

Row one returns the first value vector unchanged — it had nowhere else to look.

The example is worth keeping in mind when reading an attention map: a row that concentrates on one position is not necessarily a strong match, since the causal mask forces the first row into that shape regardless of the scores.

Your Institute @yourname Sep 22, 2026

Layout of a Scaling Study (advanced folder structure)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

A project that produces a paper has to keep three kinds of thing apart that are easy to mix: the installed source, the outputs of individual runs, and the material the paper is written from. Once several sweeps and a performance benchmark live in the same repository, the folder structure is what decides whether a figure can be traced back to the run that produced it.

The tree below is five levels deep in places. Source sits under src/ as an installable package, each run gets its own timestamped folder under experiments/runs/, benchmark scripts and their results live together, and the paper’s figures and tables are generated from the run folders by a script rather than pasted in by hand.

scaling-study/
├── pyproject.toml
├── src/
│   └── scaling_study/
│       ├── data/
│       │   ├── tokenizer.py       # train or load the tokenizer
│       │   └── shards.py          # memory-mapped token shards
│       ├── model/
│       │   ├── attention.py       # causal attention
│       │   ├── blocks.py          # residual + norm + MLP
│       │   └── config.py          # dataclass per model size
│       ├── kernels/
│       │   ├── reference.py       # slow, obviously correct
│       │   └── triton/            # fused attention kernels
│       ├── train/
│       │   ├── loop.py            # one step, one eval, one checkpoint
│       │   ├── optim.py           # schedule and gradient clipping
│       │   └── distribute.py      # data parallel wrapper
│       └── eval/
│           ├── perplexity.py      # loss per token, not per sequence
│           └── scaling_fit.py     # power-law fit over sizes
├── configs/
│   ├── registry.py                # names the sweeps
│   └── sweep/                     # one file per sweep point
├── experiments/
│   └── runs/
│       └── 2026-09-18-a3f2/
│           ├── config.yaml        # exactly what was launched
│           ├── metrics.jsonl      # one line per evaluation
│           └── checkpoints/
├── benchmarks/
│   ├── attention_bench.py
│   └── results/
├── paper/
│   ├── make_figures.py            # reads runs/, writes figures
│   ├── figures/
│   └── tables/
└── tests/

The folder that carries the most weight is experiments/runs/: one directory per launch, holding the config it was started with, its metric log and its checkpoints. That single convention is what turns a plot into something reproducible — a figure script can walk those directories, read the loss curves and rebuild every panel from artifacts, so a reviewer’s question about which configuration produced a point has a file to look at rather than a memory to trust.

Your Institute @yourname Sep 22, 2026

A Survey of Chain-of-Thought Prompting: Single Chains, Sampling and Demonstration Construction (survey)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

Chain-of-thought prompting began as a single sentence appended to a prompt and is now a family of strategies that differ in what they add: a fixed reasoning skeleton, several sampled chains and a vote, demonstrations the method writes for itself, or calls to an external tool in the middle of the reasoning. This survey groups the entries in its bibliography by that question, following the framing of the earlier survey of prompting strategies \cite{Yu2023-qr}, and asks in each group what the reported gain is actually attributed to.

Table 1. The families differ in what they add to the prompt and in what the reported improvement is attributed to.

FamilyWhat is addedReported effectRepresentative work
Single chainan instruction to reason step by steplarge gains on multi-step tasks\cite{Wang2022-hh}, \cite{Cheng2025-sl}
Structured chaina fixed order of sub-tasksfewer unsupported statements\cite{Sultan2024-rc}, \cite{Cheng2024-az}
Sampling and votingseveral chains, then an aggregation ruleaccuracy rises with the sample countself-consistency \cite{Wang2022-ir}, uncertainty-guided \cite{Kumar2024-bj}
Demonstration constructionchains written or selected by the methodremoves hand-written examples\cite{Shao2023-lx}, \cite{Diao2024-at}, \cite{Ye2023-wa}
Contrastive and correctivewrong chains as negative examplesfewer shortcut answers\cite{Chia2023-cz}, \cite{Tian2023-bk}
Tool-augmentedcalls to an external tool inside the chaingrounding on computation\cite{Inaba2023-cg}

The diagram below shows where the families differ in time: the first four change what is put into the prompt, while sampling and voting and the tool-augmented family change what happens after the model has answered.

sequenceDiagram
    participant Q as Question
    participant P as Prompt
    participant M as Model
    participant A as Aggregator
    Q->>P: question plus worked examples
    P->>M: ask for k independent chains
    M->>M: reason step by step
    M->>A: k answers with their chains
    A->>A: majority vote over answers
    A->>Q: single answer

Proposed theory: reliability of a chain and the gain from voting. Model a chain of \(L\) steps as correct only if every step is, with per-step reliability \(p\) and independence between steps, and write \(q\) for the probability that a single sampled chain yields the correct final answer. The theory this survey proposes for testing is the pair of statements below: the reliability of one chain, and what voting over several of them does to it.

$$ \Pr(\text{chain is correct}) = p^{L} , $$$$ \Pr(\text{majority vote is correct}) \to 1 \quad \text{as} \ k \to \infty \qquad \text{whenever} \quad q \gt \tfrac{1}{2} . $$

The second statement is where the method’s limit lives: sampling changes neither \(p\) nor \(L\), so at \(q \leq \tfrac{1}{2}\) more samples do not help, and a task on which chains are individually unreliable needs a change to the prompt rather than a larger sample.

Algorithm 1 writes the sampling rule that the voting family shares, and makes the two quantities above concrete: \(k\) independent draws and one aggregation step.

Listing 1 is the aggregation step on its own, which is where the method is usually implemented badly: the vote is over extracted answers, not over chains, so an answer that appears in fluent prose has to be parsed before it can be counted. Run as printed it reports answer B with 57% of the vote.

from collections import Counter


def self_consistency(answers):
    """Majority vote over the answers extracted from sampled chains."""
    counts = Counter(answers)
    best, votes = counts.most_common(1)[0]
    return best, votes / len(answers)


if __name__ == "__main__":
    answers = ["B", "C", "B", "B", "D", "C", "B"]
    answer, share = self_consistency(answers)
    print(f"answer {answer} with {share:.0%} of the vote")

What the surveyed work leaves open is the same in both directions: whether a chain improves an answer or merely accompanies it, which the studies of hallucination cues \cite{Cheng2025-wj} and of what matters in a chain \cite{Wang2022-hh} both probe, and how a demonstrated gain should be reported when the same prompt is reused across tasks — the question the earlier survey raises and which the later comparisons of zero-shot and few-shot settings \cite{Cheng2025-sl} make sharper.

Your Institute @yourname Sep 21, 2026

The Variance Identity (identity)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

An identity is an equation that holds for every admissible value of its variables, and this one converts a variance into two expectations, which is often the difference between a quantity that can be estimated in one pass and one that cannot.

Its use in this field is everywhere a second moment appears: batch normalisation, the analysis of gradient noise, and the decomposition of an estimator’s error all begin by applying it.

Identity (variance). For a random variable \(X\) with finite second moment,

$$ \operatorname{Var}(X) = \mathbb{E}\!\left[X^{2}\right] - \left(\mathbb{E}[X]\right)^{2}, \qquad \operatorname{Var}(X) = \mathbb{E}\!\left[(X - \mathbb{E}[X])^{2}\right] . $$

The equality follows by expanding the square in the second expression and using linearity of expectation. The practical difference between the two forms is what has to be stored: the first can be accumulated from running sums of \(x\) and \(x^{2}\), while the second wants the mean before the sum can be formed — a difference that matters when statistics are computed over a stream.

Read as a constraint rather than a formula, the identity says a variance can never be negative, since it is an expectation of a square; the first form makes that fact easy to lose sight of, and the second makes it immediate.

Your Institute @yourname Sep 21, 2026

Bayes' Rule (rule)

Demo note. This note demonstrates what the SciDraft Hugo theme can do for academic and scientific publishing — for research institutions, researchers and students. Its content is demonstration material only: readers should ignore whether the demo content is correct.

Bayes’ rule is the rule for turning a model’s likelihood into a statement about hypotheses, and it is used twice in a language-model workflow: once to reason about uncertainty in evaluation, and once whenever a prior over prompts or parameters is combined with observed data.

Written out, the rule is a rearrangement of the definition of conditional probability, and its content is the division by the evidence term, which is what makes the posterior a distribution rather than a score.

Rule (Bayes). For events \(A\) and \(B\) with \(\Pr(B) \gt 0\),

$$ \Pr(A \mid B) = \frac{\Pr(B \mid A)\,\Pr(A)}{\Pr(B)} , \qquad \Pr(B) = \sum_{A'} \Pr(B \mid A')\,\Pr(A') , $$

and in the continuous case with densities the sums become integrals. The three ingredients are the prior \(\Pr(A)\), the likelihood \(\Pr(B \mid A)\) and the evidence \(\Pr(B)\), and only the first two are modelling choices: the evidence is whatever makes the posterior integrate to one.

Using the rule well means noticing when the evidence is hard to compute: in models with many parameters the denominator is an integral over everything, which is why the posterior is usually approximated rather than evaluated.