랭킹으로 돌아가기

NirDiamant/Prompt_Engineering

Jupyter Notebookdiamant-ai.com

22 prompt engineering techniques with hands-on Jupyter Notebook tutorials, from fundamental concepts to advanced strategies for leveraging LLMs.

aiprompt-engineeringtutorialsllmspythongenaillmchatgptclaudelangchainopenaiprompting
스타 성장
스타
7.7k
포크
986
주간 성장
이슈
1
2k4k6k
25년 9월25년 12월26년 4월26년 7월
README

PRs Welcome LinkedIn Twitter Discord

Prompt Engineering Techniques: Comprehensive Repository for Development and Implementation 🖋️

Welcome to one of the most extensive and dynamic collections of Prompt Engineering tutorials and implementations available today. This repository serves as a comprehensive resource for learning, building, and sharing prompt engineering techniques, ranging from basic concepts to advanced strategies for leveraging large language models.

22 hands-on tutorials covering everything from basic prompt templates to advanced techniques like chain-of-thought, self-consistency, and tree-of-thought prompting.

🎓 From prompts to production

Prompt to Production - my full course on building software with AI the way professionals do: the methods and paradigms behind reliable, efficient, modular production systems, taught systematically. 17 modules, each pairing a video lecture with a hands-on lab, from your first structured prompt to a working production system.

🎁 Try a full module, free

🎬
7-minute
video lecture
🛠️
Hands-on
tutorial
🤖
AI assistant
inside Claude Code

One npm install adds the module's AI assistant to your Claude Code, and it guides you through the tutorial as you build.

Claim your free module

🎯 Sponsors

📫 Stay Updated!

🚀
Cutting-edge
Updates
💡
Expert
Insights
🎯
Top 0.1%
Content

Subscribe to DiamantAI Newsletter

Join over 50,000 AI enthusiasts getting unique cutting-edge insights and free tutorials! Plus, subscribers get exclusive early access and special discounts to our upcoming RAG Techniques course!

DiamantAI's newsletter

Introduction

Prompt engineering is at the forefront of artificial intelligence, revolutionizing the way we interact with and leverage AI technologies. This repository is designed to guide you through the development journey, from basic prompt structures to advanced, cutting-edge techniques.

Our goal is to provide a valuable resource for everyone - from beginners taking their first steps in AI to seasoned practitioners pushing the boundaries of what's possible. By offering a range of examples from foundational to complex, we aim to facilitate learning, experimentation, and innovation in the rapidly evolving field of prompt engineering.

Furthermore, this repository serves as a platform for showcasing innovative prompt engineering techniques. Whether you've developed a novel approach or found an innovative application for existing techniques, we encourage you to share your work with the community.

📖 The book version of this repo

Prompt Engineering from Zero to Hero - all 22 techniques from this repo, fully explained with step-by-step breakdowns and hands-on exercises.

Amazon Kindle - $9.99 · Paperback · Gumroad PDF

🔍 RAG Techniques - 40+ notebooks on retrieval-augmented generation.

🤖 GenAI Agents - implementations and tutorials for building AI agent systems.

🚀 Agents Towards Production - code-first tutorials for shipping production-grade agents.

🧠 Agent Memory Techniques - 30 notebooks on agent memory: vector stores, graphs, Mem0, Zep.

Join the community

Contributions make this better - propose ideas, share techniques, or give feedback via CONTRIBUTING.md.

r/EducationalAI · Discord · LinkedIn

Key Features

  • 🎓 Learn prompt engineering techniques from beginner to advanced levels
  • 🧠 Explore a wide range of prompt structures and applications
  • 📚 Step-by-step tutorials and comprehensive documentation
  • 🛠️ Practical, ready-to-use prompt implementations
  • 🌟 Regular updates with the latest advancements in prompt engineering
  • 🤝 Share your own prompt engineering creations with the community

Prompt Engineering Techniques

Explore our extensive list of prompt engineering techniques, ranging from basic to advanced:

