ElemedexA pocket encyclopedia of AI architectures
Neural probabilistic language model
No. 017

Neural probabilistic language model

NNLM (Bengio et al.)

Vector Pocket

It was the first to keep every word in a vector pocket. Since it knows that "cat" and "dog" are alike, once it has read that the cat is walking in the bedroom, it suspects the dog might be too. Reading fourteen million words five times took it three weeks and forty processors.

Height
table C + 1 hidden (tanh) + softmax
Weight
almost 100 MB (the largest net)
Parameters
≈ 2 M (Brown) · ≈ 12 M (AP News)
Context
2–5 previous words (n = 3–6)
Training data
Brown (≈ 1.18 M words) · AP News 1995–96 (≈ 14 M)
Year
2003
Generation
2 · Classical machine learning
Creators
Yoshua Bengio, Réjean Ducharme, Pascal Vincent & Christian Jauvin (Université de Montréal)
Kind
Model

Base stats

Total
160

Approximate, ordinal scales meant for comparing species with each other; the hard numbers are in the data sheet.

Weaknesses

  • The softmax over the whole vocabulary takes 99.7% of the computation.
  • Fixed window: it only sees the previous n − 1 words.
  • A single vector per word: polysemy is poorly served.
  • Slow for its time: weeks of training on a CPU cluster.

Habitat

It grew up reading the Brown corpus, a varied sample of written English, and two years of Associated Press news. Today its most lasting invention, the embedding table, lives inside every language model: each LLM stores such a matrix for its vocabulary.

Moves

Abilities

Shared vector table
A matrix C with one row per word, shared by every position in the window and learned together with the rest of the network.
Smooth probability
Probability is a continuous function of the vectors: words that are close in the space yield similar predictions, and one sentence seen informs many neighboring sentences.
Output-parallel training
Since almost all the computation is in the softmax, each processor in a cluster handles a slice of the vocabulary.

Anatomy

Bengio et al.'s (2003) network, with n = 4 for illustration (in the experiments n went up to 6). Each previous word is looked up in the same table C; the vectors are concatenated and pass through a hidden layer, and a softmax gives the probability of each next word: y = b + Wx + U·tanh(d + Hx). The direct connections W are optional.

Evolution chain

017 Neural probabilistic language model
  • drops the deep network: shallow, fast training on billions of words019 word2vec

Bengio, Ducharme, Vincent and Jauvin's neural probabilistic language model is the first neural language model that worked at a serious scale: a network that, given the last few words, estimates the probability of the next one and, in order to do so, simultaneously learns a vector for every word in the vocabulary. A first version was presented at NIPS 2000; the journal version is from 2003.

The problem

An n-gram model estimates probabilities by counting short sequences. The obstacle is the curse of dimensionality: with a 100,000-word vocabulary, modeling the joint distribution of ten consecutive words would take on the order of 10⁵⁰ free parameters, and almost any test sentence differs from every sentence seen in training (Bengio et al., 2003, p. 1137). N-grams generalize by gluing together short overlapping fragments; nothing tells them that "cat" and "dog" are alike.

How it works

The proposal has two pieces (Bengio et al., 2003, pp. 1139–1143):

  1. A table C of |V| × m numbers: each row is the vector (today we would say the embedding) of one word, with m = 30, 60 or 100 dimensions for vocabularies of about 17,000 words.
  2. A network that takes the vectors of the previous n − 1 words, concatenates them, passes them through a hidden layer with a hyperbolic tangent, and ends in a softmax over the whole vocabulary: y = b + Wx + U·tanh(d + Hx), where the matrix W, which connects the words directly to the output, is optional.

Table and network are trained together, by gradient descent on the log-likelihood of the corpus. Since the probability is a smooth function of the vectors, and words that play similar roles end up with nearby vectors, having seen "The cat is walking in the bedroom" also raises the probability of "A dog was running in a room" and of a combinatorial number of neighboring sentences (2003, pp. 1139–1140). The authors trace the idea of representing symbols with distributed vectors to early connectionism, citing Hinton (1986) and Elman (1990) (2003, p. 1140).

Results

It was tested on the Brown corpus (≈ 1.18 million words) and on Associated Press news from 1995–1996 (≈ 14 million training words) (Bengio et al., 2003, p. 1147). Compared with the best n-gram, test perplexity dropped by about 24% on Brown and 8% on AP News, and averaging the network with a trigram helped further: the two made their errors in different places (2003, p. 1148). The cost was large for the time: five passes over AP News took about three weeks on 40 CPUs (2003, p. 1148), and 99.7% of the computation went into the output layer (2003, p. 1145). By the paper's own formula, the AP News network has about 12 million parameters (our calculation); the authors mention almost 100 MB for their largest network (2003, p. 1144).

Offspring and limits

Table C survives: every current language model stores an embedding matrix, randomly initialized and adjusted during training (Alammar & Grootendorst, 2024, pp. 57–58). Mikolov, Chen, et al. (2013) took this network as the reference "NNLM" and noted that most of its cost lay in the nonlinear hidden layer; by removing it they obtained word2vec (2013, secs. 2.1, 3).

The limits are flagged in the paper itself: the window is fixed (n − 1 words), the softmax over the whole vocabulary is very expensive, and each word occupies a single point in the space, so polysemy is poorly served (Bengio et al., 2003, p. 1152). Bank is the same vector by the river and at the counter, to use the example of Alammar & Grootendorst (2024, p. 11). Recurrent networks and attention would tackle the fixed window; contextual embeddings, polysemy.

Sources

  • Alammar, J., & Grootendorst, M. (2024). Hands-on large language models: Language understanding and generation. O’Reilly Media. §
  • Bender, E. M., & Koller, A. (2020). Climbing towards NLU: On meaning, form, and understanding in the age of data. In D. Jurafsky, J. Chai, N. Schluter, & J. Tetreault (Eds.), Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics (pp. 5185–5198). Association for Computational Linguistics. https://doi.org/10.18653/v1/2020.acl-main.463 §
  • Bengio, Y., Ducharme, R., Vincent, P., & Jauvin, C. (2003). A neural probabilistic language model. Journal of Machine Learning Research, 3, 1137–1155. https://www.jmlr.org/papers/v3/bengio03a.html §
  • Brunila, M., & LaViolette, J. (2022). What company do words keep? Revisiting the distributional semantics of J.R. Firth & Zellig Harris. In M. Carpuat, M.-C. de Marneffe, & I. V. Meza Ruiz (Eds.), Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (pp. 4403–4417). Association for Computational Linguistics. https://doi.org/10.18653/v1/2022.naacl-main.327 §
  • Elman, J. L. (1990). Finding structure in time. Cognitive Science, 14(2), 179–211. https://doi.org/10.1207/s15516709cog1402_1 §
  • Firth, J. R. (1957). A synopsis of linguistic theory, 1930–1955. In Studies in linguistic analysis (pp. 1–32). Blackwell. §
  • Harris, Z. S. (1954). Distributional structure. Word, 10(2–3), 146–162. https://doi.org/10.1080/00437956.1954.11659520 §
  • Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word representations in vector space (arXiv:1301.3781). arXiv. https://doi.org/10.48550/arXiv.1301.3781 §