CoolFace
Modelpublic

Fu01978/TinyLM

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes34downloads
Model Card

TinyLM

A 3.4M parameter causal language model trained from scratch, for experimentation.

Architecture

HyperparameterValue
Parameters3.403.968
Layers4
Hidden size64
Attention heads4
FFN dim192
Embedding rank32
Context length256
TokenizerGPT-2 (50257 vocab)

Uses a factored (low-rank) embedding to keep the vocab projection from eating the entire parameter budget, with weight tying on the output head.

Training

DatasetsSkylion007/openwebtext (10k samples), roneneldan/TinyStories (10k samples)
OptimizerAdamW (lr=3e-3, weight_decay=0.01)
SchedulerCosine annealing with warm restarts
Mixed precisionfp16 (torch.cuda.amp)
HardwareNvidia P100

Usage

python
from huggingface_hub import snapshot_download
import importlib.util
import torch

# Download files
snapshot_download(repo_id="Fu01978/TinyLM", local_dir="./tinylm")

# Load via script
spec   = importlib.util.spec_from_file_location("modeling_tinylm", "./tinylm/modeling_tinylm.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

model, tokenizer, config = module.load_tinylm("./tinylm")
model.eval()

# Generate
output = module.generate(model, tokenizer, "Once upon a time, ")
print(output)