{"id":17717144,"url":"https://github.com/nirdiamant/prompt_engineering","last_synced_at":"2026-10-29T21:14:44.091Z","repository":{"id":259432917,"uuid":"870554327","full_name":"NirDiamant/Prompt_Engineering","owner":"NirDiamant","description":"22 prompt engineering techniques with hands-on Jupyter Notebook tutorials, from fundamental concepts to advanced strategies for leveraging LLMs.","archived":false,"fork":false,"pushed_at":"2026-10-27T14:12:49.000Z","size":21297,"stargazers_count":7916,"open_issues_count":16,"forks_count":1033,"subscribers_count":86,"default_branch":"main","last_synced_at":"2026-10-28T01:42:05.176Z","etag":null,"topics":["ai","chain-of-thought","chatgpt","claude","few-shot-learning","genai","generative-ai","gpt","in-context-learning","langchain","llm","llms","machine-learning","openai","prompt-engineering","prompting","python","tutorials"],"latest_commit_sha":null,"homepage":"https://diamant-ai.com","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NirDiamant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"accessibility":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","claude":null,"gemini":null,"cursor":null,"copilot":null,"dco":null,"cla":null,"disclosure":null},"funding":{"github":"NirDiamant"}},"created_at":"2024-10-10T08:52:12.000Z","updated_at":"2026-10-27T23:02:17.000Z","dependencies_parsed_at":"2026-10-20T20:38:15.376Z","dependency_job_id":null,"html_url":"https://github.com/NirDiamant/Prompt_Engineering","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":"0.11111111111111116","last_synced_commit":"e62c1f783fa59d942bd29a8eae136f93b04fed05"},"previous_names":["nirdiamant/prompt_engineering"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NirDiamant/Prompt_Engineering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NirDiamant%2FPrompt_Engineering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NirDiamant%2FPrompt_Engineering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NirDiamant%2FPrompt_Engineering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NirDiamant%2FPrompt_Engineering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NirDiamant","download_url":"https://codeload.github.com/NirDiamant/Prompt_Engineering/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NirDiamant%2FPrompt_Engineering/sbom","scorecard":null,"funding_links":["https://github.com/sponsors/NirDiamant"],"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":346510206,"owners_count":38563212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-29T02:00:07.416Z","response_time":114,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chain-of-thought","chatgpt","claude","few-shot-learning","genai","generative-ai","gpt","in-context-learning","langchain","llm","llms","machine-learning","openai","prompt-engineering","prompting","python","tutorials"],"created_at":"2024-10-25T14:11:47.202Z","updated_at":"2026-10-29T21:14:44.061Z","avatar_url":"https://github.com/NirDiamant.png","language":"Jupyter Notebook","funding_links":["https://github.com/sponsors/NirDiamant"],"categories":["Prompts"],"sub_categories":[],"readme":"[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/in/nir-diamant-759323134/)\n[![Twitter](https://img.shields.io/twitter/follow/NirDiamantAI?label=Follow%20@NirDiamantAI\u0026style=social)](https://twitter.com/NirDiamantAI)\n[![Discord](https://img.shields.io/badge/Discord-Join%20our%20community-7289da?style=flat-square\u0026logo=discord\u0026logoColor=white)](https://discord.gg/cA6Aa4uyDX)\n\n# Prompt Engineering Techniques: Comprehensive Repository for Development and Implementation 🖋️\n\nWelcome 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.\n\n\n\u003e **22 hands-on tutorials** covering everything from basic prompt templates to advanced techniques like chain-of-thought, self-consistency, and tree-of-thought prompting.\n\n\u003ch2 align=\"center\"\u003e🎓 From prompts to production\u003c/h2\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n**[Prompt to Production](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=course-free-module-cta\u0026target=https%3A%2F%2Fwww.diamant-ai.com%2Fcourses%3Futm_source%3Dgithub%26utm_medium%3Dreadme%26utm_campaign%3Dprompt-engineering\u0026retarget=0\u0026text=course-free-module-cta)** - 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.\n\n**The course is live.** Every module is out, lecture and lab.\n\n### 🎁 Try it on your own repo, free\n\nYour coding agent starts every session knowing nothing about your project, so it guesses. Paste one line into the agent you already have open, and about fifteen minutes later your repository has a docs layer written from the code itself, plus a card scoring what your agent knew before and after.\n\nWe ran it on six repositories you already depend on. Each one was asked five questions about itself, cold, then again after the layer was written. The last column counts statements in that project's **own documentation** that its **own code disproves**:\n\n| repo | before | after | own docs its code disproves |\n|---|---|---|---|\n| fastapi | 2 of 5 | **5 of 5** | 2 |\n| flask | 3 of 5 | **5 of 5** | 6 |\n| django | 3 of 5 | **4 of 5** | 1 |\n| express | 2 of 5 | **4 of 5** | 4 |\n| requests | 2 of 5 | **4 of 5** | 0 |\n| langchain | 5 of 5 | **4 of 5** | 5 |\n\nFlask's six include four documentation examples that raise `TypeError` when you run them. Langchain scored *lower* afterwards, because it already ships a 380-line agent instruction file and the cold read was grading theirs; that row is in the table anyway.\n\nClone any of those repos, paste the same line, and check the number yourself. No signup.\n\n\u003ca href=\"https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=course-free-module-direct\u0026target=https%3A%2F%2Fp2p-course.diamant-ai.com%2Flectures%2F00-present%3Futm_source%3Dgithub%26utm_medium%3Dreadme%26utm_campaign%3Dprompt-engineering-direct\u0026retarget=0\u0026text=course-free-module-direct\"\u003e\u003cimg src=\"images/free-module-button.svg\" alt=\"Claim your free module\" width=\"420\"\u003e\u003c/a\u003e\n\n### 👉 [**Get the full course**](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=course-full-cta\u0026target=https%3A%2F%2Fwww.diamant-ai.com%2Fcourses%3Futm_source%3Dgithub%26utm_medium%3Dreadme%26utm_campaign%3Dprompt-engineering\u0026retarget=0\u0026text=course-full-cta)\n\n\u003c/div\u003e\n\n## 🎯 Sponsors\n\n\u003cdiv align=\"center\"\u003e\n\n\u003ca href=\"https://coderabbit.link/nir\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"images/coderabbit_Dark_Type_Mark.png\"\u003e\n    \u003cimg src=\"images/coderabbit_Light_Type_Mark_Orange.png\" height=\"60\" alt=\"Coderabbit\"\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://www.qodo.ai/?utm_source=diamantai\u0026utm_medium=github\u0026utm_campaign=prompt-engineering\u0026utm_content=readme-sponsor\"\u003e\n  \u003cimg src=\"images/qodo-logo.svg\" height=\"60\" alt=\"Qodo\"\u003e\n\u003c/a\u003e\n\n\u003c/div\u003e\n\n## 📫 Stay Updated!\n\n\u003cdiv align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e🚀\u003cbr\u003e\u003cb\u003eCutting-edge\u003cbr\u003eUpdates\u003c/b\u003e\u003c/td\u003e\n\u003ctd align=\"center\"\u003e💡\u003cbr\u003e\u003cb\u003eExpert\u003cbr\u003eInsights\u003c/b\u003e\u003c/td\u003e\n\u003ctd align=\"center\"\u003e🎯\u003cbr\u003e\u003cb\u003eTop 0.1%\u003cbr\u003eContent\u003c/b\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n[![Subscribe to DiamantAI Newsletter](images/subscribe-button.svg)](https://newsletter.diamant-ai.com/?r=336pe4\u0026utm_campaign=pub-share-checklist)\n\n*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!***\n\u003c/div\u003e\n\n[![DiamantAI's newsletter](images/substack_image.png)](https://newsletter.diamant-ai.com/?r=336pe4\u0026utm_campaign=pub-share-checklist)\n\n\u003ch2 align=\"center\"\u003e🎬 Prefer video?\u003c/h2\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n*I break these ideas down into short, one-idea-per-episode explainers on YouTube.*\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd width=\"33%\" align=\"center\" valign=\"top\"\u003e\n  \u003ca href=\"https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026amp;click=youtube-readme-llm\u0026amp;target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtKXvKKVQ1Dc\u0026amp;retarget=0\u0026amp;text=youtube-readme-llm\"\u003e\n    \u003cimg src=\"https://img.youtube.com/vi/tKXvKKVQ1Dc/mqdefault.jpg\" width=\"100%\" alt=\"\"\u003e\n    \u003cbr\u003e\u003cb\u003eHow LLMs Actually Work (and Why AI Makes Things Up)\u003c/b\u003e\n  \u003c/a\u003e\u003cbr\u003e\n  \u003csub\u003erecalling a fact and inventing one are literally the same move\u003c/sub\u003e\n\u003c/td\u003e\n\u003ctd width=\"33%\" align=\"center\" valign=\"top\"\u003e\n  \u003ca href=\"https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026amp;click=youtube-readme-ctx\u0026amp;target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Da7bteK6c3Ng\u0026amp;retarget=0\u0026amp;text=youtube-readme-ctx\"\u003e\n    \u003cimg src=\"https://img.youtube.com/vi/a7bteK6c3Ng/mqdefault.jpg\" width=\"100%\" alt=\"\"\u003e\n    \u003cbr\u003e\u003cb\u003eContext Is the New Code\u003c/b\u003e\n  \u003c/a\u003e\u003cbr\u003e\n  \u003csub\u003ethe shift from writing the code to shaping what the model sees\u003c/sub\u003e\n\u003c/td\u003e\n\u003ctd width=\"33%\" align=\"center\" valign=\"top\"\u003e\n  \u003ca href=\"https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026amp;click=youtube-readme-cc\u0026amp;target=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0fU8GdipOjc\u0026amp;retarget=0\u0026amp;text=youtube-readme-cc\"\u003e\n    \u003cimg src=\"https://img.youtube.com/vi/0fU8GdipOjc/mqdefault.jpg\" width=\"100%\" alt=\"\"\u003e\n    \u003cbr\u003e\u003cb\u003eStop Thinking Claude Code Is Magic. Here's How It Works\u003c/b\u003e\n  \u003c/a\u003e\u003cbr\u003e\n  \u003csub\u003ewhat the agent loop is actually doing on every turn\u003c/sub\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n[![Subscribe on YouTube](https://img.shields.io/youtube/channel/subscribers/UCatj5F2gohksvfNmnEpRnNA?style=social)](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=youtube-subscribe-channel\u0026target=https%3A%2F%2Fwww.youtube.com%2F%40DiamantAI%3Fsub_confirmation%3D1\u0026retarget=0\u0026text=youtube-subscribe-channel) \u0026nbsp; [**Browse every episode →**](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=youtube-all-episodes\u0026target=https%3A%2F%2Fwww.youtube.com%2F%40DiamantAI\u0026retarget=0\u0026text=youtube-all-episodes)\n\n\u003c/div\u003e\n\n## Introduction\n\nPrompt 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.\n\nOur 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.\n\nFurthermore, 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.\n\n## 📖 The book version of this repo\n\n**[Prompt Engineering from Zero to Hero](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=book-buy-pe-gumroad\u0026target=https%3A%2F%2Fnirdiamant.gumroad.com%2Fl%2Fmtxrfk\u0026retarget=0\u0026text=book-buy-pe-gumroad)** - all 22 techniques from this repo, fully explained with step-by-step breakdowns and hands-on exercises.\n\n[Amazon Kindle - $9.99](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=book-buy-pe-kindle\u0026target=https%3A%2F%2Fwww.amazon.com%2Fdp%2FB0DZ85RPB5\u0026retarget=0\u0026text=book-buy-pe-kindle) · [Paperback](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=book-buy-pe-paper\u0026target=https%3A%2F%2Fwww.amazon.com%2Fdp%2FB0DZ9RVKMJ\u0026retarget=0\u0026text=book-buy-pe-paper) · [Gumroad PDF](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=book-buy-pe-gumroad\u0026target=https%3A%2F%2Fnirdiamant.gumroad.com%2Fl%2Fmtxrfk\u0026retarget=0\u0026text=book-buy-pe-gumroad)\n\n## Related Projects\n\n🔍 **[RAG Techniques](https://github.com/NirDiamant/RAG_Techniques)** - 40+ notebooks on retrieval-augmented generation.\n\n🤖 **[GenAI Agents](https://github.com/NirDiamant/GenAI_Agents)** - implementations and tutorials for building AI agent systems.\n\n🚀 **[Agents Towards Production](https://github.com/NirDiamant/agents-towards-production)** - code-first tutorials for shipping production-grade agents.\n\n🧠 **[Agent Memory Techniques](https://github.com/NirDiamant/Agent_Memory_Techniques)** - 30 notebooks on agent memory: vector stores, graphs, Mem0, Zep.\n\n## Join the community\n\nContributions make this better - propose ideas, share techniques, or give feedback via **[CONTRIBUTING.md](https://github.com/NirDiamant/Prompt_Engineering/blob/main/CONTRIBUTING.md)**.\n\n**[r/EducationalAI](https://www.reddit.com/r/EducationalAI/)** · **[Discord](https://discord.gg/cA6Aa4uyDX)** · **[LinkedIn](https://www.linkedin.com/in/nir-diamant-759323134/)**\n\n## Key Features\n\n- 🎓 Learn prompt engineering techniques from beginner to advanced levels\n- 🧠 Explore a wide range of prompt structures and applications\n- 📚 Step-by-step tutorials and comprehensive documentation\n- 🛠️ Practical, ready-to-use prompt implementations\n- 🌟 Regular updates with the latest advancements in prompt engineering\n- 🤝 Share your own prompt engineering creations with the community\n\n## Prompt Engineering Techniques\n\nExplore our extensive list of prompt engineering techniques, ranging from basic to advanced:\n\n| # | Category | Technique | Description |\n|---|----------|-----------|-------------|\n| 1 | 🎓 **Fundamental Concepts** | [Introduction to Prompt Engineering](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/intro-prompt-engineering-lesson.ipynb) | Comprehensive introduction to fundamental concepts of prompt engineering |\n| 2 | 🎓 **Fundamental Concepts** | [Basic Prompt Structures](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/basic-prompt-structures.ipynb) | Exploration of single-turn and multi-turn prompt structures |\n| 3 | 🎓 **Fundamental Concepts** | [Prompt Templates and Variables](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-templates-variables-jinja2.ipynb) | Creating and using prompt templates with variables |\n| 4 | 🔧 **Core Techniques** | [Zero-Shot Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/zero-shot-prompting.ipynb) | Performing tasks without specific examples |\n| 5 | 🔧 **Core Techniques** | [Few-Shot Learning](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/few-shot-learning.ipynb) | Learning from a small number of examples |\n| 6 | 🔧 **Core Techniques** | [Chain of Thought (CoT)](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/cot-prompting.ipynb) | Step-by-step reasoning processes |\n| 7 | 🎯 **Advanced Strategies** | [Self-Consistency](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/self-consistency.ipynb) | Multiple reasoning paths and result aggregation |\n| 8 | 🎯 **Advanced Strategies** | [Constrained Generation](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/constrained-guided-generation.ipynb) | Setting up output constraints |\n| 9 | 🎯 **Advanced Strategies** | [Role Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/role-prompting.ipynb) | Assigning specific roles to AI models |\n| 10 | 🚀 **Advanced Implementations** | [Task Decomposition](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/task-decomposition-prompts.ipynb) | Breaking down complex tasks |\n| 11 | 🚀 **Advanced Implementations** | [Prompt Chaining](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-chaining-sequencing.ipynb) | Connecting multiple prompts |\n| 12 | 🚀 **Advanced Implementations** | [Instruction Engineering](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/instruction-engineering-notebook.ipynb) | Crafting clear instructions |\n| 13 | ⚡ **Optimization** | [Prompt Optimization](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-optimization-techniques.ipynb) | A/B testing and refinement |\n| 14 | ⚡ **Optimization** | [Handling Ambiguity](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/ambiguity-clarity.ipynb) | Resolving ambiguous prompts |\n| 15 | ⚡ **Optimization** | [Length Management](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-length-complexity-management.ipynb) | Managing prompt complexity |\n| 16 | 🛠️ **Specialized Applications** | [Negative Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/negative-prompting.ipynb) | Avoiding undesired outputs |\n| 17 | 🛠️ **Specialized Applications** | [Prompt Formatting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-formatting-structure.ipynb) | Various prompt formats |\n| 18 | 🛠️ **Specialized Applications** | [Task-Specific Prompts](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/specific-task-prompts.ipynb) | Prompts for specific tasks |\n| 19 | 🌍 **Advanced Applications** | [Multilingual Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/multilingual-prompting.ipynb) | Cross-lingual techniques |\n| 20 | 🌍 **Advanced Applications** | [Ethical Considerations](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/ethical-prompt-engineering.ipynb) | Bias avoidance and inclusivity |\n| 21 | 🌍 **Advanced Applications** | [Prompt Security](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-security-and-safety.ipynb) | Preventing injections |\n| 22 | 🌍 **Advanced Applications** | [Effectiveness Evaluation](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/evaluating-prompt-effectiveness.ipynb) | Evaluating prompt performance |\n\n### 🌱 Fundamental Concepts\n\n1. **[Introduction to Prompt Engineering](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/intro-prompt-engineering-lesson.ipynb)**\n\n   #### Overview 🔎\n   A comprehensive introduction to the fundamental concepts of prompt engineering in the context of AI and language models.\n\n   #### Implementation 🛠️\n   Combines theoretical explanations with practical demonstrations, covering basic concepts, structured prompts, comparative analysis, and problem-solving applications.\n\n2. **[Basic Prompt Structures](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/basic-prompt-structures.ipynb)**\n\n   #### Overview 🔎\n   Explores two fundamental types of prompt structures: single-turn prompts and multi-turn prompts (conversations).\n\n   #### Implementation 🛠️\n   Uses OpenAI's GPT model and LangChain to demonstrate single-turn and multi-turn prompts, prompt templates, and conversation chains.\n\n3. **[Prompt Templates and Variables](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-templates-variables-jinja2.ipynb)**\n\n   #### Overview 🔎\n   Introduces creating and using prompt templates with variables, focusing on Python and the Jinja2 templating engine.\n\n   #### Implementation 🛠️\n   Covers template creation, variable insertion, conditional content, list processing, and integration with the OpenAI API.\n\n### 🔧 Core Techniques\n\n4. **[Zero-Shot Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/zero-shot-prompting.ipynb)**\n\n   #### Overview 🔎\n   Explores zero-shot prompting, allowing language models to perform tasks without specific examples or prior training.\n\n   #### Implementation 🛠️\n   Demonstrates direct task specification, role-based prompting, format specification, and multi-step reasoning using OpenAI and LangChain.\n\n5. **[Few-Shot Learning and In-Context Learning](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/few-shot-learning.ipynb)**\n\n   #### Overview 🔎\n   Covers Few-Shot Learning and In-Context Learning techniques using OpenAI's GPT models and the LangChain library.\n\n   #### Implementation 🛠️\n   Implements basic and advanced few-shot learning, in-context learning, and best practices for example selection and evaluation.\n\n6. **[Chain of Thought (CoT) Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/cot-prompting.ipynb)**\n\n   #### Overview 🔎\n   Introduces Chain of Thought (CoT) prompting, encouraging AI models to break down complex problems into step-by-step reasoning processes.\n\n   #### Implementation 🛠️\n   Covers basic and advanced CoT techniques, applying them to various problem-solving scenarios and comparing results with standard prompts.\n\n### 🔍 Advanced Strategies\n\n7. **[Self-Consistency and Multiple Paths of Reasoning](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/self-consistency.ipynb)**\n\n   #### Overview 🔎\n   Explores techniques for generating diverse reasoning paths and aggregating results to improve AI-generated answers.\n\n   #### Implementation 🛠️\n   Demonstrates designing diverse reasoning prompts, generating multiple responses, implementing aggregation methods, and applying self-consistency checks.\n\n8. **[Constrained and Guided Generation](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/constrained-guided-generation.ipynb)**\n\n   #### Overview 🔎\n   Focuses on techniques to set up constraints for model outputs and implement rule-based generation.\n\n   #### Implementation 🛠️\n   Uses LangChain's PromptTemplate for structured prompts, implements constraints, and explores rule-based generation techniques.\n\n9. **[Role Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/role-prompting.ipynb)**\n\n   #### Overview 🔎\n   Explores assigning specific roles to AI models and crafting effective role descriptions.\n\n   #### Implementation 🛠️\n   Demonstrates creating role-based prompts, assigning roles to AI models, and refining role descriptions for various scenarios.\n\n### 🚀 Advanced Implementations\n\n10. **[Task Decomposition in Prompts](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/task-decomposition-prompts.ipynb)**\n\n    #### Overview 🔎\n    Explores techniques for breaking down complex tasks and chaining subtasks in prompts.\n\n    #### Implementation 🛠️\n    Covers problem analysis, subtask definition, targeted prompt engineering, sequential execution, and result synthesis.\n\n11. **[Prompt Chaining and Sequencing](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-chaining-sequencing.ipynb)**\n\n    #### Overview 🔎\n    Demonstrates how to connect multiple prompts and build logical flows for complex AI-driven tasks.\n\n    #### Implementation 🛠️\n    Explores basic prompt chaining, sequential prompting, dynamic prompt generation, and error handling within prompt chains.\n\n12. **[Instruction Engineering](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/instruction-engineering-notebook.ipynb)**\n\n    #### Overview 🔎\n    Focuses on crafting clear and effective instructions for language models, balancing specificity and generality.\n\n    #### Implementation 🛠️\n    Covers creating and refining instructions, experimenting with different structures, and implementing iterative improvement based on model responses.\n\n### 🎨 Optimization and Refinement\n\n13. **[Prompt Optimization Techniques](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-optimization-techniques.ipynb)**\n\n    #### Overview 🔎\n    Explores advanced techniques for optimizing prompts, focusing on A/B testing and iterative refinement.\n\n    #### Implementation 🛠️\n    Demonstrates A/B testing of prompts, iterative refinement processes, and performance evaluation using relevant metrics.\n\n14. **[Handling Ambiguity and Improving Clarity](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/ambiguity-clarity.ipynb)**\n\n    #### Overview 🔎\n    Focuses on identifying and resolving ambiguous prompts and techniques for writing clearer prompts.\n\n    #### Implementation 🛠️\n    Covers analyzing ambiguous prompts, implementing strategies to resolve ambiguity, and exploring techniques for writing clearer prompts.\n\n15. **[Prompt Length and Complexity Management](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-length-complexity-management.ipynb)**\n\n    #### Overview 🔎\n    Explores techniques for managing prompt length and complexity when working with large language models.\n\n    #### Implementation 🛠️\n    Demonstrates techniques for balancing detail and conciseness, and strategies for handling long contexts including chunking, summarization, and iterative processing.\n\n### 🛠️ Specialized Applications\n\n16. **[Negative Prompting and Avoiding Undesired Outputs](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/negative-prompting.ipynb)**\n\n    #### Overview 🔎\n    Explores negative prompting and techniques for avoiding undesired outputs from large language models.\n\n    #### Implementation 🛠️\n    Covers basic negative examples, explicit exclusions, constraint implementation using LangChain, and methods for evaluating and refining negative prompts.\n\n17. **[Prompt Formatting and Structure](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-formatting-structure.ipynb)**\n\n    #### Overview 🔎\n    Explores various prompt formats and structural elements, demonstrating their impact on AI model responses.\n\n    #### Implementation 🛠️\n    Demonstrates creating various prompt formats, incorporating structural elements, and comparing responses from different prompt structures.\n\n18. **[Prompts for Specific Tasks](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/specific-task-prompts.ipynb)**\n\n    #### Overview 🔎\n    Explores the creation and use of prompts for specific tasks: text summarization, question-answering, code generation, and creative writing.\n\n    #### Implementation 🛠️\n    Covers designing task-specific prompt templates, implementing them using LangChain, executing with sample inputs, and analyzing outputs for each task type.\n\n### 🌍 Advanced Applications\n\n19. **[Multilingual and Cross-lingual Prompting](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/multilingual-prompting.ipynb)**\n\n    #### Overview 🔎\n    Explores techniques for designing prompts that work effectively across multiple languages and for language translation tasks.\n\n    #### Implementation 🛠️\n    Covers creating multilingual prompts, implementing language detection and adaptation, designing cross-lingual translation prompts, and handling various writing systems and scripts.\n\n20. **[Ethical Considerations in Prompt Engineering](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/ethical-prompt-engineering.ipynb)**\n\n    #### Overview 🔎\n    Explores the ethical dimensions of prompt engineering, focusing on avoiding biases and creating inclusive and fair prompts.\n\n    #### Implementation 🛠️\n    Covers identifying biases in prompts, implementing strategies to create inclusive prompts, and methods to evaluate and improve the ethical quality of AI outputs.\n\n21. **[Prompt Security and Safety](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/prompt-security-and-safety.ipynb)**\n\n    #### Overview 🔎\n    Focuses on preventing prompt injections and implementing content filters in prompts for safe and secure AI applications.\n\n    #### Implementation 🛠️\n    Covers techniques for prompt injection prevention, content filtering implementation, and testing the effectiveness of security and safety measures.\n\n22. **[Evaluating Prompt Effectiveness](https://github.com/NirDiamant/Prompt_Engineering/blob/main/all_prompt_engineering_techniques/evaluating-prompt-effectiveness.ipynb)**\n\n    #### Overview 🔎\n    Explores methods and techniques for evaluating the effectiveness of prompts in AI language models.\n\n    #### Implementation 🛠️\n    Covers setting up evaluation metrics, implementing manual and automated evaluation techniques, and providing practical examples using OpenAI and LangChain.\n\n## Getting Started\n\nTo begin exploring and implementing prompt engineering techniques:\n\n1. Clone this repository:\n   ```\n   git clone https://github.com/NirDiamant/Prompt_Engineering.git\n   ```\n2. Navigate to the technique you're interested in:\n   ```\n   cd all_prompt_engineering_techniques\n   ```\n3. Follow the detailed implementation guide in each technique's notebook.\n\n## 📚 Recommended reading\n\n*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.*\n\n- [Build a Large Language Model (From Scratch)](https://www.amazon.com/dp/1633437167?tag=diamantai-pe-20) by Sebastian Raschka. Build a GPT-style model end to end in PyTorch.\n- [AI Engineering: Building Applications with Foundation Models](https://www.amazon.com/dp/1098166302?tag=diamantai-pe-20) by Chip Huyen. Canonical reference for productionizing foundation-model apps.\n- [Hands-On Large Language Models](https://www.amazon.com/dp/1098150961?tag=diamantai-pe-20) by Jay Alammar and Maarten Grootendorst. Visual, practical LLM walkthroughs.\n- [Natural Language Processing with Transformers](https://www.amazon.com/dp/1098136799?tag=diamantai-pe-20) by Lewis Tunstall, Leandro von Werra, and Thomas Wolf. From the Hugging Face team.\n- [Designing Machine Learning Systems](https://www.amazon.com/dp/1098107969?tag=diamantai-pe-20) by Chip Huyen. ML systems in production, still the standard reference.\n\n---\n\n## 📚 More from the same author\n\n**[RAG Made Simple](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=book-buy-gumroad-rag-cta\u0026target=https%3A%2F%2Fdiamant-ai.com%2Frag-made-simple%3Fcode%3DRAGKING\u0026retarget=0\u0026text=book-buy-gumroad-rag-cta)** - the 400-page visual guide to RAG, the retrieval layer behind advanced agents. 33% off with code RAGKING.\n\n*Run a course, newsletter, or dev community? You can [earn 25% recommending the books](https://europe-west1-rag-techniques-views-tracker.cloudfunctions.net/rag-techniques-tracker?notebook=prompt-engineering--readme\u0026click=affiliate-signup\u0026target=https%3A%2F%2Fnirdiamant.gumroad.com%2Faffiliates\u0026retarget=0\u0026text=affiliate-signup) to your audience.*\n\n## Contributing\n\nWe welcome contributions from the community! If you have a new technique or improvement to suggest:\n\n1. Fork the repository\n2. Create your feature branch: `git checkout -b feature/AmazingFeature`\n3. Commit your changes: `git commit -m 'Add some AmazingFeature'`\n4. Push to the branch: `git push origin feature/AmazingFeature`\n5. Open a pull request\n\n## License\n\nThis project is licensed under a custom non-commercial license - see the [LICENSE](LICENSE) file for details.\n\n---\n\n⭐️ If you find this repository helpful, please consider giving it a star!\n\nKeywords: Prompt Engineering, AI, Machine Learning, Natural Language Processing, LLM, Language Models, NLP, Conversational AI, Zero-Shot Learning, Few-Shot Learning, Chain of Thought\n\n![](https://europe-west1-prompt-eng-views-tracker.cloudfunctions.net/prompt-eng-tracker?notebook=main-readme)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirdiamant%2Fprompt_engineering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirdiamant%2Fprompt_engineering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirdiamant%2Fprompt_engineering/lists"}