Skip to content
RED SAGSkills

Prompt Engineering interview questions and answers

Prompt engineering questions check whether you can get reliable, well-formatted output from a language model.

Below are 60 Prompt Engineering questions with the correct answer and a short explanation, grouped from fresher to experienced level. Try each one before you open the answer.

What Prompt Engineering interviews usually check

  • ✓Clear instructions and context
  • ✓Few-shot examples
  • ✓Structured output
  • ✓Reducing hallucinations
  • ✓Testing and iterating prompts

Prompt Engineering interview questions for freshers easy

1. The required keyword in JSON Schema

In a JSON Schema for structured output, what does "required": ["name", "email"] mean?

  1. A.The fields must be the first two keys in order
  2. B.The fields must be non-empty strings
  3. C.The fields are only allowed when other fields exist
  4. D.The object must contain the name and email keys
Show answer

Answer: D. The object must contain the name and email keys

The required keyword lists properties that must be present in the object. It does not check type, order or emptiness; those come from "type", "minLength" and similar keywords on each property.

2. Parsing a JSON reply in Python

What does this Python code print?

import json
data = json.loads('{"tags": ["rag", "eval"], "score": null}')
print(len(data["tags"]), data["score"])
  1. A.2 null
  2. B.2 None
  3. C.11 None
  4. D.KeyError: score
Show answer

Answer: B. 2 None

json.loads turns a JSON array into a Python list (length 2) and JSON null into Python None. print shows None, not null. Remember to handle None values when the model leaves a field empty.

3. Improving a vague prompt

The prompt "Write about our new phone" gives generic, inconsistent results. Which change helps the most?

  1. A.Add "please" and "thank you" to the prompt
  2. B.State the audience, purpose, length, tone, key facts to include and the output format
  3. C.Write the prompt in capital letters
  4. D.Ask the same vague question several times and pick one
Show answer

Answer: B. State the audience, purpose, length, tone, key facts to include and the output format

Models fill missing details with generic guesses. Saying who the text is for, what it should achieve, how long it should be, which facts to use and how it should be formatted removes ambiguity and makes results consistent.

4. Getting a consistent format

Your app needs every answer as three bullet points of at most 15 words each, but the model writes paragraphs. What is the best fix?

  1. A.Increase temperature
  2. B.Ask the model to "be shorter"
  3. C.Use a longer system prompt about the company history
  4. D.State the exact format and limits clearly and show one example of the desired output
Show answer

Answer: D. State the exact format and limits clearly and show one example of the desired output

Models follow precise format instructions much better than vague ones, and an example removes any doubt. For machine-read output, structured output features or JSON schemas are even more reliable, with validation in code.

5. The model forgot the last message

Your chatbot sends only the newest user message to the API, and the model keeps forgetting what was said earlier. Why?

  1. A.The model memory is full and needs to be cleared
  2. B.Temperature is set too high
  3. C.The model only remembers messages written in English
  4. D.The API is stateless, so you must send the relevant conversation history with every request
Show answer

Answer: D. The API is stateless, so you must send the relevant conversation history with every request

Chat model APIs do not remember past calls by default. Each request must include the messages the model should know about. Apps keep the history themselves and resend it, often trimming or summarising it to fit the context window.

6. Using XML-style tags

Why do many prompt engineers wrap parts of a prompt in tags like <document> and <instructions>?

<instructions>Summarise the document in 3 bullet points.</instructions>
<document>
{{ticket_text}}
</document>
  1. A.Tags make the model run faster
  2. B.Models can only read text inside tags
  3. C.Tags clearly mark where each part starts and ends, so the model mixes them up less and outputs are easier to parse
  4. D.Tags encrypt the content so the provider cannot read it
Show answer

Answer: C. Tags clearly mark where each part starts and ends, so the model mixes them up less and outputs are easier to parse

Clear labels help the model tell instructions apart from data, examples and context. They also let you refer to parts by name ("use only the text in <document>") and ask for output in tags that your code can extract. Any consistent delimiter works; tags are simply clear and popular.

7. Prefilling the response

Some APIs let you write the first few characters of the assistant reply yourself. What is a common use of this "prefill"?

  1. A.Starting the reply with "{" so the model continues straight into JSON with no chatty preamble
  2. B.Hiding the reply from the user
  3. C.Making the model answer in fewer tokens than the limit
  4. D.Giving the model a password
Show answer

Answer: A. Starting the reply with "{" so the model continues straight into JSON with no chatty preamble

When you prefill, the model continues from your text as if it had written it. Starting with "{" or an opening tag skips greetings like "Sure, here is the JSON" and steers the format. Not every provider or model supports prefill, so check the docs.

8. What top_p controls

