Azure-AI_Foundry

Knowledge Check: Fine-Tuning Azure OpenAI Models

Test your understanding with these 15 scenario-based questions.


Question 1: Decision Framework

Your team’s chatbot needs to answer questions about company HR policies that change quarterly. The current system prompt with a few examples works reasonably well but sometimes misses nuances in the policy documents. What should you try first?

Answer **B) Implement RAG to retrieve current policy documents at query time.** Since the policies change quarterly, fine-tuning would require retraining every quarter and the model could hallucinate outdated policies. RAG retrieves the current documents at query time, ensuring up-to-date answers. The decision framework says: prompt engineering -> RAG -> fine-tune. The prompt already works reasonably well, and the issue is access to changing knowledge -- which is RAG's strength.

Question 2: JSONL Format

Which of the following is a valid fine-tuning JSONL line?

Answer **B) `{"messages": [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi!"}]}`** Azure OpenAI chat fine-tuning requires the `messages` array format with at least one user and one assistant message. Option A uses the legacy completions format. Option C is a bare array without the `messages` key. Option D has no assistant message, which is required for the model to learn from.

Question 3: Overfitting

During your fine-tuning job, you observe that training loss drops to 0.01 while validation loss starts at 0.8, drops to 0.3, then rises back to 0.6. What is happening?

Answer **B) The model is overfitting -- it memorized training data.** The classic sign of overfitting is validation loss initially decreasing (the model is learning generalizable patterns) then increasing (the model starts memorizing training-specific patterns). The very low training loss (0.01) confirms the model fits the training data almost perfectly. Mitigation: reduce epochs, increase dataset size, or lower the learning rate multiplier.

Question 4: Hyperparameters

You have a dataset of 75 examples. When you set all hyperparameters to auto, Azure OpenAI will most likely select which n_epochs value?

Answer **C) 10-15 epochs.** For small datasets (100 or fewer examples), `auto` typically selects a higher epoch count (around 10-15) so the model sees each example multiple times. Larger datasets (1000+) use fewer epochs (2-3) since there is more diverse data to learn from. This is a heuristic -- always monitor validation loss to confirm the epoch count is appropriate.

Question 5: Cost Components

A fine-tuning training run costs $5.00. After training, you deploy the model and use it for 8 hours before deleting the deployment. If hosting costs $1.70/hour, what is the total cost (excluding inference)?

Answer **C) $18.60** Total = Training cost + Hosting cost = $5.00 + (8 hours x $1.70/hr) = $5.00 + $13.60 = $18.60. Fine-tuning has three cost components: training (one-time), hosting (per hour while deployed), and inference (per token when used). Even if you make zero inference calls, you pay for the hours the deployment is active.

Question 6: Data Quality

You are preparing 200 training examples. During validation, you discover 15 examples have empty assistant responses and 8 are exact duplicates. What should you do?

Answer **C) Remove the 15 empty responses and 8 duplicates; add replacements if possible.** Empty assistant responses teach the model to output nothing -- always remove them. Duplicates waste training budget and can bias the model toward those specific examples. After removing the 23 problematic examples, you still have 177 -- well above the 50+ recommended. If you can replace them with new quality examples, even better.

Question 7: Distillation

Your company uses gpt-4o for contract summarization and spends $3,000/month on inference. You want to reduce costs. Which approach is most appropriate?

Answer **B) Generate training data with gpt-4o, then fine-tune gpt-4o-mini on those responses.** This is model distillation. By using gpt-4o (teacher) to generate high-quality responses, then fine-tuning gpt-4o-mini (student) on them, you typically retain 90-95% of the quality at a fraction of the inference cost. Option A might work but quality often drops on specialized tasks. Option C does not reduce costs. Option D helps but will not achieve the same cost reduction as using a smaller model.

Question 8: Continuous Fine-Tuning

You have a fine-tuned model in production. New training data arrives monthly. When performing continuous fine-tuning, which practice helps prevent catastrophic forgetting?

Answer **C) Use a lower learning rate multiplier and mix ~20% old data with new data.** Catastrophic forgetting occurs when new training overwrites previously learned patterns. A lower learning rate makes smaller weight updates, and mixing in old examples reinforces previous learning. Options A and B would accelerate forgetting. Option D works but is expensive and wasteful -- you lose the benefit of incremental improvement.

