# winterblossom0/llm-mini-project architecture

> Architecture diagram of the GitHub repository winterblossom0/llm-mini-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/winterblossom0/llm-mini-project
- Repository: https://github.com/winterblossom0/llm-mini-project

## Overview

1. **Repository shape**
   - This is a notebook-driven research repo, not an application server or library.
   - The main “pipeline” is encoded in ordered notebooks from `01_...` through `08_...`, with each notebook producing artifacts consumed by the next stage.

2. **Primary goal**
   - The project measures how domain fine-tuning changes internal concept geometry in small language models.
   - It focuses on two model families: `smollm3` and `qwen25`, and three fine-tune domains: medical, code, and finance.

3. **Input data layer**
   - `01_Data_Preparation.ipynb` builds and validates the training and evaluation datasets.
   - The `eval_set/` directory holds the concept-question sets and summary manifests used for downstream auditing:
     politics, violence, nsfw, misinformation, plus a general evaluation set.

4. **Representation/probe setup**
   - `02_SAE_Training_SmolLM.ipynb` and `03_SAE_Training_Qwen.ipynb` train the SAE/probe infrastructure for each model family.
   - This layer creates the feature space used to extract and compare concept vectors later in the pipeline.

5. **Baseline concept extraction**
   - `04_Baseline_Extract_SmolLM.ipynb` and `05_Baseline_Extract_Qwen.ipynb` extract pre-fine-tune concept vectors.
   - These baselines establish the reference geometry for each model, concept axis, and relevant layer.

6. **Fine-tuning branch**
   - `06a/06b/06c_*` notebooks fine-tune SmolLM on medical, code, and finance.
   - `07a/07b/07c_*` do the same for Qwen.
   - The fine-tuning outputs are adapter/checkpoint artifacts stored in the `finetuned_models_*` outputs referenced by the README.

7. **Audit input/output boundary**
   - The audit stage compares pre- and post-fine-tune artifacts rather than raw generations alone.
   - Saved concept vectors are organized by model, domain, concept, and layer, then consumed by the final audit notebook.

8. **Geometry audit subsystem**
   - `08_geometric_audit.ipynb` computes the core metrics: rotation, cosine drift, and concept conflation.
   - This notebook also produces the machine-readable metrics and human-readable summaries that the README describes as `audit_results/` and `audit_reports/`.

9. **Qualitative evaluation path**
   - The repo also generates before/after answer samples from a fixed prompt set.
   - This provides a surface-level check alongside the internal-geometry metrics, using the same evaluation prompts for consistency.

10. **Key data flow**
   - The pipeline flows from prepared datasets → SAE/probe training → baseline concept vectors → domain adapters/checkpoints → post-fine-tune concept vectors → geometric audit reports.
   - The important architectural boundary is between model adaptation and measurement: fine-tuning changes the model, while the audit notebooks quantify how those changes affect concept separation.

11. **Artifact-centric design**
   - The repo’s outputs are first-class: concept vectors, audit metrics, and comparison reports are the durable products of the workflow.
   - Because the notebooks are run in order and the outputs are run-dependent, reproducibility depends on preserving the generated artifacts for each model/domain combination.

12. **What an architecture diagram should show**
   - A left-to-right flow with four major stages: data prep, representation learning, fine-tuning branches for two model families, and geometric audit.
   - A separate evaluation/input box for `eval_set/`, and output boxes for saved concept vectors, audit metrics, and human-readable reports.

