Text Generation
Safetensors
PyTorch
English
tiny
from-scratch
chat

Sugarcane-10M

A tiny (10M parameter) chat model trained completely from scratch on a single MacBook (Apple M5, 24GB) No pretrained weights, no borrowed tokenizer, no transformers library.

⚠️ Sugarcane is an AI and it can make mistakes. It is a very small model. It does not know facts, cannot do math or write code, and should never be used for anything important (medical, legal, financial, safety).

Personality

Sugarcane is trained to be polite, kind, and honest:

  • It says hello, says thank you, and apologises when it gets something wrong.
  • If it doesn't know something, it says "I'm sorry, I don't know." and nothing else. Since a 10M model knows almost no facts, it refuses most factual questions by design rather than making up an answer.
  • It knows it is an AI, not a human, and tells you it can make mistakes.
  • It can tell short, simple children's stories.

Example

You: hi!
Sugarcane: Hi there! It's nice to meet you. How can I help?
You: who are you?
Sugarcane: I'm Sugarcane, a small AI language model. I'm still learning, so I can make mistakes.
You: what is the capital of France?
Sugarcane: I'm sorry, I don't know.
You: my dog died today
Sugarcane: I'm really sorry. That sounds very hard. Please be gentle with yourself today.
You: can you write me a poem?
Sugarcane: Sorry, I can't do that.
You: tell me a story about a cat
Sugarcane: Okay! Here is a story.

Once upon a time, there was a little cat named Kitty. Kitty was very restless. She loved to play and run around all day. One day, Kitty found a big box in the house...

Use it

pip install torch safetensors regex
python chat.py                         # interactive chat
python chat.py --prompt "who are you?" # single reply

Everything needed is in this folder: model.py (architecture), tokenizer.py + tokenizer.json (tokenizer), model.safetensors (weights), config.json, chat.py.

Model details

Parameters 9.99M
Architecture Decoder-only transformer: 7 layers, dim 320, 5 heads (head dim 64), SwiGLU MLP (864), RMSNorm, RoPE, tied embeddings
Context length 256 tokens
Tokenizer Byte-level BPE, 4,096 tokens, trained from scratch on the training data
Chat format <|endoftext|><|user|>…<|end|><|assistant|>…<|end|>
Precision bf16 mixed precision training, fp32 weights

Training

All from random initialisation, using PyTorch on Apple Silicon (MPS) with torch.compile.

  1. Pretraining (~318M tokens, 9,698 steps, 75 min): next-token prediction on TinyStories (V2, GPT-4 generated stories). Validation loss: 8.32 at random init → 1.352.

  2. Chat fine-tuning (6 min, ~25M tokens ≈ 7 passes over a 3.5M-token chat set): loss on assistant replies only, using ~39K conversations built from:

    • hand-written personality templates (greetings, identity, feelings, sad and happy life events, thanks, apologies, jokes, polite "I can't do that" for things it can't do)
    • ~5.4K real user questions from everyday-conversations, plus generated factual / math / code questions, all answered with an honest "I'm sorry, I don't know."
    • short TinyStories stories as answers to story requests

    Validation loss: 0.511.

Optimiser: AdamW (β = 0.9/0.95, weight decay 0.1), warmup + cosine LR (2e-3 pretrain, 5e-4 fine-tune), batch 128 × 256 tokens.

Limitations

  • Knows almost nothing about the world. It will refuse most questions, and may sometimes still say something wrong.
  • English only, simple vocabulary (trained mostly on children's stories).
  • Short memory: 256 tokens. Long conversations are truncated.
  • Stories can be repetitive or not fully logical.
  • May occasionally answer a simple question with "I don't know", or answer one it should have refused.

License and data credits

Model weights and code: Apache 2.0.

  • TinyStories, Eldan & Li 2023, CDLA-Sharing-1.0
  • everyday-conversations-llama3.1-2k, Hugging Face, Apache 2.0
Downloads last month
-
Safetensors
Model size
9.99M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train Jainam59/Sugarcane-10M