An API call sets top_p = 0.9. What does this setting do when the model picks each next token?

  1. A.It forces the model to pick the single most likely token 90% of the time
  2. B.It samples only from the smallest set of tokens whose probabilities add up to 90%
  3. C.It cuts the reply off once 90% of max_tokens has been used
  4. D.It lowers every token probability by 10% before sampling
Show answer

Answer: B. It samples only from the smallest set of tokens whose probabilities add up to 90%

top_p is nucleus sampling: tokens are sorted by probability and only the top ones that together reach 90% stay in the draw. Unlikely tail tokens are removed, which keeps output focused while still allowing some variety.

9. Saying why a rule exists

A prompt says "Never use ellipses." A better version says "Your reply will be read aloud by a text-to-speech engine, so never use ellipses, because it cannot pronounce them." Why is the second version better?

  1. A.Longer prompts always score higher in every evaluation
  2. B.The model ignores any rule that has no reason attached
  3. C.The reason lets the model apply the rule to related cases too
  4. D.Giving a reason makes the reply cheaper to generate
Show answer

Answer: C. The reason lets the model apply the rule to related cases too

When the model knows the goal behind an instruction, it can generalise: here it may also avoid other symbols a speech engine reads badly. A bare rule is followed more narrowly. Context about purpose is one of the cheapest ways to improve instruction following.

10. Defining what "urgent" means

A ticket classifier labels tickets "urgent" or "normal", but different runs disagree on borderline tickets. Which prompt change helps most?

  1. A.Change the label names to "U" and "N" to save tokens
  2. B.Ask the model to be careful when choosing labels
  3. C.Put the labels in bold so the model notices them
  4. D.Define "urgent" with concrete criteria and a borderline example
Show answer

Answer: D. Define "urgent" with concrete criteria and a borderline example

Inconsistent labels usually mean the category is vague. Writing down the criteria (for example, payment failed or service down for a business user) and showing a borderline case gives the model the same decision rule every time.

11. Removing chatty openers

Your summariser starts every reply with "Sure! Here is a summary of the text you provided:" and the downstream app shows this to users. What is the cleanest prompt fix?

  1. A.Raise max_tokens so the opener does not crowd out the summary
  2. B.Ask the model to be less polite in general
  3. C.Strip the first 50 characters of every reply in code
  4. D.Tell it to output only the summary, with no introduction or closing remarks
Show answer

Answer: D. Tell it to output only the summary, with no introduction or closing remarks

The model is adding conversational framing because nothing says not to. A direct instruction to return only the summary fixes it at the source. Cutting a fixed number of characters breaks whenever the opener changes length.

12. Temperature set to 1.9

A developer sets temperature to 1.9 for "more creative" ad copy. Replies now contain odd word choices and sometimes nonsense. Why?

  1. A.Temperature above 1 makes the model switch languages on purpose
  2. B.The model stops reading the system prompt at high temperature
  3. C.High temperature doubles max_tokens and the reply runs on
  4. D.High temperature flattens probabilities, so unlikely tokens get picked often
Show answer

Answer: D. High temperature flattens probabilities, so unlikely tokens get picked often

Temperature divides the logits before sampling; values above 1 flatten the distribution so rare, poor tokens are chosen far more often. For creative text, moderate values (around 0.7 to 1.0) usually give variety without breaking coherence.

13. Replies sent on WhatsApp

Your bot's replies are delivered as WhatsApp messages to customers in India. Which instruction suits this channel?

  1. A.Use wide markdown tables for every price list
  2. B.Start every reply with an H1 heading
  3. C.Write long essays so customers have full detail
  4. D.Keep replies short and avoid markdown tables and headings
Show answer

Answer: D. Keep replies short and avoid markdown tables and headings

WhatsApp shows plain text on small screens and does not render markdown tables or headings, so they appear as raw symbols. Short messages with simple line breaks read well on phones.

14. Five headlines that all look alike

You ask for "5 headlines for our sale" and get five near-identical lines. Which instruction helps most?

  1. A.Ask for 5 headlines, each with a different angle
  2. B.Ask for 50 headlines and keep the first 5
  3. C.Ask for 5 headlines in the same style
  4. D.Ask for 5 headlines without punctuation
Show answer

Answer: A. Ask for 5 headlines, each with a different angle

Saying how the options should differ (for example price, urgency, quality, humour, festive theme) gives the model a reason to vary them. Without that, it tends to produce close variations of its most likely answer.

15. Customers writing in Hinglish

Many Indian customers write messages like "mera order abhi tak nahi aaya, kab aayega?". What is a sensible prompt instruction?

  1. A.Reject any message that is not in standard English
  2. B.Translate every reply into formal Sanskrit-heavy Hindi
  3. C.Expect Hinglish and reply in the customer's own style and script
  4. D.Ask the customer to resend the message in English
