Skip to content
OPQAI.
Sourced intermediate / 💻 Coding Free tools

Learn 22 Prompt Engineering Techniques with Jupyter Notebooks

Job to be done: Implement advanced prompt engineering strategies for LLMs

🇳🇬 Ways to use this in Nigeria

Ideas to get you started, adapt to your situation.

  • Entrepreneur

    As an entrepreneur building an AI-powered customer service chatbot for Nigerian businesses, use these techniques to ensure the bot provides accurate, culturally appropriate, and helpful responses to common customer queries.

  • Student

    As a computer science student, apply these prompt engineering methods to refine your final year project's AI component, ensuring it generates precise and relevant outputs for your specific research problem.

  • 9-5 employee

    As a digital marketing specialist, use these prompt engineering techniques to generate more engaging and effective social media content and ad copy for your company's campaigns, improving reach and conversion.

What you’ll get

You’ll gain access to a comprehensive collection of 22 hands-on tutorials for prompt engineering. These tutorials will guide you through applying various techniques, from foundational concepts to advanced strategies, to interact more effectively with Large Language Models (LLMs). This approach provides practical, code-first examples in Jupyter Notebooks, allowing direct experimentation and understanding of how different prompt strategies influence LLM outputs.

Tools you need

  • Jupyter Notebook (free): An interactive computing environment for running Python code and tutorials.
  • A Large Language Model (LLM) (freemium / paid), To experiment with the prompt engineering techniques. Specific LLMs are not mentioned in the source, but common options include OpenAI’s ChatGPT, Google’s Gemini, or Anthropic’s Claude.

Steps

  1. Visit the GitHub Repository: Open your web browser and navigate to the project’s GitHub page.

    You should see the repository’s main page with folders like all_prompt_engineering_techniques and files like README.md.

  2. Download the Code: On the GitHub page, locate the green “Code” button. Click it, then choose “Download ZIP” to get all the repository files to your computer. Alternatively, if you’re familiar with Git, you can clone the repository using git clone https://github.com/NirDiamant/Prompt_Engineering.git in your terminal.

    You should have a .zip file downloaded (or the repository cloned) containing all the project files.

  3. Install Dependencies: Unzip the downloaded file. Open a terminal or command prompt, navigate to the unzipped project folder, and install the required Python libraries. The repository includes a requirements.txt file listing these.

    pip install -r requirements.txt

    You should see messages indicating that the necessary packages are being installed. Once complete, you’ll return to your command prompt.

  4. Launch Jupyter Notebook: In the same terminal or command prompt, while still in the project folder, start the Jupyter Notebook server.

    jupyter notebook

    Your web browser should automatically open a new tab displaying the Jupyter Notebook dashboard, showing the contents of your project folder.

  5. Open a Tutorial Notebook: In the Jupyter Notebook dashboard, navigate into the all_prompt_engineering_techniques folder. Choose any of the .ipynb files (Jupyter Notebook files) to open a specific tutorial. For a beginner, start with one of the earlier-numbered notebooks if available, as they often cover fundamental concepts.

    The chosen notebook will open in a new tab, displaying code cells and markdown explanations.

  6. Run and Experiment: Read through the notebook’s explanations. Execute the code cells one by one by clicking on a cell and pressing Shift + Enter (or using the “Run” button in the toolbar). The author doesn’t share specific prompts for a single workflow, as this repository covers 22 techniques. Each notebook will guide you through different prompt engineering examples. You will typically find code cells where you can define and modify prompts to interact with an LLM.

    You should see the output of each code cell appear directly below it, demonstrating the LLM’s response to the given prompts. Experiment by changing the prompt text within the code cells and re-running them to observe how the LLM’s output changes.

Original source

This workflow is based on the extensive GitHub repository by NirDiamant, titled “Prompt_Engineering”. It serves as a comprehensive resource offering 22 hands-on Jupyter Notebook tutorials that cover a wide range of prompt engineering techniques for Large Language Models.

Notes & variations

  • Free-tier alternatives: If installing Python and Jupyter locally is challenging, consider using Google Colab (https://colab.research.google.com). It’s a free, cloud-based Jupyter environment that requires no setup and runs directly in your browser. You can upload the .ipynb files directly to Colab. For the LLM itself, many providers like Google (Gemini), OpenAI (ChatGPT), and Anthropic (Claude) offer free tiers or free access to their models, which you can integrate into your notebooks via their APIs.
  • Common mistake: A frequent pitfall is not installing all the required libraries (step 3) before trying to run the notebooks. This will lead to ModuleNotFoundError errors. Always ensure your Python environment is correctly set up with all dependencies.
  • Tip for better results: Don’t just run the code; actively modify the prompts and parameters within the notebooks. Experiment with different phrasings, add constraints, or change the desired output format. This hands-on experimentation is key to truly understanding how prompt engineering influences LLM behavior.

Keep going

More Coding workflows