Skip to content

Commit 566584a

Browse files
Merge pull request #3646 from mrbullwinkle/mrb_03_20_2025_fine_tuning_update
[Azure OpenAI] fine-tuning updates
2 parents 210b39c + f7e8542 commit 566584a

File tree

2 files changed

+11
-227
lines changed

2 files changed

+11
-227
lines changed

articles/ai-services/openai/includes/fine-tuning-python.md

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ For large data files, we recommend that you import from an Azure Blob store. La
110110
111111
The following Python example uploads local training and validation files by using the Python SDK, and retrieves the returned file IDs.
112112

113-
# [OpenAI Python 1.x](#tab/python-new)
114-
115113
```python
116114
# Upload fine-tuning files
117115

@@ -144,42 +142,6 @@ print("Validation file ID:", validation_file_id)
144142

145143
```
146144

147-
# [OpenAI Python 0.28.1](#tab/python)
148-
149-
[!INCLUDE [Deprecation](../includes/deprecation.md)]
150-
151-
```python
152-
# Upload fine-tuning files
153-
154-
import openai
155-
import os
156-
157-
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
158-
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT")
159-
openai.api_type = 'azure'
160-
openai.api_version = '2024-02-01' # This API version or later is required
161-
162-
training_file_name = 'training_set.jsonl'
163-
validation_file_name = 'validation_set.jsonl'
164-
165-
# Upload the training and validation dataset files to Azure OpenAI with the SDK.
166-
167-
training_response = openai.File.create(
168-
file=open(training_file_name, "rb"), purpose="fine-tune", user_provided_filename="training_set.jsonl"
169-
)
170-
training_file_id = training_response["id"]
171-
172-
validation_response = openai.File.create(
173-
file=open(validation_file_name, "rb"), purpose="fine-tune", user_provided_filename="validation_set.jsonl"
174-
)
175-
validation_file_id = validation_response["id"]
176-
177-
print("Training file ID:", training_file_id)
178-
print("Validation file ID:", validation_file_id)
179-
```
180-
181-
---
182-
183145
## Create a customized model
184146

185147
After you upload your training and validation files, you're ready to start the fine-tuning job.
@@ -205,7 +167,6 @@ print("Job ID:", response.id)
205167
print("Status:", response.id)
206168
print(response.model_dump_json(indent=2))
207169
```
208-
---
209170

210171
You can also pass additional optional parameters like hyperparameters to take greater control of the fine-tuning process. For initial training we recommend using the automatic defaults that are present without specifying these parameters.
211172

@@ -226,7 +187,7 @@ from openai import AzureOpenAI
226187
client = AzureOpenAI(
227188
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
228189
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
229-
api_version="2024-02-01" # This API version or later is required
190+
api_version="2024-10-21" # This API version or later is required
230191
)
231192

232193
client.fine_tuning.jobs.create(
@@ -265,7 +226,7 @@ When each training epoch completes a checkpoint is generated. A checkpoint is a
265226
You can run the list checkpoints command to retrieve the list of checkpoints associated with an individual fine-tuning job. You might need to upgrade your OpenAI client library to the latest version with `pip install openai --upgrade` to run this command.
266227

267228
```python
268-
response = client.fine_tuning.jobs.list_events(fine_tuning_job_id=job_id, limit=10)
229+
response = client.fine_tuning.jobs.checkpoints.list(job_id)
269230
print(response.model_dump_json(indent=2))
270231
```
271232

@@ -336,7 +297,7 @@ resource_group = "<YOUR_RESOURCE_GROUP_NAME>"
336297
resource_name = "<YOUR_AZURE_OPENAI_RESOURCE_NAME>"
337298
model_deployment_name ="gpt-35-turbo-ft" # custom deployment name that you will use to reference the model when making inference calls.
338299

339-
deploy_params = {'api-version': "2024-10-21"}
300+
deploy_params = {'api-version': "2024-10-01"} # control plane API version rather than dataplane API for this call
340301
deploy_headers = {'Authorization': 'Bearer {}'.format(token), 'Content-Type': 'application/json'}
341302

342303
deploy_data = {
@@ -378,7 +339,7 @@ from openai import AzureOpenAI
378339
client = AzureOpenAI(
379340
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
380341
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
381-
api_version="2024-02-01"
342+
api_version="2024-10-21"
382343
)
383344

384345
response = client.fine_tuning.jobs.create(

0 commit comments

Comments
 (0)