Main entry points: [`01_Data_Preparation.ipynb`](https://github.com/winterblossom0/llm-mini-project/blob/main/01_Data_Preparation.ipynb) (Data prep), [`08_geometric_audit.ipynb`](https://github.com/winterblossom0/llm-mini-project/blob/main/08_geometric_audit.ipynb) (Geometry audit), [`02_SAE_Training_SmolLM.ipynb`](https://github.com/winterblossom0/llm-mini-project/blob/main/02_SAE_Training_SmolLM.ipynb) (SmolLM SAE), [`03_SAE_Training_Qwen.ipynb`](https://github.com/winterblossom0/llm-mini-project/blob/main/03_SAE_Training_Qwen.ipynb) (Qwen SAE)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data & eval"]
  node_data_prep["Data prep<br/>notebook"]
  node_eval_set[("Eval set<br/>question bank")]
end

subgraph group_representation["Representation learning"]
  node_sae_smollm["SmolLM SAE<br/>training notebook"]
  node_sae_qwen["Qwen SAE<br/>training notebook"]
  node_base_smollm["SmolLM baseline<br/>extraction notebook"]
  node_base_qwen["Qwen baseline<br/>extraction notebook"]
end

subgraph group_adaptation["Domain adaptation"]
  node_smollm_med["SmolLM medical<br/>fine-tune notebook"]
  node_smollm_code["SmolLM code<br/>fine-tune notebook"]
  node_smollm_finance["SmolLM finance<br/>fine-tune notebook"]
  node_qwen_med["Qwen medical<br/>fine-tune notebook"]
  node_qwen_code["Qwen code<br/>fine-tune notebook"]
  node_qwen_finance["Qwen finance<br/>fine-tune notebook"]
end

subgraph group_audit["Geometry audit"]
  node_post_vectors[("Post vectors<br/>saved artifacts")]
  node_audit_nb["Geometry audit<br/>analysis notebook"]
  node_audit_metrics["Audit metrics<br/>results artifact"]
  node_audit_reports["Audit reports<br/>report artifact"]
  node_qual_samples["Answer samples<br/>evaluation artifact"]
end

node_data_prep -->|"prepared data"| node_sae_smollm
node_data_prep -->|"prepared data"| node_sae_qwen
node_sae_smollm -->|"features"| node_base_smollm
node_sae_qwen -->|"features"| node_base_qwen
node_data_prep -->|"train data"| node_smollm_med
node_data_prep -->|"train data"| node_smollm_code
node_data_prep -->|"train data"| node_smollm_finance
node_data_prep -->|"train data"| node_qwen_med
node_data_prep -->|"train data"| node_qwen_code
node_data_prep -->|"train data"| node_qwen_finance
node_smollm_med -->|"concept vectors"| node_post_vectors
node_smollm_code -->|"concept vectors"| node_post_vectors
node_smollm_finance -->|"concept vectors"| node_post_vectors
node_qwen_med -->|"concept vectors"| node_post_vectors
node_qwen_code -->|"concept vectors"| node_post_vectors
node_qwen_finance -->|"concept vectors"| node_post_vectors
node_base_smollm -->|"baseline"| node_audit_nb
node_base_qwen -->|"baseline"| node_audit_nb
node_post_vectors -->|"post-tune"| node_audit_nb
node_eval_set -->|"audit prompts"| node_audit_nb
node_audit_nb -->|"metrics"| node_audit_metrics
node_audit_nb -->|"summary"| node_audit_reports
node_audit_nb -->|"samples"| node_qual_samples

click node_data_prep "https://github.com/winterblossom0/llm-mini-project/blob/main/01_Data_Preparation.ipynb"
click node_eval_set "https://github.com/winterblossom0/llm-mini-project/tree/main/eval_set"
click node_sae_smollm "https://github.com/winterblossom0/llm-mini-project/blob/main/02_SAE_Training_SmolLM.ipynb"
click node_sae_qwen "https://github.com/winterblossom0/llm-mini-project/blob/main/03_SAE_Training_Qwen.ipynb"
click node_base_smollm "https://github.com/winterblossom0/llm-mini-project/blob/main/04_Baseline_Extract_SmolLM.ipynb"
click node_base_qwen "https://github.com/winterblossom0/llm-mini-project/blob/main/05_Baseline_Extract_Qwen.ipynb"
click node_smollm_med "https://github.com/winterblossom0/llm-mini-project/blob/main/06a_SmolLM_Medical_FineTune.ipynb"
click node_smollm_code "https://github.com/winterblossom0/llm-mini-project/blob/main/06b_SmolLM_Code_FineTune.ipynb"
click node_smollm_finance "https://github.com/winterblossom0/llm-mini-project/blob/main/06c_SmolLM_Finance_FineTune.ipynb"
click node_qwen_med "https://github.com/winterblossom0/llm-mini-project/blob/main/07a_Qwen_Medical_FineTune.ipynb"
click node_qwen_code "https://github.com/winterblossom0/llm-mini-project/blob/main/07b_Qwen_Code_FineTune.ipynb"
click node_qwen_finance "https://github.com/winterblossom0/llm-mini-project/blob/main/07c_Qwen_Finance_FineTune.ipynb"
click node_audit_nb "https://github.com/winterblossom0/llm-mini-project/blob/main/08_geometric_audit.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_data_prep,node_eval_set toneBlue
class node_sae_smollm,node_sae_qwen,node_base_smollm,node_base_qwen toneAmber
class node_smollm_med,node_smollm_code,node_smollm_finance,node_qwen_med,node_qwen_code,node_qwen_finance toneMint
class node_post_vectors,node_audit_nb,node_audit_metrics,node_audit_reports,node_qual_samples toneRose
```

## Components

### Data & eval

Dataset preparation and fixed evaluation question sets.

- [Data prep](https://github.com/winterblossom0/llm-mini-project/blob/main/01_Data_Preparation.ipynb): notebook · Builds and validates training/evaluation datasets for the pipeline. · `01_Data_Preparation.ipynb`
- [Eval set](https://github.com/winterblossom0/llm-mini-project/tree/main/eval_set): question bank · Fixed concept-question sets and manifests for auditing and qualitative checks. · `eval_set`

### Representation learning

SAE/probe training and baseline concept extraction for each model family.

- [SmolLM SAE](https://github.com/winterblossom0/llm-mini-project/blob/main/02_SAE_Training_SmolLM.ipynb): training notebook · Trains the SmolLM representation/probe layer used for later concept extraction. · `02_SAE_Training_SmolLM.ipynb`
- [Qwen SAE](https://github.com/winterblossom0/llm-mini-project/blob/main/03_SAE_Training_Qwen.ipynb): training notebook · Trains the Qwen representation/probe layer used for later concept extraction. · `03_SAE_Training_Qwen.ipynb`
- [SmolLM baseline](https://github.com/winterblossom0/llm-mini-project/blob/main/04_Baseline_Extract_SmolLM.ipynb): extraction notebook · Extracts pre-fine-tune concept vectors for SmolLM. · `04_Baseline_Extract_SmolLM.ipynb`
- [Qwen baseline](https://github.com/winterblossom0/llm-mini-project/blob/main/05_Baseline_Extract_Qwen.ipynb): extraction notebook · Extracts pre-fine-tune concept vectors for Qwen. · `05_Baseline_Extract_Qwen.ipynb`

### Domain adaptation

Domain fine-tuning branches for SmolLM and Qwen across medical, code, and finance.

- [SmolLM medical](https://github.com/winterblossom0/llm-mini-project/blob/main/06a_SmolLM_Medical_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for medical fine-tuning. · `06a_SmolLM_Medical_FineTune.ipynb`
- [SmolLM code](https://github.com/winterblossom0/llm-mini-project/blob/main/06b_SmolLM_Code_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for code fine-tuning. · `06b_SmolLM_Code_FineTune.ipynb`
- [SmolLM finance](https://github.com/winterblossom0/llm-mini-project/blob/main/06c_SmolLM_Finance_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for finance fine-tuning. · `06c_SmolLM_Finance_FineTune.ipynb`
- [Qwen medical](https://github.com/winterblossom0/llm-mini-project/blob/main/07a_Qwen_Medical_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for medical fine-tuning. · `07a_Qwen_Medical_FineTune.ipynb`
- [Qwen code](https://github.com/winterblossom0/llm-mini-project/blob/main/07b_Qwen_Code_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for code fine-tuning. · `07b_Qwen_Code_FineTune.ipynb`
- [Qwen finance](https://github.com/winterblossom0/llm-mini-project/blob/main/07c_Qwen_Finance_FineTune.ipynb): fine-tune notebook · Domain adaptation branch for finance fine-tuning. · `07c_Qwen_Finance_FineTune.ipynb`

### Geometry audit

Post-training comparison of concept geometry and reporting outputs.

- **Post vectors**: saved artifacts · Saved concept vectors organized by model, domain, concept, and layer after fine-tuning.
- [Geometry audit](https://github.com/winterblossom0/llm-mini-project/blob/main/08_geometric_audit.ipynb): analysis notebook · Computes rotation, cosine drift, and concept conflation across baseline and fine-tuned models. · `08_geometric_audit.ipynb`
- **Audit metrics**: results artifact · Machine-readable metric outputs from the geometric audit.
- **Audit reports**: report artifact · Human-readable comparison summaries and narrative findings.
- **Answer samples**: evaluation artifact · Before/after sample responses from fixed prompts for qualitative comparison.

## Connections

- Data prep → SmolLM SAE: prepared data · Prepared datasets feed SmolLM representation training.
- Data prep → Qwen SAE: prepared data · Prepared datasets feed Qwen representation training.
- SmolLM SAE → SmolLM baseline: features · SmolLM SAE/probe features enable baseline concept extraction.
- Qwen SAE → Qwen baseline: features · Qwen SAE/probe features enable baseline concept extraction.
- Data prep → SmolLM medical: train data · Prepared data supports domain fine-tuning for SmolLM.
- Data prep → SmolLM code: train data · Prepared data supports domain fine-tuning for SmolLM.
- Data prep → SmolLM finance: train data · Prepared data supports domain fine-tuning for SmolLM.
- Data prep → Qwen medical: train data · Prepared data supports domain fine-tuning for Qwen.
- Data prep → Qwen code: train data · Prepared data supports domain fine-tuning for Qwen.
- Data prep → Qwen finance: train data · Prepared data supports domain fine-tuning for Qwen.
- SmolLM medical → Post vectors: concept vectors · Fine-tuned SmolLM artifacts are converted into post-tune concept vectors.
- SmolLM code → Post vectors: concept vectors · Fine-tuned SmolLM artifacts are converted into post-tune concept vectors.
- SmolLM finance → Post vectors: concept vectors · Fine-tuned SmolLM artifacts are converted into post-tune concept vectors.
- Qwen medical → Post vectors: concept vectors · Fine-tuned Qwen artifacts are converted into post-tune concept vectors.
- Qwen code → Post vectors: concept vectors · Fine-tuned Qwen artifacts are converted into post-tune concept vectors.
- Qwen finance → Post vectors: concept vectors · Fine-tuned Qwen artifacts are converted into post-tune concept vectors.
- SmolLM baseline → Geometry audit: baseline · Baseline geometry is compared against post-fine-tune vectors.
- Qwen baseline → Geometry audit: baseline · Baseline geometry is compared against post-fine-tune vectors.
- Post vectors → Geometry audit: post-tune · Post-fine-tune concept vectors are audited against the baseline.
- Eval set → Geometry audit: audit prompts · Fixed evaluation sets provide the shared comparison prompts.
- Geometry audit → Audit metrics: metrics · Geometric comparisons are exported as machine-readable metrics.
- Geometry audit → Audit reports: summary · Audit notebook generates human-readable summaries and reports.
- Geometry audit → Answer samples: samples · Audit workflow also emits before/after qualitative answer samples.
