179 questions
No questions match those filters.
You're building a few-shot prompt. How should you actua...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansFew-shot example selection is really a small retrieval problem hiding inside a prompting decision, and the three common strategies trade simplicity for relevance. Random sampling picks examples arbitrarily from a pool — cheap, requires no infrastructure, and is enough when the task is simple and the main thing the examples need to convey is output format rather than nuanced task boundaries.
Diversity-based selection curates a fixed set that deliberately spans the range of inputs the task will see, including awkward edge cases, so the model’s in-context behavior generalizes rather than overfitting to whatever pattern happened to get sampled. This is a good default static prompt when you can’t retrieve dynamically per query but still want broad coverage.
Similarity-based selection embeds the incoming query and retrieves the k nearest examples from a labeled pool at request time, so every prompt gets demonstrations that are maximally relevant to that specific input. This consistently produces the best task accuracy in practice, because relevant analogies teach the model more than generic ones — but it requires an embedding index, a retrieval step per request, and adds latency that fixed prompts don’t have. The right choice depends on whether that infrastructure and latency cost is justified by the accuracy gain for your specific task.