FreeExam
A closed notebook, a blank card, and a pencil on a wooden desk.

Context engineering basics

50 cards

Prompts, retrieval, and the other pieces that fill a model's context window.

Card 1 of 50

Front. Context-engineering. What is context engineering?

These cards are original study material. They are not questions from a named employer or a live hiring loop.

All 50 cards in this deck

  1. 1.Context-engineering

    What is context engineering?

    Deciding what goes into a model's input on each call, such as instructions, examples, retrieved text, history, and tool results, and in what form.

  2. 2.Context-window

    What is the context window?

    The maximum number of tokens a model can process in one call, including both the input and the generated output.

  3. 3.Token-budget

    What must fit in the token budget for one call?

    The system prompt, examples, retrieved passages, conversation history, tool definitions and results, and the room reserved for the reply.

  4. 4.Stateless

    Does a model remember earlier calls?

    No. Each call sees only what is in that call's input. Chat history works because the application resends it.

  5. 5.Tokenizer-count

    Why do token counts differ between models?

    Each model has its own tokenizer, so the same text can split into a different number of tokens.

  6. 6.System-prompt

    What is a system prompt?

    Instructions set by the application that frame the model's role, rules, and format for the whole conversation.

  7. 7.Few-shot

    What is few-shot prompting?

    Including a few worked examples of the task in the prompt, so the model can follow the pattern.

  8. 8.Zero-shot

    What is zero-shot prompting?

    Asking the model to do a task from instructions alone, without examples.

  9. 9.Delimiters

    Why wrap inserted text in delimiters or tags?

    To make clear where instructions end and data begins. The text is still in the prompt; tags only label it.

  10. 10.Instruction-placement

    Where should key instructions go in a long prompt?

    Usually near the start in the system prompt, and often restated near the end, since models use the start and end of long inputs most reliably.

  11. 11.Lost-in-middle

    What is the 'lost in the middle' effect?

    Models tend to use information at the start and end of a long input better than information buried in the middle.

  12. 12.Rag

    What is retrieval-augmented generation (RAG)?

    Fetching relevant passages for each request and inserting them into the prompt, so the model can answer from them.

  13. 13.Chunking

    What is chunking?

    Splitting documents into smaller passages for indexing and retrieval.

  14. 14.Chunk-size

    What is the chunk size tradeoff?

    Small chunks are precise but can lose surrounding context. Large chunks keep context but dilute the match and use more tokens.

  15. 15.Chunk-overlap

    Why do neighboring chunks often overlap?

    So a sentence or idea near a boundary appears whole in at least one chunk.

  16. 16.Embedding

    What is a text embedding?

    A vector representing a piece of text, where texts with similar meaning end up close together.

  17. 17.Embedding-match

    Why must queries and documents use the same embedding model?

    Different models produce vectors in different spaces, often with different sizes, so comparing them is meaningless.

  18. 18.Similarity

    What is cosine similarity?

    A measure of how closely two vectors point in the same direction, from -1 to 1, used to compare embeddings.

  19. 19.Vector-index

    What is a vector index?

    A data structure that finds the nearest stored vectors to a query vector quickly, often approximately.

  20. 20.Ann

    What is approximate nearest neighbor search?

    Search that trades a little accuracy for large speed gains, such as HNSW graphs or IVF partitions.

  21. 21.Top-k

    What does top-k mean in retrieval?

    The number of nearest results returned for a query.

  22. 22.Index-freshness

    Can vector search find a document added after the last index build?

    No. A document must be embedded and indexed before search can return it.

  23. 23.Bm25

    What is BM25?

    A keyword-based ranking function that scores documents by term matches, weighted by how rare the terms are and adjusted for document length.

  24. 24.Hybrid-search

    What is hybrid search?

    Combining keyword search and embedding search, so exact terms like codes and meaning-based matches both count.

  25. 25.Rrf

    What is reciprocal rank fusion?

    A simple way to merge ranked lists by giving each item a score based on its rank in each list and summing them.

  26. 26.Reranker

    What is a reranker?

    A model that reads the query and each candidate passage together and rescores them more accurately than first-stage search.

  27. 27.Rerank-score

    What does a high reranker score mean?

    The passage looks relevant to this query by the reranker's judgment. It does not prove the passage is correct.

  28. 28.Metadata-filter

    What is a metadata filter?

    A rule restricting search to documents with certain attributes, such as product, date, or access level.

  29. 29.Pre-post-filter

    Why filter during search instead of after?

    Filtering after taking the top k can leave few or no results. Filtering during search keeps k results that all pass.

  30. 30.Access-control

    Where should document permissions be enforced in RAG?

    In retrieval, before any text reaches the model. Instructions in the prompt are not a security boundary.

  31. 31.Query-rewrite

    What is query rewriting?

    Rephrasing or expanding the user's question before searching, to better match how documents are written.

  32. 32.Multi-query

    What is multi-query retrieval?

    Searching with several versions of the question and merging the results, which widens coverage.

  33. 33.Recall-at-k

    What does recall at k measure for retrieval?

    The share of queries where a needed passage appears in the top k results.

  34. 34.Precision-at-k

    What does precision at k measure?

    The share of the top k results that are relevant.

  35. 35.Distractors

    Can adding more passages hurt an answer?

    Yes. Irrelevant passages can distract the model or bury the useful one.

  36. 36.Dangling-reference

    What goes wrong when a chunk says 'this limit' and the noun is in the previous chunk?

    The model receives the number without knowing what it applies to. Adding headings or context to each chunk helps.

  37. 37.Citations

    Why ask the model to cite sources?

    So each claim can be traced to a passage the model was given, and unsupported claims are easier to spot.

  38. 38.Grounding

    What does it mean for an answer to be grounded?

    Its claims are supported by the provided sources rather than by guesses.

  39. 39.Conversation-history

    How is conversation history kept within limits?

    By dropping old turns, summarizing them, or storing key facts separately and reinserting them when needed.

  40. 40.Dropped-turn

    What happens to a constraint that only appeared in a dropped turn?

    The model no longer has it, unless it was summarized or saved and reinserted.

  41. 41.Prompt-vs-finetune

    How does putting examples in a prompt differ from fine-tuning on them?

    Prompt examples affect only calls that include them. Fine-tuning changes the weights, so it affects every call.

  42. 42.Training-vs-context

    What is the difference between knowledge in the weights and in the context?

    Weight knowledge comes from training and may be outdated or vague. Context knowledge is exactly the text supplied on this call.

  43. 43.Prompt-cache

    What is prompt caching?

    Reusing the computed state for a repeated prompt prefix across calls, which cuts cost and latency. It is not memory of past conversations.

  44. 44.Kv-cache

    What does the KV cache hold?

    Keys and values for tokens already processed in the current generation, so new tokens do not recompute them.

  45. 45.Stop-sequence

    What is a stop sequence?

    A string that ends generation when the model produces it. It does not change the input.

  46. 46.Max-tokens

    What does the max output tokens setting do?

    Caps how many tokens the model may generate. Too low cuts answers off; it also reserves space in the window.

  47. 47.Structured-data

    Can a model reliably filter rows from a table it has only had described?

    No. It only has the rows included in its input. Large data should be queried by a tool and the results inserted.

  48. 48.Tool-results

    Why trim or summarize large tool results?

    Raw outputs can fill the window with irrelevant detail, raising cost and making the useful part harder to find.

  49. 49.Long-context-vs-rag

    What is the tradeoff between long context and retrieval?

    Long context is simpler and avoids missed retrieval, but costs more per call and can still miss details. Retrieval is cheaper but can fail to fetch the right passage.

  50. 50.Context-eval

    How do you know a context change helped?

    Score the system on a fixed evaluation set before and after the change, looking at answer quality, cost, and latency.