openai-cookbook
openai-cookbook copied to clipboard
[PROBLEM] Errors in Fine-Tuning for retrieval augmented generation (RAG) with Qdrant
trafficstars
I was trying to run this particular notebooks
- https://github.com/openai/openai-cookbook/blob/main/examples/fine-tuned_qa/ft_retrieval_augmented_generation_qdrant.ipynb
- https://cookbook.openai.com/examples/fine-tuned_qa/ft_retrieval_augmented_generation_qdrant
Where I got these 2 errors for these particular lines in cell 10
- Line 15
file=open(self.training_file_path, "r"),
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[<ipython-input-34-2cc5ff431133>](https://localhost:8080/#) in <cell line: 1>()
----> 1 model_id = fine_tuner.fine_tune_model()
2 model_id
1 frames
[<ipython-input-33-eb412b9caab8>](https://localhost:8080/#) in fine_tune_model(self)
45 self.create_openai_file()
46 self.wait_for_file_processing()
---> 47 self.create_fine_tuning_job()
48 self.wait_for_fine_tuning()
49 return self.retrieve_fine_tuned_model()
[<ipython-input-33-eb412b9caab8>](https://localhost:8080/#) in create_fine_tuning_job(self)
27 # print(self.file_object)
28 self.fine_tuning_job = client.fine_tuning.jobs.create(
---> 29 training_file=self.file_object['id'],
30 model=self.model_name,
31 suffix=self.suffix,
TypeError: 'FileObject' object is not subscriptable
- Line 29
training_file=self.file_object['id'],
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
[<ipython-input-36-2cc5ff431133>](https://localhost:8080/#) in <cell line: 1>()
----> 1 model_id = fine_tuner.fine_tune_model()
2 model_id
13 frames
[/usr/local/lib/python3.10/dist-packages/httpx/_multipart.py](https://localhost:8080/#) in __init__(self, name, value)
130 )
131 if isinstance(fileobj, io.TextIOBase):
--> 132 raise TypeError(
133 "Multipart file uploads must be opened in binary mode, not text mode."
134 )
TypeError: Multipart file uploads must be opened in binary mode, not text mode.
Identify the file to be fixed https://github.com/openai/openai-cookbook/blob/main/examples/fine-tuned_qa/ft_retrieval_augmented_generation_qdrant.ipynb
Describe a solution The solution is
file=open(self.training_file_path, "rb")
training_file=self.file_object.id,
Screenshots
Additional context For sure, these errors were minimal and could be rectified by most of the people running the notebook, but I just thought to point them out
Also I am not sure what these will carry to the next parts of the code, as Fine-tuning them requires paid API