Train conversational language models from scratch.
Project description
Flatbuild
Build conversational language models from scratch.
An open-source framework for training compact decoder-only language models from random initialization using a modular, configuration-driven pipeline.
GitHub: https://github.com/flatseek/flatbuild · Organization: https://github.com/flatseek
Part of the Flatseek ecosystem
Flatseek (Keyword Search) • Flatvec (Vector Search) • Flatask (RAG Runtime) • Flatlens (Data Visualization) • Flatbuild (LLM Training) • Flattune (LLM Fine-Tuning) • Flatrun (LLM Inference)
See It In Action
The repository includes a small conversational dataset that demonstrates the complete Flatbuild workflow—from dataset to training, export, and inference.
Example dataset (data/demo/dataset.jsonl):
{"messages":[{"role":"system","content":"You are Flatbot, a helpful, friendly, and concise conversational assistant."},{"role":"user","content":"What gas do plants absorb?"},{"role":"assistant","content":"Plants absorb carbon dioxide from the atmosphere."}]}
Train the model:
flatbuild train configs/demo.yaml
Example output:
Loaded config: configs/demo.yaml
Project: demo
Loaded 1000 samples
Train: 850 Validation: 150
Epoch 1/4 loss=4.9630 val_loss=5.2337 ppl=187.49 acc=36.4%
Epoch 2/4 loss=4.2745 val_loss=4.0206 ppl=55.73 acc=46.3%
Epoch 3/4 loss=2.6530 val_loss=3.2722 ppl=26.37 acc=49.6%
Epoch 4/4 loss=1.9804 val_loss=2.8162 ppl=16.71 acc=54.2%
Run completed.
Artifacts:
outputs/demo/20260802T014922Z
Export the trained checkpoint:
flatbuild export \
outputs/demo/20260802T014922Z/checkpoints/final \
--format safetensors
Wrote model.safetensors
Copied tokenizer files
outputs/demo/20260802T014922Z/checkpoints/export_safetensors
Run the exported model with Flatrun.
pip install flatrun
Then run the exported checkpoint:
flatrun \
--model outputs/demo-large/20260802T014922Z/checkpoints/export_safetensors \
--prompt "who are you?"
Example output:
Detected format: safetensors
Tokenizer vocab: 2603
Chat template: Qwen2 ChatML
Loaded model in 0.01 s
Prompt:
who are you?
Generated:
'I I I 1 1 1 Ocean classic...... c solar that that that'
This tiny demonstration trains a decoder-only language model from scratch using 1,000 conversational examples and showcases the complete Flat pipeline:
Conversation Dataset
│
▼
Flatbuild Training
│
▼
Model Checkpoint
│
▼
SafeTensors Export
│
▼
Flatrun Inference
The bundled demo model is intentionally small and only trained for a few epochs, so the generated text is not expected to be meaningful. Its purpose is to demonstrate the complete end-to-end workflow. The same pipeline scales to larger datasets and larger language models without changing the training or deployment process.
Overview
A modular training framework for building compact language models.
Flatbuild is an open-source Python framework for training decoder-only language models entirely from random initialization.
Instead of requiring a large pre-trained checkpoint, Flatbuild provides every component of the training pipeline—including datasets, tokenizer training, model architecture, optimization, checkpointing, evaluation, and exporting—inside a single configurable framework.
Every training run is driven by a YAML configuration, making experiments reproducible, portable, and easy to automate.
Why Flatbuild?
Most modern training frameworks assume you already have a base model.
Flatbuild starts one layer lower.
It provides a complete reference implementation of the entire language-model training pipeline where every module can be inspected, replaced, extended, or optimized independently.
The resulting checkpoints can be exported to SafeTensors or HuggingFace Transformers and used directly by Flatrun or any compatible inference runtime.
Highlights
- Train decoder-only Transformers from scratch
- YAML-driven reproducible experiments
- Built-in tokenizer training
- Grouped Query Attention (GQA)
- RoPE positional embeddings
- RMSNorm and SwiGLU
- Gradient accumulation
- Mixed precision (FP32 / FP16 / BF16)
- Configurable chat templates
- JSONL, Parquet, and HuggingFace datasets
- SafeTensors and HuggingFace export
- Modular architecture for research and experimentation
Installation
pip install -e ".[dev]"
Development dependencies include:
- pytest
- ruff
- mypy
PyTorch is required at runtime.
Install the build matching your platform (CPU, CUDA, or Apple MPS).
Configuration
Training is controlled entirely through a YAML file.
Example:
name: demo
dataset:
type: conversation
path: data/demo/dataset.jsonl
max_length: 256
tokenizer:
source: train
vocab_size: 1024
model:
hidden_dim: 256
n_layers: 4
n_heads: 4
n_kv_heads: 2
context_length: 256
optimizer:
type: adamw
lr: 3e-4
trainer:
epochs: 1
batch_size: 8
See configs/demo.yaml for the complete configuration.
CLI
flatbuild train
flatbuild resume
flatbuild evaluate
flatbuild export
flatbuild generate
flatbuild inspect
flatbuild benchmark
Run:
flatbuild --help
for the complete command reference.
Training Pipeline
Dataset
│
▼
Tokenizer
│
▼
Model
│
▼
Training Loop
│
▼
Checkpoint
│
▼
Evaluation
│
▼
Export
Every stage is configurable and replaceable.
Current Features
Flatbuild currently supports:
- Decoder-only Transformer
- Grouped Query Attention (GQA)
- Rotary Position Embeddings (RoPE)
- RMSNorm
- SwiGLU
- AdamW optimizer
- Cosine learning-rate scheduler
- Linear warmup
- Early stopping
- Gradient accumulation
- Mixed precision training
- BPE tokenizer training
- Chat template formatting
- JSONL datasets
- Parquet datasets
- HuggingFace datasets
- SafeTensors export
- HuggingFace Transformers export
Roadmap
Future releases are planned to include:
- Supervised Fine-Tuning (SFT)
- LoRA
- QLoRA
- DPO
- MoE architectures
- Vision-language models
- Distributed training
- Multi-node training
- Advanced evaluation benchmarks
Quick Start
Train the bundled demo model:
flatbuild train configs/demo.yaml
A typical run will:
- Load the demo conversational dataset
- Train a tokenizer (or reuse an existing one)
- Train a decoder-only Transformer from scratch
- Save checkpoints, metrics, and metadata
- Export the final model
Outputs are written to:
outputs/demo/<run-id>/
License
Apache License 2.0
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flatbuild-0.1.0.tar.gz.
File metadata
- Download URL: flatbuild-0.1.0.tar.gz
- Upload date:
- Size: 87.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d76b4a7fdcc878f88f7b7657925f157f9dbe5f99ce193f23d3a20c66c3f5b11
|
|
| MD5 |
f8a48ea33f75df1ab10a51b9732cedd0
|
|
| BLAKE2b-256 |
b85757316c35ab72efe95ebab28f1615daaf6ff7f1d0c7a2328846d1582f34e3
|
Provenance
The following attestation bundles were made for flatbuild-0.1.0.tar.gz:
Publisher:
publish.yml on flatseek/flatbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flatbuild-0.1.0.tar.gz -
Subject digest:
8d76b4a7fdcc878f88f7b7657925f157f9dbe5f99ce193f23d3a20c66c3f5b11 - Sigstore transparency entry: 2318721743
- Sigstore integration time:
-
Permalink:
flatseek/flatbuild@9b963393ec97939a79540f8b88548ebc452b034b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/flatseek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b963393ec97939a79540f8b88548ebc452b034b -
Trigger Event:
release
-
Statement type:
File details
Details for the file flatbuild-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flatbuild-0.1.0-py3-none-any.whl
- Upload date:
- Size: 94.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1f7e6d155bbb3069461f77a9c8ab613a841de1c4185959167f61e5402a5e1cb
|
|
| MD5 |
cbb2bf10693e39dc676f1f4a2f1e1679
|
|
| BLAKE2b-256 |
895e57b967aec138262443651792454234160b8149338164e1dfe5affb67b150
|
Provenance
The following attestation bundles were made for flatbuild-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on flatseek/flatbuild
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flatbuild-0.1.0-py3-none-any.whl -
Subject digest:
c1f7e6d155bbb3069461f77a9c8ab613a841de1c4185959167f61e5402a5e1cb - Sigstore transparency entry: 2318721818
- Sigstore integration time:
-
Permalink:
flatseek/flatbuild@9b963393ec97939a79540f8b88548ebc452b034b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/flatseek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9b963393ec97939a79540f8b88548ebc452b034b -
Trigger Event:
release
-
Statement type: