liveBook · Manning

Language model

As explained in Learn AI-Assisted Python Programming, Second Edition

A large language model is a machine-learning model that represents statistical relationships among language elements and predicts sequences of text from context.

A large language model (LLM) represents relationships among words and uses context to predict a likely sequence of text. Given a prompt, it predicts one word at a time until it completes a response. Because those choices are nondeterministic, the same prompt can produce different answers. An LLM generates plausible text; it does not guarantee understanding, correctness, or intent. section 1.2.3 section 6.5.2

Predicting the next word

For “The person opened the ________,” an LLM might predict “door” or “box.” Both fit the context, while “the,” “it,” or “open” fit poorly. It continues making similar predictions to produce a complete answer, such as Python code generated from a natural-language prompt. section 1.2.3

Working with an LLM requires treating its output as a suggestion rather than a verified result:

  • Describe a desired program in ordinary language through a prompt. section 1.2.3
  • Expect different responses because generation is random or nondeterministic. section 1.2.3 section 6.5.2
  • Test and inspect generated code instead of assuming that it is correct or secure. section 1.5 section 6.5.2
  • Prefer an editable language such as Python when generated code needs correction, rather than inspecting machine code directly. section 1.2.3
Figure 1.2 Going from prompt to program with Copilot
figure

Trace the path from a natural-language prompt to a generated program through Copilot. section 1.2.3

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains contextual next-word prediction, nondeterminism, and limited understanding, but does not descend into model implementation.
Examples
Uses next-word completion, Copilot-generated Python, classroom-seat prompts, and doctests to illustrate prediction and verification.
What you can do after
Evaluate generated responses by refining prompts, comparing alternatives, testing code, and checking correctness and security.
How it connects
Connects large language models with prompts, prompt engineering, programming languages, compilers, and software testing.

Also explained in

Compare how 67 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.