Skip to content

Instantly share code, notes, and snippets.

@csiebler
Last active November 23, 2023 14:28
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save csiebler/d137386c4a63cc34810151bcdf150d54 to your computer and use it in GitHub Desktop.
Save csiebler/d137386c4a63cc34810151bcdf150d54 to your computer and use it in GitHub Desktop.
Azure OpenAI Service prompt examples

GPT-3 examples (using mostly text-davinci-003)

Information extraction from claim phone conversations

  • Engine: text-davinci-003 (also works in text-davinci-002, but might require more instructions to get a correct JSON back)
  • Temperature: 0.7
You must extract the following information from the phone conversation below:

1. Call reason (key: reason)
2. Cause of the incident (key: cause)
3. Names of all drivers as an array (key: driver_names)
4. Insurance number (key: insurance_number)
5. Accident location (key: location)
6. Car damages as an array (key: damages)
7. A short, yet detailed summary (key: summary)

Make sure fields 1 to 6 are answered very short, e.g. for location just say the location name
Please answer in JSON machine-readable format, using the keys from above.

Phone conversation:
Hi I just had a car accident and wanted to report it. OK, I hope you're alright, what happened? I was driving on the I-18 and I hit another car. Are you OK? Yeah, I'm just a little shaken up. That's understandable. Can you give me your full name? Sure, it's Sarah standl. Do you know what caused the accident? I think I might have hit a pothole. OK, where did the accident take place? On the I-18 freeway. Was anyone else injured? I don't think so. But I'm not sure. OK, well we'll need to do an investigation. Can you give me the other drivers information? Sure, his name is John Radley. And your insurance number. OK. Give me a minute. OK, it's 546452. OK, what type of damages has the car? Headlights are broken and the airbags went off. Are you going to be able to drive it? I don't know. I'm going to have to have it towed. Well, we'll need to get it inspected. I'll go ahead and start the claim and we'll get everything sorted out. Thank you.

JSON:

