Papers · Architectures and attention · 2014

Neural Machine Translation by Jointly Learning to Align and Translate

Dzmitry Bahdanau, KyungHyun Cho, Yoshua Bengio

The notation of the Bahdanau attention paper, explained: its 25 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.

Read the paper on arXiv

Read from arXiv's HTML version: 25 displayed equations and 99 pieces of inline math. 34 symbols and constructs from the catalog.

The paper's displayed equations

Open any of them in the decoder for a symbol-by-symbol reading.

  1. (1)
    ht=f(xt,ht−1)h_{t}=f\left(x_{t},h_{t-1}\right)
    Decode →
  2. c=q({h1,⋯ ,hTx}),c=q\left(\left\{h_{1},\cdots,h_{T_{x}}\right\}\right),
    Decode →
  3. (2)
    p(y)=∏t=1Tp(yt∣{y1,⋯ ,yt−1},c),p(\mathbf{y})=\prod_{t=1}^{T}p(y_{t}\mid\left\{y_{1},\cdots,y_{t-1}\right\},c),
    Decode →
  4. (3)
    p(yt∣{y1,⋯ ,yt−1},c)=g(yt−1,st,c),p(y_{t}\mid\left\{y_{1},\cdots,y_{t-1}\right\},c)=g(y_{t-1},s_{t},c),
    Decode →
  5. (4)
    p(yi∣y1,…,yi−1,x)=g(yi−1,si,ci),p(y_{i}|y_{1},\ldots,y_{i-1},\mathbf{x})=g(y_{i-1},s_{i},c_{i}),
    Decode →
  6. si=f(si−1,yi−1,ci).s_{i}=f(s_{i-1},y_{i-1},c_{i}).
    Decode →
  7. (5)
    ci=∑j=1Txαijhj.c_{i}=\sum_{j=1}^{T_{x}}\alpha_{ij}h_{j}.
    Decode →
  8. (6)
    αij=exp⁡(eij)∑k=1Txexp⁡(eik),\alpha_{ij}=\frac{\exp\left(e_{ij}\right)}{\sum_{k=1}^{T_{x}}\exp\left(e_{ik}\right)},
    Decode →
  9. eij=a(si−1,hj)e_{ij}=a(s_{i-1},h_{j})
    Decode →
  10. si=f(si−1,yi−1,ci)=(1−zi)∘si−1+zi∘s~i,s_{i}=f(s_{i-1},y_{i-1},c_{i})=(1-z_{i})\circ s_{i-1}+z_{i}\circ\tilde{s}_{i},
    Decode →
  11. s~i=tanh⁡(We(yi−1)+U[ri∘si−1]+Cci),\tilde{s}_{i}=\tanh\left(We(y_{i-1})+U\left[r_{i}\circ s_{i-1}\right]+Cc_{i}\right),
    Decode →
  12. zi=σ(Wze(yi−1)+Uzsi−1+Czci),ri=σ(Wre(yi−1)+Ursi−1+Crci),\begin{gathered}z_{i} =\sigma\left(W_{z}e(y_{i-1})+U_{z}s_{i-1}+C_{z}c_{i}\right), \\ r_{i} =\sigma\left(W_{r}e(y_{i-1})+U_{r}s_{i-1}+C_{r}c_{i}\right),\end{gathered}
    Decode →

Famous equations in this paper

Symbols, by category

Most used first. The examples are written as the paper writes them.

Notation conventions

  1. hth_{t}, xtx_{t}, ht−1h_{t-1}

    Subscript (index or label) 305 uses

    A subscript picks an element (xᵢ), a time step (h_t), a named copy (W_q), or the parameters (p_θ).

  2. hh, ff, xx

    Italic letters (variables) 300 uses

    A plain italic letter is a variable; conventions say what kind (x input, y target, W weights…).

  3. ⋯\cdots, …\ldots, …\dots

    Dots (ellipsis) 17 uses

    “And so on”: continue the pattern.

  4. s~\tilde{s}, t~\tilde{t}

    Tilde accent 10 uses

    A modified version of the variable: noisy, corrupted, proposed or intermediate.

  5. E‾\overline{E}

    Bar (mean) 5 uses

    A bar usually marks an average: x̄ is the mean of the x values.

  6. 050^{5}, 121^{2}, 0−60^{-6}

    Superscript (power or label) 4 uses

    Usually a power (x² = x·x), but a capital or a word up there is often just a label (W^Q).

