Card 1 of 50
Front. Budget-count. What counts against the token budget of a served request?
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.Budget-count
What counts against the token budget of a served request?
Every input token, including system prompt, tools, history, and retrieved text, plus the output tokens generated.
2.Server-count
Why count tokens on the server with the model's own tokenizer?
Estimates from characters or another tokenizer can be off, causing requests to fail or be truncated unexpectedly.
3.Tokenizer-pin
Why pin the tokenizer version with the model?
A different tokenizer gives different counts and IDs, breaking budgets, caches, and outputs.
4.Over-limit
What should a server do when a request exceeds the context limit?
Either reject it with a clear error or apply a documented truncation policy. It must never silently cut arbitrary text.
5.Truncation-policy
Why must the server define which part truncation drops?
Dropping the oldest history, the middle, or retrieved text gives very different answers. Callers need to know which.
6.Truncation-flag
Why return a flag when input was truncated?
So callers and traces know the model did not see the full input.
7.Attends-over
What does the model attend over when a prompt is served?
Only the tokens actually sent in that request, after any truncation. Nothing else on the server is visible.
8.Prompt-cache
What does a prompt cache store?
The computed KV state of a prompt prefix, so later requests with the same prefix can skip that prefill.
9.Cache-key
What is the key for a prompt cache entry?
The exact token sequence of the prefix, along with the model version. One changed token early on means a miss.
10.Two-prefixes
Two different prefixes are both in the prompt cache. How is that stored?
As separate entries, though a tree structure can share the tokens they have in common at the start.
11.Radix
What is prefix sharing with a radix tree?
Storing cached prefixes in a tree so requests that share a beginning reuse the same KV blocks.
12.Cache-ttl
What is a prompt cache TTL?
How long an unused entry stays before it is evicted. Short TTLs save memory but lower the hit rate.
13.Eviction
What eviction policy do prompt caches often use?
Least recently used: when memory runs short, drop the entries that have gone unused the longest.
14.Hit-rate
Why monitor the prompt cache hit rate?
Hits cut latency and cost. A sudden drop often means a prompt change put variable text before the stable prefix.
15.Timestamp-prefix
Why is putting the current time at the top of a system prompt costly?
It changes every request, so the prefix never matches and the cache never hits.
16.Model-change-cache
What happens to cached prefixes when the model weights change?
They are invalid, since KV values depend on the weights. The cache must be cleared or keyed by model version.
17.Kv-fp32
How many bytes does one fp32 element of the KV cache use?
Four. bf16 and fp16 use two, and fp8 uses one.
18.Kv-per-token
How much KV cache does one token need?
2 × layers × KV heads × head dim × bytes per element, for the key and value in every layer.
19.Kv-capacity
What sets how many concurrent long requests a GPU can serve?
The memory left after the weights, divided by the KV cache each request needs at its length.
20.Kv-offload
What is KV cache offloading?
Moving inactive KV blocks to CPU memory or disk and loading them back when needed, trading latency for capacity.
21.Kv-lifetime
When is a request's KV cache freed?
When the request finishes, unless the server keeps its prefix in a prompt cache for reuse.
22.Index-build
What does building a vector index involve?
Chunking documents, embedding each chunk, and inserting the vectors and metadata into an index structure.
23.Embed-pin
Why pin the embedding model version?
Query and document vectors must come from the same model. Upgrading it means re-embedding the whole corpus.
24.Reembed
How do you switch embedding models safely?
Build a new index with the new model alongside the old, evaluate it, then switch traffic with an alias.
25.Alias
What is an index alias?
A stable name that points to one index version, so swapping or rolling back is a pointer change.
26.Incremental
What is an incremental index update?
Adding, changing, or deleting only the affected chunks, instead of rebuilding the whole index.
27.Deleted-source
A document is deleted at the source but not in the index. What can search still do?
Return its old chunks, which can expose removed or outdated content.
28.Tombstone
What is a tombstone in an index?
A marker that a record was deleted, so searches skip it until the space is reclaimed by compaction.
29.Stable-ids
Why give chunks stable IDs?
So updates and deletes can find the right records, and citations and logs point to the same chunk over time.
30.Freshness
What is index freshness lag?
The time between a source change and when search reflects it. It should be measured and have a target.
31.Filter-time
When does a metadata filter take effect?
At query time, when the search runs. Pre-filtering restricts candidates before the vector search, post-filtering removes results after.
32.Post-filter-gap
Why can post-filtering return too few results?
If most of the top k fail the filter, few or none remain.
33.Acl
How are document permissions enforced in retrieval?
Store access labels with each chunk and filter on the caller's identity in every query.
34.Ann-params
What do ANN search parameters such as ef or nprobe trade off?
Recall against latency: searching more of the index finds more true neighbors but takes longer.
35.Shards
Why shard a vector index?
To spread a large index across machines for memory and speed. Queries go to all shards and results are merged.
36.Replicas
Why replicate a vector index?
For more query throughput and to survive a node failure.
37.Embed-batch
Why batch embedding calls when indexing?
Batches use the GPU or API far more efficiently, cutting cost and time for large backfills.
38.Embed-cache
Why cache embeddings by content hash?
Unchanged chunks do not need re-embedding on each rebuild, which saves cost.
39.Retrieval-metrics
What retrieval metrics should be monitored in production?
Query latency, empty-result rate, filter hit rates, index size, freshness lag, and error rate.
40.Empty-rate
What can a rise in the empty-retrieval rate mean?
A broken filter, an index swap that lost data, or new queries that the corpus does not cover.
41.Offline-recall
Why keep a labeled query set for the retriever?
To measure recall@k on each index or model change before it goes live.
42.Log-prompts
What is in a full prompt log?
Everything sent to the model, including user text and retrieved documents, which may contain personal or restricted data.
43.Retention-choice
Full prompt logs contain retrieved and user text. What kind of choice is the retention period?
A policy choice about privacy, compliance, and debugging needs, not just a storage setting.
44.Log-hash
What can be logged instead of full prompts?
Token counts, chunk IDs, prompt template version, and hashes, which support debugging without storing raw text.
45.Template-version
Why log the prompt template version with each request?
So output changes can be traced to the template that produced them.
46.Max-output
Why set a server-side cap on output tokens?
To bound latency, cost, and KV memory for each request.
47.Streaming
What does streaming change for the client?
Tokens arrive as they are generated, lowering perceived latency. Total generation time stays the same.
48.Admission
What is admission control for long requests?
Rejecting or queueing requests when KV memory is short, instead of letting them fail midway.
49.Priority
Why separate queues for short and long prompts?
Long prefills can delay many short requests. Separate queues or chunked prefill keep short latency low.
50.Context-cost
What usually dominates the cost of a RAG request?
Input tokens from retrieved passages and history, which are paid on every request unless cached.
