# Prompting Basics — Large Language Models

Source: https://www.geekswithgeeks.com/en/llms/u-prompting

> Write clear instructions with context, format and examples.

## Say what, for whom, in what shape

Treat a prompt like a brief to a capable colleague who knows nothing about your situation. Include: the **task**, the **audience**, necessary **context**, **constraints**, the exact **output format**, and one or two **examples** (few-shot) of good output. A **system prompt** sets durable role and rules; the **user message** holds the specific request. Ask the model to say "I don't know" when information is missing, and to quote its sources when you supply documents. Iterate: change one thing at a time and compare results on a fixed set of test inputs.

## Prompt, ground, act

Good prompts, retrieved facts and tools make a model useful in a product.

![Four layers: prompt, retrieve, call tools, check.](assets/figures/llms/section-5-map.svg) — Figure 5.1 — Prompt, retrieve, call tools and check.

## A structured prompt

A template that states role, task, rules, format and an example. Placeholders are in braces.

```text
You are a support assistant for {product}.
Task: classify the ticket below and draft a reply.
Rules:
- Use only the policy text provided; if it does not cover the case, say so.
- Keep the reply under 80 words.
Output JSON: {"category": "...", "reply": "..."}

Example ticket: "I was charged twice."
Example output: {"category": "billing", "reply": "Sorry about that..."}

Policy: {policy_text}
Ticket: {ticket_text}
```

**Quiz:** What does a system prompt do?

- [ ] Replaces the tokenizer
- [ ] Trains the model
- [x] Sets durable role and rules for the conversation
- [ ] Increases context length

*Answer:* Sets durable role and rules for the conversation. It carries standing instructions that apply across the user's messages.