Show answer

Answer: C. Expect Hinglish and reply in the customer's own style and script

Code-mixed Hindi-English in Latin script is very common. Large models usually understand it; the prompt should say it is expected and set the reply style, such as answering in simple Hinglish when the customer uses it.

16. Writing ₹ amounts the Indian way

A finance assistant for Indian users writes "₹1,250,000". The product team wants "₹12,50,000". What should the prompt do?

  1. A.State the Indian digit grouping rule and show one example
  2. B.Ask the model to avoid numbers in all replies
  3. C.Tell the model it is in India and nothing else
  4. D.Ask for amounts in scientific notation
Show answer

Answer: A. State the Indian digit grouping rule and show one example

The Indian system groups the last three digits and then pairs (12,50,000 = 12.5 lakh). An explicit format rule with an example is clearer than hoping the model infers it; for critical values, format numbers in code.

17. When to hand off to a human

A telecom support bot should pass some chats to a human agent. Which instruction is most useful?

  1. A.Hand off whenever the bot feels the chat is getting hard
  2. B.List clear triggers, e.g. a legal threat or third failed fix
  3. C.Never hand off, so costs stay low
  4. D.Hand off every chat after the first message
Show answer

Answer: B. List clear triggers, e.g. a legal threat or third failed fix

Concrete triggers (legal or safety issues, repeated failure, explicit request for a person, high-value account) give consistent decisions. Vague feelings lead to random handoffs or none at all.

18. Replies that ignore the customer

A loyalty-programme bot gives generic answers even though your database knows each member's tier and points balance. What should you do?

  1. A.Ask the model to guess the customer's tier from their tone
  2. B.Insert the relevant profile fields into the prompt for each request
  3. C.Fine-tune a separate model for every customer
  4. D.Tell customers to type their tier in each message
Show answer

Answer: B. Insert the relevant profile fields into the prompt for each request

The model knows only what is in the prompt. Adding the member's tier, points and recent orders (only what is needed) lets it answer personally and correctly.

19. A draft that is almost right

In a chat with an LLM, a draft press release is good except that it is too long and misses the launch date. What is the efficient next step?

  1. A.Start a new chat and repeat the original request
  2. B.Say "make it better" and see what changes
  3. C.Copy the draft into a different model with no context
  4. D.Ask for specific edits: cut to 200 words and add the date
Show answer

Answer: D. Ask for specific edits: cut to 200 words and add the date

Targeted feedback keeps what already works and fixes exactly what does not. Vague requests like "make it better" can change good parts, and starting over loses progress.

20. Advance received from a customer

A customer pays ₹50,000 in advance for goods that will be delivered next month. How is this shown in this month’s balance sheet?

  1. A.As revenue for this month
  2. B.As a current asset
  3. C.As part of equity
  4. D.As a current liability (advance from customer)
Show answer

Answer: D. As a current liability (advance from customer)

The business has not yet delivered the goods, so it has not earned the revenue. It owes the customer either the goods or a refund, which makes the advance a liability. Under Ind AS 115 or IFRS 15 it is called a contract liability.

Prompt Engineering intermediate interview questions medium

21. Changing the 0.5 cut-off

A churn model outputs probabilities. Calling a customer costs ₹20 and a lost customer costs ₹2,000. Why would you set the action threshold well below 0.5?

  1. A.Lower thresholds always improve accuracy
  2. B.The model is trained to output scores below 0.5
  3. C.Missing a churner costs far more than a wasted call
  4. D.Thresholds below 0.5 reduce false positives
Show answer

Answer: C. Missing a churner costs far more than a wasted call

Because a missed churner is 100 times as costly as an unneeded call, it pays to act even when churn probability is fairly low. A lower threshold catches more churners at the price of more false positives. 0.5 is only right when both errors cost the same.

22. What schema-constrained output guarantees

You turn on strict structured output with a JSON schema, so decoding is constrained to the schema. What does this still NOT guarantee?

  1. A.That the output parses as JSON
  2. B.That required keys are present
  3. C.That enum fields use one of the allowed values
  4. D.That the extracted values are factually correct
Show answer

Answer: D. That the extracted values are factually correct

Constrained decoding only allows tokens that keep the output valid against the schema, so syntax, required keys and enums are enforced. It cannot check that a date or amount was read correctly from the source. You still need business validation and evals.

23. Where to put fixed rules

In a customer chat assistant, where should rules like "always respond in a polite tone and never share internal pricing formulas" go?

  1. A.Inside every user message, typed by the customer
  2. B.In the final assistant message
  3. C.In the system prompt, which applies to the whole conversation and has higher priority than user turns
  4. D.Nowhere; models follow these rules automatically
