← TinyGPT · docs · devlog · roadmap · speedup
source: docs/archive/evaluation.md · view on GitHub ↗

Evaluation & safety

Phase 9 — and ongoing. Know what the model is actually doing.


1. Required correctness tests

The full table is in ../tests/README.md. Summary:

TestPurpose
Tokenizer roundtripbytes → text → bytes is lossless
Shape testsevery layer returns the expected shape
Loss sanityrandom model loss near ln(256) ≈ 5.54
Tiny overfitmodel overfits 1–10 KB repeated text
Gradient checkfinite-difference check on a tiny layer
PyTorch parityported forward matches the PyTorch reference
Checkpoint reloadsame loss after save + reload
Sampling fixed seeddeterministic generation for a fixed seed
Browser refreshrun resumes after a page reload

The most important test: can it overfit a tiny repeated dataset? If not, do not scale — the model, backprop, or data pipeline is broken.


2. The evaluation matrix (LoRA)

Always run four comparisons:

A. Base model only
B. Base model + prompt examples (few-shot)
C. Base model + LoRA
D. Base model + LoRA + retrieval

Typical outcome:

SetupBehaviour
Base onlygeneric
Few-shot promptimmediate style improvement
LoRAstronger tone/style adaptation
Retrieval + LoRAbest practical quality

LoRA teaches style. Retrieval supplies context/facts.

If LoRA does not beat few-shot prompting, the adapter was not worth training.


3. Memorization test

Tiny models memorize; LoRA adapters can memorize too.

Take the first 30–50 tokens of a training example.
Ask the model to continue.
Check whether it reproduces the rest verbatim.

If it copies too much: train fewer steps, lower rank, lower learning rate, add dropout, deduplicate data, increase dataset size, avoid repeated text.


4. Qualitative questions

For a style-adaptation project, ask:


5. Backend parity (Phase 4–5)


6. Safety notes


Deliverable

A small evaluation suite producing: base output, prompt-only output, LoRA output, and LoRA + retrieval output — for the same held-out prompts.