{"id":1944,"date":"2026-02-11T09:29:15","date_gmt":"2026-02-11T17:29:15","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/foundry\/?p=1944"},"modified":"2026-02-11T09:29:15","modified_gmt":"2026-02-11T17:29:15","slug":"beyond-the-prompt-why-and-how-to-fine-tune-your-own-models","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/foundry\/beyond-the-prompt-why-and-how-to-fine-tune-your-own-models\/","title":{"rendered":"Beyond the Prompt &#8211; Why and How to Fine-tune Your Own Models"},"content":{"rendered":"<p>Large Language Models (LLMs) have reached a point where general intelligence is no longer the bottleneck. The real challenge in enterprise AI systems behavioral alignment ensuring models that produce consistent, reliable, policy-compliant outputs on a scale. Prompt engineering and Retrieval-Augmented Generation (RAG) are powerful but they do not change model behavior. Fine-tuning will solve this by customizing a pretrained AI model with additional training on a specific task or dataset to improve performance, add new skills, or enhance accuracy.<\/p>\n<p>This post explores what <a href=\"https:\/\/ai.azure.com\/\">Microsoft Foundry<\/a> fine-tuning is, when using it, the fine-tuning approaches it supports<strong>\u00a0<\/strong>and code examples on how to run Fine-tuning on Microsoft Foundry.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-1945 size-large\" src=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1-e1769772384708-1024x652.webp\" alt=\"image 1 image\" width=\"1024\" height=\"652\" srcset=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1-e1769772384708-1024x652.webp 1024w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1-e1769772384708-300x191.webp 300w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1-e1769772384708-768x489.webp 768w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-1-e1769772384708.webp 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p><strong>What Is Microsoft Foundry Fine-Tuning:<\/strong><\/p>\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/ai-foundry\/concepts\/fine-tuning-overview?view=foundry-classic\">Microsoft Foundry fine-tuning<\/a> allows you to customize pre-trained foundation models (OpenAI and open models) using task-specific datasets, producing a specialized model that behaves predictably for your use case while maintaining Azure\u2019s enterprise-grade security, governance, and observability.<\/p>\n<p><strong>Key Benefits and top use cases of Fine-tuning:<\/strong><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-2.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-1966 size-full\" src=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-2.webp\" alt=\"image 2 image\" width=\"973\" height=\"586\" srcset=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-2.webp 973w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-2-300x181.webp 300w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-2-768x463.webp 768w\" sizes=\"(max-width: 973px) 100vw, 973px\" \/><\/a><\/p>\n<ul>\n<li><strong>Domain Specialization:<\/strong>\u00a0Adapt a language model for specialized domains like medicine, finance, or law to understand technical jargon and deliver more accurate, domain-specific responses.<\/li>\n<li><strong>Task Performance:<\/strong>\u00a0Optimize a model for tasks like sentiment analysis, code generation, translation, or summarization to achieve higher performance than a general-purpose model.<\/li>\n<li><strong>Style and Tone:<\/strong>\u00a0Fine-tune the model to match your preferred communication style, such as formal business, brand voice, or technical writing.<\/li>\n<li><strong>Instruction Following:<\/strong>\u00a0Enhance the model\u2019s ability to follow formatting rules, multi-step instructions, and structured outputs, including selecting the right agent in multi-agent workflows.<\/li>\n<li><strong>Compliance and Safety:<\/strong>\u00a0Train a fine-tuned model to adhere to organizational policies, regulatory requirements, or other guidelines unique to your application.<\/li>\n<li><strong>Language or Cultural Adaptation:<\/strong>\u00a0Tailor a language model to a specific language, dialect, or cultural context when general-purpose models fall short, without the cost of training from scratch.<\/li>\n<\/ul>\n<p><strong>Supported Finetuning Methods:\u00a0<\/strong><\/p>\n<ul>\n<li>Supervised Finetuning<\/li>\n<li>Direct Preference Optimization<\/li>\n<li>Reinforcement Finetuning<\/li>\n<\/ul>\n<p><strong>Supervised Fine-Tuning (SFT)<\/strong>\u00a0is foundational training technique that trains a pre-trained model on input-output pairs for a specific task. It helps the model give more accurate, consistent, and task-specific responses, such as summarizing text, answering questions, or generating code, while keeping the knowledge from the original base model.<\/p>\n<p><strong>Best use cases for SFT:<\/strong><\/p>\n<ol>\n<li>Text Classification &amp; Labeling<\/li>\n<li>Question Answering &amp; Knowledge Extraction<\/li>\n<li>Text Summarization<\/li>\n<li>Code Generation &amp; Analysis<\/li>\n<li>Structured Output &amp; Formatting<\/li>\n<li>Domain-Specific Language or Style Alignment<\/li>\n<li>Multi-Agent or Tool-Calling Workflows<\/li>\n<\/ol>\n<p><strong>How it works:\u00a0<\/strong>You provide the model with a fixed set of examples, and it learns to produce the desired output for a given input. It&#8217;s a &#8220;learn by example&#8221; approach.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-3.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-1967 size-full\" src=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-3.webp\" alt=\"image 3 image\" width=\"981\" height=\"627\" srcset=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-3.webp 981w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-3-300x192.webp 300w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/image-3-768x491.webp 768w\" sizes=\"(max-width: 981px) 100vw, 981px\" \/><\/a><\/p>\n<p><strong>Supervised Finetuning Code Snippet:\u00a0<\/strong>It is supported by Microsoft Foundry SDK and Foundry UI. This demonstrates the code snipped using Microsoft Foundry SDK:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"lia-code-sample styles_border__BAltG line-numbers language-python\" tabindex=\"0\"><code class=\"language-python\"><span class=\"token keyword\">import<\/span> os <span class=\"token keyword\">from<\/span> dotenv <span class=\"token keyword\">import<\/span> load_dotenv <span class=\"token keyword\">from<\/span> azure<span class=\"token punctuation\">.<\/span>identity <span class=\"token keyword\">import<\/span> DefaultAzureCredential <span class=\"token keyword\">from<\/span> azure<span class=\"token punctuation\">.<\/span>ai<span class=\"token punctuation\">.<\/span>projects <span class=\"token keyword\">import<\/span> AIProjectClient load_dotenv<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> endpoint <span class=\"token operator\">=<\/span> os<span class=\"token punctuation\">.<\/span>environ<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">\"AZURE_AI_PROJECT_ENDPOINT\"<\/span><span class=\"token punctuation\">)<\/span> model_name <span class=\"token operator\">=<\/span> os<span class=\"token punctuation\">.<\/span>environ<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">\"MODEL_NAME\"<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\"># Define dataset file paths training_file_path = \"training.jsonl\" validation_file_path = \"validation.jsonl\" credential = DefaultAzureCredential() project_client = AIProjectClient(endpoint=endpoint, credential=credential) openai_client = project_client.get_openai_client() with open(validation_file_path, \"rb\") as f: validation_file = openai_client.files.create(file=f, purpose=\"fine-tune\") openai_client.files.wait_for_processing(validation_file.id) with open(training_file_path, \"rb\") as f: train_file = openai_client.files.create(file=f, purpose=\"fine-tune\") openai_client.files.wait_for_processing(train_file.id) fine_tune_job = openai_client.fine_tuning.jobs.create( model=model_name, training_file=train_file.id, validation_file=validation_file.id, method={ \"type\": \"supervised\", \"supervised\": {\"hyperparameters\": {\"n_epochs\": 3, \"batch_size\": 1, \"learning_rate_multiplier\": 1.0}}, }, suffix=\"pubmed-summarization\" )<\/span><\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Data Format Example:<\/strong>\u00a0The training data sample should contain min. of 10 lines<\/p>\n<pre class=\"lia-code-sample styles_border__BAltG line-numbers language-json\" tabindex=\"0\"><code class=\"language-json\"><span class=\"token punctuation\">{<\/span> <span class=\"token property\">\"messages\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token property\">\"role\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"system\"<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token property\">\"content\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"You are a medical research summarization assistant. Create concise, accurate abstracts of medical research articles that capture the key findings and methodology.\"<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token property\">\"role\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"user\"<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token property\">\"content\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"Summarize this medical research article:\\n\\n[full article text]\"<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token property\">\"role\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"assistant\"<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token property\">\"content\"<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">\"[generated abstract]\"<\/span> <span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">}<\/span><\/code><\/pre>\n<p><strong>Cookbooks:\u00a0<\/strong>SFT with PubMed Medical Research Summarization Dataset<\/p>\n<p>This cookbook <a href=\"https:\/\/github.com\/microsoft-foundry\/fine-tuning\/tree\/main\/Demos\/SFT_PubMed_Summarization\">fine-tuning\/Demos\/SFT_PubMed_Summarization at main \u00b7 microsoft-foundry\/fine-tuning<\/a> demonstrates how to fine-tune language models using\u00a0Supervised Fine-Tuning (SFT)\u00a0with the PubMed Medical Research Summarization dataset on Azure AI.<\/p>\n<p>After executing the cookbook, one can navigate to Foundry Portal to monitor the job details.<\/p>\n<div class=\"styles_lia-table-wrapper__h6Xo9 styles_table-responsive__MW0lN\">\n<p><strong>Fine-tuning job view in Microsoft Foundry:\u00a0<\/strong><\/p>\n<p>Navigate to Microsoft Foundry at https:\/\/ai.azure.com then the fine-tuning section to view the job details and execution progress<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-1968 size-full\" src=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss.webp\" alt=\"Training Loss image\" width=\"1306\" height=\"580\" srcset=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss.webp 1306w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss-300x133.webp 300w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss-1024x455.webp 1024w, https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2026\/01\/Training-Loss-768x341.webp 768w\" sizes=\"(max-width: 1306px) 100vw, 1306px\" \/><\/a><\/p>\n<\/div>\n<p><strong>Key highlights:<\/strong><\/p>\n<ol>\n<li>This cookbook uses GPT4.1 as the base model and\u00a0<a href=\"https:\/\/www.kaggle.com\/datasets\/thedevastator\/pubmed-article-summarization-dataset\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">PubMed Article Summarization Dataset on Kaggle<\/a>\u00a0as the reference training data set.<\/li>\n<li><strong>Prerequisites:\u00a0<\/strong>Ensure you have Azure subscription with Microsoft Foundry project; you must have Azure AI User role, have access to the required models and set up an AI Foundry project<\/li>\n<li><strong>Dataset Preparation:<\/strong>\u00a0Finetuning expects the datasets in JSONL formats, the JSONL can be found here: Use the training.jsonl and validation.jsonl available in this Cookbook sample<\/li>\n<li><strong>Finetune Job:<\/strong>\u00a0Configure with default hyper parameters and run the finetune job<\/li>\n<li><strong>Deployment:<\/strong>\u00a0Optionally, deploy the finetuned model to a serverless endpoint and perform sample inferences.<\/li>\n<\/ol>\n<p><strong>Results of Finetuning<\/strong><\/p>\n<div class=\"styles_lia-table-wrapper__h6Xo9 styles_table-responsive__MW0lN\">\n<table border=\"1\">\n<thead>\n<tr>\n<th>Metric<\/th>\n<th>Base Model<\/th>\n<th>Fine-Tuned Model<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Task Accuracy<\/td>\n<td>70\u201380%<\/td>\n<td>88\u201395%<\/td>\n<\/tr>\n<tr>\n<td>Prompt Length<\/td>\n<td>800\u20131200 tokens<\/td>\n<td>200\u2013400 tokens<\/td>\n<\/tr>\n<tr>\n<td>Inference Cost<\/td>\n<td>Baseline (1.0x)<\/td>\n<td>0.5\u20130.7x<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Large Language Models (LLMs) have reached a point where general intelligence is no longer the bottleneck. The real challenge in enterprise AI systems behavioral alignment ensuring models that produce consistent, reliable, policy-compliant outputs on a scale. Prompt engineering and Retrieval-Augmented Generation (RAG) are powerful but they do not change model behavior. Fine-tuning will solve this [&hellip;]<\/p>\n","protected":false},"author":206592,"featured_media":1563,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1944","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-foundry"],"acf":[],"blog_post_summary":"<p>Large Language Models (LLMs) have reached a point where general intelligence is no longer the bottleneck. The real challenge in enterprise AI systems behavioral alignment ensuring models that produce consistent, reliable, policy-compliant outputs on a scale. Prompt engineering and Retrieval-Augmented Generation (RAG) are powerful but they do not change model behavior. Fine-tuning will solve this [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts\/1944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/users\/206592"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/comments?post=1944"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts\/1944\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/media\/1563"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/media?parent=1944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/categories?post=1944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/tags?post=1944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}