Your LLM feature works well but is too slow and expensive. How would you reduce cost and latency without hurting quality?
What the interviewer wants to hear
- Measure where tokens and time go first
- Prompt caching with a stable prefix
- Shorter prompts and outputs, fewer examples
- Route to smaller models where evals allow
- Batch offline work and stream user-facing replies
- Guard quality with evals before and after
Model answer
I would start by measuring: input and output tokens per request, time to first token, total time and cost per feature. Then I would apply the cheapest safe changes. I would restructure the prompt so the stable parts come first and enable prompt caching. I would trim unused instructions, examples and retrieved chunks, and ask for shorter outputs, since output tokens are slower and pricier. Next I would test routing: send simple requests to a smaller, faster model and keep the large model for hard cases. Work that is not interactive, like nightly labelling, can move to a batch API at a discount. For user-facing replies I would stream so the response feels faster. Every change goes through the eval set first, so I only keep savings that do not lower quality.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Prompt Engineer questions
- How would you build an evaluation set for a prompt that writes replies to customer complaints?
- When would you split a task into a chain of prompts instead of one large prompt? What are the trade-offs?
- A marketing team wants all generated content to match their brand voice. How do you achieve consistency?
- How do you know when prompt engineering has reached its limit and another approach, such as RAG or fine-tuning, is needed?
- Write the outline of a system prompt for a banking support assistant. What sections would it include and why?
- Design the prompt and retrieval setup for a customer support bot that answers from a help centre. What choices matter most?
- How do you design tool definitions so an LLM agent uses them correctly?
- How would you handle personal data in an LLM workflow that processes customer emails?
- How would you set up regression testing for prompts so changes can be shipped safely?