Skip to content

Commit 2f31fb1

Browse files
committed
Merge branch 'main' of https://github.com/openai/openai-cookbook into alowden/fine_tuning_techniques_dpo
2 parents 860de79 + 6bccfd9 commit 2f31fb1

21 files changed

+1157
-35
lines changed

examples/Reinforcement_Fine_Tuning.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,8 @@
13391339
"outputs": [],
13401340
"source": [
13411341
"# Set your training and test file paths\n",
1342-
"train_file = \"data/medical_01_verifiable_problem_train_with_prompt.jsonl\"\n",
1343-
"test_file = \"data/medical_01_verifiable_problem_val_with_prompt.jsonl\"\n",
1342+
"train_file = \"data/medical_01_verifiable_problem_train_simple_prompt.jsonl\"\n",
1343+
"test_file = \"data/medical_01_verifiable_problem_val_simple_prompt.jsonl\"\n",
13441344
"\n",
13451345
"def upload_file(file_path: str) -> str:\n",
13461346
" \"\"\"Upload a file to the OpenAI platform for fine-tuning.\"\"\"\n",
@@ -1389,7 +1389,7 @@
13891389
"grader = model_grader_2\n",
13901390
"response_format = None\n",
13911391
"compute_multiplier = 1.0\n",
1392-
"etest_samples = 1\n",
1392+
"eval_samples = 1\n",
13931393
"eval_interval = 5"
13941394
]
13951395
},
@@ -1409,7 +1409,7 @@
14091409
"# Launch the RFT job\n",
14101410
"payload = dict(\n",
14111411
" training_file=train_file_id,\n",
1412-
" test_file=test_file_id,\n",
1412+
" validation_file=test_file_id,\n",
14131413
" model=model,\n",
14141414
" suffix=suffix,\n",
14151415
" method=dict(\n",
@@ -1419,7 +1419,7 @@
14191419
" response_format=response_format,\n",
14201420
" hyperparameters=dict(\n",
14211421
" compute_multiplier=compute_multiplier,\n",
1422-
" etest_samples=etest_samples,\n",
1422+
" eval_samples=eval_samples,\n",
14231423
" eval_interval=eval_interval,\n",
14241424
" n_epochs=n_epochs,\n",
14251425
" reasoning_effort=reasoning_effort,\n",
@@ -2116,7 +2116,7 @@
21162116
"name": "python",
21172117
"nbconvert_exporter": "python",
21182118
"pygments_lexer": "ipython3",
2119-
"version": "3.11.8"
2119+
"version": "3.12.9"
21202120
}
21212121
},
21222122
"nbformat": 4,