Greek letters

  1. α\alpha

    Alpha 10 uses

    Often a learning rate or step size; also attention weights αᵢⱼ or a mixing weight.

  2. σ\sigma

    Sigma (lowercase) 8 uses

    Either the sigmoid function σ(z) = 1/(1+e⁻ᶻ) or a standard deviation. The context decides.

  3. ϵ\epsilon

    Epsilon 1 use

    A tiny constant for numerical safety (10⁻⁸ in Adam), or noise ε ~ 𝒩(0, I).

  4. ρ\rho

    Rho 1 use

    A correlation coefficient, a decay rate (RMSprop, Adadelta), or an importance ratio in RL.

Vectors and matrices

  1. y\mathbf{y}, x\mathbf{x}, h→\overrightarrow{h}

    Bold lowercase (vector) 50 uses

    A bold lowercase letter is a vector: a list of numbers.

  2. ×\times

    Times (cross) 18 uses

    Usually the “by” in a shape (n × d); also plain multiplication or a cross product.

  3. KK, VV

    Q, K, V (query, key, value) 11 uses

    In attention: queries Q, keys K and values V, each a matrix with one row per token.

  4. va⊤v_{a}^{\top}, yi⊤y_{i}^{\top}, h→j⊤\overrightarrow{h}_{j}^{\top}

    Transpose 7 uses

    Swap rows and columns. xᵀy is a dot product; xyᵀ is an outer product.

  5. (⋅)\left(\cdot\right), (⋅)(\cdot)

    Centre dot 2 uses

    A dot product between vectors, plain multiplication between numbers, or an empty slot f(·).

  6. Bold uppercase (matrix) 1 use

    A bold capital letter is a matrix (or a higher-order tensor).

Calculus and gradients

  1. t′t^{\prime}, n′n^{\prime}

    Prime 6 uses

    Either a derivative, f′(x), or simply "another one": x′ is a second sample, s′ the next state.

Probability and statistics

  1. qq, pp

    Probability p(x) 9 uses

    A probability or probability density; p is usually the true or model distribution, q an approximation.

  2. ∣\mid, ∣|

    Given (conditional bar) 5 uses

    “Given”: p(y | x) is the probability of y given that x is known.

  3. exp⁡\exp

    Exponential 5 uses

    The exponential function eˣ, with e ≈ 2.718. Always positive.

  4. ∝\propto

    Proportional to 1 use

    Equal up to a constant factor that does not depend on the variable of interest.

  5. ;;

    Semicolon (parameterized by) 1 use

    In p(x; θ), the semicolon separates the variable x from fixed parameters θ.

Functions and operators

  1. ∘\circ

    Composition (circle) 11 uses

    Function composition: (f ∘ g)(x) = f(g(x)). Some papers use it for elementwise products.

  2. tanh⁡\tanh

    Hyperbolic tangent 7 uses

    An S-shaped activation squashing any number into (−1, 1).

  3. ∑j=1Tx\sum_{j=1}^{T_{x}}, ∑k=1Tx\sum_{k=1}^{T_{x}}

    Summation 4 uses

    Add up the expression for every value of the index, from the bottom limit to the top.

  4. Fraction 2 uses

    Division: the top divided by the bottom.

  5. ∏t=1T\prod_{t=1}^{T}

    Product 1 use

    Multiply the expression for every value of the index.

  6. Cases (piecewise) 1 use

    A piecewise definition: the value on each line applies when that line’s condition holds.

  7. max⁡\max

    Max and min 1 use

    The largest (or smallest) value, over the arguments or over the range in the subscript.

  8. arg max⁡y\argmax_{\mathbf{y}}

    Argmax 1 use

    The input that makes the function largest, not the largest value itself.

Sets, shapes and definitions

  1. ∈\in

    Element of 22 uses

    “Is in” or “belongs to”: x ∈ S says x is a member of the set S.

  2. RKx\mathbb{R}^{K_{x}}, RKy\mathbb{R}^{K_{y}}, Rn\mathbb{R}^{n}

    Tensor shapes 22 uses

    ℝ with a superscript of sizes joined by × declares an array’s shape: ℝ^{B×T×d} is a 3-axis tensor.

  3. {h1,⋯ ,hTx}\left\{h_{1},\cdots,h_{T_{x}}\right\}, {y1,⋯ ,yt−1}\left\{y_{1},\cdots,y_{t-1}\right\}, {h1,⋯ ,hT}\left\{h_{1},\cdots,h_{T}\right\}

    Set braces 6 uses

    A set: a collection of items. {x | condition} is every x that satisfies the condition.

  4. >>

    Inequalities 1 use

    Less than / greater than (or equal). ≪ means “much smaller than”.

1 thing the catalog has no entry for yet
  • \overleftarrow \overleftarrow 12

Formulas from arXiv's HTML version of the paper, © their authors; the explanations are this site's. Title and authors as arXiv lists them.

More architectures and attention papers