Show answer

Answer: C. In the system prompt, which applies to the whole conversation and has higher priority than user turns

System prompts hold stable rules, persona and constraints for every turn, and models are trained to give them priority over user messages. But they are not a security boundary: sensitive data should not be in the prompt at all if it must never leak.

24. Answers too basic for experts

An internal tool for cardiologists gives answers that explain basic terms like "blood pressure". Which change is most effective?

  1. A.Ask for shorter answers only
  2. B.In the system prompt, describe the audience as practising cardiologists and ask for technical detail without basic definitions
  3. C.Increase top-p
  4. D.Add "you are smart" to the prompt
Show answer

Answer: B. In the system prompt, describe the audience as practising cardiologists and ask for technical detail without basic definitions

The model guesses the reader when you do not tell it, often assuming a general audience. Stating the audience and the expected depth changes vocabulary, detail and assumptions. A role for the model plus a clear audience works better than either alone.

25. CRITICAL in capitals everywhere

An older prompt says "CRITICAL: You MUST ALWAYS use the search tool!" After moving to a newer, more instruction-following model, it calls search even for "hi". What is the best change?

  1. A.Add more capital letters so the rule is even clearer
  2. B.Repeat the rule three times in the system prompt
  3. C.Move the rule into the user message instead
  4. D.Soften it to a calm rule about when search is useful
Show answer

Answer: D. Soften it to a calm rule about when search is useful

Shouting was a workaround for older models that missed instructions. Modern models take instructions seriously, so the same emphasis makes them over-apply the rule. A normal sentence such as "use search when the question needs current or company data" gives better judgement.

26. Labels with stray spelling

A JSON output field "category" should be one of five values, but the model sometimes writes "Refunds", "refund" or "money back". What is the strongest fix?

  1. A.Make the field an enum of the five values in the schema
  2. B.Lowercase the field in code and hope for the best
  3. C.Ask the model to "spell categories carefully"
  4. D.Make the category field optional
Show answer

Answer: A. Make the field an enum of the five values in the schema

An enum in a JSON schema lists the only allowed strings. With schema-constrained decoding or strict tool parameters, the model cannot emit any other value, so downstream code can rely on an exact match.

27. Asking the general question first

Before answering "Can my Dubai free-zone company invoice a mainland client?", a prompt first asks the model "What general rules govern free-zone versus mainland trading?" and then answers using that. What is this technique called?

  1. A.Step-back prompting
  2. B.Self-consistency
  3. C.Few-shot prompting
  4. D.Prompt prefilling
Show answer

Answer: A. Step-back prompting

Step-back prompting asks the model to first state the higher-level concept or principle behind a question, then reason from it to the specific case. It often helps on questions that need background rules before the details.

28. Searching with a draft answer

Short user questions retrieve poor documents. A colleague suggests asking the LLM to write a hypothetical answer first and embedding that text for the search. What is this technique?

  1. A.Prompt caching
  2. B.Beam search
  3. C.Logit bias
  4. D.HyDE
Show answer

Answer: D. HyDE

HyDE (hypothetical document embeddings) generates a fake answer that looks like the documents you want and searches with its embedding. It often lands closer to real answer passages than a short question does. The draft itself is not shown to users; only the retrieved documents are used.

29. Brand names getting translated

A prompt translates an app's English strings into Hindi. Product names like "PayLater" and the term "UPI" keep being translated or transliterated inconsistently. What is the best fix?

  1. A.Translate one word at a time in separate calls
  2. B.Provide a glossary of fixed terms and their handling
  3. C.Ask for a more literal translation in general
  4. D.Lower max_tokens so there is less to translate
Show answer

Answer: B. Provide a glossary of fixed terms and their handling

A glossary tells the model exactly how to treat brand names and technical terms, which keeps them consistent across thousands of strings. General style instructions do not pin down specific terms.

30. Different answers at temperature 0

With temperature 0 and the same prompt, a model occasionally returns slightly different text. Which explanation is most accurate?

  1. A.Temperature 0 is secretly the same as temperature 1
  2. B.The model learns from each call and then changes its answer
  3. C.Small numeric differences in serving mean exact repeats are not promised
  4. D.Providers randomly edit replies to stop copying
Show answer

Answer: C. Small numeric differences in serving mean exact repeats are not promised

Even with greedy decoding, batching, parallel floating-point maths and some model architectures can change results slightly between runs. Providers generally do not promise bit-for-bit determinism, so tests should allow for small variation.

31. A security team gets refused

An internal tool for a company's security team refuses many legitimate questions about how common malware works. What is an appropriate prompt change?

  1. A.Tell the model it will be shut down if it refuses
  2. B.Rephrase every question as fiction
  3. C.State who the users are and their defensive purpose
  4. D.Raise the temperature until refusals stop
