How winterblossom0/llm-mini-project works
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 Data prep · 08_geometric_audit.ipynb Geometry audit · 02_SAE_Training_SmolLM.ipynb SmolLM SAE · 03_SAE_Training_Qwen.ipynb Qwen SAE
Components 17
Data & eval
Dataset preparation and fixed evaluation question sets.
Representation learning
SAE/probe training and baseline concept extraction for each model family.
- SmolLM SAE · Trains the SmolLM representation/probe layer used for later concept extraction.
02_SAE_Training_SmolLM.ipynb - Qwen SAE · Trains the Qwen representation/probe layer used for later concept extraction.
03_SAE_Training_Qwen.ipynb - SmolLM baseline · Extracts pre-fine-tune concept vectors for SmolLM.
04_Baseline_Extract_SmolLM.ipynb - Qwen baseline · 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 · Domain adaptation branch for medical fine-tuning.
06a_SmolLM_Medical_FineTune.ipynb - SmolLM code · Domain adaptation branch for code fine-tuning.
06b_SmolLM_Code_FineTune.ipynb - SmolLM finance · Domain adaptation branch for finance fine-tuning.
06c_SmolLM_Finance_FineTune.ipynb - Qwen medical · Domain adaptation branch for medical fine-tuning.
07a_Qwen_Medical_FineTune.ipynb - Qwen code · Domain adaptation branch for code fine-tuning.
07b_Qwen_Code_FineTune.ipynb - Qwen finance · 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 concept vectors organized by model, domain, concept, and layer after fine-tuning.
- Geometry audit · Computes rotation, cosine drift, and concept conflation across baseline and fine-tuned models.
08_geometric_audit.ipynb - Audit metrics · Machine-readable metric outputs from the geometric audit.
- Audit reports · Human-readable comparison summaries and narrative findings.
- Answer samples · Before/after sample responses from fixed prompts for qualitative comparison.
Connections 23
- 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.