liveBook · Manning

Context

As explained in Understanding AI

Context is information about a situation, user, objective, constraints, or prior knowledge that conditions how a model interprets a request and selects relevant knowledge.

Why can the same question produce a generic answer one moment and a useful one the next? Often, the difference is context: the information that tells a language model what situation it is responding to and which details matter most. section 3.1 section 3.1.1

At a basic level, language models generate text by predicting what comes next. To make that prediction, they use the words and details already available. Context therefore guides selection: it does not add new knowledge to the model, but helps it identify which of its knowledge is relevant to the request. section 1.2.2 section 3.1.1

From broad question to usable answer

“Tell me about electric cars” leaves the goal unclear. Adding context makes the request more specific: “I’m a first-time electric vehicle buyer deciding whether one suits my family. My budget is $30,000, I live in an apartment, cannot install a home charger, and have no prior knowledge.” The topic has not changed, but the response can now focus on an appropriate decision, constraints, and level of explanation. section 3.1 section 3.1.1

Useful prompt context commonly answers four questions:

  • Who are you? State the perspective or role that shapes the answer, such as a first-time buyer or marketing manager. section 3.1.1
  • What are you trying to achieve? Name the decision, task, or objective behind the request. section 3.1.1
  • What constraints apply? Include limits such as budget, time, or available resources. section 3.1.1
  • What do you already know? Indicate the knowledge level the explanation should assume. section 3.1.1

Context is one part of a well-structured prompt. The main point states the task, while the action specifies how the answer should be delivered, such as its format, audience, tone, length, or level of detail. Clear communication matters more than clever wording. section 3.1 section 3.5

Context also matters inside the model. Earlier sequential models such as RNNs carried information forward word by word, so early details could weaken in long inputs. Attention addresses this by letting a model focus directly on the earlier words most relevant to its current prediction. section 1.2.2 section 1.3

Figure 1.3 How attention selects relevant context. Instead of carrying context forward only step by step, attention allows a model to directly attend to the most relevant parts of the input. In this example, when predicting the word after “now it’s…,” the model assigns more weight to words such as “umbrella” and “at home,” making “raining” a more likely continuation.

The umbrella sentence shows the contrast: when completing “and now it’s…,” attention can give greater weight to “umbrella” and “at home,” making “raining” a stronger continuation. section 1.3

Good context improves relevance, not reliability by itself. Even a clear prompt can receive hallucinated, overconfident, biased, or otherwise unsuitable output, so treat responses as information to evaluate rather than unquestioned answers. section 3.5

How Understanding AI covers it

How deep it goes
Defines context, demonstrates four prompt categories, and contrasts sequential retention with attention; it does not detail attention internals.
Examples
Uses electric-vehicle buyer prompts and an umbrella sentence completed as “raining.”
What it assumes
Introduces the idea from everyday requests and assumes no prior knowledge of electric vehicles in its main prompt example.
What you can do after
Apply it by adding identity, objective, constraints, and prior knowledge to make prompts more relevant.
How it connects
Connects context to next-word prediction, RNNs, attention, prompt engineering, constraints, and prior knowledge.

Also explained in

Compare how 30 books explain context →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Understanding AI. The section links point to the parts of the book it draws on.