Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

Language Model

Also Neural Language Model

A language model computes, for a sequence of previous tokens, a probability distribution over the vocabulary for the next token; it is count-based (n-gram model) or neural.

Properties#

Tokens. One text can be tokenized in different ways; a token may include spaces and punctuation. For “To be, or not to be”:

  • words: To be or not to be
  • subwords: To be , or not to be (modern language models)
  • characters: T o b e , … (the lecture’s n-gram models)

Variants.

Count-based (N-Gram Model)Neural language model
How Pr⁡\Pr is computednormalized counts of token sequences in a training textforward pass through a neural network
Context sizesmall nn; ∣V∣n\lvert V \rvert^n n-grams make large nn infeasiblevery large, up to 10610^6 tokens
Unseen contextsno distribution; smoothing (random next token)the network computes a distribution for every prompt

A neural language model with a very large network is a large language model (LLM). All of these, including LLMs, are “the same kind of model”, only trained and computed differently.

  • Long prompts: if the prompt has more than nn tokens, only the last nn are considered, or a subset of the text is selected via Retrieval-Augmented Generation.
  • Generating text: repeatedly pick a next token from the distribution (e.g. via cumulative counts, N-Gram Model > Formula), append it to the prompt, repeat. LLM services return the next kk tokens at once.
  • Base vs. instruct models, system prompt, temperature and the API: see Large Language Model.

Example#

Sources#

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only