Llama Models Prompt Guide

Prompt Engineering Guidelines

1. Be Explicit and Direct

  • Say exactly what you want (length, format, tone).

  • Avoid vague instructions.

Example: “Summarize this report into 3 bullet points, under 15 words each, highlighting decisions and deadlines.”


2. Assign a Role (System Prompt)

  • Use the system prompt to set expectations.

Example: “You are a financial analyst. Provide concise, professional reports in plain English.”

This creates consistency across all outputs.


3. Step-by-Step Reasoning (Chain-of-Thought)

  • Encourage reasoning by asking for step-by-step solutions.

  • Example: “Solve this math problem. Show your reasoning before giving the final answer.”


4. Use Few-Shot Examples

  • Demonstrate the format you want with examples.

Example:

User: Translate English to French.

English: "Good morning" French: "Bonjour"

Output: English: "How are you?" French: "Comment ça va?"


5. Constrain Outputs

  • If you need structured data, specify the exact format (JSON, CSV, tables).

Example:

User: Summarize this meeting into JSON with fields: decisions, next_steps, owners.

Output: { "decisions": "Budget approved", "next_steps": "Launch campaign", "owners": "Marketing team" }


6. Multi-Turn Consistency

  • Remind LLaMA of previous instructions if a conversation runs long.

Example: “Remember to always answer in JSON format.”


7. Sampling & Reliability

  • Use techniques like self-consistency (multiple runs, majority answer) for tasks that require correctness.

Example: Run LLaMA 5 times on a reasoning task, pick the most common answer.


Templates

General Task Prompt

User: You are a project manager. Summarize this meeting transcript into 5 bullet points, under 15 words each. Context: This will be shared with the executive team. Constraints: Only include decisions and deadlines.

Output: • Budget increase approved • Deadline extended to Q4 • Hiring 3 new engineers • Product beta launch in June • Next review set for July 15

Few-Shot Prompt

User: Translate English to French. Follow the examples below and keep answers short and accurate.

English: "Good morning" French: "Bonjour"

English: "How are you?" French: "Comment ça va ?"

English: "See you tomorrow" French:

Output: "À demain"

Learn more about Llama Prompt Engineering in the official Prompting Guide and the Llama 4 Prompt Format reference

Last updated