--- license: mit library_name: tiny-dlms pipeline_tag: zero-shot-classification language: [en] tags: - tiny-dlms - decision-model - from-scratch - pytorch - multiple-choice - intent-classification datasets: - HuggingFaceFW/fineweb-edu - Muennighoff/babi - clinc/clinc_oos - PolyAI/banking77 - tau/commonsense_qa --- # tiny-dlms-rhoa: Rhoa 4x128 Rhoa (ῥόα, the pomegranate) is a tiny decision model: it reads a situation and a list of options, scores every option and picks one. This is the best Rhoa: pre-trained on 2 GB of web text, then fine-tuned. It does not write: one forward pass scores all options and a softmax over them gives one probability each. Written and trained from scratch in PyTorch (no Hugging Face `transformers`): tokenizer, Transformer, training. Code, all the other checkpoints and the full benchmark: [GitHub](https://github.com/benisalla/tiny-dlms) · [project page](https://benisalla.github.io/tiny-dlms/). A learning project, not a production model. ## Usage ```bash pip install "tiny-dlm[hub] @ git+https://github.com/benisalla/tiny-dlms" ``` ```python from tiny_dlm.data import Decision, collate from tiny_dlm.hub import from_pretrained model, tokenizer, config = from_pretrained("liamsi/tiny-dlms-rhoa") context = "i lost my card yesterday , what should i do ?" options = ["lost or stolen card", "change pin", "card arrival"] idx, cand_mask, _ = collate([Decision(context, options, options[:1])], tokenizer) choice, probs = model.decide(idx, cand_mask) print(options[choice.item()], probs[0].tolist()) ``` ## Model | | | |---|---| | Layers x width | 4 x 128 (4 heads) + 1 layer where the options look at each other | | Tokenizer | byte-level BPE, 8,192 tokens, trained on the web text | | Input | ` context option`, up to 128 tokens | | Blocks | RMSNorm, RoPE, SwiGLU | | Weights | 2.36 M | | Training steps | 14,000 | ## Training 1. Masked-token pre-training on 2 GB of [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) web text (479M tokens). 2. Fine-tuning on 4 datasets at once: bAbI (2-6 options), CLINC150 (151 intents), Banking77 (77 intents) and CommonsenseQA (5 options). ## Results | Dataset (held-out test) | Options | This model | Random | |---|---|---|---| | bAbI | 6 | **100.0%** | 28.2% | | CLINC150 | 151 | **72.6%** | 0.7% | | Banking77 | 77 | **84.4%** | 1.3% | | CommonsenseQA | 5 | **20.8%** | 20.0% | CommonsenseQA stays near random for every model: a few million weights cannot hold world knowledge. ## The tiny-dlms models | Model | | |---|---| | [tiny-dlms-rhoa](https://huggingface.co/liamsi/tiny-dlms-rhoa) | the best Rhoa: pre-trained on 2 GB of web text, then fine-tuned | | [tiny-dlms-rhoa-small](https://huggingface.co/liamsi/tiny-dlms-rhoa-small) | the small Rhoa, pre-trained on 2 GB of web text, then fine-tuned | | [tiny-dlms-rhoa-gpt2](https://huggingface.co/liamsi/tiny-dlms-rhoa-gpt2) | Rhoa with GPT-2 blocks (LayerNorm, learned positions, GELU), pre-trained on 2 GB of web text | | [tiny-dlms-rhoa-base](https://huggingface.co/liamsi/tiny-dlms-rhoa-base) | the pre-trained Rhoa before fine-tuning: masked-token prediction on 2 GB of web text | | [tiny-dlms-melon-car](https://huggingface.co/liamsi/tiny-dlms-melon-car) | Mēlon driving CarRacing from pixels | | [tiny-dlms-melon-car-small](https://huggingface.co/liamsi/tiny-dlms-melon-car-small) | the small Mēlon driving CarRacing from pixels | | [tiny-dlms-melon-maze](https://huggingface.co/liamsi/tiny-dlms-melon-maze) | Mēlon solving mazes from pixels |