Skip to content

Commit d251d6e

Browse files
committed
ruff run
1 parent 2f31fb1 commit d251d6e

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

examples/Fine_tuning_direct_preference_optimization_guide.ipynb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@
589589
" \"type\": \"dpo\",\n",
590590
" \"dpo\": {\n",
591591
" \"hyperparameters\": {\n",
592-
" \"n_epochs\": 2, \n",
593-
" \"beta\": 0.1, \n",
594-
" \"batch_size\": 8, \n",
592+
" \"n_epochs\": 2,\n",
593+
" \"beta\": 0.1,\n",
594+
" \"batch_size\": 8,\n",
595595
" }\n",
596596
" },\n",
597597
" },\n",
@@ -610,7 +610,7 @@
610610
},
611611
{
612612
"cell_type": "code",
613-
"execution_count": 25,
613+
"execution_count": null,
614614
"metadata": {},
615615
"outputs": [],
616616
"source": [
@@ -620,13 +620,13 @@
620620
" responses = await generate_responses(testset, model=job.fine_tuned_model)\n",
621621
"\n",
622622
" post_run = sync_client.evals.runs.create(\n",
623-
" name=ft.id,\n",
624-
" eval_id=logs_eval.id,\n",
625-
" data_source={\n",
626-
" \"type\": \"responses\",\n",
627-
" \"source\": {\"type\": \"responses\", \"limit\": len(test_pairs)},\n",
628-
" },\n",
629-
")"
623+
" name=ft.id,\n",
624+
" eval_id=logs_eval.id,\n",
625+
" data_source={\n",
626+
" \"type\": \"responses\",\n",
627+
" \"source\": {\"type\": \"responses\", \"limit\": len(test_pairs)},\n",
628+
" },\n",
629+
" )"
630630
]
631631
},
632632
{
@@ -661,21 +661,16 @@
661661
").data\n",
662662
"post_scores = [s.results[0][\"score\"] for s in post_data]\n",
663663
"\n",
664+
"# print scores & a sample comparison from the test set for illustration\n",
664665
"print(\n",
665666
" \"Δ mean:\",\n",
666-
" sum(t - b for b, t in zip(base_scores, post_scores))\n",
667-
" / len(base_scores),\n",
667+
" sum(t - b for b, t in zip(base_scores, post_scores)) / len(base_scores),\n",
668668
")\n",
669-
"# print a sample comparison from the test set for illustration\n",
670669
"print(\"\\n=== SAMPLE COMPARISON ===\")\n",
671670
"idx = 0\n",
672671
"print(f\"Prompt:\\n {testset[idx]['item']['input']}\\n\")\n",
673-
"print(\n",
674-
" f\"Base model reply: \\n {base_data[idx].sample.output[0].content} \\n\"\n",
675-
")\n",
676-
"print(\n",
677-
" f\"DPO-tuned model reply \\n {post_data[idx].sample.output[0].content}\"\n",
678-
")"
672+
"print(f\"Base model reply: \\n {base_data[idx].sample.output[0].content} \\n\")\n",
673+
"print(f\"DPO-tuned model reply \\n {post_data[idx].sample.output[0].content}\")"
679674
]
680675
}
681676
],

0 commit comments

Comments
 (0)