Skip to content
Back to skills

Train Llm From Scratch

ASecurity

"Route train-llm-from-scratch workflows for from-scratch PyTorch

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
developmentpythongobashbackend

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill train-llm-from-scratch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Train Llm From Scratch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Train Llm From Scratch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-train-llm-from-scratch/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-train-llm-from-scratch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: train-llm-from-scratch
description: "Route train-llm-from-scratch workflows for from-scratch PyTorch
  LLM pretraining, SFT, reward modeling, DPO/ORPO/KTO, PPO, GRPO/RLVR,
  evaluation, chat, configs, UI, and data validation."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# train-llm-from-scratch

Use this repo skill when a task involves the `train-llm-from-scratch` project: a
pure-PyTorch educational LLM stack covering raw text tokenization, decoder-only
Transformer pretraining, SFT, reward modeling, DPO/ORPO/KTO, PPO, GRPO/RLVR,
GSM8K evaluation, chat, JSON configs, and a Streamlit control panel.

## Start Here

1. If the task may depend on repo freshness, read
   [`references/repo-provenance.md`](references/repo-provenance.md).
2. For setup, optional extras, backend expectations, and import checks, read
   [`references/installation.md`](references/installation.md).
3. Run [`scripts/check_environment.py`](scripts/check_environment.py) when you
   need a safe import/backend smoke check in the user's environment.
4. If checkpoint contents or model dimensions are unclear, run
   [`scripts/inspect_checkpoint.py`](scripts/inspect_checkpoint.py) before
   loading the model.
5. Route to the narrowest sub-skill below. Keep this root as the router; do not
   bury detailed stage work here.

## Sub-Skill Routing

| User task | Read |
|---|---|
| Prepare or validate Pile HDF5, packed SFT HDF5, preference JSONL, RL prompt JSONL, arithmetic curriculum, tokenizer/mask/data-loader issues | [`sub-skills/data-preparation/SKILL.md`](sub-skills/data-preparation/SKILL.md) |
| Inspect the custom Transformer, plan base pretraining, choose legacy vs modern pretraining, DDP/bf16, memory, checkpoint/resume, tiny model smoke | [`sub-skills/model-pretraining/SKILL.md`](sub-skills/model-pretraining/SKILL.md) |
| Run or debug SFT, reward model, DPO/ORPO/KTO, PPO, GRPO/RLVR, rollout/log-probs, KL/reward metrics, post-training pipeline sequencing | [`sub-skills/post-training-rlhf/SKILL.md`](sub-skills/post-training-rlhf/SKILL.md) |
| Evaluate on GSM8K, build stage tables, chat with checkpoints, choose raw vs chat mode, sampling controls, answer parsing/verifier behavior | [`sub-skills/evaluation-chat/SKILL.md`](sub-skills/evaluation-chat/SKILL.md) |
| Edit JSON configs, use smoke configs, inspect CLI override precedence, operate the Streamlit UI, inspect metrics JSONL/job logs | [`sub-skills/configuration-ui/SKILL.md`](sub-skills/configuration-ui/SKILL.md) |

## Install And Import Baseline

The package metadata exposes import roots `config`, `data_loader`, `src`, and
`ui`. A typical editable install from a compatible checkout is:

```bash
pip install -e .
pip install -e ".[train]"   # datasets + optional wandb for data/post-training
pip install -e ".[ui]"      # streamlit + pandas + altair for the control panel
pip install -e ".[docs]"    # mkdocs tooling, only for docs-site work
```

For the selected training workflows, use a PyTorch build that matches the
machine. Full training is CUDA-oriented; CPU smoke configs are useful for parser,
config, and algorithm checks but do not verify large CUDA/bf16/DDP training.

Minimal import smoke:

```bash
python - <<'PY'
from src.models.transformer import Transformer
from src.post_training.chat_template import encode_chat, EOT_ID
ids, mask = encode_chat([
    {"role": "user", "content": "What is 2+2?"},
    {"role": "assistant", "content": "<answer>4</answer>"},
])
print(len(ids), len(mask), sum(mask), ids[-1] == EOT_ID)
print(Transformer(n_head=2, n_embed=16, context_length=8, vocab_size=64, N_BLOCKS=1).__class__.__name__)
PY
```

## Common Operating Rules

- Start with smoke configs or dry-run command builders before launching long
  training, data downloads, or multi-GPU jobs.
- Validate data files before training. Mask/data errors silently corrupt SFT,
  preference optimization, and RL rewards.
- Treat `/ephemeral`-style paths in examples as user-configurable storage roots,
  not mandatory constants.
- Keep Weights & Biases optional. The repo writes local JSONL metrics even when
  W&B is disabled or unavailable.
- Use greedy decoding for comparable GSM8K stage tables; sampling is for chat.
- Do not claim CUDA coverage from CPU-only smoke tests. For CUDA claims, verify a
  torch CUDA allocation and at least a tiny model forward on the target host.

## Troubleshooting

Read [`references/troubleshooting.md`](references/troubleshooting.md) for
cross-cutting install/import/backend/checkpoint routing. Workflow-specific
failures live in each sub-skill's nearest `references/troubleshooting.md`.

Files in this skill

  • SKILL.md4.5 KB
  • references/installation.md4.2 KB
  • references/repo-provenance.md2.7 KB
  • references/repo-routing-metadata.json598 B
  • references/troubleshooting.md4.6 KB
  • scripts/check_environment.py5.6 KB
  • scripts/inspect_checkpoint.py4.5 KB
  • sub-skills/configuration-ui/SKILL.md2.7 KB
  • sub-skills/configuration-ui/references/configuration.md7.4 KB
  • sub-skills/configuration-ui/references/control-panel-ui.md6.7 KB
  • sub-skills/configuration-ui/references/troubleshooting.md7.7 KB
  • sub-skills/configuration-ui/scripts/inspect_metrics_jsonl.py5.9 KB
  • sub-skills/configuration-ui/scripts/print_config_summary.py6.3 KB
  • sub-skills/data-preparation/SKILL.md3.7 KB
  • sub-skills/data-preparation/references/data-formats.md5.8 KB
  • sub-skills/data-preparation/references/troubleshooting.md6.9 KB
  • sub-skills/data-preparation/references/workflows.md6.4 KB
  • sub-skills/data-preparation/scripts/inspect_h5_tokens.py7 KB
  • sub-skills/data-preparation/scripts/validate_preference_jsonl.py7.1 KB
  • sub-skills/data-preparation/scripts/validate_rl_prompts_jsonl.py8.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.