# Category Technique Description
1 🎓 Fundamental Concepts Introduction to Prompt Engineering Comprehensive introduction to fundamental concepts of prompt engineering
2 🎓 Fundamental Concepts Basic Prompt Structures Exploration of single-turn and multi-turn prompt structures
3 🎓 Fundamental Concepts Prompt Templates and Variables Creating and using prompt templates with variables
4 🔧 Core Techniques Zero-Shot Prompting Performing tasks without specific examples
5 🔧 Core Techniques Few-Shot Learning Learning from a small number of examples
6 🔧 Core Techniques Chain of Thought (CoT) Step-by-step reasoning processes
7 🎯 Advanced Strategies Self-Consistency Multiple reasoning paths and result aggregation
8 🎯 Advanced Strategies Constrained Generation Setting up output constraints
9 🎯 Advanced Strategies Role Prompting Assigning specific roles to AI models
10 🚀 Advanced Implementations Task Decomposition Breaking down complex tasks
11 🚀 Advanced Implementations Prompt Chaining Connecting multiple prompts
12 🚀 Advanced Implementations Instruction Engineering Crafting clear instructions
13 Optimization Prompt Optimization A/B testing and refinement
14 Optimization Handling Ambiguity Resolving ambiguous prompts
15 Optimization Length Management Managing prompt complexity
16 🛠️ Specialized Applications Negative Prompting Avoiding undesired outputs
17 🛠️ Specialized Applications Prompt Formatting Various prompt formats
18 🛠️ Specialized Applications Task-Specific Prompts Prompts for specific tasks
19 🌍 Advanced Applications Multilingual Prompting Cross-lingual techniques
20 🌍 Advanced Applications Ethical Considerations Bias avoidance and inclusivity
21 🌍 Advanced Applications Prompt Security Preventing injections
22 🌍 Advanced Applications Effectiveness Evaluation Evaluating prompt performance

🌱 Fundamental Concepts

  1. Introduction to Prompt Engineering

    Overview 🔎

    A comprehensive introduction to the fundamental concepts of prompt engineering in the context of AI and language models.

    Implementation 🛠️

    Combines theoretical explanations with practical demonstrations, covering basic concepts, structured prompts, comparative analysis, and problem-solving applications.

  2. Basic Prompt Structures

    Overview 🔎

    Explores two fundamental types of prompt structures: single-turn prompts and multi-turn prompts (conversations).

    Implementation 🛠️

    Uses OpenAI's GPT model and LangChain to demonstrate single-turn and multi-turn prompts, prompt templates, and conversation chains.

  3. Prompt Templates and Variables

    Overview 🔎

    Introduces creating and using prompt templates with variables, focusing on Python and the Jinja2 templating engine.

    Implementation 🛠️

    Covers template creation, variable insertion, conditional content, list processing, and integration with the OpenAI API.

🔧 Core Techniques

  1. Zero-Shot Prompting

    Overview 🔎

    Explores zero-shot prompting, allowing language models to perform tasks without specific examples or prior training.

    Implementation 🛠️

    Demonstrates direct task specification, role-based prompting, format specification, and multi-step reasoning using OpenAI and LangChain.

  2. Few-Shot Learning and In-Context Learning

    Overview 🔎

    Covers Few-Shot Learning and In-Context Learning techniques using OpenAI's GPT models and the LangChain library.

    Implementation 🛠️

    Implements basic and advanced few-shot learning, in-context learning, and best practices for example selection and evaluation.

  3. Chain of Thought (CoT) Prompting

    Overview 🔎

    Introduces Chain of Thought (CoT) prompting, encouraging AI models to break down complex problems into step-by-step reasoning processes.

    Implementation 🛠️

    Covers basic and advanced CoT techniques, applying them to various problem-solving scenarios and comparing results with standard prompts.

