# Prompt Engineering Techniques

## About

Prompt engineering techniques are structured methods used to influence how a Large Language Model (LLM) interprets instructions, reasons through problems, accesses knowledge, and produces output.

Because LLMs are probabilistic systems, their behavior is not fixed. Instead, their output depends heavily on:

* How the task is framed
* What context is provided
* How reasoning is encouraged
* How output is constrained
* How knowledge is injected

Prompt engineering techniques provide systematic ways to control these dimensions.

Rather than relying on trial-and-error experimentation, these techniques introduce repeatable design patterns that improve reliability, determinism, and production readiness.

## Core Categories of Prompt Engineering Techniques

Prompt engineering techniques can be broadly classified into five major categories:

```
Prompt Engineering Techniques
│
├── 1. Input-Based Techniques
├── 2. Reasoning-Based Techniques
├── 3. Knowledge-Grounded Techniques
├── 4. Output-Control Techniques
└── 5. Meta-Prompting Techniques
```

Each category targets a different stage of the model’s behavior.

### 1. Input-Based Techniques

**Focus:** How the problem is presented to the model.

These techniques influence how the model interprets the task before reasoning begins.

They include:

* Zero-shot prompting
* Few-shot prompting
* Role-based prompting
* Instruction framing
* Context injection
* Structured input formatting

**Goal:** Reduce ambiguity and guide interpretation.

### 2. Reasoning-Based Techniques

**Focus:** How the model processes and reasons about the problem.

These techniques encourage structured thinking rather than direct answer generation.

They include:

* Chain-of-Thought prompting
* Step-by-step reasoning
* Self-consistency prompting
* Tree-of-Thought reasoning
* ReAct (Reason + Act)

**Goal:** Improve logical correctness and reduce reasoning errors.

### 3. Knowledge-Grounded Techniques

**Focus:** Where the model gets its information from.

These techniques reduce hallucination by grounding outputs in verifiable data.

They include:

* Retrieval-Augmented Generation (RAG)
* Context window optimization
* Source-constrained answering
* Embedding-based retrieval
* Tool-augmented prompting

**Goal:** Increase factual reliability and domain alignment.

### 4. Output-Control Techniques

**Focus:** What the model is allowed to generate.

These techniques enforce structure and determinism.

They include:

* JSON schema enforcement
* Structured output prompting
* Constrained formatting
* Style control
* Length constraints
* Stop sequences

**Goal:** Make outputs automation-ready and production-safe.

### 5. Meta-Prompting Techniques

**Focus:** How prompts interact with other prompts.

These techniques build layered or multi-step AI workflows.

They include:

* Prompt chaining
* Self-critique prompting
* Reflection prompting
* Iterative refinement
* Prompt templating
* Automated prompt generation

**Goal:** Enable scalable and reusable AI systems.

## Why This Categorization Matters ?

These categories align with how LLM systems operate:

1. Input Interpretation
2. Internal Reasoning
3. Knowledge Access
4. Output Generation
5. System-Level Orchestration

Understanding techniques through this layered model allows prompt engineering to be treated as system design rather than informal experimentation.

## Engineering Perspective

From a backend architecture standpoint, following can be interpreted in general

* Input-Based Techniques = API request design
* Reasoning-Based Techniques = Business logic guidance
* Knowledge-Grounded Techniques = Data layer integration
* Output-Control Techniques = Response schema enforcement
* Meta-Prompting Techniques = Workflow orchestration

This mapping makes prompt engineering intuitive for software engineers.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/ai/generative-ai/large-language-models-llm/prompt-engineering/prompt-engineering-techniques.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
