Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Prompt Engineering for Developers @ AWS Communi...

Prompt Engineering for Developers @ AWS Community Day Adria 2024

Slobodan Stojanović

October 18, 2024
Tweet

More Decks by Slobodan Stojanović

Other Decks in Programming

Transcript

  1. TL;DR, Wait until war is declared, and destroy the Goeben

    Winston Churchi!, head of Admiralty, July 31, 1914
  2. TL;DR, Wait until war is declared, and destroy the Goeben

    "… do not at this stage be brought to action against superior forces." Winston Churchi!, head of Admiralty, July 31, 1914
  3. I am sure that your unclear instructions never caused major

    disruption of someone's fleet*, but you definitely have many stories * the Goeben did that to the Russian fl"t in the Black Sea during WW1
  4. Prompts: - Prompts are instructions - You te! an LLM

    what you want, and it tries to reply based its training and your instructions - more clear instructions = better reply - LLM always answer, but not always based on truth
  5. The prompt is a set of textual instructions that fit

    LLM's context and other limitations
  6. "Write a 500-word article about the bad influence of Amazon's

    RTO policy on Lambda cold starts" Also valid prompt
  7. Some parts of your instructions might be more important than

    other or you might want to make them repeatable
  8. We often need a response from an LLM to follow

    the specific structure we defined
  9. User: // Some long instructions But always reply with valid

    JSON and nothing else! Here's your JSON: ```json { "some": "JSON", Assistant:
  10. User: // Your instructions Answer with valid JSON and nothing

    else. { " Assistant: System: // Your system prompt
  11. User: // Your instructions Answer with valid JSON and nothing

    else. { " Assistant: System: // Your system prompt
  12. User: // Your instructions Answer with valid JSON and nothing

    else. { " Assistant: System: // Your system prompt some": "valid", "JSON": true }
  13. ChatGPT and Claude often don't do the task perfectly immediately.

    It takes some back and forth before you get the desired outcome.
  14. "Great product, 10/10": {"label": "positive"} "Didn't work very well": {"label":

    "negative"} "Super helpful, worth it": {"label": "positive"}
  15. User: Assistant: "Great product, 10/10" {"label": "positive"} User: Assistant: "Didn't

    work very we!" {"label": "negative"} User: Assistant: "Super helpful, worth it" System: // Your system prompt
  16. User: Assistant: "Great product, 10/10" {"label": "positive"} User: Assistant: "Didn't

    work very we!" {"label": "negative"} User: Assistant: "Super helpful, worth it" {"label": "POSITIVE"} System: // Your system prompt
  17. But in reality, it would probably just give you a

    new Linkedin employment status
  18. Adding "Let's think step by step" or a similar phrase

    uses more tokens for the response, but it often gives you better results
  19. OpenAI O1 preview: "We've developed a new series of AI

    models designed to spend more time thinking before they respond."
  20. OpenAI O1 preview: "They can reason through complex tasks and

    solve harder problems than previous models in science, coding, and math."
  21. User: Assistant: Do some complex calculations and give me an

    analysis. I need an answer from calc tool, here are the arguments to pass it System: // Your system prompt
  22. User: Assistant: Do some complex calculations and give me an

    analysis. I n"d an answer from calc tool, here are the arguments to pass it User: Assistant: // Ca!s JS function and returns result Here's the analysis System: // Your system prompt
  23. Commander's Intent: - Purpose: Why personnel must complete the assignment.

    - Task: What the objective or goal entails. - End state: How the result should look.
  24. You can try something like this: Here's my prompt: ${INITIAL

    PROMPT } Rewrite it to fo!ow the Co#ander's Intent Statement. Ask for missing details.
  25. "There are seven types of information that a person could

    present to help the people receiving the request to understand what to do" Sources of Power Book by Gary Klein
  26. 1. The purpose of the task (the higher level goals)

    2.The objective of the task (an image of desired outcome) 3.The sequence of steps in the plan 4.The rationale for the plan 5.The key decisions that may have to be made 6.Antigoals 7.Constrains and other considerations
  27. @slobodan_ • Hint the beginning of an answer, LLM will

    follow • Give examples (few-shot prompting) • Ask an LLM to think step by step • Help an LLM with tools (tools are just functions) • Ask an LLM to help you improve the prompt