AI-300 · LESSON 5
Optimize generative AI systems and model performance10–15% · 2 topics
Learn optimizing RAG retrieval performance and accuracy, and model customization such as fine-tuning.
5.1Optimize retrieval-augmented generation (RAG) performance and accuracy
Concept
RAG answer quality depends on whether retrieval surfaces the right information. In Azure AI Search, accuracy improves with hybrid search combining keywords (BM25) and vectors, reranking with the semantic ranker, appropriate chunking and query rewriting.
How it works / steps
- Split documents into chunks by units of meaning, with overlap
- Create vectors with an embedding model and use hybrid vector-and-keyword search
- Rerank top results with the semantic ranker
- Tune top-k and relevance thresholds to reduce irrelevant chunks
- Measure retrieval evaluation (retrieval precision, recall) and answer evaluation (groundedness) separately
Workplace example
A problem where searching by product model number misses is solved by hybrid search also catching exact keyword matches, and the semantic ranker then reorders the top results.
Common confusions and exam tips
- Model numbers and proper nouns are easily missed by vector search alone; hybrid helps
- Chunks that are too large mix in irrelevant information; too small loses context
- Separate whether wrong answers are a retrieval problem or a generation problem
Mini quiz
Q1. In RAG, weakly related documents are mixed into the grounding for answers. Which retrieval-side items should be tuned?
- Maximum answer tokens
- Similarity threshold and number of results
- Tone of the system message
- Generation model temperature
Show answer and explanation
Answer: B Similarity threshold and number of results
Raising the threshold or reducing the number of results makes it easier to exclude weakly related documents. [Other options] Temperature, maximum tokens and tone are generation-side settings and do not change which documents retrieval returns.
Q2. In RAG over long policy documents, answers lack the surrounding context they need. What should be tuned?
- Chunk size (and overlap)
- Only the number of results (top-k)
- The generation model’s temperature value
- The embedding model’s number of dimensions
Show answer and explanation
Answer: A Chunk size (and overlap)
Chunks that are too small split context. Tune size and overlap while evaluating. [Other options] Retrieving more results does not restore context cut by splitting. Dimensions and temperature do not fix missing context.
Reference links
5.2Implement advanced fine-tuning and model customization
Concept
Fine-tuning further trains a model on your data to adapt it to format, style or specialized tasks. Foundry supports supervised fine-tuning (SFT), DPO (direct preference optimization) learning from preference pairs, reinforcement fine-tuning (RFT) for reasoning models and more. Distillation, training a small model on a large model’s outputs, is also effective for reducing cost.
How it works / steps
- First check whether prompts and RAG can meet the requirements
- Prepare training data as JSONL (conversation format) and split it into training and validation
- Choose the method (SFT, DPO, RFT) and base model suited to the goal
- Compare the trained model with the original on evaluation data
- Deploy the fine-tuned model, also considering hosting charges
Workplace example
To summarize insurance assessment memos in a fixed format, SFT is run on 500 inputs with ideal summaries, greatly reducing format breakage compared with prompting alone.
Common confusions and exam tips
- For adding the latest facts or frequently changing information, RAG suits better than fine-tuning
- DPO requires “pairs of good and bad answers”
- Fine-tuned models incur hosting charges while deployed
Mini quiz
Q1. In which case is fine-tuning more suitable than RAG?
- When you want to narrow answers according to each user’s access rights
- When you want to stabilize output format, tone or behavior on a specific task
- When you want to show users citations of the documents that grounded the answer
- When you want answers to correctly reflect internal information updated daily
Show answer and explanation
Answer: B When you want to stabilize output format, tone or behavior on a specific task
RAG suits reflecting the latest knowledge; fine-tuning suits adjusting behavior. [Other options] Reflecting the latest information, showing citations and narrowing by permissions suit RAG and are hard to achieve with fine-tuning.
Q2. Which is an appropriate flow for putting a fine-tuned model into production?
- Deploy to production as soon as training ends and evaluate based on production usage
- Publish the old and new models on separate endpoints and let users choose
- Confirm the training loss dropped, replace the old model and switch everything at once
- Confirm it meets criteria in evaluation, version it and roll it out gradually
Show answer and explanation
Answer: D Confirm it meets criteria in evaluation, version it and roll it out gradually
Manage fine-tuned models from development to production the same as other models: evaluation, versioning and gradual rollout. [Other options] Training loss alone cannot judge business quality. Deploying before evaluation is risky. Letting users choose is not a gradual rollout.
Reference links
Lessons are written by this site based on public information and do not guarantee exam content. Product specifications change, so check the latest information at the reference links.
Notes (unofficial, original questions, no pass guarantee)
- The questions on this site are original practice questions written by this site based on publicly available skills outlines and exam guides. They are not actual exam questions.
- Microsoft, Azure, Copilot, Microsoft 365, Dynamics 365 and Power Platform are trademarks of the Microsoft group of companies. This site is not affiliated with or endorsed by Microsoft.
- This content is a study aid and does not guarantee a pass. Exam content, format and prerequisites may change without notice; always check the latest information on the official page before taking the exam.
- Your accuracy on the mock exam cannot be converted to the official (scaled) score and does not predict a pass or fail.
- Progress is saved only in this browser (localStorage) unless you sign in with Google to sync it. You can delete it from the Cookie & storage settings page (Japanese).