Skip to content

Commit 58c9834

Browse files
Merge branch 'main' into agents-sdk-pm-advisor-cookbook
2 parents 9c93271 + a140048 commit 58c9834

File tree

4 files changed

+71
-41
lines changed

4 files changed

+71
-41
lines changed

authors.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ prashantmital-openai:
1717
website: "https://www.linkedin.com/in/pmital/"
1818
avatar: "https://avatars.githubusercontent.com/u/173949238?v=4"
1919

20-
theophile-openai:
20+
theophile-oai:
2121
name: "Theophile Sautory"
2222
website: "https://www.linkedin.com/in/theophilesautory"
2323
avatar: "https://avatars.githubusercontent.com/u/206768658?v=4"

examples/Reinforcement_Fine_Tuning.ipynb

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@
689689
"\n",
690690
"We can visualize the full score distribution on the training set.\n",
691691
"\n",
692-
"> **Note:** : In practice, analyzing model errors at scale often involves a mix of manual review and automated methods-like tagging failure types or clustering predictions by score and content. That workflow is beyond the scope of this guide, but it's a valuable next step once you've identified broad patterns."
692+
"> Note: In practice, analyzing model errors at scale often involves a mix of manual review and automated methods-like tagging failure types or clustering predictions by score and content. That workflow is beyond the scope of this guide, but it's a valuable next step once you've identified broad patterns."
693693
]
694694
},
695695
{
@@ -1968,7 +1968,7 @@
19681968
"source": [
19691969
"Looking at the distruibution of scores, we observe that RFT helped shift the model’s predictions out of the mid-to-low score zone (0.4–0.5) and into the mid-to-high range (0.5–0.6). Since the grader emphasizes clinical similarity over lexical match, this shift reflects stronger medical reasoning-not just better phrasing-according to our *expert* grader. As observed in the 0.9-1.0 range, some verbosity crept in despite mitigations and slightly lowering scores throughout, though it often reflected more complete, semantically aligned answers. A future grader pass could better account for these cases.\n",
19701970
"\n",
1971-
"Note, because the earlier `combined_grader` was designed to reward lexical correctness, its accuracy didnʼt improve much-which is expected. That gap reinforces why validating your model grader is critical, and why you should monitor for reward-hacking. In our case, we used `o3` to spot-check grading behavior, but domain expert review is essential. "
1971+
"Note that, because the earlier `combined_grader` was designed to reward lexical correctness, its accuracy didnʼt improve much-which is expected. That gap reinforces why validating your model grader is critical, and why you should monitor for reward-hacking. In our case, we used `o3` to spot-check grading behavior, but domain expert review is essential. "
19721972
]
19731973
},
19741974
{
@@ -2019,22 +2019,17 @@
20192019
},
20202020
{
20212021
"cell_type": "code",
2022-
"execution_count": null,
2022+
"execution_count": 1,
20232023
"metadata": {},
20242024
"outputs": [
20252025
{
2026-
"data": {
2027-
"text/markdown": [
2028-
"**Classifying staging type**\n",
2029-
"\n",
2030-
"The user provided a clinical scenario of a 35-year-old female with a 5 cm oral tumor and a 2 cm lymph node. They're asking how to stage it according to the TNM classification. This is a diagnosis query, so the correct answer type here is \"diagnosis.\" Considering the tumor's size, it appears to be classified as T3 since it's greater than 4 cm. Thus, I think the staging might be Stage II, but I'll confirm that."
2031-
],
2032-
"text/plain": [
2033-
"<IPython.core.display.Markdown object>"
2034-
]
2035-
},
2036-
"metadata": {},
2037-
"output_type": "display_data"
2026+
"name": "stdout",
2027+
"output_type": "stream",
2028+
"text": [
2029+
"Classifying staging type\n",
2030+
"\n",
2031+
"The user provided a clinical scenario of a 35-year-old female with a 5 cm oral tumor and a 2 cm lymph node. They're asking how to stage it according to the TNM classification. This is a diagnosis query, so the correct answer type here is \"diagnosis.\" Considering the tumor's size, it appears to be classified as T3 since it's greater than 4 cm. Thus, I think the staging might be Stage II, but I'll confirm that.\n"
2032+
]
20382033
}
20392034
],
20402035
"source": [
@@ -2045,27 +2040,21 @@
20452040
},
20462041
{
20472042
"cell_type": "code",
2048-
"execution_count": null,
2043+
"execution_count": 2,
20492044
"metadata": {},
20502045
"outputs": [
20512046
{
2052-
"data": {
2053-
"text/markdown": [
2054-
"**Clarifying T staging for cancers**\n",
2055-
"\n",
2056-
"I’m digging into T staging for head and neck cancers in the oral cavity. So, T1 applies to tumors 2 cm or less, T2 for those over 2 cm but not more than 4 cm, and T3 is for tumors over 4 cm. T4a indicates invasion into adjacent structures. The patient's tumor measures 5 cm, which is over 4 cm. I’m not sure if it fits T3 or T4a, since T4a involves additional invasiveness, not just size.\n",
2057-
"**Determining T and N staging**\n",
2058-
"\n",
2059-
"I’m looking at a 5 cm tumor in the oral cavity. It seems there’s no mention of invasion into adjacent structures, so I’m categorizing it as T3 due to its size. T4a usually means invasion into structures like bone or skin. According to the TNM classification, since I see no such invasion, T classification remains T3.\n",
2060-
"\n",
2061-
"Moving on to N staging, I see there's a single lymph node of 2 cm on the same side; this fits the N1 classification for metastasis, as it’s less than 3 cm."
2062-
],
2063-
"text/plain": [
2064-
"<IPython.core.display.Markdown object>"
2065-
]
2066-
},
2067-
"metadata": {},
2068-
"output_type": "display_data"
2047+
"name": "stdout",
2048+
"output_type": "stream",
2049+
"text": [
2050+
"Clarifying T staging for cancers\n",
2051+
"\n",
2052+
"I’m digging into T staging for head and neck cancers in the oral cavity. So, T1 applies to tumors 2 cm or less, T2 for those over 2 cm but not more than 4 cm, and T3 is for tumors over 4 cm. T4a indicates invasion into adjacent structures. The patient's tumor measures 5 cm, which is over 4 cm. I’m not sure if it fits T3 or T4a, since T4a involves additional invasiveness, not just size. Determining T and N staging\n",
2053+
"\n",
2054+
"I’m looking at a 5 cm tumor in the oral cavity. It seems there’s no mention of invasion into adjacent structures, so I’m categorizing it as T3 due to its size. T4a usually means invasion into structures like bone or skin. According to the TNM classification, since I see no such invasion, T classification remains T3.\n",
2055+
"\n",
2056+
"Moving on to N staging, I see there's a single lymph node of 2 cm on the same side; this fits the N1 classification for metastasis, as it’s less than 3 cm.\n"
2057+
]
20692058
}
20702059
],
20712060
"source": [

examples/o-series/o3o4-mini_prompting_guide.ipynb

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,28 @@
176176
"# Responses API\n",
177177
"\n",
178178
"### Reasoning Items for Better Performance\n",
179-
"We’ve released a [cookbook](https://cookbook.openai.com/examples/responses_api/reasoning_items) detailing the benefits of using the responses API. It is worth restating a few of the main points in this guide as well. o3/o4-mini are both trained with its internal reasoning persisted between toolcalls within a single turn. Persisting these reasoning items between toolcalls during inference will therefore lead to higher intelligence and performance in the form of better decision in when and how a tool gets called. Responses allow you to persist these reasoning items (maintained either by us or yourself through encrypted content if you do not want us to handle state-management) while Chat Completion doesn’t. Switching to the responses API and allowing the model access to reasoning items between function calls is the easiest way to squeeze out as much performance as possible for function calls. Here is an the example in the cookbook, reproduced for convenience, showing how you can pass back the reasoning item using `encrypted_content` in a way which we do not retain any state on our end\n",
180-
"\n",
181-
"```\n",
179+
"We’ve released a [cookbook](https://cookbook.openai.com/examples/responses_api/reasoning_items) detailing the benefits of using the responses API. It is worth restating a few of the main points in this guide as well. o3/o4-mini are both trained with its internal reasoning persisted between toolcalls within a single turn. Persisting these reasoning items between toolcalls during inference will therefore lead to higher intelligence and performance in the form of better decision in when and how a tool gets called. Responses allow you to persist these reasoning items (maintained either by us or yourself through encrypted content if you do not want us to handle state-management) while Chat Completion doesn’t. Switching to the responses API and allowing the model access to reasoning items between function calls is the easiest way to squeeze out as much performance as possible for function calls. Here is an the example in the cookbook, reproduced for convenience, showing how you can pass back the reasoning item using `encrypted_content` in a way which we do not retain any state on our end:\n"
180+
]
181+
},
182+
{
183+
"cell_type": "code",
184+
"execution_count": 2,
185+
"metadata": {},
186+
"outputs": [
187+
{
188+
"name": "stdout",
189+
"output_type": "stream",
190+
"text": [
191+
"The current temperature in Paris is about 18.8 °C.\n"
192+
]
193+
}
194+
],
195+
"source": [
196+
"from openai import OpenAI\n",
182197
"import requests\n",
198+
"import json\n",
199+
"client = OpenAI()\n",
200+
"\n",
183201
"\n",
184202
"def get_weather(latitude, longitude):\n",
185203
" response = requests.get(f\"https://api.open-meteo.com/v1/forecast?latitude={latitude}&longitude={longitude}&current=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m\")\n",
@@ -206,14 +224,37 @@
206224
"context = [{\"role\": \"user\", \"content\": \"What's the weather like in Paris today?\"}]\n",
207225
"\n",
208226
"response = client.responses.create(\n",
209-
" model=\"o4-mini\",\n",
227+
" model=\"o3\",\n",
210228
" input=context,\n",
211229
" tools=tools,\n",
230+
" store=False,\n",
231+
" include=[\"reasoning.encrypted_content\"] # Encrypted chain of thought is passed back in the response\n",
212232
")\n",
213233
"\n",
214234
"\n",
215-
"response.output\n",
216-
"```\n"
235+
"context += response.output # Add the response to the context (including the encrypted chain of thought)\n",
236+
"tool_call = response.output[1]\n",
237+
"args = json.loads(tool_call.arguments)\n",
238+
"\n",
239+
"\n",
240+
"\n",
241+
"result = get_weather(args[\"latitude\"], args[\"longitude\"])\n",
242+
"\n",
243+
"context.append({ \n",
244+
" \"type\": \"function_call_output\",\n",
245+
" \"call_id\": tool_call.call_id,\n",
246+
" \"output\": str(result)\n",
247+
"})\n",
248+
"\n",
249+
"response_2 = client.responses.create(\n",
250+
" model=\"o3\",\n",
251+
" input=context,\n",
252+
" tools=tools,\n",
253+
" store=False,\n",
254+
" include=[\"reasoning.encrypted_content\"]\n",
255+
")\n",
256+
"\n",
257+
"print(response_2.output_text)"
217258
]
218259
},
219260
{

registry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
path: examples/Reinforcement_Fine_Tuning.ipynb
3434
date: 2025-05-23
3535
authors:
36-
- theophile-openai
36+
- theophile-oai
3737
tags:
3838
- reinforcement-learning
3939
- fine-tuning

0 commit comments

Comments
 (0)