Prompting for text#

In this notebook we collect a few use-cases for prompting chatGPT. We will also see some not so useful cases.

from openai import OpenAI
from IPython.core.magic import register_line_cell_magic
from IPython.display import display, Markdown
@register_line_cell_magic
def prompt(line:str, cell:str, model="gpt-3.5-turbo"):
    """A prompt helper function that sends a message to openAI
    and prints out the text response.
    """
    message = line + "\n" + cell
    client = OpenAI()
    response = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": message}]
    )
    text = response.choices[0].message.content
    display(Markdown(text))

Translation#

chatGPT works very well for translating text.

%%prompt
Translate the following joke to German:

What is every parent's favorite Christmas song? Silent Night!

Was ist das Lieblingsweihnachtslied aller Eltern? Stille Nacht!

Restructuring data#

It also works well for extracting data from text.

%%prompt
Given a story, please restructure the contained data.

Story:
The compute center of the university recently conducted a study to figure 
out needs of students for computational resources. After interviewing 100 
students they concluded that most of them were happy with 250 GB of cloud
storage.

Restructure the story above to extract these numbers:
* Number of students asked:
* Cloud storage size:

Number of students asked: 100 Cloud storage size: 250 GB

Knowledge#

chatGPT has some weak sides when it comes to quering for data. It may, or may not tell the truth. Also not that the used model is trained on the internet from the past.

%%prompt
What's Robert Haase's (Uni Leipzig) research field ?

Robert Haase’s research field at the University of Leipzig is in the area of computer science, specifically in the field of computer vision and microscopy image analysis. He focuses on developing algorithms and techniques for analyzing and processing large-scale microscopic images to extract meaningful information and gain insights into biological processes.

%%prompt
What's Robert Haase's (TU Dresden) research field ?

As of my knowledge, Robert Haase is primarily associated with the field of bioimage analysis, particularly focusing on the development and application of computational methods for the analysis and visualization of biological images, such as microscopy data. However, please note that research interests and fields can evolve over time, so it is recommended to refer to the most recent information or contact the individual directly for the most accurate details.

Math#

%%prompt
If there are 100 students who each require 250 GB of cloud storage, how much storage do we need in total ? 

To calculate the total storage needed, multiply the storage requirement per student by the number of students:

250 GB * 100 students = 25,000 GB

Therefore, the total storage needed is 25,000 GB.

%%prompt
I have 5 apples, 6 oranges and 4 potatoes. How many fruits to I have?

You have a total of 11 fruits (5 apples + 6 oranges).

%%prompt
How many o are in Woolloomooloo ?

There are 6 o’s in Woolloomooloo.

Exercise#

Come up with two more examples: One where chatGPT works reproducibly, and one where it reproducibly answers wrong information or denies answering.