Skip to content

Instantly share code, notes, and snippets.

@adeptusnull
Forked from disler/README.md
Created December 3, 2024 19:49
Show Gist options
  • Save adeptusnull/a9119a9ef9821999aa5ec7de0ea4956d to your computer and use it in GitHub Desktop.
Save adeptusnull/a9119a9ef9821999aa5ec7de0ea4956d to your computer and use it in GitHub Desktop.

Revisions

  1. @disler disler revised this gist Nov 24, 2024. No changes.
  2. @disler disler renamed this gist Nov 24, 2024. 1 changed file with 0 additions and 0 deletions.
  3. @disler disler created this gist Nov 24, 2024.
    30 changes: 30 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # Four Level framework for prompt engineering
    > Watch the breakdown here in a [Q4 2024 prompt engineering update video](https://youtu.be/ujnLJru2LIs)
    >
    > [LLM library](https://github.com/simonw/llm)
    >
    > [Ollama](https://ollama.com/)
    ## Level 1: Ad hoc prompt
    - Quick, natural language prompts for rapid prototyping
    - Perfect for exploring model capabilities and behaviors
    - Can be run across multiple models for comparison
    - Great for one-off tasks and experimentation

    ## Level 2: Structured prompt
    - Reusable prompts with clear purpose and instructions
    - Uses XML/structured format for better model performance
    - Contains static variables that can be modified
    - Solves well-defined, repeatable problems

    ## Level 3: Structured prompt with example output
    - Builds on Level 2 by adding example outputs
    - Examples guide the model to produce specific formats
    - Increases consistency and reliability of outputs
    - Perfect for when output format matters

    ## Level 4: Structured prompt with dynamic content
    - Production-ready prompts with dynamic variables
    - Can be integrated into code and applications
    - Infinitely scalable through programmatic updates
    - Foundation for building AI-powered tools and agents
    13 changes: 13 additions & 0 deletions level_2_prompt_summarize.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <purpose>
    Summarize the given content based on the instructions and example-output
    </purpose>

    <instructions>
    <instruction>Output in markdown format</instruction>
    <instruction>Summarize into 4 sections: High level summary, Main Points, Sentiment, and 3 hot takes biased toward the author and 3 hot takes biased against the author</instruction>
    <instruction>Write the summary in the same format as the example-output</instruction>
    </instructions>

    <content>
    {...} <<< update this manually
    </content>
    33 changes: 33 additions & 0 deletions level_3_prompt_summarize.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <purpose>
    Summarize the given content based on the instructions and example-output
    </purpose>

    <instructions>
    <instruction>Output in markdown format</instruction>
    <instruction>Summarize into 4 sections: High level summary, Main Points, Sentiment, and 3 hot takes biased toward the author and 3 hot takes biased against the author</instruction>
    <instruction>Write the summary in the same format as the example-output</instruction>
    </instructions>

    <example-output>

    # Title

    ## High Level Summary
    ...

    ## Main Points
    ...

    ## Sentiment
    ...

    ## Hot Takes (biased toward the author)
    ...

    ## Hot Takes (biased against the author)
    ...
    </example-output>

    <content>
    {...} <<< update this manually
    </content>
    33 changes: 33 additions & 0 deletions level_4_prompt_summarize.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <purpose>
    Summarize the given content based on the instructions and example-output
    </purpose>

    <instructions>
    <instruction>Output in markdown format</instruction>
    <instruction>Summarize into 4 sections: High level summary, Main Points, Sentiment, and 3 hot takes biased toward the author and 3 hot takes biased against the author</instruction>
    <instruction>Write the summary in the same format as the example-output</instruction>
    </instructions>

    <example-output>

    # Title

    ## High Level Summary
    ...

    ## Main Points
    ...

    ## Sentiment
    ...

    ## Hot Takes (biased toward the author)
    ...

    ## Hot Takes (biased against the author)
    ...
    </example-output>

    <content>
    {{content}} <<< update this dynamically with code
    </content>
    3 changes: 3 additions & 0 deletions spicy_summarize_level_1_prompt.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    Summarize the content with 3 hot takes biased toward the author and 3 hot takes biased against the author

    ...paste content here...
    28 changes: 28 additions & 0 deletions vscode_structured_prompt_code_snippet.code-snippet
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    {
    "XML Prompt Block 1": {
    "prefix": "px1",
    "body": [
    "<purpose>",
    " $1",
    "</purpose>",
    "",
    "<instructions>",
    " <instruction>$2</instruction>",
    " <instruction>$3</instruction>",
    " <instruction>$4</instruction>",
    "</instructions>",
    "",
    "<${5:block1}>",
    "$6",
    "</${5:block1}>"
    ],
    "description": "Generate XML prompt block with instructions and block1"
    },
    "XML Tag Snippet Inline": {
    "prefix": "xxi",
    "body": [
    "<${1:tag}>$2</${1:tag}>",
    ],
    "description": "Create an XML tag with a customizable tag name and content"
    }
    }