MEGA

A from-scratch Mixture-of-Experts language model — reference implementation

Model →
Frankenstein-Labs/mega-small
Dataset →
Frankenstein-Labs/mega-corpus
Source code →
github.com/Frankenstein-Labs/mega-moe

Load and run

pip install "git+https://github.com/Frankenstein-Labs/mega-moe.git"

from mega.hub.serialization import from_pretrained
from mega.tokenizer.tokenizer import MegaTokenizer
import torch

model = from_pretrained("Frankenstein-Labs/mega-small")
tok = MegaTokenizer.from_pretrained("Frankenstein-Labs/mega-small")

ids = [tok.bos_token_id, *tok.encode("17 + 16 =")]
out = model(torch.tensor([ids]))
print("17 + 16 =", tok.decode([int(out.logits[0, -1].argmax())]))

Verified results

metricvalue
perplexity (structured corpus)3.07
next-token accuracy0.667
arithmetic accuracy (a op b =)0.35
parameters31.53M total / 16.7M active
training loss6.72 → 1.02 over 1,500 steps