Skip to content

Commit 828a22a

Browse files
committed
Update python version
1 parent c05a25b commit 828a22a

File tree

1 file changed

+15
-76
lines changed

1 file changed

+15
-76
lines changed

examples/Fine_tuning_direct_preference_optimisation_guide.ipynb

Lines changed: 15 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"cell_type": "code",
120-
"execution_count": 1,
120+
"execution_count": 6,
121121
"metadata": {},
122122
"outputs": [],
123123
"source": [
@@ -146,7 +146,7 @@
146146
},
147147
{
148148
"cell_type": "code",
149-
"execution_count": 2,
149+
"execution_count": null,
150150
"metadata": {},
151151
"outputs": [],
152152
"source": [
@@ -247,17 +247,9 @@
247247
},
248248
{
249249
"cell_type": "code",
250-
"execution_count": 3,
250+
"execution_count": null,
251251
"metadata": {},
252-
"outputs": [
253-
{
254-
"name": "stdout",
255-
"output_type": "stream",
256-
"text": [
257-
"Dataset ready with 500 pairs.\n"
258-
]
259-
}
260-
],
252+
"outputs": [],
261253
"source": [
262254
"import random\n",
263255
"import nest_asyncio\n",
@@ -313,27 +305,9 @@
313305
},
314306
{
315307
"cell_type": "code",
316-
"execution_count": 4,
308+
"execution_count": null,
317309
"metadata": {},
318-
"outputs": [
319-
{
320-
"data": {
321-
"text/plain": [
322-
"{'input': {'messages': [{'role': 'system',\n",
323-
" 'content': 'You are a customer‑support assistant.'},\n",
324-
" {'role': 'user',\n",
325-
" 'content': 'Are there any special discounts available for customers who stay with you for an extended period?'}]},\n",
326-
" 'preferred_output': [{'role': 'assistant',\n",
327-
" 'content': 'Hey there, awesome friend! 🌟 Thanks a ton for sticking with Good Vibes Corp — we absolutely LOVE our long-term customers! 🎉 Yes, we totally have some fantastic special discounts and perks just for folks who stay with us for the long haul. Think of it as our way of saying THANK YOU for being part of the Good Vibes family! 💖\\n\\nTo get all the juicy'}],\n",
328-
" 'non_preferred_output': [{'role': 'assistant',\n",
329-
" 'content': 'Please specify the duration of your extended stay and the location or service you are inquiring about for accurate discount information.'}]}"
330-
]
331-
},
332-
"execution_count": 4,
333-
"metadata": {},
334-
"output_type": "execute_result"
335-
}
336-
],
310+
"outputs": [],
337311
"source": [
338312
"# set dataset sizes\n",
339313
"random.shuffle(pairs)\n",
@@ -358,17 +332,9 @@
358332
},
359333
{
360334
"cell_type": "code",
361-
"execution_count": 5,
335+
"execution_count": null,
362336
"metadata": {},
363-
"outputs": [
364-
{
365-
"name": "stdout",
366-
"output_type": "stream",
367-
"text": [
368-
"Baseline mean score: 2.0\n"
369-
]
370-
}
371-
],
337+
"outputs": [],
372338
"source": [
373339
"import io\n",
374340
"import json\n",
@@ -473,17 +439,9 @@
473439
},
474440
{
475441
"cell_type": "code",
476-
"execution_count": 6,
442+
"execution_count": null,
477443
"metadata": {},
478-
"outputs": [
479-
{
480-
"name": "stdout",
481-
"output_type": "stream",
482-
"text": [
483-
"Fine-tuning job created: job_id = ftjob-Gp4cJVYiSc43tdU7cCgqPl6V\n"
484-
]
485-
}
486-
],
444+
"outputs": [],
487445
"source": [
488446
"# create training file\n",
489447
"train_buf = io.BytesIO(\"\\n\".join(json.dumps(p) for p in train_pairs).encode())\n",
@@ -525,28 +483,9 @@
525483
},
526484
{
527485
"cell_type": "code",
528-
"execution_count": 8,
486+
"execution_count": null,
529487
"metadata": {},
530-
"outputs": [
531-
{
532-
"name": "stdout",
533-
"output_type": "stream",
534-
"text": [
535-
"Δ mean: 0.5\n",
536-
"\n",
537-
"=== SAMPLE COMPARISON ===\n",
538-
"Prompt:\n",
539-
" Hello, I placed an order for a gadget last week. Could you tell me the expected delivery date?\n",
540-
"\n",
541-
"Base model reply [score 2]:\n",
542-
" Hello! Could you please provide me with your order number or the email address used for the purchase? This will help me check the expected delivery date for your gadget.\n",
543-
"\n",
544-
"DPO-tuned model reply [score 2]:\n",
545-
" Hello! I'd be happy to help you with your order. Could you please provide me with your order number or any other details related to your purchase? That way, I can check the status and give you the expected delivery date.\n",
546-
"\n"
547-
]
548-
}
549-
],
488+
"outputs": [],
550489
"source": [
551490
"job = sync_client.fine_tuning.jobs.retrieve(ft.id)\n",
552491
"if job.status == \"succeeded\":\n",
@@ -556,7 +495,7 @@
556495
" sum(t[\"score\"] - b[\"score\"] for b, t in zip(base_scores, post_scores))\n",
557496
" / len(base_scores),\n",
558497
" )\n",
559-
" # print a sample comparison from the evaluation for illustration\n",
498+
" # print a sample comparison from the test set for illustration\n",
560499
" print(\"\\n=== SAMPLE COMPARISON ===\")\n",
561500
" idx = 0\n",
562501
" print(f\"Prompt:\\n {test_prompts[idx]}\\n\")\n",
@@ -573,7 +512,7 @@
573512
],
574513
"metadata": {
575514
"kernelspec": {
576-
"display_name": "Python 3",
515+
"display_name": ".venv311",
577516
"language": "python",
578517
"name": "python3"
579518
},
@@ -587,7 +526,7 @@
587526
"name": "python",
588527
"nbconvert_exporter": "python",
589528
"pygments_lexer": "ipython3",
590-
"version": "3.9.6"
529+
"version": "3.11.13"
591530
}
592531
},
593532
"nbformat": 4,

0 commit comments

Comments
 (0)