🔍 Advanced Strategies

  1. Self-Consistency and Multiple Paths of Reasoning

    Overview 🔎

    Explores techniques for generating diverse reasoning paths and aggregating results to improve AI-generated answers.

    Implementation 🛠️

    Demonstrates designing diverse reasoning prompts, generating multiple responses, implementing aggregation methods, and applying self-consistency checks.

  2. Constrained and Guided Generation

    Overview 🔎

    Focuses on techniques to set up constraints for model outputs and implement rule-based generation.

    Implementation 🛠️

    Uses LangChain's PromptTemplate for structured prompts, implements constraints, and explores rule-based generation techniques.

  3. Role Prompting

    Overview 🔎

    Explores assigning specific roles to AI models and crafting effective role descriptions.

    Implementation 🛠️

    Demonstrates creating role-based prompts, assigning roles to AI models, and refining role descriptions for various scenarios.

🚀 Advanced Implementations

  1. Task Decomposition in Prompts

    Overview 🔎

    Explores techniques for breaking down complex tasks and chaining subtasks in prompts.

    Implementation 🛠️

    Covers problem analysis, subtask definition, targeted prompt engineering, sequential execution, and result synthesis.

  2. Prompt Chaining and Sequencing

    Overview 🔎

    Demonstrates how to connect multiple prompts and build logical flows for complex AI-driven tasks.

    Implementation 🛠️

    Explores basic prompt chaining, sequential prompting, dynamic prompt generation, and error handling within prompt chains.

  3. Instruction Engineering

    Overview 🔎

    Focuses on crafting clear and effective instructions for language models, balancing specificity and generality.

    Implementation 🛠️

    Covers creating and refining instructions, experimenting with different structures, and implementing iterative improvement based on model responses.

🎨 Optimization and Refinement

  1. Prompt Optimization Techniques

    Overview 🔎

    Explores advanced techniques for optimizing prompts, focusing on A/B testing and iterative refinement.

    Implementation 🛠️

    Demonstrates A/B testing of prompts, iterative refinement processes, and performance evaluation using relevant metrics.

  2. Handling Ambiguity and Improving Clarity

    Overview 🔎

    Focuses on identifying and resolving ambiguous prompts and techniques for writing clearer prompts.

    Implementation 🛠️

    Covers analyzing ambiguous prompts, implementing strategies to resolve ambiguity, and exploring techniques for writing clearer prompts.

  3. Prompt Length and Complexity Management

    Overview 🔎

    Explores techniques for managing prompt length and complexity when working with large language models.

    Implementation 🛠️

    Demonstrates techniques for balancing detail and conciseness, and strategies for handling long contexts including chunking, summarization, and iterative processing.

🛠️ Specialized Applications

  1. Negative Prompting and Avoiding Undesired Outputs

    Overview 🔎

    Explores negative prompting and techniques for avoiding undesired outputs from large language models.

    Implementation 🛠️

    Covers basic negative examples, explicit exclusions, constraint implementation using LangChain, and methods for evaluating and refining negative prompts.

  2. Prompt Formatting and Structure

    Overview 🔎

    Explores various prompt formats and structural elements, demonstrating their impact on AI model responses.

    Implementation 🛠️

    Demonstrates creating various prompt formats, incorporating structural elements, and comparing responses from different prompt structures.

  3. Prompts for Specific Tasks

    Overview 🔎

    Explores the creation and use of prompts for specific tasks: text summarization, question-answering, code generation, and creative writing.

    Implementation 🛠️

    Covers designing task-specific prompt templates, implementing them using LangChain, executing with sample inputs, and analyzing outputs for each task type.

