Femto
a 48M-parameter language model that runs bash and Python on its own
2 min readupdated
Femto is a tiny decoder-only language model with just 48.2M parameters (~193 MB in fp32), trained from scratch in pure JAX without relying on off-the-shelf architectures like transformers. Creator Moksh Jain took it through a complete modern training pipeline: pretraining on 10B tokens, context extension to 16k, fine-tuning on chat and tool-use data, and 900 steps of GRPO (reinforcement learning with live code execution). As a result, the model can call external tools to run bash commands, execute Python scripts, search Wikipedia, check the weather, and invoke JSON functions. The project is designed as a transparent research and learning sandbox that you can read, reproduce, and modify end to end.
Key features
- Built-in tool use: the model autonomously generates calls for bash, Python, Wikipedia search, weather, and custom JSON functions, then reads their outputs.
- Custom compact architecture: 10 layers (d_model 512), SSSL hybrid attention (7 sliding-window layers with a 512-token window and 3 global layers without positional encodings), ReLU² MLP, and the Muon optimizer.
- Reproducible in a single evening: the full training run takes around 7.5 hours on a single node with 4× A100-80GB (~3.5e18 FLOPs).
- Multiple checkpoints included: comes with the final RL version (
femto), a post-mid-training version (femto-mid), and base models for 2k and 16k context lengths.
What you can do
- Study the full LLM lifecycle from scratch: explore pure JAX and NumPy code without heavy frameworks—from the 16,384-token BPE tokenizer to RL with execution verification.
- Experiment with tool use and RL on modest hardware: the weights take up less than 200 MB, making inference and fine-tuning easy to run on a single GPU or even a CPU.
- Adapt the recipe for your own projects: use the open scripts and dataset mix as a template to train custom, small-scale specialized agents.
Example
uv run python cli.py # чат с femto на CPU или GPU
uv run python agent_eval.py --run_name=femto --suites=terminal,gsm8kRead more
DetailsPost-RL metrics: 1.00 on seen terminal task types (0.33 on unseen), 0.635 on weather forecasting, 0.21 on search-augmented QA, and 0.145 on GSM8K with Python.
On the CORE metric, the base
femto-base-2k model scores 0.127 (compared to 0.114 for GPT-2 124M).Requires the original repository code (weights are loaded via
numpy); not supported in transformers.Limitations: English only, handles mostly single-step tasks, prone to hallucinations without search, and has no safety filtering.










Comments