Matriisi-1.0 / README.md
BenjaminHelle's picture
Upload folder using huggingface_hub
a678708 verified
|
Raw History Blame Contribute Delete
5.27 kB
---
language:
- en
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
tags:
- causal-lm
- llama
- small-language-model
- base-model
- trained-from-scratch
- tiny-model
---
# Matriisi 1.0
**Matriisi** (Finnish for "matrix") is a compact, Llama-style causal language model built for experimentation and tinkering. It is a **base model**: it continues text, it doesn't follow instructions, like a chat assistant.
Its main strength is **token efficiency**. Models in this size range are typically trained on several billion tokens or more. Matriisi sees only about 500M. It gives up a little benchmark performance in exchange for a much smaller training budget, and still handles short English text, simple math and small code snippets.
| | |
|---|---|
| Type | Base (pretrained) causal LM, not instruction-tuned |
| Size | 9,992,448 parameters (~40 MB in float32) |
| Context | 4,096 tokens |
| Training data | 502M tokens, one pass |
| Domains | English prose, code, math and science, general knowledge |
| Runs on | Anything, including a plain CPU |
## Model details
| Property | Value |
|---|---|
| Architecture | Llama-style decoder (`LlamaForCausalLM`) |
| Parameters | 9,992,448 (about 10M) |
| Layers | 10 |
| Hidden size | 256 |
| Attention heads | 4 (head dimension 64) |
| Feed-forward size | 686 |
| Context length | 4,096 tokens |
| Vocabulary | 8,192-token byte-level BPE |
| Embeddings | Input and output weights tied |
| Model format | Safetensors, float32 |
| Training checkpoint | Step 15,332; validation loss 2.7431 |
The model uses RMSNorm, RoPE and SwiGLU, with no attention or MLP biases. The tokenizer and its special-token IDs are part of the model and must be used together with these weights.
## Training data
Matriisi was pretrained for one pass over a prepared stream of 502,383,824 tokens, around 50 training tokens per parameter. The measured mixture:
| Category | Training tokens | Share |
|---|---:|---:|
| English | 274,764,764 | 54.7% |
| Code | 76,047,126 | 15.1% |
| Math and science | 76,839,148 | 15.3% |
| General knowledge and reasoning | 74,732,786 | 14.9% |
Sources include project and open-source code, English prose, FineWeb-Edu, FineMath, Sci-Base textbook text, Wikipedia and HotpotQA.
## Intended use
Good fits:
- Local experimentation with small language models
- Generating or completing short text and code snippets
- A starting point for domain adaptation or fine-tuning
Not a good fit:
- Question answering, factual lookup or anything where correctness matters
- Chat or instruction following (prompts are treated as text to continue, not requests)
## Evaluation
Zero-shot multiple-choice evaluation with `lm-eval` 0.4.13 and Arithmark-3. All results are `acc_norm`.
| Benchmark | Score |
|---|---:|
| HellaSwag | 27.13% |
| ARC-Easy | 33.04% |
| ARC-Challenge | 21.50% |
| PIQA | 54.19% |
| Arithmark-3 | 34.6% |
## Limitations
- With fewer than 10M parameters, capacity is very limited. Expect incoherent continuations, wrong answers, repetitive text and invalid code.
- Training data may contain errors, biases, unsafe material or copyrighted content inherited from its sources.
- English only, in practice.
## Use with Transformers
Recommended starting settings, from short local sampling trials: temperature `0.6`, top-k `40`, top-p `0.8`, repetition penalty `1.1`, and up to `128` new tokens. For code, greedy decoding (`temperature=0`) may give simpler completions, but it does not ensure correctness.
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "BenjaminHelle/Matriisi-1.0"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
prompt = "# A function that returns the square of a number\n"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
**inputs,
max_new_tokens=128,
do_sample=True,
temperature=0.6,
top_k=40,
top_p=0.8,
repetition_penalty=1.1,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=False))
```
### Prompting tips
Matriisi continues text, so write prompts as the *beginning* of something rather than as a request.
- **General text:** start a sentence or paragraph and let the model finish it.
- **Code:** the training format uses a file marker and path, so mimic it for source-code continuation:
```text
<|file|>main.c
#include <stdio.h>
```
- **Comments as prompts:** a leading comment describing a function (as in the example above) also works as a prompt.
## Training procedure
Matriisi was trained from scratch on a RX 7600 with a custom training pipeline and exported to the standard Transformers Llama causal-LM format, which supports a 4,096-token context. Training used a 500M-token prepared corpus, a byte-level BPE tokenizer built for the project, and a single pass over the shuffled training stream. `export_metadata.json` records the source checkpoint step, validation loss, parameter count and tokenizer hash.
## Citation
If you use this model, please cite it as:
```bibtex
@misc{matriisi_1_0,
title = {Matriisi 1.0},
author = {Benjamin Helle},
year = {2026}
}
```