Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
AWS · AIB-C01 · BETA

Prompts, tokens, and context windows

AIB-C01 · Lesson 5 of 26 · 30:08

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Lesson 5 of the free AWS Certified AI Business Strategist series (AIB-C01 beta exam, domain 1, AI fundamentals and literacy). In this lesson: prompt engineering basics, principles of a good prompt, examples and output formats, iterate and evaluate, tokens, and context windows. With three quick checks and a recap, and AnyCompany Foods, a fictional maker of soups, sauces, and snacks, as the running example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Blame the model?

AnyCompany's marketing team tried a generative AI assistant, and gave up after a week: the answers were vague, too long, and sometimes made up facts. The team blamed the model. In most cases, the problem was the prompt, and the limits of what the model can take in at once.

Prompt engineering basics

A prompt is the input you give a generative model: the instructions, the context, and the question. Prompt engineering is the practice of writing prompts that reliably produce the output you want. It needs no coding, and it is often the cheapest way to improve results, before you consider any other technique. Small changes in wording can change the answer a lot, so test prompts, and keep the ones that work.

Principles of a good prompt

Good prompts share a few principles. Be clear and specific about the task: ask for a product description of about eighty words, not just something about this soup. Give context: the audience, the brand voice, and the facts the model must use. Set constraints, such as what to avoid, and ask the model to say when it does not know. And split complex work into steps, instead of asking for everything at once.

Examples and output formats

Examples are powerful: one or a few examples of the output you want, called few shot prompting, show the model the pattern to follow. A prompt with no examples at all is called zero shot. You can also give the model a role, such as a food safety expert, to shape its tone and focus. And state the output format, like a table, a list of bullet points, or fields that another system can process.

Iterate and evaluate

Prompting is iterative: try, review the output, and refine. Keep a small set of test questions with expected answers, and check each new prompt against them. Share the prompts that work as templates, so that teams get consistent results. And remember that a prompt guides a model, but it cannot give the model facts it does not have.

Tokens

Generative models do not read words, they read tokens: small pieces of text, often a word or part of a word. As a rough guide for English, a token is about three quarters of a word, but the exact count depends on the model. Tokens matter for business, because many services charge per token, for the input and for the output. Longer prompts and longer answers cost more, and they take longer to produce.

Context windows

The context window is the maximum number of tokens that a model can consider at once: the prompt, any documents you add, the conversation so far, and the answer. When a conversation or a document goes beyond it, the extra content is cut, and the model simply does not see it. Even within the limit, very long inputs raise cost and latency, and details in the middle can get less attention. Typical signs are answers that forget earlier instructions, miss facts from long documents, or stop in the middle of a sentence because of an output limit. Remedies include summarizing earlier turns, splitting documents, retrieving only the relevant passages, or choosing a model with a larger window.

Recap

Let's recap. Prompt engineering is often the cheapest way to improve results, with no coding. Be specific, give context, set constraints, and split complex work into steps. Examples, a role, and a stated output format make results consistent. Models read tokens, and many services charge per token for input and output. The context window limits what a model sees at once, so summarize, split, or retrieve only what matters.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A marketer types: “write something about our new soup”. The answer is generic and far too long. What would improve it most?

    • A larger model
    • Fine-tuning a model first
    • A specific prompt: audience, facts, length, tone
    • A shorter prompt with less context
    Show the answer

    A specific prompt: audience, facts, length, tone

    A specific prompt, with the audience, the facts, the length, and the tone, guides the model to the output you want. “A larger model” is wrong, because a larger model still has to guess what a vague prompt means. “Fine-tuning a model first” is wrong, since fine-tuning is slow and costly, and it should come after better prompts, not before. And “A shorter prompt with less context” is wrong, because less context makes the answer even more generic.

  2. AnyCompany wants every product summary in the same structure: a title, three benefits, and the allergens. What is the best approach?

    • Give an example and state the output format
    • Remove all constraints from the prompt
    • Use a one word prompt
    • Switch to fixed rules for writing
    Show the answer

    Give an example and state the output format

    An example of the structure, with the output format stated in the prompt, shows the model exactly what to produce. “Remove all constraints from the prompt” is wrong, because removing constraints makes the structure vary even more. “Use a one word prompt” is wrong, since a one word prompt gives the model no structure to follow. And “Switch to fixed rules for writing” is wrong, because rules cannot write a fresh summary for each new product.

  3. AnyCompany’s assistant answers questions about a 200-page supplier contract, but ignores the clauses near the end. Short contracts work fine. What is the most likely cause?

    • The model was not fine-tuned
    • The contract exceeds the context window
    • The prompt has too few examples
    • Drift in the contract data
    Show the answer

    The contract exceeds the context window

    The contract does not fit in the context window, so part of it is cut, and the model never sees it. “The model was not fine-tuned” is wrong, because fine-tuning changes behavior, and it would not make the model see the end of a long document. “The prompt has too few examples” is wrong, since short contracts work fine with the same prompt. And “Drift in the contract data” is wrong, because drift is a change over time, while this problem depends on the length of the document.