examples/evaluation/use-cases/mcp_eval_notebook.ipynb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@
450450
"id": "ee1f655b",
451451
"metadata": {},
452452
"source": [
453+
"Note that the 4.1 model was constructed to never use its tools to answer the query thus it never called the MCP server. The o4-mini model wasn't explicitly instructed to use it's tools either but it wasn't forbidden, thus it called the MCP server 3 times. We can see that the 4.1 model performed worse than the o4 model. Also notable is the one example that the o4-mini model failed was one where the MCP tool was not used.\n",
454+
"\n",
453455
"We can also check a detailed analysis of the outputs from each model for manual inspection and further analysis."
454456
]
455457
},
@@ -806,6 +808,30 @@
806808
" print(item.sample.output[0].content)"
807809
]
808810
},
811+
{
812+
"cell_type": "markdown",
813+
"id": "0936def6",
814+
"metadata": {},
815+
"source": [
816+
"## How can we improve?\n",
817+
"\n",
818+
"If we add the phrase \"Always use your tools since they are the way to get the right answer in this task.\" to the system message of the o4-mini model, what do you think will happen? (try it out)\n",
819+
"\n",
820+
"<br><br><br>\n",
821+
"\n",
822+
"\n",
823+
"If you guessed that the model would now call to MCP tool everytime and get every answer correct, you are right!"
824+
]
825+
},
826+
{
827+
"cell_type": "markdown",
828+
"id": "cf797a91",
829+
"metadata": {},
830+
"source": [
831+
"![Evaluation Data Tab](../../../images/mcp_eval_improved_output.png)\n",
832+
"![Evaluation Data Tab](../../../images/mcp_eval_improved_data.png)"
833+
]
834+
},
809835
{
810836
"cell_type": "markdown",
811837
"id": "924619e0",

examples/o-series/o3o4-mini_prompting_guide.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@
163163
"Validate arguments against the format before sending the call; if you are unsure, ask for clarification instead of guessing.\n",
164164
"```\n",
165165
"\n",
166+
"3. Another note on lazy behavior\n",
167+
"We are aware of rare instances of lazy behavior from o3, such as stating it does not have enough time to complete a task, promising to follow up separately, or giving terse answers even when explicitly prompted to provide more detail. We have found that the following steps help ameliorate this behavior:\n",
168+
"\n",
169+
" a. Start a new conversation for unrelated topics:\n",
170+
" When switching to a new or unrelated topic, begin a fresh conversation thread rather than continuing in the same context. This helps the model focus on the current subject and prevents it from being influenced by previous, irrelevant context, which can sometimes lead to incomplete or lazy responses. For example, if you were previously discussing code debugging and now want to ask about documentation best practices, which does not require previous conversation context, start a new conversation to ensure clarity and focus.\n",
171+
"\n",
172+
" b. Discard irrelevant past tool calls/outputs when the list gets too long, and summarize them as context in the user message:\n",
173+
" If the conversation history contains a long list of previous tool calls or outputs that are no longer relevant, remove them from the context. Instead, provide a concise summary of the important information as part of the user message. This keeps the context manageable and ensures the model has access to only the most pertinent information. For instance, if you have a lengthy sequence of tool outputs, you can summarize the key results and include only that summary in your next message.\n",
174+
"\n",
175+
" c. We are constantly improving our models and expect to have this issue addressed in future versions.\n",
176+
"\n",
177+
"\n",
166178
"### Avoid Chain of Thought Prompting\n",
167179
"Since these models are reasoning models and produce an internal chain of thought, they do not have to be explicitly prompted to plan and reason between toolcalls. Therefore, a developer should not try to induce additional reasoning before each function call by asking the model to plan more extensively. Asking a reasoning model to reason more may actually hurt the performance. \n",
168180
"\n",

examples/partners/eval_driven_system_design/receipt_inspection.ipynb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,9 @@
139139
"\n",
140140
"### 2. Assemble Examples (Gather Data)\n",
141141
"\n",
142-
"It's very rare that a real-world project will start with all the data necessary to get\n",
143-
"to a satisfactory solution, much less to establish confidence.\n",
144-
"\n",
145-
"In our case, we're going to assume that we have a decent sample of system *inputs*, \n",
146-
"in the form of but receipt images, but start without any fully annotated data. We find \n",
147-
"this is a not-unusual situation when automating an existing process. Instead, \n",
148-
"we'll walk through the process of building that out as we go along by collaborating with\n",
149-
"domain experts, and make our evals progressively more comprehensive.\n",
150-
"In our case, we're going to assume that we have a decent sample of system *inputs*\n",
151-
"(here, photographs of receipts), but start without any fully annotated data. We'll walk\n",
152-
"through the process of incrementally expanding our test and training sets as we go along\n",
153-
"and make our evals progressively more comprehensive.\n",
142+
"It's very rare for a real-world project to begin with all the data necessary to achieve a satisfactory solution, let alone establish confidence.\n",
143+
"\n",
144+
"In our case, we'll assume we have a decent sample of system *inputs*, in the form of but receipt images, but start without any fully annotated data. We find this is a not-unusual situation when automating an existing process. We'll walk through the process of incrementally expanding our test and training sets in collaboration with domain experts as we go along and make our evals progressively more comprehensive.\n",
154145
"\n",
155146
"### 3. Build an End-to-End V0 System\n",
156147
"\n",
20 KB
Binary file not shown.

0 commit comments

Comments
 (0)