Show answer

Answer: C. State who the users are and their defensive purpose

Models judge requests by likely intent. Stating that users are verified security staff doing defensive analysis gives legitimate context. Tricks like threats or fiction framing are unreliable and amount to jailbreaking.

32. Pulling a table out of a PDF

You need line items from scanned invoices into your database. Which prompt design is most reliable?

  1. A.Ask the model to describe the whole table in a paragraph
  2. B.Ask for the table "in any format you like"
  3. C.Ask the model to redraw the table in ASCII art
  4. D.Name the columns and types; ask for one JSON row per item
Show answer

Answer: D. Name the columns and types; ask for one JSON row per item

Naming columns (description, quantity, unit_price, gst_rate) with types, and asking for one structured row per item, gives output your code can load directly. Free-form descriptions need fragile parsing.

33. Sending 500 table rows

You must send 500 rows with the same 6 fields into a prompt. Why does CSV usually use fewer tokens than a JSON array of objects?

  1. A.CSV is compressed automatically by the API
  2. B.JSON tokens cost double the price of CSV tokens
  3. C.JSON repeats key names on each row; CSV names them once
  4. D.The model skips CSV rows it does not need
Show answer

Answer: C. JSON repeats key names on each row; CSV names them once

In a JSON array of objects, each row carries all six keys plus braces and quotes, which adds up over 500 rows. CSV states the column names once. The model reads both well, so compact formats save cost and context.

34. Arabic that sounds too formal

Emirati users say the bot's Arabic replies feel stiff, like a news broadcast. What prompt change addresses this?

  1. A.Ask for Arabic written in Latin letters only
  2. B.Ask for the reply to be translated twice over
  3. C.Ask for friendly Gulf Arabic and show example replies
  4. D.Remove the word Arabic from the prompt
Show answer

Answer: C. Ask for friendly Gulf Arabic and show example replies

Unless told otherwise, models often default to Modern Standard Arabic, which reads as formal. Naming the dialect and register you want, and showing examples, steers replies toward a natural local style.

35. A useful code-review prompt

You want an LLM to review pull requests. Which prompt is most likely to give useful comments?

  1. A.Only the PR title, asking "is this code good?"
  2. B.The whole repository with no instructions
  3. C.The diff alone, asking for a quality score from 1 to 10
  4. D.The diff, your standards, and a request for line-referenced issues
Show answer

Answer: D. The diff, your standards, and a request for line-referenced issues

Reviews are useful when grounded in the actual change and your team's rules, and when output is actionable. Asking for specific issue types (bugs, security, tests) with line references produces comments a developer can act on.

36. Writing background facts first

A prompt first asks the model to list relevant facts about monsoon effects on crop yields, then answers the user's question using those facts. What is this called?

  1. A.Retrieval-augmented generation
  2. B.Prompt chaining with tools
  3. C.Contrastive decoding
  4. D.Generated knowledge prompting
Show answer

Answer: D. Generated knowledge prompting

Generated knowledge prompting has the model produce relevant background knowledge before answering. Unlike RAG, the facts come from the model itself, so they can still be wrong; it helps recall but does not add new information.

37. Tickets with two topics

A ticket says "My refund has not arrived and I also cannot log in." Your classifier allows only one label, so one issue is always lost. What is the better design?

  1. A.Pick the label for whichever issue is mentioned first
  2. B.Ask the model to merge both into a new label
  3. C.Reject tickets that have more than one issue
  4. D.Allow a list of labels, each chosen from the fixed label set
Show answer

Answer: D. Allow a list of labels, each chosen from the fixed label set

Real messages often contain several intents. A multi-label output (an array of enum values, maybe with a primary flag) captures all of them, and routing logic can then handle each one.

38. Showing what not to write

To discourage jargon, a prompt includes three "bad example" replies full of jargon, labelled "Don't write like this". Outputs start to contain that jargon. Why?

  1. A.The model cannot read the word "don't" in prompts
  2. B.Bad examples are deleted by the API
  3. C.Examples are strong signals; the model copies them
  4. D.Jargon is always produced at temperature 0
Show answer

Answer: C. Examples are strong signals; the model copies them

Models pick up patterns from any examples in the prompt, even ones marked as negative. It is usually better to show good examples, and if a contrast is needed, keep the bad one short and pair it with the improved version.

39. Ranking 30 candidates in one prompt

You ask an LLM to rank 30 job applications in one prompt. Re-running with the list shuffled gives a very different order. What does this show and what helps?

  1. A.Order bias; rank smaller groups or compare pairs, and shuffle
  2. B.The model is broken and must be replaced
  3. C.Rankings are only stable at temperature 2
  4. D.The model needs the applications sorted by name
