Text Generation
MLX
Safetensors
PyTorch
English
from-scratch
tiny
chat

Run this model with HF Jobs

Run Jainam59/MangoShake-50M on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/Jainam59/MangoShake-50M. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/Jainam59/MangoShake-50M on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/Jainam59/MangoShake-50M. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/Jainam59/MangoShake-50M. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

MangoShake-50M

A 52.7M parameter language model trained from scratch on a MacBook Pro (M5, 24 GB). No pretrained weights and no transformers: the tokenizer, architecture and training code are all written for this model.

This repo has two versions of the same model:

File Version What it does
model.safetensors MangoShake-50M (chat) Answers messages. Use chat.py.
base.safetensors MangoShake-50M-Base (pretrained only) Continues text. Use generate.py. Good starting point for your own fine-tuning.

MangoShake is a small model and makes mistakes. It doesn't know facts, can't do math or write code, and shouldn't be used for anything that matters.

Usage

pip install torch safetensors
python chat.py                                    # chat, interactive
python chat.py --prompt "hello"                   # chat, one reply
python generate.py "Once upon a time" --tokens 200   # base model, continue text

Runs on CPU on any machine; --device cuda or --device mps also work.

Chat model

It is trained to be polite and honest about what it doesn't know:

You: who are you?
MangoShake: I'm MangoShake, a small AI. I like to be kind and helpful, but I don't know very much, and I can make mistakes.
You: what is the capital of France?
MangoShake: I'm sorry, I don't know the answer to that.
You: i feel sad today
MangoShake: I'm sorry you're feeling sad. It's okay to feel that way. Maybe talking to a friend could help too.
You: are you chatgpt?
MangoShake: No, I'm MangoShake, a small open-weight AI model. I'm much smaller than those assistants.

It declines factual questions on purpose rather than making up answers, and it can tell short children's stories (they don't always follow the topic you ask for).

Base model

Once upon a time, there was a little boy named Tim. Tim loved to play outside. One day, Tim put on
his shoes and went to the park. He was very happy. At the park, Tim saw a big dog. The dog wanted to
play with Tim. Tim was scared. He did not know if the dog could be nice.

It writes fluent children's stories. General text is grammatical but often wrong or vague. It doesn't follow instructions.

Model details

Parameters 52.7M
Architecture decoder-only transformer, 14 layers, width 512, 8 heads, SwiGLU MLP (1376), RMSNorm (pre-norm), RoPE, tied embeddings
Context 512 tokens
Tokenizer byte-level BPE, 16,384 tokens, trained from scratch; id 16383 is end-of-text
Chat format <eot><|user|>\n…\n<|assistant|>\n…<eot>; <eot> ends each reply
Weights bf16

Training

Trained with MLX on the M5 GPU at ~15k tokens/s.

Pretraining (base model). 530M tokens (~10 tokens per parameter), 65% FineWeb-Edu and 35% TinyStories, over ~7.5 hours in four runs. Each run continued from the previous checkpoint on data the model hadn't seen.

Tokens seen Val loss FineWeb-Edu Val loss TinyStories
192M 3.707 1.458
298M 3.590 1.369
457M 3.532 1.341
530M 3.499 1.335

AdamW (β 0.9/0.95, weight decay 0.1), peak LR 1.5e-3 with warmup and cosine decay, 65K tokens per step, bf16 mixed precision.

Chat fine-tuning (chat model). 15 minutes from the base model, 13.2M tokens, loss on assistant replies only. 40K conversations made from persona templates, real user questions from everyday-conversations (answered with an honest "I don't know"), and TinyStories stories for story requests. Validation loss 0.49.

Limitations

  • Knows almost nothing about the world; the chat model declines most questions.
  • English only, simple vocabulary.
  • 512-token memory; long conversations lose their oldest turns.
  • Stories can be repetitive or illogical and may ignore the requested topic.

License

Weights and code: Apache 2.0.

  • FineWeb-Edu, Hugging Face, ODC-By 1.0
  • TinyStories, Eldan & Li 2023, CDLA-Sharing-1.0 (stories generated with GPT-3.5/GPT-4)
  • everyday-conversations-llama3.1-2k, Hugging Face, Apache 2.0
Downloads last month
-
Safetensors
Model size
52.7M params
Tensor type
BF16
·
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train Jainam59/MangoShake-50M