Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to Generative AI Notes
Topic #502

Prompt Structure

A well-structured prompt separates its parts clearly — instructions, context, the actual task, and output format — instead of blending everything into one undifferentiated paragraph the model has to parse itself.

A Reusable Structure

[ROLE / INSTRUCTIONS]
You are a customer support assistant for an online bookstore.

[CONTEXT]
Order #4521: placed 3 days ago, status "shipped", carrier BlueDart.

[TASK]
Answer the customer's question using only the order information above.

[OUTPUT FORMAT]
Respond in 2-3 sentences, friendly tone, no greetings/sign-offs.

[USER QUESTION]
Where is my order?

Labeled sections (even informally, with headers or clear line breaks) make it much easier for the model to identify what's an instruction versus what's data versus what's the actual question — and easier for a human maintaining the prompt to update one part without breaking another.

Before/After

Unstructured:
"You're a support bot for a bookstore answer the customer
politely order 4521 was placed 3 days ago shipped via bluedart
where is my order"

Structured (see above): same information, but the model doesn't
have to guess where instructions end and the actual data/question
begins.

Why This Matters More As Prompts Grow

A short, simple prompt can get away with being unstructured. Once a prompt includes retrieved context (RAG), examples (few-shot), formatting rules, and a user's actual question, clear structure is what keeps the model from misreading which part is an instruction versus which part is data to act on — a real, observed failure mode in unstructured long prompts.

Delimiters Help the Model (and You) Separate Data From Instructions

Summarize the text between the triple quotes.

\"\"\"
[user-provided or retrieved text goes here]
\"\"\"

This is also a meaningful security practice — see Prompt Injection for why clearly separating instructions from untrusted data matters beyond just clarity.

Common Mistakes

  • Mixing instructions and user/retrieved data in one undifferentiated block, making it easier for embedded text to be misread as an instruction
  • Over-structuring a genuinely simple prompt with unnecessary sections, adding token overhead for no real benefit

Interview Relevance

"How would you structure a prompt that includes retrieved context, a few examples, and a user's question?" — a strong answer describes clearly separated, labeled sections, and mentions delimiters for untrusted/retrieved text specifically.

Practice Question

Restructure this prompt with clear sections: "you are a helpful assistant answer based on this doc: [doc text] be concise the question is what is the refund policy"

Related Notes

Want to go beyond the notes?

Join CodingNow's Generative AI course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →