Formula

Recursive Formula for Memory as a Cumulative Average

The cumulative average for the memory component can be calculated efficiently using a recursive formula. The memory state at the current step, Memi\mathrm{Mem}_i, is computed based on the current key-value pair (ki,vi)(\mathbf{k}_i, \mathbf{v}_i) and the memory state from the previous step, Memi1\mathrm{Mem}_{i-1}. The recursive formula is expressed as: Memi=(ki,vi)+iMemi1i+1\mathrm{Mem}_i = \frac{(\mathbf{k}_i, \mathbf{v}_i) + i \cdot \mathrm{Mem}_{i-1}}{i + 1} This approach prevents the need to recalculate the sum of all historical key-value pairs at each step, significantly increasing computational efficiency.

Image 0

0

1

Updated 2026-05-02

Contributors are:

Who are from:

Tags

Ch.2 Generative Models - Foundations of Large Language Models

Foundations of Large Language Models

Foundations of Large Language Models Course

Computing Sciences

Related