News article processing

  • Engine: text-davinci-003 (won't work well with 002)
  • Temperature: 0.7

(News article courtesy of WDR - link)

Extract information from the news article below. In detail, please perform:

1. one sentence summary in German
2. All names
3. All German States

Return the results in a JSON document with the keys summary, names, and states.

News article:
Die Isolationspflicht für Corona-Infizierte steht in NRW auf der Kippe. Die Landesregierung plant eine Entscheidung. Außerdem sollen die Corona-Regeln am Arbeitsplatz im Februar enden. In NRW könnte die Isolationspflicht für Corona-Infizierte bald enden. Gesundheitsminister Karl-Josef Laumann (CDU) kündigte am Mittwoch eine Entscheidung der Landesregierung in dieser Frage an. Ein konkretes Datum nannte er jedoch nicht. "Ich kann nur sagen, dass ich davon ausgehe, dass bis auf Sachsen, Berlin und Brandenburg am 1. Februar alle Länder aus der Isolationspflicht raus sind", sagte er über die Situation in anderen Bundesländern. Die Landesregierung prüfe, ob NRW noch dabei bleibe oder nicht. Bayern, Schleswig-Holstein, Rheinland-Pfalz und Hessen seien bereits vor Weihnachten aus der Isolationspflicht rausgegangen und die Corona-Zahlen hätten sich dort nicht anders entwickelt als in den Bundesländern mit einer Isolationspflicht. "Dann wären im Grunde genommen alle landesrechtlichen Regelungen weitestgehend - wenn man das dann so machen würde - am 1. Februar raus", sagte Laumann.

Results:

Information retrieval and data formatting

  • Engine: text-davinci-002 or better
  • Temperature: 0.7

Classify companies into verticals:

Classify Microsoft, UBS, SAP, FedEx and Zurich Insurance into their verticals.

Change formatting:

Classify Microsoft, UBS, SAP, FedEx and Zurich Insurance into their verticals. Write the answer as COMPANY#INDUSTRY. Do not write it as a ordered list, but write a new line for each.

Add revenue:

Classify Microsoft, UBS, SAP, FedEx and Zurich Insurance into their verticals. Also add the yearly revenue for each company. Write the answer as COMPANY#INDUSTRY#REVENUE. Do not write it as a ordered list, but write a new line for each.

Format revenue:

Classify Microsoft, UBS, SAP, FedEx and Zurich Insurance into their verticals. Also add the yearly revenue for each company. Write the answer as COMPANY#INDUSTRY#REVENUE. Write revenue as $x.xxbn. Do not write it as a ordered list, but write a new line for each.

Dealing with missing data / avoiding hallucination

  • Engine: text-davinci-002 or text-davinci-003 (text-davinci-003 is less prone to suffer from hallucination)
  • Temperature: 0.7

Bad:

If a vehicle will be used at any time, proof of automobile liability insurance is required with the following limits of coverage: $500,000 limit minimum combined single limit.

Are the children insured?

Better:

If a vehicle will be used at any time, proof of automobile liability insurance is required with the following limits of coverage: $500,000 limit minimum combined single limit.

Are the children insured? If the answer is not in the text, write "Answer not found".

Getting more precise answers by asking for explanations

  • Engine: text-davinci-002 or text-davinci-003
  • Temperature: 0.7

Might return a highly incorrect result (not always though):

What is the annual energy demand in kWh for a single-family household with four people. Assume they are home 330 days per year.

Typically returns an accurate result:

What is the annual energy demand in kWh for a single-family household with four people. Assume they are home 330 days per year.
Please think step by step and explain the calculation step by step.

Information extraction from NDAs

  • Engine: text-davinci-003
  • Temperature: 0.7
From the following NDA, please extract the following information:

- When the contract was signed
- Who signed the contract
- Address of the person signing the contract
- Fine for breaching the contract

Answer in JSON. Use the keys signing_date, name, address, and fine_amount. Format the signing_date as MM/DD/YYYY.

NDA:
On the date of August 17th, 2019, as an employee of Contoso Restaurant, I, Mateo Gomez, residing in 1234 Hollywood Boulevard Los Angeles CA, with social security number: 123-45-6789, hereby declare to fully support and promote the top priorities delegated to me at Contoso Restaurant, and vow to never disclose any information including but not limited to trade secrets, finances, delivery schedules, and recipes.
If I, Mateo Gomez, accidentally or with intent breach the conditions set forth in this contract, understand fully that I shall receive a written termination to the following email address mateo@contosorestaurant.com as well as a fine of up to $10,000.

Extracted information in JSON:

Letter writing in German

  • Engine: text-davinci-003 (won't work well with text-davinci-002)
  • Temperature: 0.7
Schreibe einen formalen Brief an die Kunden in Deutsch.

- Wartungsfenster für den 14. Februar von 14 bis 15 Uhr geplant, da Leitungsarbeiten, erwarten sie Ausfallszeiten.
- Biete Hilfe unter info@operations.de an
- Bitte um Verzeihung
- Benutze 00:00 als Zeitformat

Brief:

Generate apps

This is similar to ChatGPT, which can generate code snippets/full simple apps.

  • Engine: text-davinci-003
  • Temperature: 0.7
Write a Flask app that shows a simple hello world website with a html template.

Then after the example has been generated, add the following prompt:

Add an API that returns the weather data for a location that the user can enter in a textbox on the hello.html site.

Codex examples (using mostly code-davinci-002)

# Table customers, columns = [CustomerId, FirstName, LastName, Company, Address, City, State, Country, PostalCode, Phone, Fax, Email, SupportRepId]
# Create a MySQL query for all customers in Texas named Jane

query = """
SELECT *
FROM customers
WHERE State = 'TX' AND FirstName = 'Jane'
"""

# open file test.json with pandas as df
df = pd.read_json('test.json')

# select top 10 orders from column order_value and sort by date column
df.sort_values(by='order_value', ascending=False).head(10)

def test(n):
    if n in {0, 1}:
        return n
    return test(n - 1) + test(n - 2)

# Explain what does test() do?
"""
SQL

table customer, columns=firstname, name, customer_id, address
table orders, columns=order_id, customer_id, product_id, product_amount
table products, columns=product_id, price, name, description

Write a query that returns the top 10 orders and show the customer name
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment