Memory processes #
This file defines the memory process of [FGL20]'s lossy-context surprisal. A memory process encodes a context as a distribution over memory representations and predicts the next word from the representation alone, so that the representation mediates all information flow from the context to the prediction. The difficulty of a word in a context is its expected surprisal over the representations the context can produce, and the average difficulty of the process under a language model and a context prior averages it over contexts and the words they predict.
A process whose encoder is deterministic and whose predictor, read through the encoder, is a language model loses no information, and its difficulty is that model's surprisal: surprisal theory is the lossless special case.
Main definitions #
MemoryProcess: an encoderKernel C Rand a predictorKernel R W.MemoryProcess.expectedSurprisal,MemoryProcess.averageDifficulty.MemoryProcess.IsLosslessFor: the process realizes a language model through a deterministic summary of the context.
Main results #
MemoryProcess.expectedSurprisal_of_dirac,MemoryProcess.expectedSurprisal_of_bernoulli: expected surprisal under a point-mass and under a two-point encoder.MemoryProcess.expectedSurprisal_eq_surprisal_of_lossless.
References #
A memory process: a lossy encoder from contexts to memory representations and a predictor from memory representations to next words. The representation mediates all information flow from the context to the prediction.
- encode : ProbabilityTheory.Kernel C R
The distribution over memory representations a context produces.
- predict : ProbabilityTheory.Kernel R W
The next-word distribution a memory representation predicts.
Instances For
The surprisal of the word w at the memory representation r.
Equations
- mp.perStateSurprisal r w = InformationTheory.surprisal (mp.predict r) w
Instances For
The expected surprisal of w in the context c: the difficulty of w under the process.
Equations
- mp.expectedSurprisal c w = ∫ (r : R), mp.perStateSurprisal r w ∂mp.encode c
Instances For
The average difficulty of the process under the language model L and the context prior
π: expected surprisal averaged over contexts and the words they predict.
Equations
- mp.averageDifficulty L π = ∫ (c : C), ∫ (w : W), mp.expectedSurprisal c w ∂L c ∂π
Instances For
The process realizes the language model L through the summary f: the encoder is
deterministic at f, and the predictor pulled back along f is L.
Equations
- mp.IsLosslessFor L = ∃ (f : C → R) (hf : Measurable f), mp.encode = ProbabilityTheory.Kernel.deterministic f hf ∧ mp.predict.comap f hf = L
Instances For
A deterministic encoder realizes the language model that reads the predictor through it.
Expected surprisal under a Bernoulli encoder, which produces r₁ with probability p and
r₂ otherwise.
A lossless process has the surprisal of the language model it realizes: surprisal theory is the lossless special case of lossy-context surprisal.