> For the complete documentation index, see [llms.txt](https://docs.blockbrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockbrain.ai/for-users/prompt-writing-guide/llama-models-prompt-guide.md).

# Llama Models Prompt Guide

Llama models respond best to clear, structured instructions. The key is to be direct, show examples, and define outputs precisely.

**Table of Contents**

1. [Be Explicit and Direct](#id-1.-be-explicit-and-direct)
2. [Assign a Role](#id-2.-assign-a-role)
3. [Ask for Step-by-Step Reasoning](#id-3.-ask-for-step-by-step-reasoning)
4. [Use Few-Shot Examples](#id-4.-use-few-shot-examples)
5. [Constrain Outputs](#id-5.-constrain-outputs)
6. [Maintain Multi-Turn Consistency](#id-6.-maintain-multi-turn-consistency)
7. [Improve Reliability with Sampling](#id-7.-improve-reliability-with-sampling)
8. [Practical Prompt Templates by Use Cases](#id-8.-practical-prompt-templates-by-use-case)

***

### 1. Be Explicit and Direct

Say exactly what you want: **length, format, tone**. Avoid vague instructions.

**Less effective:**

```
Summarize this report
```

**More effective:**

```
Summarize this report into 3 bullet points, under 15 words each, highlighting decisions and deadlines.
```

***

### 2. Assign a Role

Set Llama’s perspective by giving it a role. This shapes style and tone.

**Example:**

```
You are a financial analyst. Provide concise, professional reports in plain English.
```

***

### 3. Ask for Step-by-Step Reasoning

Guide Llama by providing the model with a series of logical steps. This helps generate well-reasoned responses for complex tasks.

**Example:**

```
You are a virtual tour guide. Describe the Eiffel Tower. 

Begin with: 
1. Why it was built. 
2. How long it took. 
3. Where materials were sourced. 

End with annual visitor numbers.
```

***

### 4. Use Few-Shot Examples

Demonstrate the format you want by showing Llama short examples.

```
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 format (JSON, CSV, table, bullets).

**Example:**

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

**Output:**

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

***

### 6. Maintain Multi-Turn Consistency

If conversations run long, remind Llama of prior rules.

**Example:**

```
Remember to always answer in JSON format
```

***

### 7. Improve Reliability with Sampling

For tasks requiring logic or math, run multiple outputs and select the most frequent answer.

**Example:**

```
Run Llama 5 times on this reasoning task. Choose the most common answer.
```

***

### 8. Prompt Templates by Use Case

**General Task Template**

```
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 Template -** Best for translation or classification tasks.

```
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"
```

**Analyze a Dataset**

```
Role: You are a data analyst.
Task: Summarize this dataset into concise business insights.
Context: Results will be presented in a leadership sync; clarity and brevity are key.
Constraints:
• Max 100 words
• Use 3 bullet points only
• Avoid numbers with decimals or complex terms

Output Example:
• Sales rose in Q3 due to strong repeat customers  
• Costs stabilized after Q2 vendor negotiations  
• Recommend focusing on B2B accounts for sustained growth

Tip: For numeric output, specify “Round all figures to whole numbers.”
```

**Summarize Emails and Next Steps**

```
Role: You are an executive assistant.
Task: Summarize this email thread and list next steps.
Context: Output will be pasted into a meeting note document.
Constraints:
• Limit summary to 3 sentences
• Use bullet format for next steps
• No filler language (“hope this helps,” etc.)

Output Example:
Summary:
The team confirmed the project scope and timeline changes.  
Next Steps:
• Update the client on final delivery date  
• Prepare revised timeline by Monday  
• Confirm approval from finance


Tip: Add “Use plain English, avoid internal jargon.”
```

***

### Final Tip

With Llama, **clarity plus examples = reliability**. Spell out roles, steps, and formats, and you’ll get consistent, structured outputs.

{% hint style="info" %}
*Learn more about Llama Prompt Engineering in the official* [*Prompting Guide*](https://www.llama.com/docs/how-to-guides/prompting/) *and the* [*Llama 4 Prompt Format reference*](https://www.llama.com/docs/model-cards-and-prompt-formats/llama4/)
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.blockbrain.ai/for-users/prompt-writing-guide/llama-models-prompt-guide.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
