openai / openai-cookbook

Examples and guides for using the OpenAI API
https://cookbook.openai.com
MIT License
58.88k stars 9.36k forks source link

[PROBLEM] Errors in Fine-Tuning for retrieval augmented generation (RAG) with Qdrant #1122

Closed AyushSinghal9020 closed 3 months ago

AyushSinghal9020 commented 6 months ago

I was trying to run this particular notebooks

Where I got these 2 errors for these particular lines in cell 10

            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
            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

image image

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

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] commented 3 months ago

This issue was closed because it has been stalled for 10 days with no activity.