← Back to Dashboard
Lab: Fine-Tuning

Phi Silica LoRA Fine-Tuning

Train a LoRA adapter in VS Code using the AI Toolkit and improve Phi Silica for your use case.

Objective

Use Low Rank Adaptation (LoRA) to fine-tune the Phi Silica model and improve accuracy for a specific task. You will generate a dataset, run a cloud fine-tuning job, and download the adapter for inference.


Prerequisites

Note: Phi Silica features are not available in China. Inference with a LoRA adapter is currently supported on Copilot+ PCs with ARM processors.

Step 1: Prepare Your Dataset

Create two JSONL files (one JSON object per line):

Each line must be a JSON object with a messages array. Every message needs:

{"messages": [{"content": "Hello, how do I reset my password?", "role": "user"}, {"content": "To reset your password, go to settings and click 'Reset Password'.", "role": "assistant"}]}
{"messages": [{"content": "Can you help me find nearby restaurants?", "role": "user"}, {"content": "Sure! Here are restaurants near you...", "role": "assistant"}]}
{"messages": [{"content": "What is the weather today?", "role": "user"}, {"content": "Sunny with a high of 25°C.", "role": "assistant"}]}
Tips: No trailing commas per line. Use diverse, high-quality examples. Aim for thousands of training samples. Test data can be smaller, but should reflect real use cases.

Step 2: Start a LoRA Project in VS Code

1Open AI Toolkit

In VS Code, open AI ToolkitModel ToolsFine-tuning, then select New Project.

2Select the Model

Choose microsoft/phi-silica from the Model Catalog and click Next.

3Name the Project

Pick a project folder and a project name. A new VS Code window will open for the project.

4Select Method

Choose LoRA from the Method list.

5Upload Datasets

Under Data, select your train.json and test.json files.

6Run with Cloud

Click Run with Cloud, select your Microsoft account, choose a subscription, then pick a resource group.


Step 3: Monitor, Download, Evaluate


Hyperparameter Guidance (Optional)

Default settings are a good baseline. If you need tuning, explore small sweeps:

Parameter Suggested Range Why it matters
learning_rate 1e-4 → 1e-2 Too high = unstable, too low = slow learning
lora_dropout 0 → 0.5 Helps reduce overfitting
weight_decay 1e-5 → 1e-1 Regularizes training
train/test samples More = better Improves generalization and metrics stability

If a parameter is missing in the UI, edit <project>/microsoft/phi-silica/lora/lora.yaml manually.


Choosing a System Prompt

Keep it short (1–2 sentences). If you need structured output (JSON, tables), use a two-sentence prompt: the first sentence describes the response in plain language, the second enforces the format.