sidddev7 / prompt-engineering

This repo contains the documents regarding prompt engineering

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prompt Engineering

Link

this is a highly demanded job in this year

Principles of Prompting

  • Principle 1 : Write clear and specific instructions

    • summary
    • Tactic 1 Use Delimiters
      • Use delimiters like backticks example
      • Using delimiters help in avoiding the prompt injection example
      • other delimiters that can be used image
    • Tactic 2 Ask for structured output
      • You can ask model to give the response in a JSON FORMAT example
    • Tactic 3 Conditional Satisfaction
      • ask model to generate the steps by following the steps given in the prompt example
      • if no stpes are there then model may return no stpes provided example
    • Tactic 4 Few shot prompting
      • model can figure out the style of answer in the prompt and try to answer in same style example
  • Principle 2 : Give model time to think

  • Model Limitations : -

  • Hallusination : - model makes statements that sound plausible but are not true

  • example

  • Reduce Hallusination by asking the model to first find relevent information and then answer the question based on that relevent information

Iterative Prompt development

Inferred prompting

Transforming

Expanding

  • Generate an email based on the prompt and other information

Temperature

Chat Workflow

Code

import panel as pn  # GUI
pn.extension()

panels = [] # collect display 

context = [ {'role':'system', 'content':"""
You are OrderBot, an automated service to collect orders for a pizza restaurant. \
You first greet the customer, then collects the order, \
and then asks if it's a pickup or delivery. \
You wait to collect the entire order, then summarize it and check for a final \
time if the customer wants to add anything else. \
If it's a delivery, you ask for an address. \
Finally you collect the payment.\
Make sure to clarify all options, extras and sizes to uniquely \
identify the item from the menu.\
You respond in a short, very conversational friendly style. \
The menu includes \
pepperoni pizza  12.95, 10.00, 7.00 \
cheese pizza   10.95, 9.25, 6.50 \
eggplant pizza   11.95, 9.75, 6.75 \
fries 4.50, 3.50 \
greek salad 7.25 \
Toppings: \
extra cheese 2.00, \
mushrooms 1.50 \
sausage 3.00 \
canadian bacon 3.50 \
AI sauce 1.50 \
peppers 1.00 \
Drinks: \
coke 3.00, 2.00, 1.00 \
sprite 3.00, 2.00, 1.00 \
bottled water 5.00 \
"""} ]  # accumulate messages


inp = pn.widgets.TextInput(value="Hi", placeholder='Enter text here…')
button_conversation = pn.widgets.Button(name="Chat!")

interactive_conversation = pn.bind(collect_messages, button_conversation)

dashboard = pn.Column(
    inp,
    pn.Row(button_conversation),
    pn.panel(interactive_conversation, loading_indicator=True, height=300),
)

dashboard

About

This repo contains the documents regarding prompt engineering