Show answer

Answer: A. Order bias; rank smaller groups or compare pairs, and shuffle

Long lists invite position effects: items early or late get favoured. Ranking in small batches, using pairwise comparisons, or averaging over several shuffled orders gives more stable results.

40. Collecting details by chat

A chatbot collects five details for a car insurance quote. Users drop off when the bot asks for all five at once. What instruction improves this?

  1. A.Ask all five again more politely
  2. B.Ask one question at a time, skipping known details
  3. C.Ask users to upload a filled-in form instead
  4. D.Guess missing details from the user's name
Show answer

Answer: B. Ask one question at a time, skipping known details

Short, single questions are easier to answer in chat, and skipping details the user already gave avoids repetition. The prompt can track which slots are filled and which remain.

Prompt Engineering interview questions for experienced candidates hard

41. Shipping a prompt change safely

A teammate rewrote the system prompt to fix one customer complaint. How should you decide whether to ship it?

  1. A.Run the full eval set (real and edge-case examples with expected outcomes) before and after, compare scores per category, then ship gradually while monitoring
  2. B.Test the one complaint example manually; if it works, ship it
  3. C.Ship it and wait for complaints
  4. D.Ask the model whether the new prompt is better
Show answer

Answer: A. Run the full eval set (real and edge-case examples with expected outcomes) before and after, compare scores per category, then ship gradually while monitoring

Prompt changes often fix one case and break others. A versioned eval set with clear pass criteria, run automatically like unit tests, catches regressions. Looking at results by category and rolling out gradually with production monitoring makes the change safe.

42. Prompting a reasoning model

You move a complex analysis task to a model with built-in extended reasoning. Your old prompt had a very detailed, rigid list of 15 thinking steps. What is generally the better approach?

  1. A.Make the thinking steps even more detailed
  2. B.Remove all context and constraints
  3. C.Give a clear goal, the relevant context, constraints and success criteria, and let the model plan its own reasoning; then check results with evals
  4. D.Ask the model to answer immediately without thinking
Show answer

Answer: C. Give a clear goal, the relevant context, constraints and success criteria, and let the model plan its own reasoning; then check results with evals

Models with built-in reasoning often do better with high-level guidance than with micromanaged steps, which can limit their approach. What they still need is a clear objective, the right information and how the output will be judged. As always, compare both prompt styles on your eval set.

43. Invented values in extraction

An extraction prompt returns "phone_number" for every resume, even those without one, sometimes inventing numbers. What is the best fix?

  1. A.Define the schema with optional fields, instruct the model to return null when the value is not present in the text, include an example with nulls, and validate values against the source
  2. B.Tell the model the phone number is very important
  3. C.Remove phone_number from the schema permanently
  4. D.Raise temperature so the model explores more options
Show answer

Answer: A. Define the schema with optional fields, instruct the model to return null when the value is not present in the text, include an example with nulls, and validate values against the source

When every field looks required, models tend to fill it. Explicit permission and an example for null values, plus a schema marking fields optional, reduce invention. A code check that the extracted value really appears in the source text catches the rest.

44. Prompt cache hit rate near zero

Your long system prompt should be cached, but the cache hit rate is almost zero. Look at how the prompt is built. Why?

system = f"""Current time: {datetime.now().isoformat()}
You are the support assistant for Acme...
(6,000 tokens of fixed policy and tool docs)"""
  1. A.Caching only works for prompts under 1,000 tokens
  2. B.The policy text is too long to cache
  3. C.Python f-strings cannot be cached
  4. D.The timestamp changes on every request and sits at the very start, so the prefix is never identical; move dynamic values to the end
Show answer

Answer: D. The timestamp changes on every request and sits at the very start, so the prefix is never identical; move dynamic values to the end

Prefix caching needs the leading tokens to match exactly. A value that changes each call at the top makes every request a cache miss for everything after it. Put the time, user data and other variables after the stable block, or round the time if it must appear early.

45. A more honest confidence score

Your classifier asks the model to also print "confidence: 0–100". The numbers are always 85–95, even on wrong answers. What is a better signal of confidence if the API supports it?

  1. A.The token log probabilities for the label the model output
  2. B.The length of the model's reply in characters
  3. C.The temperature value used for the call
  4. D.Asking the model to explain why it is confident
Show answer

Answer: A. The token log probabilities for the label the model output

Self-reported confidence is just more generated text and is often poorly calibrated. Log probabilities show how much probability the model actually gave to the chosen label token versus alternatives, which tends to track correctness better. You should still check calibration on labelled data.

46. Solving easy sub-problems first

