A transformer block has two principal sublayers: multi-head attention and a positionwise feedforward neural network. Each sublayer has a residual connection and layer normalization. To make the components explicit, let contain the representations of sequence positions. For head , learned projections form
The scaled dot-product attention output is
where the softmax function acts along each row and is an optional attention mask. For causal self-attention, disallowed future positions receive before the softmax function, giving zero attention weights. In self-attention, queries, keys, and values all come from the same input sequence. The multi-head attention output concatenates the heads and projects them:
A standard post-normalization transformer block can then be written
Here layer normalization normalizes the feature coordinates of each position separately, within each example, and applies learned scales and shifts. The positionwise feedforward neural network applies the same two affine maps and activation function at every position, for example
Thus attention mixes information between positions, while the feedforward sublayer transforms each position's features. The residual connections support propagation through a deep stack, and dropout is often used during training. Pre-normalization variants move layer normalization before the sublayer. A model's positional encoding supplies order information to the sequence representation or attention mechanism; a decoder in an encoder-decoder model also has a cross-attention sublayer between its self-attention and feedforward neural network sublayers.
Evaluating the negative functional gradient at yields
Thus the evaluation vector follows
This is exactly the limiting prediction dynamics in part (ii). If , subtracting the two systems gives with zero initial value, so for every .
An infinitely wide neural network in this regime follows the same training-prediction dynamics as kernel regression with its neural tangent kernel and matching initial predictions. For this squared-error loss function, the relevant algorithm is gradient flow in the Reproducing kernel Hilbert space. Matching predictions at arbitrary additional inputs also requires the corresponding cross-input neural tangent kernel to freeze and the initial predictions there to match. A finite-width neural network can change its feature map during training, so the equivalence depends on the assumptions rather than holding for every architecture and parameterization.
For in the Reproducing kernel Hilbert space , take the directional derivative:
The reproducing property says . Hence
Each kernel section belongs to the Reproducing kernel Hilbert space, so this finite sum is an admissible element. Uniqueness of a vector with these inner products gives the functional gradient
Under the stated infinite-width scaling and freezing assumptions, the deterministic limiting kernel matrix has entries
For a sequence of finite-width networks, this expectation is interpreted in the stated width limit. The resulting neural tangent kernel is a positive-semidefinite kernel, since every finite coefficient vector gives .
The prediction gradient flow is linear:
The matrix exponential solves the constant-coefficient system because the residual satisfies . Each positive-eigenvalue component decays exponentially; a component in the null space of stays at its initial residual. Thus for every initial prediction if is a positive-definite matrix. The limiting kernel matrix being deterministic does not require to be deterministic.
Let be the Jacobian matrix with row . Differentiating the squared-error loss function gives
The parameter gradient flow is consequently . The chain rule then gives
where, explicitly,
It is a Gram matrix and therefore a positive semidefinite matrix: . These derivatives are understood wherever the network is differentiable; for piecewise differentiable activations the same calculation applies along differentiable portions of the trajectory.
Reciprocation reverses the order of positive numbers, so
This is the pullback of the positive-semidefinite kernel from part (i) by . Explicitly, the feature map into the same L2 space is
Hence is a positive-semidefinite kernel, with for every allowed input.
Choose two inputs . Their proposed kernel matrix is
The coefficient vector gives
Thus is not a positive semidefinite matrix, and
Equivalently, its determinant is negative.
Take the real L2 space and the feature map
Each indicator function belongs to because its squared L2 norm is . Their inner product is the length of the overlapping intervals:
This realizes as a positive-semidefinite kernel; it is also the Brownian covariance kernel.
The closure property of positive-semidefinite kernels gives three constructions, each seen directly from the feature maps .
Another useful consequence is pullback: if and is a positive-semidefinite kernel on , then has feature map .
For every , every choice , and every coefficient vector , the required condition is
Thus for the kernel matrix . For a feature map, this follows from
In kernel methods, the term positive-definite kernel commonly uses this non-strict inequality. Strict positive definiteness is the stronger requirement that the expression be positive for distinct inputs and every nonzero ; it is not required here.
In this setting a positive-semidefinite kernel is an inner-product similarity: there exist a real Hilbert space and a feature map such that
The feature map may be infinite-dimensional. Equivalently, is symmetric and every finite kernel matrix is a positive semidefinite matrix. The equivalence follows by forming the canonical feature space of a positive-semidefinite kernel and taking its Hilbert space completion.
The printed minimization of the evidence lower bound has no solution. To distinguish that literal result from the usual variational inference optimum, put . The preceding Kullback-Leibler divergence satisfies
Its unique global minimum occurs at . Since , this is the unique global maximum of the evidence lower bound:
The optimal common variance is the harmonic mean of the two posterior variances. However, as either or . Therefore
The source PDF confirms the minimization wording; replacing it by maximization would give the finite value above, consistently with part (i).
The independent coordinates make the logarithm of the probability density ratio a sum. For coordinate , its contribution to the Kullback-Leibler divergence is
because . Thus, retaining all constants,
Here and , so both normal densities are nondegenerate.
Use the factorization inside the evidence lower bound:
Hence
The marginal likelihood is independent of the variational parameter , so maximizing the evidence lower bound is equivalent to minimizing the Kullback-Leibler divergence. Nonnegativity of the Kullback-Leibler divergence also gives .
For under the posterior density ,
The independent-draw variance of a sample mean therefore yields
Since
we again obtain
The optimum is again generally unavailable as an evaluable normalized density without knowing .
A proposal with too much mass where the posterior density is tiny makes reciprocal weights unstable. In particular, proposal tails that are too heavy relative to the posterior distribution can make infinite. This contrasts with ordinary importance sampling, whose dangerous denominator is . Choosing a normalized restricted to a well-covered posterior region is allowed, although a very small region can make most draws contribute zero and increase variance. Taking gives the Harmonic mean estimator of Bayesian model evidence, illustrating why very small likelihood values can cause severe instability.
For reciprocal importance sampling, use the same and but draw from the posterior density . Here the support requirement is reversed: the normalized density must vanish almost everywhere that . Thus may be confined to a subset of the posterior distribution's support. For ,
Consequently,
It is the estimate of the reciprocal that is an unbiased estimator. Taking its reciprocal does not generally produce an unbiased estimator of : inversion is nonlinear. In fact, when the average is strictly positive and the relevant expectation exists, Jensen's inequality gives .
With , , and as above, independence of the draws gives the variance of a sample mean:
This formula allows infinite variance. To identify the optimum, write . Then
The last equality uses . Its nonnegative integrand proves
Indeed, all importance weights then equal . This is a formal optimum: evaluating the normalized posterior density generally already requires the unknown marginal likelihood.
Poor coverage of regions with substantial posterior mass produces large weights. In particular, excessively light proposal tails, a proposal that is too narrow, or a missed mode can make enormous or infinite. A proposal that is unnecessarily diffuse can also waste nearly all draws on negligible posterior probability. Omitting target support altogether violates unbiasedness, rather than merely increasing variance.
Put and . The support condition for importance sampling is essential: almost everywhere that . For one draw , the importance weight satisfies
By linearity of expectation,
This proves that it is an unbiased estimator. If the proposal omits a region of positive target mass, the expected value instead misses that region's contribution; the unconditional unbiasedness claim needs the stated support condition for importance sampling.
Evaluate Bayes' theorem at the posterior mode :
The multivariate normal density in the Laplace approximation has height at its mean. Therefore
Equivalently, the approximate log marginal likelihood is
The determinant factor accounts for the volume of the locally plausible parameter region, which the peak likelihood alone does not measure.
Write . Choose an interior maximum a posteriori estimate, a globally maximizing posterior mode
Suppose is twice continuously differentiable near and its negative Hessian matrix is a positive-definite matrix. The second-order Taylor expansion is
Exponentiating and normalizing this local approximation gives the Laplace approximation
Thus the approximate mean is the posterior mode, and the approximate covariance matrix is the inverse local curvature. This normal approximation is useful when most posterior probability is concentrated around this mode. A boundary mode, singular curvature, or several substantial modes requires a modified approximation.

Pinned article: Introduction to the OurBigBook Project

Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
We have two killer features:
  1. topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculus
    Articles of different users are sorted by upvote within each article page. This feature is a bit like:
    • a Wikipedia where each user can have their own version of each article
    • a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
    This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.
    Figure 1.
    Screenshot of the "Derivative" topic page
    . View it live at: ourbigbook.com/go/topic/derivative
  2. local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:
    This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
    Figure 5. . You can also edit articles on the Web editor without installing anything locally.
    Video 3.
    Edit locally and publish demo
    . Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension.
  3. https://raw.githubusercontent.com/ourbigbook/ourbigbook-media/master/feature/x/hilbert-space-arrow.png
  4. Infinitely deep tables of contents:
    Figure 6.
    Dynamic article tree with infinitely deep table of contents
    .
    Descendant pages can also show up as toplevel e.g.: ourbigbook.com/cirosantilli/chordate-subclade
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact