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

Context engineering basics

50 cards

Retrieval models, ranking metrics, prompts, and long-context terms a study treats as known.

Card 1 of 50

Front. Rag. What does retrieval-augmented generation do with the text it fetches?

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.Rag

    What does retrieval-augmented generation do with the text it fetches?

    Puts it in the model's input so generation can condition on it. Nothing is written into the weights.

  2. 2.Parametric

    What is parametric versus non-parametric knowledge?

    Parametric knowledge is stored in the weights. Non-parametric knowledge sits in an external store that is retrieved at inference time.

  3. 3.Insert-no-weights

    Does inserting a passage into the prompt change the saved weights?

    No. It only changes the activations for that call.

  4. 4.Knowledge-conflict

    What is a knowledge conflict?

    A retrieved passage says something different from what the model learned in training. Studies measure which source the output follows.

  5. 5.Sparse

    What is sparse retrieval?

    Matching on exact terms with high-dimensional mostly-zero vectors, such as TF-IDF or BM25, served from an inverted index.

  6. 6.Bm25

    What does BM25 score?

    Term overlap between query and document, weighted by how rare each term is, with term frequency saturating and a length normalization.

  7. 7.Inverted-index

    What is an inverted index?

    A map from each term to the list of documents that contain it.

  8. 8.Dense

    What is dense retrieval?

    Encoding queries and documents as low-dimensional vectors and ranking by vector similarity.

  9. 9.Bi-encoder

    At query time, what comparison does a bi-encoder make?

    It encodes the query once and compares that vector with document vectors computed in advance, usually by dot product or cosine.

  10. 10.Cross-encoder

    What is a cross-encoder?

    A model that reads query and document together and outputs one relevance score. It is more accurate but too slow to score a whole corpus.

  11. 11.Late-interaction

    What is late interaction, as in ColBERT?

    Keep one vector per token, and score by summing each query token's best match among the document's token vectors.

  12. 12.Pooling

    What are CLS pooling and mean pooling?

    Two ways to turn token states into one vector: take one designated token's state, or average all token states.

  13. 13.Cosine-dot

    When do cosine similarity and dot product give the same ranking?

    When all vectors are normalized to unit length.

  14. 14.Infonce

    What is the InfoNCE contrastive loss?

    A softmax loss that pushes a query's score for its positive document above its scores for a set of negatives.

  15. 15.In-batch-neg

    What are in-batch negatives?

    Using the other examples' positives in the same batch as negatives, which is cheap and makes larger batches help.

  16. 16.Hard-neg

    What are hard negatives?

    Non-relevant documents that look relevant, often mined with BM25 or an earlier model. They make contrastive training sharper.

  17. 17.False-neg

    What is the false-negative problem in mined negatives?

    Some mined negatives are actually relevant but unlabeled, so training pushes the model away from correct answers.

  18. 18.Ann

    What is approximate nearest-neighbor search?

    Finding vectors close to the query without comparing against every vector, trading a little recall for large speedups.

  19. 19.Hnsw

    What is HNSW?

    A layered graph index for nearest-neighbor search where queries walk from coarse upper layers to dense lower ones.

  20. 20.Pq

    What is product quantization?

    Compressing vectors by splitting them into sub-vectors and storing each as a codebook index, which saves memory but adds error.

  21. 21.Matryoshka

    What are Matryoshka embeddings?

    Embeddings trained so a prefix of the vector, such as the first 256 of 1024 dimensions, is still a usable embedding.

  22. 22.Recall-k

    What is recall@k?

    The fraction of relevant documents that appear in the top k results.

  23. 23.Precision-k

    What is precision@k?

    The fraction of the top k results that are relevant.

  24. 24.Mrr

    What is mean reciprocal rank?

    The average over queries of 1 divided by the rank of the first relevant result.

  25. 25.Ndcg

    What does nDCG measure?

    Ranking quality with graded relevance, discounting gains lower in the list and normalizing by the ideal ordering.

  26. 26.Beir

    What is zero-shot retrieval evaluation, as in BEIR?

    Testing a retriever on datasets and domains it was not trained on, to measure out-of-domain transfer.

  27. 27.Rerank

    What is a two-stage retrieve-then-rerank pipeline?

    A fast retriever picks candidates, then a slower, more accurate model reorders them.

  28. 28.Rrf

    What is reciprocal rank fusion?

    Combining several rankings by summing 1/(k + rank) for each document, which needs no score calibration.

  29. 29.Hybrid

    Why combine sparse and dense retrieval?

    Sparse handles exact names and rare terms well, and dense handles paraphrase. Fusing them usually beats either alone.

  30. 30.Metadata-filter

    Where can metadata filters act in a retriever?

    Before the search, restricting candidates, or after it, removing results. Post-filtering can leave fewer than k results.

  31. 31.Chunking

    What is chunking?

    Splitting documents into passages that are embedded and retrieved one at a time.

  32. 32.Chunk-overlap

    Why use overlapping chunks?

    So a fact that sits across a boundary still appears whole in at least one chunk.

  33. 33.Granularity

    What is the trade-off in chunk size?

    Small chunks are precise but lose context. Large chunks keep context but dilute the embedding and use more of the window.

  34. 34.Query-expansion

    What is query expansion?

    Adding related terms or rewrites to the query to raise recall.

  35. 35.Hyde

    What is HyDE?

    Have a model write a hypothetical answer and retrieve with its embedding instead of the raw question's.

  36. 36.Asymmetric

    What is asymmetric retrieval?

    Short queries matched against long documents. Some embedding models use different prefixes or encoders for each side.

  37. 37.Faithfulness

    What is faithfulness in RAG evaluation?

    Whether each claim in the output is supported by the retrieved text, separate from whether it is true.

  38. 38.Retrieval-vs-gen

    The gold passage is in the top k but the answer states an unsupported detail. Which stage failed?

    Generation. Retrieval succeeded, and the model added something the passage does not support.

  39. 39.Citation

    What are citation precision and citation recall?

    Precision: cited passages actually support the claim. Recall: every claim that needs support has a citation.

  40. 40.Prompt-template

    What is a prompt template?

    Fixed text with slots, where the question, passages, and examples are filled in for each input.

  41. 41.Few-shot

    What is few-shot prompting?

    Putting a handful of solved examples in the prompt before the new input.

  42. 42.Order-sensitivity

    Why report results over several example orders?

    Few-shot accuracy can change a lot when the same examples are reordered, so one order may be lucky.

  43. 43.Lost-middle

    What is the lost-in-the-middle effect?

    Models often use information at the start or end of a long context better than information in the middle.

  44. 44.Needle

    What does a needle-in-a-haystack test measure?

    Whether a model can find one planted fact at different depths of a long filler context. Passing it does not show multi-step reasoning over long text.

  45. 45.Effective-length

    What is effective context length?

    The length at which a model still uses information reliably, which can be well short of the maximum it accepts.

  46. 46.Kv-exists

    When do a retrieved passage's keys and values exist in the KV cache?

    Only after the passage is placed in the prompt and the model runs prefill over it.

  47. 47.Prefill

    What is prefill?

    The forward pass over all prompt tokens at once, which fills the KV cache before generation starts.

  48. 48.Distractor

    What is a distractor passage?

    Retrieved text that looks relevant but does not answer the question. Studies add them to test robustness.

  49. 49.Oracle-retrieval

    What is an oracle retrieval baseline?

    Giving the model the gold passage directly, which sets an upper bound for what better retrieval could gain.

  50. 50.Closed-book

    What is a closed-book baseline?

    Running the same model with no retrieved text, to show how much retrieval actually adds.