A prompt first asks the model to list the sub-questions needed to solve a tricky problem, then solves them in order, feeding each answer into the next. What is this approach and when does it help most?

  1. A.Self-consistency; when the answer is a single word
  2. B.Least-to-most prompting; when later steps need earlier answers
  3. C.Prefilling; when output must start with a fixed token
  4. D.Zero-shot prompting; when the task has no steps
Show answer

Answer: B. Least-to-most prompting; when later steps need earlier answers

Least-to-most prompting decomposes a problem into simpler sub-problems and solves them in sequence, each using the previous results. It helps on compositional tasks harder than any example shown, where one-pass reasoning tends to skip steps.

47. Exploring several reasoning paths

What distinguishes tree-of-thoughts prompting from plain chain of thought?

  1. A.It writes one line of reasoning and then translates it
  2. B.It explores and scores several reasoning paths, and can backtrack
  3. C.It removes reasoning and asks only for the final answer
  4. D.It shares reasoning between different users' requests
Show answer

Answer: B. It explores and scores several reasoning paths, and can backtrack

Chain of thought follows one path. Tree of thoughts generates multiple candidate steps, evaluates which look promising, and searches (for example breadth-first) with the option to drop dead ends. It costs many more calls but helps on puzzles and planning.

48. A strict 160-character limit

SMS alerts must be at most 160 characters. The prompt says so, yet about 8% of outputs are 170–190 characters. What is the most reliable solution?

  1. A.Repeat the 160-character rule five times
  2. B.Use temperature 0 so the model counts exactly
  3. C.Ask the model to count characters out loud first
  4. D.Check length in code and regenerate or shorten when it is over
Show answer

Answer: D. Check length in code and regenerate or shorten when it is over

Models see tokens, not characters, so they estimate length poorly. Keep the instruction (and aim a bit lower), but enforce hard limits in code: measure, then retry with feedback or trim. Never rely on the prompt alone for a hard constraint.

49. Examples with random labels

A 2022 study ("Rethinking the Role of Demonstrations") found that replacing the correct labels in few-shot examples with random labels often hurt classification accuracy only slightly. What does this suggest?

  1. A.Examples teach format and label set, not only the mapping
  2. B.Labels in examples are always ignored, so remove them
  3. C.Wrong labels improve accuracy and should be preferred
  4. D.Few-shot prompting has no effect on model output
Show answer

Answer: A. Examples teach format and label set, not only the mapping

The study showed that much of the benefit comes from showing the label space, the kind of inputs and the output format. That does not mean labels never matter; on hard or unusual tasks, correct labels still help, so keep them right.

50. Banning a word with logit_bias

You try to stop the word "guarantee" by setting logit_bias to -100 for the token ID of "guarantee". The word still appears sometimes. Why?

  1. A.The word has other token forms, like " guarantee"
  2. B.logit_bias only works when temperature is 2
  3. C.A bias of -100 makes the token more likely
  4. D.logit_bias applies only to the system prompt
Show answer

Answer: A. The word has other token forms, like " guarantee"

Logit bias works on token IDs, and one word can map to several tokens: " guarantee", "Guarantee", or pieces like "guar" + "antee". Banning one ID misses the variants, and banning shared pieces can break other words. Post-checks in code are often more reliable.

51. Old and new policies both retrieved

A HR bot retrieves both the 2024 and 2026 leave policies, which disagree, and sometimes answers from the old one. What is the best prompt-side fix?

  1. A.Ask the model to average the two policies
  2. B.Tell the model to pick whichever policy is longer
  3. C.Remove all dates so the model is not confused
  4. D.Show each document's date and say to follow the latest
Show answer

Answer: D. Show each document's date and say to follow the latest

Without dates, the model cannot tell which source is current. Including metadata such as effective date and telling it to prefer the most recent valid policy resolves conflicts; better still, filter superseded documents out at retrieval time.

52. Twenty reviews in one call

To save cost, you send 20 reviews per call and ask for 20 sentiment labels. Sometimes labels shift by one position or one review is skipped. What is the best fix?

  1. A.Send 40 reviews per call so errors average out
  2. B.Ask for labels in reverse order
  3. C.Remove line breaks between reviews to save tokens
  4. D.Give each review an ID and require output keyed by those IDs
Show answer

Answer: D. Give each review an ID and require output keyed by those IDs

When outputs are matched by position, one skip misaligns everything after it. Numbering items and asking for {id: label} output lets code detect missing or extra IDs and retry just those, while keeping the batching savings.

53. Cost of a small-then-large cascade

Every request goes first to a small model costing ₹0.10. In 30% of cases its answer fails a check and the request is sent again to a large model costing ₹1.00. What is the average cost per request?

  1. A.₹0.40
  2. B.₹0.37
  3. C.₹0.30
  4. D.₹1.10
