Skip to content

Small fixes for reading the input files correctly and to the OpenAIFi… #1801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"\n",
"We will also be integrating Qdrant and Few-Shot Learning to boost the model's performance and reduce hallucinations. This could serve as a practical guide for ML practitioners, data scientists, and AI Engineers interested in leveraging the power of OpenAI models for specific use-cases. 🤩\n",
"\n",
"Note: This notebook uses the gpt-3.5-turbo model. Fine-tuning on the SQuAD dataset with this setup yields only minimal gains for more advanced models such as gpt-4o or gpt-4.1. As such, this notebook is primarily intended as a guide for fine-tuning workflows and retrieval-augmented generation (RAG) practices\n",
"\n",
"## Why should you read this blog?\n",
"\n",
"You want to learn how to \n",
Expand Down Expand Up @@ -559,7 +561,7 @@
"\n",
" def create_openai_file(self):\n",
" self.file_object = client.files.create(\n",
" file=open(self.training_file_path, \"r\"),\n",
" file=open(self.training_file_path, \"rb\"),\n",
" purpose=\"fine-tune\",\n",
" )\n",
"\n",
Expand All @@ -571,19 +573,22 @@
"\n",
" def create_fine_tuning_job(self):\n",
" self.fine_tuning_job = client.fine_tuning.jobs.create(\n",
" training_file=self.file_object[\"id\"],\n",
" training_file=self.file_object.id,\n",
" model=self.model_name,\n",
" suffix=self.suffix,\n",
" )\n",
"\n",
" def wait_for_fine_tuning(self, sleep_time=45):\n",
" while self.fine_tuning_job.status != 'succeeded':\n",
" while True:\n",
" # Retrieve the latest fine-tuning job status\n",
" self.fine_tuning_job = client.fine_tuning.jobs.retrieve(self.fine_tuning_job.id)\n",
" print(\"Job Status:\", self.fine_tuning_job.status)\n",
" if self.fine_tuning_job.status in {'succeeded', 'failed', 'cancelled'}:\n",
" break\n",
" time.sleep(sleep_time)\n",
" self.fine_tuning_job.refresh()\n",
" print(\"Job Status: \", self.fine_tuning_job.status)\n",
"\n",
" def retrieve_fine_tuned_model(self):\n",
" self.model_id = client.fine_tuning.jobs.retrieve(self.fine_tuning_job[\"id\"]).fine_tuned_model\n",
" self.model_id = client.fine_tuning.jobs.retrieve(self.fine_tuning_job.id).fine_tuned_model\n",
" return self.model_id\n",
"\n",
" def fine_tune_model(self):\n",
Expand Down