# databrickslabs/dolly architecture

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

- Interactive diagram: https://gitdiagram.com/databrickslabs/dolly
- Repository: https://github.com/databrickslabs/dolly

## Overview

Dolly is an instruction-following language model, with this repository providing fine-tuning and response-generation code. The principal workflow configures a training run, prepares instruction/response examples and a pretrained model, fine-tunes and saves the model, then loads that output for instruction-based generation. GPU-family configurations and the documented Hugging Face inference workflow are also represented. Edges reflect shown calls, writes, or README statements; unsampled implementation details are not inferred.

Main entry points: [`training/generate.py`](https://github.com/databrickslabs/dolly/blob/master/training/generate.py) (Generation pipeline), [`train_dolly.py`](https://github.com/databrickslabs/dolly/blob/master/train_dolly.py) (Training notebook), [`training/trainer.py`](https://github.com/databrickslabs/dolly/blob/master/training/trainer.py) (Fine-tuning trainer), [`training/consts.py`](https://github.com/databrickslabs/dolly/blob/master/training/consts.py) (Prompt constants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Training orchestration"]
  node_notebook["Training notebook<br/>[train_dolly.py]"]
end

subgraph group_train["Fine-tuning"]
  node_prompts["Prompt constants<br/>[consts.py]"]
  node_trainer["Fine-tuning trainer<br/>[trainer.py]"]
end

subgraph group_infer["Response generation"]
  node_generation["Generation pipeline<br/>[generate.py]"]
end

subgraph group_hardware["GPU configuration"]
  node_configs["GPU configs"]
end

node_operator(("Model user"))
node_dataset[("Dolly instruction data")]
node_base[("Pretrained model")]
node_saved[("Fine-tuned model")]
node_transformers["Transformers pipeline"]
node_response["Generated response"]

node_operator -->|"configures run"| node_notebook
node_notebook -->|"selects config"| node_configs
node_notebook -->|"invokes training"| node_trainer
node_notebook -->|"imports settings"| node_prompts
node_trainer -->|"uses formats"| node_prompts
node_dataset -->|"training examples"| node_trainer
node_base -->|"fine-tunes"| node_trainer
node_trainer -->|"saves model"| node_saved
node_notebook -->|"loads and calls"| node_generation
node_generation -->|"uses format"| node_prompts
node_operator -->|"provides instruction"| node_generation
node_generation -->|"loads model"| node_saved
node_generation -->|"subclasses pipeline"| node_transformers
node_generation -->|"returns text"| node_response

click node_notebook "https://github.com/databrickslabs/dolly/blob/master/train_dolly.py"
click node_prompts "https://github.com/databrickslabs/dolly/blob/master/training/consts.py"
click node_trainer "https://github.com/databrickslabs/dolly/blob/master/training/trainer.py"
click node_configs "https://github.com/databrickslabs/dolly/tree/master/config"
click node_generation "https://github.com/databrickslabs/dolly/blob/master/training/generate.py"

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_notebook,node_operator toneBlue
class node_prompts,node_trainer,node_dataset,node_base,node_saved toneAmber
class node_generation toneMint
class node_configs toneRose
class node_transformers,node_response toneIndigo
```

## Components

### Training orchestration

- [Training notebook](https://github.com/databrickslabs/dolly/blob/master/train_dolly.py): `train_dolly.py`

### Fine-tuning

- [Prompt constants](https://github.com/databrickslabs/dolly/blob/master/training/consts.py): `training/consts.py`
- [Fine-tuning trainer](https://github.com/databrickslabs/dolly/blob/master/training/trainer.py): `training/trainer.py`

### Response generation

- [Generation pipeline](https://github.com/databrickslabs/dolly/blob/master/training/generate.py): `training/generate.py`

### GPU configuration

- [GPU configs](https://github.com/databrickslabs/dolly/tree/master/config): `config`

### Other components

- **Model user**
- **Dolly instruction data**
- **Pretrained model**
- **Fine-tuned model**
- **Transformers pipeline**
- **Generated response**

## Connections

- Model user → Training notebook: configures run (evidence: `train_dolly.py`)
- Training notebook → GPU configs: selects config (evidence: `train_dolly.py`)
- Training notebook → Fine-tuning trainer: invokes training (evidence: `train_dolly.py`)
- Training notebook → Prompt constants: imports settings (evidence: `train_dolly.py`)
- Fine-tuning trainer → Prompt constants: uses formats (evidence: `training/trainer.py`)
- Dolly instruction data → Fine-tuning trainer: training examples (evidence: `README.md`)
- Pretrained model → Fine-tuning trainer: fine-tunes (evidence: `README.md`)
- Fine-tuning trainer → Fine-tuned model: saves model (evidence: `training/trainer.py`)
- Training notebook → Generation pipeline: loads and calls (evidence: `train_dolly.py`)
- Generation pipeline → Prompt constants: uses format (evidence: `training/generate.py`)
- Model user → Generation pipeline: provides instruction (evidence: `training/generate.py`)
- Generation pipeline → Fine-tuned model: loads model
- Generation pipeline → Transformers pipeline: subclasses pipeline (evidence: `training/generate.py`)
- Generation pipeline → Generated response: returns text (evidence: `training/generate.py`)
