LLM guide

Practical o3 Prompting

Structure reasoning tasks so the model can identify the goal, inputs, constraints, and required output.

Free11 min read

Structure reasoning tasks

o3 is an older OpenAI reasoning model and the techniques carry to current reasoning models.

Put the task first. Separate the facts, rules, and answer format. Ask for a result and then ask the model to explain the result when that explanation is useful.

logic taskRead the following puzzle carefully and determine the final answer. After providing the answer, explain the logical steps you took to reach the conclusion. Puzzle: Three friends, Alice, Bob, and Carol, are wearing hats, either red or blue. Each can see the others’ hats but not their own. They are told that at least one person is wearing a red hat. Alice says: “I cannot determine the color of my hat.” Bob says: “I cannot determine the color of my hat.” Carol says: “I know the color of my hat.” What color hat is Carol wearing, and what color hats are Alice and Bob wearing? Output Format: 1. State the hat color for Carol. 2. State the hat colors for Alice and Bob. 3. Provide a step-by-step explanation of the logical deduction process.

Use few-shot examples with care

One example can show an unusual format or style. Keep it short and use it only when a written specification would be less clear.

custom JSON# Task: Extract User Data and Format as Custom JSON Extract the username, email, and user ID from the following text. Format the extracted information into a JSON object according to the structure shown in the example below. Example Input: User profile for: alice_smith (ID: 1001). Contact email: alice.s@example.com. Example Output: ```json { “user_details”: { “identifier”: 1001, “contact_info”: { “email_address”: “alice.s@example.com”, “profile_name”: “alice_smith” } } } ``` Text to Process: User profile for: bob_jones (ID: 1002). Contact email: bob.j@web.com.

Roles and simulations

Roles can focus an analysis or a simulation. Define the role, the source material, and the output format.

tool simulationYou are simulating a user attempting to use a new command-line data processing tool. The tool’s documentation is provided below in triple backticks. Simulate a user’s thought process and command inputs for the task: “Filter the dataset ‘sales.csv’ to only include rows where the ‘Region’ column is ‘Europe’ and save the output to ‘europe_sales.csv’.” Include potential errors a user might make based on common command-line mistakes (e.g., typos, incorrect syntax, missing arguments) and show how the tool might respond (simulated tool output). Then show the corrected command. Simulate the interaction for the filtering task from start to successful completion.

Prompting for tool use

Provide data when the task needs calculation. Ask for current information when it needs a search. Make the requested result clear.

data analysis# Task: Analyze Sales Data Analyze the following sales data for Q1 2024. The data is provided as a CSV string in a code block. Calculate the following metrics: 1. Total revenue across all products. 2. Average revenue per product. 3. The product with the highest total revenue. 4. The month with the highest total revenue. Provide the results clearly labeled.
current information# Task: Get Current Exchange Rate What is the current exchange rate between the US Dollar (USD) and the Euro (EUR)? Specifically, how many Euros equal one US Dollar? Provide the exchange rate value.

Output control

For work that feeds another system, define the shape of the result. Name required fields, types, limits, and anything the model must leave out.

strict JSON# Task: Extract Product Data and Format as Strict JSON Array Extract information about the products described in the text below. Format the extracted information as a JSON array. Each object in the array MUST strictly adhere to the following JSON schema definition. Any product information found in the text should be included if it fits the schema. Do not include any text or explanation outside the JSON array.

Iterative refinement and self-correction

Use the next turn to point to a missing part or a specific error. Give a measurable criterion for the revision.

correct code# Task: Correct Error in Previous Code Review the Python function `calculate_average` you provided in the last turn. It has a potential `ZeroDivisionError` if the input `numbers` list is empty. Modify the function to handle the case of an empty list by returning `0` instead of raising an error. Provide the complete, corrected function code in a Markdown block.
revise a summary# Task: Review and Revise Summary Review the summary you provided in the previous turn. Ensure it meets the following criteria: 1. The summary must be no more than **75 words**. 2. It must explicitly mention the report’s findings on **model efficiency** and **ethical implications**. Revise the summary if necessary to meet these criteria. Provide only the revised summary.

Handling large contexts

Mark large inputs with clear delimiters. Point to the sections that matter and split complex analysis into separate requests when needed.

document analysis# Task: Analyze Sections of Technical Report Read the following technical report provided in triple backticks. Extract the key findings from the section titled “**Experimental Results**”. Summarize the proposed future work from the section titled “**Future Work and Limitations**”. Provide the extracted key findings from Section 4 as a bulleted list. Provide the summary of future work from Section 6 as a single paragraph. Clearly label each part of the output.

Published here first.