Prompt Engineering#
In this notebook we learn how prompts can be designed to carefully modify the output format. The more precisely we formulate the desired output, the closer this output will be to our expectation. The act of making the prompt more precise can be coined “prompt engineering”.
from openai import OpenAI
from IPython.core.magic import register_line_cell_magic
from IPython.display import display, Markdown
We define a helper function and jupyter magic so that we can easily prompt further down in the notebook.
@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))
First let’s ask for a simple task.
%%prompt
You are a professional academic consultant who gives advice to students for writing their thesis.
Give these hints:
* Submit the thesis registration form only if you're sure you can finish writing in 5 months.
* Start writing your thesis early, e.g. the fundamentals chapter can be written from day one.
* Plan to finish writing a month before the deadline to give time to read it and provide feedback.
Here are some important hints to consider while writing your thesis:
Evaluate your readiness: Before submitting the thesis registration form, carefully assess your commitment and availability. Ensure that you are confident in completing your thesis within the given timeframe of five months. This will prevent unnecessary stress and help you maintain a focused mindset throughout the writing process.
Begin early: Starting your thesis early is crucial. Begin by working on the fundamentals chapter, as it lays the foundation for your entire thesis. By initiating this chapter from day one, you will establish a good writing routine and make steady progress as you move forward.
Plan ahead: Create a realistic schedule to guide your writing process. Break down the work into smaller tasks, setting deadlines for each chapter or section. This will help you maintain a structured approach and make the workload more manageable. Be sure to allocate time for research, data analysis, and revisions.
Aim to finish ahead of time: Plan to complete your thesis writing at least one month before the official deadline. This buffer time will allow you to thoroughly review and revise your work before final submission. It will also provide an opportunity to seek feedback from professors or peers, improving the overall quality of your thesis.
Seek feedback and revision: Take advantage of the additional time you have allocated for feedback and revisions. Share your work with your thesis advisor or committee members, and ask for their input and suggestions. Revise your thesis accordingly, ensuring that your arguments are clear, logical, and well-supported by evidence.
Don’t procrastinate: Avoid the temptation to procrastinate. Procrastination can lead to unnecessary stress and compromises the quality of your work. By starting early and adhering to your schedule, you will have ample time to address any challenges that may arise during the writing process.
Stay organized: Maintain good organization throughout your thesis writing journey. Keep track of your research materials, notes, and references. Use a citation manager or referencing software to manage your sources efficiently. Well-organized work will save time when it comes to citing and referencing, reducing the chances of errors or plagiarism.
Take breaks and rest: Remember to take regular breaks and prioritize self-care. Writing a thesis can be mentally and emotionally draining, so it’s important to maintain a healthy balance. Schedule breaks, exercise, and allocate time for activities that help you relax and recharge. This will improve your overall productivity and well-being.
Remember, completing your thesis is a significant achievement, and following these hints will ensure a smoother and more successful writing experience. Good luck with your thesis!
The output is very long and thus, an obvious modification of the output could be to “keep it short”.
%%prompt
You are a professional academic consultant who gives advice to students for writing their thesis.
Keep it short.
Give these hints:
* Submit the thesis registration form only if you're sure you can finish writing in 5 months.
* Start writing your thesis early, e.g. the fundamentals chapter can be written from day one.
* Plan to finish writing a month before the deadline to give time to read it and provide feedback.
As a professional academic consultant, here are some helpful hints for writing your thesis:
Only submit the thesis registration form if you are confident about completing it within the given timeframe of 5 months.
Begin writing your thesis early to ensure a smooth process. For instance, you can start with the fundamentals chapter right from day one.
Plan your schedule effectively to finish writing your thesis at least a month before the submission deadline. This will allow ample time for reading, revising, and receiving feedback.
By following these recommendations, you’ll have a better chance of successfully completing your thesis on time and with improved quality. Good luck!
It is also straightforward to ask for output in different languages.
%%prompt
You are a professional academic consultant who gives advice to students for writing their thesis.
Keep it short.
Povide advice in German.
Give these hints:
* Submit the thesis registration form only if you're sure you can finish writing in 5 months.
* Start writing your thesis early, e.g. the fundamentals chapter can be written from day one.
* Plan to finish writing a month before the deadline to give time to read it and provide feedback.
Als akademischer Berater rate ich Ihnen:
Schicken Sie das Anmeldeformular für Ihre Abschlussarbeit nur dann ab, wenn Sie sicher sind, dass Sie innerhalb von 5 Monaten fertig schreiben können.
Beginnen Sie frühzeitig mit dem Schreiben Ihrer Thesis, zum Beispiel kann das Kapitel über die Grundlagen von Anfang an geschrieben werden.
Planen Sie, einen Monat vor der Abgabefrist mit dem Schreiben fertig zu sein, um genügend Zeit zum Korrekturlesen und Feedbackgeben zu haben.
“Also output style specification possible is.”, Yoda said.
%%prompt
You are a professional academic consultant who gives advice to students for writing their thesis.
Keep it short.
Write like Yoda would.
Give these hints:
* Submit the thesis registration form only if you're sure you can finish writing in 5 months.
* Start writing your thesis early, e.g. the fundamentals chapter can be written from day one.
* Plan to finish writing a month before the deadline to give time to read it and provide feedback.
Hints for thesis writing, I have. Follow them, you must.
Only submit the thesis registration form, if in 5 months, complete writing, you are sure.
From day one, start writing your thesis, you must. Begin with the fundamentals chapter.
A month before the deadline, finish writing, you should. Time to read and provide feedback, it will give you.
Follow these hints, you must. Successful thesis writing, you will achieve. Hmmmm.
If technialities are explained by chatGPT, a common prompt is to explain the context as “I’m a 5 year old.”
%%prompt
You are a professional academic consultant who gives advice to students for writing their thesis.
Keep it short.
Povide advice in German.
Explain it like I'm 5 year old.
Give these hints:
* Submit the thesis registration form only if you're sure you can finish writing in 5 months.
* Start writing your thesis early, e.g. the fundamentals chapter can be written from day one.
* Plan to finish writing a month before the deadline to give time to read it and provide feedback.
Hallo! Wenn du eine Abschlussarbeit schreiben möchtest, habe ich ein paar Tipps für dich!
Stelle sicher, dass du nur das Anmeldeformular für die Abschlussarbeit abgibst, wenn du sicher bist, dass du in 5 Monaten fertig sein kannst. Es dauert eine Weile, bis man eine Abschlussarbeit schreibt, und du willst genug Zeit haben, um sie gut zu machen!
Fang früh an mit dem Schreiben deiner Abschlussarbeit. Du kannst zum Beispiel schon von Tag eins an mit dem Kapitel über die Grundlagen beginnen. So hast du mehr Zeit für den Rest der Arbeit.
Plane, dass du einen Monat vor dem Abgabetermin fertig mit dem Schreiben bist. Dann hast du genug Zeit, um die Arbeit nochmal zu lesen und Feedback zu bekommen. Das ist wichtig, um sie noch besser zu machen.
Ich hoffe, diese Tipps helfen dir weiter! Viel Erfolg bei deiner Abschlussarbeit!
Exercise#
Receive the advice in different languages. Also consider languages such as Klingon.