🌍 Advanced Applications

  1. Multilingual and Cross-lingual Prompting

    Overview 🔎

    Explores techniques for designing prompts that work effectively across multiple languages and for language translation tasks.

    Implementation 🛠️

    Covers creating multilingual prompts, implementing language detection and adaptation, designing cross-lingual translation prompts, and handling various writing systems and scripts.

  2. Ethical Considerations in Prompt Engineering

    Overview 🔎

    Explores the ethical dimensions of prompt engineering, focusing on avoiding biases and creating inclusive and fair prompts.

    Implementation 🛠️

    Covers identifying biases in prompts, implementing strategies to create inclusive prompts, and methods to evaluate and improve the ethical quality of AI outputs.

  3. Prompt Security and Safety

    Overview 🔎

    Focuses on preventing prompt injections and implementing content filters in prompts for safe and secure AI applications.

    Implementation 🛠️

    Covers techniques for prompt injection prevention, content filtering implementation, and testing the effectiveness of security and safety measures.

  4. Evaluating Prompt Effectiveness

    Overview 🔎

    Explores methods and techniques for evaluating the effectiveness of prompts in AI language models.

    Implementation 🛠️

    Covers setting up evaluation metrics, implementing manual and automated evaluation techniques, and providing practical examples using OpenAI and LangChain.

Getting Started

To begin exploring and implementing prompt engineering techniques:

  1. Clone this repository:
    git clone https://github.com/NirDiamant/Prompt_Engineering.git
    
  2. Navigate to the technique you're interested in:
    cd all_prompt_engineering_techniques
    
  3. Follow the detailed implementation guide in each technique's notebook.

This list contains Amazon affiliate links. As an Amazon Associate I earn from qualifying purchases. Every book below is one I've read and genuinely recommend to engineers working in this space. The companion book to this repo is featured separately at the top of this README.


📚 More from the same author

RAG Made Simple - the 400-page visual guide to RAG, the retrieval layer behind advanced agents. 33% off with code RAGKING.

Run a course, newsletter, or dev community? You can earn 25% recommending the books to your audience.

Contributing

We welcome contributions from the community! If you have a new technique or improvement to suggest:

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/AmazingFeature
  3. Commit your changes: git commit -m 'Add some AmazingFeature'
  4. Push to the branch: git push origin feature/AmazingFeature
  5. Open a pull request

License

This project is licensed under a custom non-commercial license - see the LICENSE file for details.


⭐️ If you find this repository helpful, please consider giving it a star!

Keywords: Prompt Engineering, AI, Machine Learning, Natural Language Processing, LLM, Language Models, NLP, Conversational AI, Zero-Shot Learning, Few-Shot Learning, Chain of Thought

관련 저장소
openclaw/openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

TypeScriptnpmOtheraiassistant
openclaw.ai
383.7k80.6k
obra/superpowers

An agentic skills framework & software development methodology that works.

ShellMIT Licenseaibrainstorming
258.9k23.1k
NousResearch/hermes-agent

The agent that grows with you

PythonPyPIMIT Licenseaiai-agent
hermes-agent.nousresearch.com
218.5k41.3k
n8n-io/n8n

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

TypeScriptnpmOtherautomationipaas
n8n.io
197.4k59.5k
Significant-Gravitas/AutoGPT

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

PythonPyPIOtheraiopenai
agpt.co
185.6k46.1k
f/prompts.chat

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

HTMLOtherchatgptai
prompts.chat
166.2k21.5k
AUTOMATIC1111/stable-diffusion-webui

Stable Diffusion web UI

PythonPyPIGNU Affero General Public License v3.0deep-learningdiffusion
164.3k30.4k
Snailclimb/JavaGuide

Java 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发

JavaScriptnpmApache License 2.0javainterview
javaguide.cn
157.2k46.2k
firecrawl/firecrawl

The API to search, scrape, and interact with the web at scale. 🔥

TypeScriptnpmGNU Affero General Public License v3.0aicrawler
firecrawl.dev
154.1k8.8k
langgenius/dify

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

TypeScriptnpmOtheraigpt
dify.ai
149.7k23.6k
open-webui/open-webui

User-friendly AI Interface (Supports Ollama, OpenAI API, ...)

PythonPyPIOtherollamaollama-webui
openwebui.com
146.3k21.2k
langchain-ai/langchain

The agent engineering platform.

PythonPyPIMIT Licenseaianthropic
docs.langchain.com/langchain/
142.3k23.7k