# artidoro/qlora architecture

> Architecture diagram of the GitHub repository artidoro/qlora, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/artidoro/qlora
- Repository: https://github.com/artidoro/qlora

## Overview

This repository packages QLoRA research workflows: finetune quantized pretrained language models with adapters, optionally evaluate on MMLU, and assess generated answers using GPT-based comparisons. The central runtime entry point is `qlora.py`; its excerpt shows model/tokenizer setup and dataset preparation, while README describes the training and inference capabilities. Separate evaluation scripts generate baseline answers and collect GPT reviewer scores. Source excerpts are partial, so some internal training transitions and demo wiring are not represented.

Main entry points: [`qlora.py`](https://github.com/artidoro/qlora/blob/main/qlora.py) (QLoRA runner), [`eval/eval_gpt_review.py`](https://github.com/artidoro/qlora/blob/main/eval/eval_gpt_review.py) (GPT answer reviewer), [`eval/qa_baseline_gpt.py`](https://github.com/artidoro/qlora/blob/main/eval/qa_baseline_gpt.py) (GPT answer generation), [`eval/prompts/vicuna_questions.jsonl`](https://github.com/artidoro/qlora/blob/main/eval/prompts/vicuna_questions.jsonl) (Benchmark questions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_finetune["Finetuning"]
  node_qlora["QLoRA runner<br/>[qlora.py]"]
  node_pretrained[("Pretrained models")]
  node_quant_adapter["Quantization and adapters<br/>[qlora.py]"]
  node_dataset["Dataset preparation<br/>[qlora.py]"]
  node_trainer["Training and checkpoints<br/>[qlora.py]"]
  node_mmlu["MMLU evaluation<br/>[qlora.py]"]
end

subgraph group_inference["Inference"]
  node_generation_example["Generation example"]
end

subgraph group_evaluation["Evaluation"]
  node_questions["Benchmark questions"]
  node_baseline["GPT answer generation<br/>[qa_baseline_gpt.py]"]
  node_reviewer["GPT answer reviewer<br/>[eval_gpt_review.py]"]
  node_review_prompts["Reviewer prompts<br/>[reviewer.jsonl]"]
  node_generations[("Model generations")]
  node_ratings[("Review ratings")]
  node_human_eval[("Human evaluation")]
end

node_researcher(("Researcher"))
node_gpt_service{{"OpenAI API"}}

node_researcher -->|"starts training"| node_qlora
node_qlora -->|"loads model"| node_pretrained
node_qlora -->|"configures"| node_quant_adapter
node_qlora -->|"prepares data"| node_dataset
node_qlora -->|"trains model"| node_trainer
node_qlora -->|"evaluates MMLU"| node_mmlu
node_researcher -->|"runs inference"| node_generation_example
node_researcher -->|"requests answers"| node_baseline
node_questions -->|"supplies questions"| node_baseline
node_baseline -->|"requests completions"| node_gpt_service
node_baseline -->|"writes answers"| node_generations
node_researcher -->|"requests review"| node_reviewer
node_questions -->|"supplies questions"| node_reviewer
node_generations -->|"compares answers"| node_reviewer
node_review_prompts -->|"configures review"| node_reviewer
node_reviewer -->|"requests judgments"| node_gpt_service
node_reviewer -->|"writes ratings"| node_ratings
node_researcher -.->|"records assessments"| node_human_eval

click node_qlora "https://github.com/artidoro/qlora/blob/main/qlora.py"
click node_quant_adapter "https://github.com/artidoro/qlora/blob/main/qlora.py"
click node_dataset "https://github.com/artidoro/qlora/blob/main/qlora.py"
click node_trainer "https://github.com/artidoro/qlora/blob/main/qlora.py"
click node_mmlu "https://github.com/artidoro/qlora/blob/main/qlora.py"
click node_generation_example "https://github.com/artidoro/qlora/blob/main/examples/guanaco_generate.py"
click node_questions "https://github.com/artidoro/qlora/blob/main/eval/prompts/vicuna_questions.jsonl"
click node_baseline "https://github.com/artidoro/qlora/blob/main/eval/qa_baseline_gpt.py"
click node_reviewer "https://github.com/artidoro/qlora/blob/main/eval/eval_gpt_review.py"
click node_review_prompts "https://github.com/artidoro/qlora/blob/main/eval/prompts/reviewer.jsonl"
click node_generations "https://github.com/artidoro/qlora/tree/main/eval/generations"
click node_ratings "https://github.com/artidoro/qlora/tree/main/eval/ratings-gpt4"
click node_human_eval "https://github.com/artidoro/qlora/tree/main/eval/ratings-human"

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_qlora,node_pretrained,node_quant_adapter,node_dataset,node_trainer,node_mmlu toneBlue
class node_generation_example toneAmber
class node_questions,node_baseline,node_reviewer,node_review_prompts,node_generations,node_ratings,node_human_eval,node_gpt_service toneMint
class node_researcher toneIndigo
```

## Components

### Finetuning

- [QLoRA runner](https://github.com/artidoro/qlora/blob/main/qlora.py): `qlora.py`
- **Pretrained models**
- [Quantization and adapters](https://github.com/artidoro/qlora/blob/main/qlora.py): `qlora.py`
- [Dataset preparation](https://github.com/artidoro/qlora/blob/main/qlora.py): `qlora.py`
- [Training and checkpoints](https://github.com/artidoro/qlora/blob/main/qlora.py): `qlora.py`
- [MMLU evaluation](https://github.com/artidoro/qlora/blob/main/qlora.py): `qlora.py`

### Inference

- [Generation example](https://github.com/artidoro/qlora/blob/main/examples/guanaco_generate.py): `examples/guanaco_generate.py`

### Evaluation

- [Benchmark questions](https://github.com/artidoro/qlora/blob/main/eval/prompts/vicuna_questions.jsonl): `eval/prompts/vicuna_questions.jsonl`
- [GPT answer generation](https://github.com/artidoro/qlora/blob/main/eval/qa_baseline_gpt.py): `eval/qa_baseline_gpt.py`
- [GPT answer reviewer](https://github.com/artidoro/qlora/blob/main/eval/eval_gpt_review.py): `eval/eval_gpt_review.py`
- [Reviewer prompts](https://github.com/artidoro/qlora/blob/main/eval/prompts/reviewer.jsonl): `eval/prompts/reviewer.jsonl`
- [Model generations](https://github.com/artidoro/qlora/tree/main/eval/generations): `eval/generations`
- [Review ratings](https://github.com/artidoro/qlora/tree/main/eval/ratings-gpt4): `eval/ratings-gpt4`
- [Human evaluation](https://github.com/artidoro/qlora/tree/main/eval/ratings-human): `eval/ratings-human`

### Other components

- **Researcher**
- **OpenAI API**

## Connections

- Researcher → QLoRA runner: starts training (evidence: `README.md`)
- QLoRA runner → Pretrained models: loads model (evidence: `qlora.py`)
- QLoRA runner → Quantization and adapters: configures (evidence: `qlora.py`)
- QLoRA runner → Dataset preparation: prepares data (evidence: `qlora.py`)
- QLoRA runner → Training and checkpoints: trains model (evidence: `README.md`)
- QLoRA runner → MMLU evaluation: evaluates MMLU (evidence: `qlora.py`)
- Researcher → Generation example: runs inference (evidence: `README.md`)
- Researcher → GPT answer generation: requests answers (evidence: `eval/qa_baseline_gpt.py`)
- Benchmark questions → GPT answer generation: supplies questions (evidence: `eval/qa_baseline_gpt.py`)
- GPT answer generation → OpenAI API: requests completions (evidence: `eval/qa_baseline_gpt.py`)
- GPT answer generation → Model generations: writes answers (evidence: `eval/qa_baseline_gpt.py`)
- Researcher → GPT answer reviewer: requests review (evidence: `eval/eval_gpt_review.py`)
- Benchmark questions → GPT answer reviewer: supplies questions (evidence: `eval/eval_gpt_review.py`)
- Model generations → GPT answer reviewer: compares answers (evidence: `eval/eval_gpt_review.py`)
- Reviewer prompts → GPT answer reviewer: configures review (evidence: `README.md`)
- GPT answer reviewer → OpenAI API: requests judgments (evidence: `eval/eval_gpt_review.py`)
- GPT answer reviewer → Review ratings: writes ratings (evidence: `eval/eval_gpt_review.py`)
- Researcher → Human evaluation: records assessments (evidence: `README.md`)
