# azure/llm-fine-tuning-azure architecture

> Architecture diagram of the GitHub repository azure/llm-fine-tuning-azure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure/llm-fine-tuning-azure
- Repository: https://github.com/azure/llm-fine-tuning-azure

## Overview

##### Project type and purpose
- This is a documentation & sample‐code repository (labs) for demonstrating LLM fine-tuning patterns on Azure.
- It provides three “lab tracks”:
- No-Code via Azure AI Foundry dashboard
- Low-Code via Azure Python SDK & Azure ML
- Pro-Code via open-source frameworks (Unsloth AI, Hugging Face TRL)

##### File structure
- Top‐level files: .md policies, README.md (overview + learning path).
- labs/fine_tuning_dashboards: markdown demos of UI driven workflows.
- labs/fine_tuning_notebooks: Jupyter notebooks grouped by model family (gpt_fine_tuning, llama2, llama3, phi) plus supporting data/config files.

##### Extract architectural insights from the README
- Three pillars of fine-tuning:
- Azure AI Foundry Dashboard
- Azure Python SDK / Azure ML workspace
- Open-source SDKs (Unsloth, HF TRL)
- Common flow: user supplies training & validation data → triggers fine-tune job → monitors progress → obtains custom model.

##### Main components
a. Users & roles
- Data Scientists / ML Engineers
b. Code & content repo
- GitHub (this repo: notebooks, dashboards, markdown)
c. No-Code path
- Azure AI Foundry UI
- Azure backend services (compute, data store, fine-tune API)
d. Low-Code path
- Azure Machine Learning workspace
- Python SDK in notebooks
- Compute resources (Compute Instances/Clusters)
- Data storage (Blob Storage for JSONL datasets)
- Model Registry / endpoints
e. Pro-Code path
- Local or cloud notebooks running Unsloth AI / Hugging Face TRL
- Containerized training environments
- Artifact store (e.g., HF Hub or local file system)
f. External services
- OpenAI APIs (for GPT-3.5, GPT-4 variants)
- Hugging Face model hub
- Azure subscription resources

##### Relationships & data flows
- User → GitHub repo (clone labs)
- For No-Code:
User → Azure AI Foundry UI → submit fine-tune job → underlying compute & storage → retrieve fine-tuned model
- For Low-Code:
Notebook → Azure ML Python SDK → Workspace → compute cluster + blob storage → run fine-tuning job → register model → deploy endpoint
- For Pro-Code:
Notebook → Unsloth/TRL SDK → local or cloud GPU environment → training data → fine-tune → save artifacts locally or push to HF hub

##### Architectural patterns & principles
- Layered separation:
- Presentation/UI layer (dashboard, notebooks)
- Orchestration layer (Azure services, SDK)
- Compute layer (clusters, containers)
- Data layer (blob storage, model registry)
- Modular “lab” modules—each notebook is a self-contained pipeline
- Reusable components: shared data & config (azure.env, JSONL files)

##### Technologies & frameworks to annotate
- Azure AI Foundry
- Azure Machine Learning SDK (azure-ml)
- Azure Blob Storage
- Compute Instances / Clusters (AML Compute)
- Jupyter Notebooks
- Unsloth AI Python SDK
- Hugging Face TRL
- OpenAI APIs

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    User["Data Scientists/ML Engineers"]:::external

    %% Repository
    Repo["Code & Content Repository (GitHub)"]:::external
    User -->|clone labs| Repo

    %% No-Code Path
    subgraph "No-Code Path" 
        NC_UI["Azure AI Foundry UI"]:::frontend
        NC_Service["Azure Backend Services\n(compute, storage, fine-tune API)"]:::orchestration
        NC_Compute["AML Compute & Storage"]:::compute
    end
    User -->|use dashboard| NC_UI
    NC_UI -->|"REST API"| NC_Service
    NC_Service -->|"provision compute/storage"| NC_Compute
    NC_Compute -->|"store model"| FineTuned

    %% Low-Code Path
    subgraph "Low-Code Path"
        LC_GPT["GPT Family Notebooks"]:::frontend
        LC_Llama2["Llama2 Notebooks"]:::frontend
        LC_SDK["Azure ML Python SDK"]:::orchestration
        LC_Workspace["Azure ML Workspace"]:::orchestration
        LC_Compute["AML Compute Cluster"]:::compute
        LC_Storage["Azure Blob Storage"]:::data
        LC_Registry["Model Registry / Endpoint"]:::data
    end
    User -->|open notebooks| LC_GPT
    User -->|open notebooks| LC_Llama2
    LC_GPT -->|"Python SDK call"| LC_SDK
    LC_Llama2 -->|"Python SDK call"| LC_SDK
    LC_SDK --> LC_Workspace
    LC_Workspace --> LC_Compute
    LC_Compute -->|"read/write JSONL"| LC_Storage
    LC_Workspace -->|"register model"| LC_Registry
    LC_Registry --> FineTuned

    %% Pro-Code Path
    subgraph "Pro-Code Path"
        PC_Llama3["Llama3 Unsloth AI Notebooks"]:::frontend
        PC_Phi["Phi Family HF TRL Notebooks"]:::frontend
        PC_SDK["Unsloth AI / HF TRL SDK"]:::orchestration
        PC_Compute["Containerized Training Env\n(local or cloud GPU)"]:::compute
        PC_Store["Artifact Store\n(local FS or HF Hub)"]:::data
    end
    User -->|run notebooks| PC_Llama3
    User -->|run notebooks| PC_Phi
    PC_Llama3 -->|"SDK call"| PC_SDK
    PC_Phi -->|"SDK call"| PC_SDK
    PC_SDK --> PC_Compute
    PC_Compute -->|"save artifacts"| PC_Store
    PC_Store --> FineTuned

    %% External Services
    ExternalOpenAI["OpenAI APIs"]:::external
    ExternalHF["Hugging Face Model Hub"]:::external
    PC_SDK -.->|"calls"| ExternalOpenAI
    PC_SDK -.->|"push/pull"| ExternalHF

    %% Central Output
    FineTuned["Fine-Tuned Model Output"]:::data

    %% Click Events
    click Repo "https://github.com/azure/llm-fine-tuning-azure/blob/main/README.md"
    click NC_UI "https://github.com/azure/llm-fine-tuning-azure/tree/main/labs/fine_tuning_dashboards/"
    click LC_GPT "https://github.com/azure/llm-fine-tuning-azure/tree/main/labs/fine_tuning_notebooks/gpt_fine_tuning/"
    click LC_Llama2 "https://github.com/azure/llm-fine-tuning-azure/tree/main/labs/fine_tuning_notebooks/llama2_fine_tuning/"
    click PC_Llama3 "https://github.com/azure/llm-fine-tuning-azure/tree/main/labs/fine_tuning_notebooks/llama3_fine_tuning/"
    click PC_Phi "https://github.com/azure/llm-fine-tuning-azure/tree/main/labs/fine_tuning_notebooks/phi_fine_tuning/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef orchestration fill:#E8D0FF,stroke:#6f42c1,color:#6f42c1
    classDef compute fill:#D0FFD6,stroke:#28a745,color:#28a745
    classDef data fill:#FFE8D0,stroke:#d15704,color:#d15704
    classDef external fill:#E8E8E8,stroke:#6c757d,color:#6c757d
```