Question 9: Vision Fine-Tuning

Which format correctly represents a user message with an image in a vision fine-tuning example?

Answer **B) `{"role": "user", "content": [{"type": "text", "text": "Describe this image."}, {"type": "image_url", "image_url": {"url": "https://example.com/img.jpg"}}]}`** Vision fine-tuning uses the same multi-part content format as the chat completions API. The `content` field becomes an array of content parts, each with a `type` field (`text` or `image_url`). The other options use incorrect formats that the API will not accept.

Question 10: Validation Split

Why should you provide a separate validation file when creating a fine-tuning job?

Answer **C) It enables monitoring of validation loss to detect overfitting during training.** The validation file is optional but highly recommended. It provides a held-out dataset that the model is evaluated against (but not trained on) at each step. If validation loss starts increasing while training loss continues to decrease, you know the model is overfitting. Without it, you can only see training loss, which always decreases and can be misleading.

Question 11: When to Fine-Tune

A startup wants their model to always respond in a specific JSON schema with exactly 5 fields, using domain-specific medical terminology. Prompt engineering achieves 70% format compliance. What should they try?

Answer **B) Fine-tune on 100+ examples of the desired JSON output format.** This is a textbook fine-tuning use case: consistent output format + domain terminology. The model needs to learn the exact schema and medical jargon, which is hard to achieve with prompt engineering alone (70% is not reliable enough for production). Fine-tuning excels at teaching format compliance and domain vocabulary. Consider also using structured output / response_format for format guarantees, but fine-tuning will still help with the medical terminology.

Question 12: Token Counting

Your dataset has 500 examples averaging 400 tokens each. You are fine-tuning gpt-4o-mini at $0.008/1K training tokens with 3 epochs. What is the approximate training cost?

Answer **C) $4.80** Total training tokens = 500 examples x 400 tokens x 3 epochs = 600,000 tokens. Cost = (600,000 / 1,000) x $0.008 = 600 x $0.008 = $4.80. Remember: you pay for every token processed across all epochs, so more epochs = higher training cost.

Question 13: Weights & Biases

What does the Weights & Biases integration provide for Azure OpenAI fine-tuning?

Answer **B) Training and validation loss visualization, experiment comparison, and metadata tracking.** W&B integration pushes training metrics (loss curves, learning rate, step counts) to your W&B dashboard. This lets you visualize training progress, compare different fine-tuning runs, and track experiment metadata. It does not optimize hyperparameters automatically, provide compute, or deploy models -- those are separate concerns.

Question 14: Model Selection

You need to fine-tune a model for a high-volume, cost-sensitive customer support chatbot. Quality needs to be good but not state-of-the-art. Latency must be low. Which model is the best starting point?

Answer **B) gpt-4o-mini (2024-07-18)** For cost-sensitive, high-volume workloads where quality needs to be good (not best-in-class), gpt-4o-mini is the sweet spot. It has lower training and inference costs than gpt-4o/gpt-4.1, faster inference (lower latency), and the 128k context window handles most support scenarios. gpt-3.5-turbo is cheaper but less capable; gpt-4o and gpt-4.1 are more expensive than needed for this use case.

Question 15: Job Management

Your fine-tuning job has been running for 2 hours and you realize you uploaded the wrong training file. What should you do?

Answer **B) Cancel the job immediately, fix the data, and create a new job.** Use `client.fine_tuning.jobs.cancel(job_id)` to stop the running job. This saves compute costs -- you pay per token processed, so stopping early reduces the bill. Option A wastes compute. Option C is not possible -- you cannot modify a running job. Option D wastes compute on the wrong job and you would have two jobs consuming resources. ```python client.fine_tuning.jobs.cancel("ftjob-abc123") ```

Scoring Guide

Score Rating Recommendation
13-15 Excellent Ready to fine-tune production models
10-12 Good Review the lessons you missed
7-9 Fair Re-read Lessons 1-3 before proceeding
0-6 Needs review Start from the Module Overview

<- Back to Module Overview