# nirdiamant/prompt_engineering

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/nirdiamant-prompt-engineering).**

7,159 stars · 918 forks · Jupyter Notebook · other

## Links

- GitHub: https://github.com/NirDiamant/Prompt_Engineering
- awesome-repositories: https://awesome-repositories.com/repository/nirdiamant-prompt-engineering.md

## Topics

`ai` `genai` `llm` `llms` `opeani` `prompt-engineering` `python` `tutorials`

## Description

This project is a comprehensive guide and framework for designing, optimizing, and securing inputs to improve the accuracy and reasoning of large language model outputs. It provides core methodologies for implementing logical reasoning steps, example-based learning, and reusable template systems.

The framework distinguishes itself through a focus on security guardrails and ethical auditing, implementing primitives to prevent adversarial prompt injection attacks and identify biases. It also emphasizes structured generation, using persona assignment and negative constraints to control the tone, expertise, and boundaries of generated text.

The project covers a broad range of capabilities including performance optimization via chain-of-thought and few-shot learning, as well as workflow management through sequential prompt chaining and context-window chunking. It further addresses the architectural needs of input standardization and output shaping to ensure consistency across different use cases.

The content is delivered primarily through Jupyter Notebooks.

## Tags

### Artificial Intelligence & ML

- [Prompt Engineering Guides](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-engineering-guides.md) — Serves as a comprehensive framework for designing, optimizing, and securing inputs for large language models.
- [Persona and Behavioral Instructions](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-prompt-engineering-templates/automated-prompt-generation/persona-and-behavioral-instructions.md) — Defines specific roles and behavioral descriptions to shift the tone, expertise, and perspective of the AI. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Chain-of-Thought Prompting](https://awesome-repositories.com/f/artificial-intelligence-ml/chain-of-thought-prompting.md) — Provides methodologies for decomposing complex problems into intermediate logical steps to improve model output accuracy. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Chaining](https://awesome-repositories.com/f/artificial-intelligence-ml/language-model-orchestration/ai-workflow-patterns/prompt-chaining.md) — Links multiple prompts together so the output of one task serves as the input for the next. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Optimizers](https://awesome-repositories.com/f/artificial-intelligence-ml/model-optimization/profiling-and-benchmarking/model-performance-optimization/prompt-optimizers.md) — Provides a framework for refining model prompts and examples to improve output accuracy and reasoning.
- [Negative Constraint Strategies](https://awesome-repositories.com/f/artificial-intelligence-ml/negative-constraint-strategies.md) — Defines explicit exclusions and negative examples to prevent the generation of undesired content. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Guided Generation](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-engineering-guides/guided-generation.md) — Provides methods to control the format, tone, and boundaries of generated text using constraints and role assignment. ([source](https://github.com/NirDiamant/Prompt_Engineering/tree/main/all_prompt_engineering_techniques/))
- [Output Formatting Constraints](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-engineering/structural-formatting-frameworks/output-formatting-constraints.md) — Implements rule-based constraints to ensure outputs adhere to specific formats, boundaries, or schemas. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Templates](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-templates.md) — Builds reusable structures with variables and conditional content to standardize model inputs. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Few-Shot Pattern Exemplification](https://awesome-repositories.com/f/artificial-intelligence-ml/zero-and-few-shot-learning/few-shot-pattern-exemplification.md) — Implements techniques for using specific examples within prompts to guide models on task patterns and output formats. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Evaluation Tools](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-prompt-configurations/prompt-evaluation-tools.md) — Includes utilities for measuring and comparing output quality across different prompt variations using automated metrics. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Context Summarizations](https://awesome-repositories.com/f/artificial-intelligence-ml/long-context-training-optimizations/context-summarizations.md) — Balances detail and conciseness through chunking and summarization to process long-form content effectively. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Iteration Workflows](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-iteration-workflows.md) — Offers guidance on the iterative process of testing and refining instructions to eliminate ambiguity and optimize performance. ([source](https://cdn.jsdelivr.net/gh/nirdiamant/prompt_engineering@main/README.md))
- [Prompt Management](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-management.md) — Organizes long or complex inputs through chaining and sequencing to maintain output coherence. ([source](https://github.com/NirDiamant/Prompt_Engineering/tree/main/all_prompt_engineering_techniques/))
- [Text Generation Controls](https://awesome-repositories.com/f/artificial-intelligence-ml/text-generation-controls.md) — Offers methods for configuring output characteristics and formatting to ensure consistent generated text schemas.
- [Context-Window Chunking](https://awesome-repositories.com/f/artificial-intelligence-ml/text-tokenizers/tokenized-file-managers/token-aware-aggregators/context-window-chunking.md) — Splits long-form content into manageable pieces sized for LLM context window limits.

### Security & Cryptography

- [LLM Prompt Injection Prevention](https://awesome-repositories.com/f/security-cryptography/llm-prompt-injection-prevention.md) — Implements content filters and security guardrails to protect against adversarial prompt injection attacks.
- [AI Personas](https://awesome-repositories.com/f/security-cryptography/identity-access-management/access-control/identity-role-management/ai-personas.md) — Defines specific roles and behavioral constraints to shift the tone and expertise of the model.
- [LLM Input Guardrails](https://awesome-repositories.com/f/security-cryptography/llm-input-guardrails.md) — Implements security layers to filter prompt injections and validate model inputs against adversarial attacks.

### Part of an Awesome List

- [Prompt Optimization](https://awesome-repositories.com/f/awesome-lists/ai/prompt-optimization.md) — Applies structured techniques like few-shot learning and chain-of-thought to improve the accuracy and reasoning of model outputs. ([source](https://github.com/NirDiamant/Prompt_Engineering/tree/main/all_prompt_engineering_techniques/))
- [Secure Workflows](https://awesome-repositories.com/f/awesome-lists/devtools/prompt-testing-and-security/secure-workflows.md) — Establishes safety guardrails and security measures to protect AI workflows from adversarial inputs. ([source](https://github.com/NirDiamant/Prompt_Engineering/tree/main/all_prompt_engineering_techniques/))

### Development Tools & Productivity

- [Prompt Templates](https://awesome-repositories.com/f/development-tools-productivity/template-based-code-generators/prompt-templates.md) — Uses reusable structures with variables and conditional logic to standardize prompts across different use cases.
