Nearby lessons

37 of 49

Prompt Engineering - Alpaca, ChatML and INST Formats

Alpaca Format — Instruction / Input / Output

The Alpaca template is a structured format used to train AI models, with three clear parts:

  • Instruction — what to do.
  • Input — additional context.
  • Output — expected result.

It makes datasets consistent and improves instruction understanding.

In simple words: Instruction + Input + Output = perfect structure. Structured learning creates powerful systems.

The homework example:

  • Instruction = write about planets.
  • Input = focus on Earth and Mars.
  • Output = 5 points.

Clear structure gives a clear answer — whether for a student or an AI model being fine-tuned.

Example01
Prompt PreviewChatGPT-style
Instruction: Write 5 Python interview questions Input: Candidate is a fresher Output: 1. What is Python? 2. What is a list? 3. What is a dictionary?
Copy the prompt and paste it into ChatGPT, Gemini, or Claude to try it.

ChatML Format — Role-Based Conversations

ChatML is the structured format for conversations in systems like ChatGPT. It uses roles — system, user, assistant — so AI can remember context across multiple turns.

  • Enables real multi-step interaction.
  • Best for chatbots and conversations.
In simple words: ChatML brings conversation into AI. Communication builds intelligence.
Plain PromptChatML
One-time inputMulti-turn
No memoryContext memory
SimpleConversational
LimitedAdvanced
Example02
Prompt PreviewChatGPT-style
SYSTEM · You are a Python mentor
What is a Python list?
A list is a collection of items
Give an example
Copy the prompt and paste it into ChatGPT, Gemini, or Claude to try it.

INST Format — LLaMA Style

The INST format wraps the instruction inside special tags and is used by LLaMA and open-source models. It is a lightweight format with no roles — just the instruction inside [INST] ... [/INST].

The exam-sheet example:

  • A question placed inside a box is easy to identify.
  • The instruction inside tags works the same way — the model knows exactly where the task begins and ends.
Example03
Prompt PreviewChatGPT-style
INST FORMAT: <s>[INST] Explain Python loops [/INST]
Copy the prompt and paste it into ChatGPT, Gemini, or Claude to try it.

Comparing All Four Formats

FormatStructureUse Case
PlainSimple textBasic prompting
AlpacaInstruction / Input / OutputModel training, datasets
ChatMLSystem / User / AssistantChatbots, conversations
INSTInstruction in [INST] tagsLLaMA / open-source models
Trainer's Note: Choose the format based on the model and the use case: ChatML for chat apps, Alpaca for datasets and training, INST for LLaMA models, plain for quick basic tasks.
Example04
Prompt PreviewChatGPT-style
SAME TOPIC IN 4 FORMATS: Explain Python loops PLAIN: Explain Python loops ALPACA: Instruction: Explain Python loops Input: Audience is beginners Output: Python loops repeat code multiple times CHATML: [{"role": "system", "content": "You are a Python teacher"}, {"role": "user", "content": "Explain Python loops"}] INST: <s>[INST] Explain Python loops [/INST]
Copy the prompt and paste it into ChatGPT, Gemini, or Claude to try it.
📝 Key Takeaways
  • Alpaca = Instruction + Input + Output (model training and datasets).
  • ChatML = System / User / Assistant with context memory.
  • INST wraps instructions in [INST] tags for LLaMA models.
  • ChatML is best for chatbots and conversations.
  • Alpaca is best for dataset creation and training.
  • Choose the format based on the model and the use case.

🧠 Test Your Knowledge

4 Questions
Progress: 0 / 4