Prompting techniques for o3-mini

There is a little guide - which was mentioned in the announcement of the new o3-mini model.

Let us have a closer look into one of the example prompts and talk about it.

I want to build a Python app that takes user questions and looks
them up in a database where they are mapped to answers. If there
is close match, it retrieves the matched answer. If there isn't,
it asks the user to provide an answer and stores the
question/answer pair in the database. Make a plan for the directory
structure you'll need, then return each file in full. Only supply
your reasoning at the beginning and end, not throughout the code.

:nerd_face:
Interesting sidenote:
this prompt shows that the OpenAI devs might be working on a database solution to cache answers.


But let’s go over to the prompt format.

First thing I see is

I want to build a Python app

it can be shortend to

Build a Python app

which removes uneccessary shyness/politeness


Secondly we have this part:

't,
it asks the user to provide an answer and stores the
question/answer pair in the database. Make a plan for the directory
structure you'

Keep an eye on the single quotes. This has a meaning in programming languages and could be seen as a grouping command and could be avoided.


and lastely I am very unsure about this:

Only supply your reasoning at the beginning and end, not throughout the code.

Do you mean it shouldn’t mix explanations with code output?
What about comments in the code?

I would propose this:

Add comments to explain the code blocks in a way that
makes it understandable for junior devs
  without knowledge of your task descriptions.

If any explanation is wanted you will receive a specific command for that later.

Possible commands for future tasks may be:

 "explain" to get a short summary
 
or

 "explain in detail" to get a detailed explanation with additional reasoning


and then give a precise definition of the desired output with an example

Now just follow the desired format precisely:

1. Outline the directory structure as a tree view in bash
2. Provide each file in full

Example format:
---

[treeview of the code]

### filename
[complete code]

### next filename
[complete code]

---

I'll be gone for a break.
I expect that you have finished the whole project when I return. 

:smiley: Happy coding!


So the full optimized prompt could look like this:

Build a Python app that maps user questions to database entries:

When a question closely matches an existing entry, 
  retrieve and display its answer; 
otherwise, 
  prompt the user for an answer and store the new question-answer pair. 

Add comments to explain the code blocks in a way that
makes it understandable for junior devs
  without knowledge of your task descriptions.


If any explanation is wanted you will receive a specific command for that later.

Possible commands for future tasks may be:

 "explain" to get a short summary
 
or

 "explain in detail" to get a detailed explanation with additional reasoning


Now just follow the desired format precisely:

1. Outline the directory structure as a tree view in bash
2. Provide each file in full

Example format:
---

[treeview of the code]

### filename
[complete code]

### next filename
[complete code]

---

I'll be gone for a break.
I expect that you have finished the whole project when I return. 

:smiley: Happy coding!


:scientist: Looking forward for your tipps and tricks

5 Likes

Well, actually it looks like that was wrong :smile:

Example prompt given by the guide

Example prompt given by me (which highlights why old techniques are outdated and also why I should have tested it before I post it)


Though I would say the codequality was way better with my prompt suggestion in terms of readability, where as the model seems to follow a predefined pattern on how to organize the architecture of the code…


I have fiddled around a bit and here is my updated approach.

Will test that and see if it works…


ok… that was far from easy peezee…

A dark-themed chat interface with a "Chat with Your Bot" title, a large message display area, and a text input box labeled "Type your question here…" with a blue "Send" button. (Captioned by AI)

have put the working application code here:

I was telling it to use pgvector - which is still technically a database solution haha

some thoughts about that

I made my first chat using gpt3 in less than 1 hour writing the code by hand… And it had wikipedia integration to get realtime data enrichment

I’ve send a request to gpt3 to ask it for possible wikipedia urls to check

then took the content - summarized it and added that to a second prompt to create an answer

— So what ChatGPT made with me is thinking way more complicated and standardized… it basically transforms me into a corporation developer

PLEASE DO NOT USE THIS IN MEDICAL APPLICATIONS!

2 Likes