Show answer

Answer: A. ₹0.40

Everyone pays the small call: ₹0.10. Then 30% also pay ₹1.00, which adds 0.3 × 1.00 = ₹0.30. Average = ₹0.40, versus ₹1.00 if every request went to the large model. The cascade only pays off if the check is reliable.

54. Per-request tool lists and caching

With Anthropic prompt caching, your app adds or removes tool definitions on each request depending on the user's plan. Cache hits are rare. Why?

  1. A.Caching only works when there are no tools at all
  2. B.Tools are cached separately and never expire
  3. C.The cache only stores the last user message
  4. D.Tools start the cached prefix, so changes invalidate it
Show answer

Answer: D. Tools start the cached prefix, so changes invalidate it

The cached prefix is built in order: tools, then system, then messages. Any change to tool definitions changes the very start of the prefix, so nothing after it can be reused. Keep the tool set stable, or group users into a few fixed tool sets.

55. An LLM that favours option A

You use an LLM to answer multiple-choice questions and notice it picks the first option more often than chance. What is a robust mitigation?

  1. A.Always put the correct answer in position A
  2. B.Ask several times with shuffled options and take the majority
  3. C.Remove the option letters and ask for free text only
  4. D.Use a higher temperature for every question
Show answer

Answer: B. Ask several times with shuffled options and take the majority

Position bias means the order of options changes the answer. Permuting options across runs and aggregating cancels the bias; it also tells you which items are unstable.

56. Tips and threats in prompts

A blog claims that adding "I will tip you $200 for a perfect answer" improves quality by 10%. What is the right response for a production prompt?

  1. A.Add it immediately since it is free
  2. B.Test it on your own eval set; effects vary a lot
  3. C.Add a threat as well to double the claimed effect
  4. D.Assume it works because the blog had charts
Show answer

Answer: B. Test it on your own eval set; effects vary a lot

Reported effects of emotional or reward phrases are inconsistent and often vanish on newer models or other tasks. Only a controlled comparison on your own data shows whether it helps; clear instructions are usually the better lever.

57. Optimising prompts from data

A framework lets you declare a task's inputs and outputs, provide a metric and some labelled examples, and then automatically searches for instructions and few-shot examples that maximise the metric. Which tool is best known for this?

  1. A.DSPy
  2. B.LangSmith
  3. C.Ollama
  4. D.Pydantic
Show answer

Answer: A. DSPy

DSPy treats prompts as parameters of a program and uses optimisers to choose instructions and demonstrations against a metric. It needs a good metric and data; otherwise it can overfit to a small set.

58. Forcing a PAN number format

You extract Indian PAN numbers, which have the pattern five capital letters, four digits, one capital letter. With an open-weight model, how can you guarantee the output matches this pattern?

  1. A.Ask the model nicely to follow the pattern
  2. B.Set temperature to 0 so it never makes mistakes
  3. C.Use regex-constrained decoding: [A-Z]{5}[0-9]{4}[A-Z]
  4. D.Add ten examples of PAN numbers to the prompt
Show answer

Answer: C. Use regex-constrained decoding: [A-Z]{5}[0-9]{4}[A-Z]

Constrained or grammar-guided decoding (for example with libraries like Outlines or a server's regex/grammar option) masks any token that would break the pattern, so output always matches. It guarantees format, not that the value is correct, so still verify against the document.

59. Where to put tool usage rules

An agent has 15 tools. Usage rules for each tool are in a long system prompt section, and the model often misuses them. What usually helps?

  1. A.Delete all tool descriptions to shorten the prompt
  2. B.Merge all 15 tools into one generic tool
  3. C.Repeat the system prompt section after every message
  4. D.Move each tool's usage guidance into its own description
Show answer

Answer: D. Move each tool's usage guidance into its own description

The model reads a tool's description at the moment it decides whether and how to call it. Putting when-to-use, when-not-to-use and argument rules there keeps guidance next to the tool and reduces confusion between similar tools.

60. How many tokens min_p keeps

Next-token probabilities are 0.50, 0.20, 0.08, 0.05 and 0.04 (others smaller). With min_p = 0.1, a token is kept if its probability is at least min_p × the top probability. How many of these five tokens are kept?

  1. A.4
  2. B.2
  3. C.3
  4. D.5
Show answer

Answer: A. 4

Threshold = 0.1 × 0.50 = 0.05. Tokens with 0.50, 0.20, 0.08 and 0.05 meet it; 0.04 does not. So 4 are kept. min_p adapts: when the top token is very likely, the threshold rises and fewer options survive.

Ready to test yourself?

Take a 15-question Prompt Engineering MCQ test with a score at the end, or practise the full Prompt Engineering question bank and earn points on the leaderboard.