ElemedexA pocket encyclopedia of AI architectures

Glossary (TM) › Architectural parts

TM090

Hidden state

Also: internal state

In Spanish: Estado oculto

The vector a recurrent network carries from one step to the next, summarizing what it has seen so far in the sequence.

In a recurrent network, the hidden state hₜ is what the network "remembers" at step t. It is computed from the current input and the previous state, hₜ = f(xₜ, hₜ₋₁) (Bahdanau et al., 2015, sec. 2.1), and reused at the next step (Witten et al., 2017, p. 457). It is "hidden" in the same sense as a hidden layer: it is neither input nor output, but an intermediate representation that nobody specifies and that is adjusted during training.

A fixed-size summary. The state always has the same dimension, whether the network has read three words or three hundred. This makes it cheap and, at the same time, limited. In sequence-to-sequence task translators, the encoder's last hidden state was the only summary of the sentence the decoder received; with long sentences, information was lost (Bahdanau et al., 2015, sec. 1; M. Mitchell, 2019, ch. 12). Attention arose to hand the decoder all the hidden states, not just the last one (Alammar & Grootendorst, 2024, pp. 13–14).

Variants. In an LSTM, alongside the hidden state there is a "memory cell" cₜ that gates protect from being overwritten (Witten et al., 2017, pp. 458–459). In state-space models such as Mamba, the state is again the protagonist: fixed in size, as opposed to a transformer's KV cache, which grows with every token. In transformer jargon, by contrast, "hidden states" are the activations of each layer for each token, even though they no longer pass from one time step to the next.

What was found inside. Elman (1990) trained a simple recurrent network to predict the next word and, clustering its hidden states, found that they were organized by category: nouns and verbs, animate and inanimate (Simple recurrent network (Elman)). Nobody had taught it grammar. For linguistics, it was one of the first demonstrations that abstract categories can emerge from pure distribution; whether that amounts to having those categories is another debate.

Sources

  • Alammar, J., & Grootendorst, M. (2024). Hands-on large language models: Language understanding and generation. O’Reilly Media. §
  • Bahdanau, D., Cho, K., & Bengio, Y. (2015). Neural machine translation by jointly learning to align and translate. In 3rd International Conference on Learning Representations (ICLR 2015). https://doi.org/10.48550/arXiv.1409.0473 §
  • Elman, J. L. (1990). Finding structure in time. Cognitive Science, 14(2), 179–211. https://doi.org/10.1207/s15516709cog1402_1 §
  • Mitchell, M. (2019). Artificial intelligence: A guide for thinking humans. Pelican Books. §
  • Witten, I. H., Frank, E., Hall, M. A., & Pal, C. J. (2017). Data mining: Practical machine learning tools and techniques (4th ed.). Morgan Kaufmann. https://doi.org/10.1016/C2015-0-02071-8 §