Hibari
An LLM engine written from first principles in PyTorch — and Koto, the conversational model built with it
Every part of Hibari is written directly: the Transformer, the byte-level BPE tokenizer, the training loop, KV-cache inference, a safety layer, a reply critic and a native GGUF exporter. No pretrained weights and no high-level model library are used. Its first model, Koto, lives in its own repository as a Git submodule of Hibari; the current release is Hibari-Koto1.3.1:29M.
What Hibari is
The engine and its name
Hibari (雲雀, Japanese for the skylark) is a research project to build a language model the long way: every layer is written and tested in this repository instead of being imported. The goal is understanding — a small model whose every number can be traced to the code, data and run that produced it.
The engine is deliberately model-agnostic: sizes come from a config file, and a model lives in its own repository. Koto is the first one; a release binds its checkpoint, tokenizer and GGUF files together by SHA-256, so a published file can always be traced back to its training run.
Author: Kavimugil Rajasekar · MIT licence · started 2026
Koto 1.3.1 at a glance
Current releaseCompared with the previous release (1.1.1, 6.2M parameters), 1.3.1 is better at following a conversation (conversation suite 0.645 → 0.733) and weaker at rewriting text (behaviour suite 0.660 → 0.628). All results →
Two repositories, one direction
Engine + submodule modelHibari
A reusable, model-agnostic Python package (hibari) that can build, train, run, evaluate and export any model of this architecture. It never imports a model.
github.com/KavimugilRajasekar/Hibari · engine 0.4.1 · 418 tests
models/Koto
Koto
One concrete model: configs, tokenizer, data recipes, training runs, evaluation suites, experiment records and release files. Koto imports Hibari and only uses it.
github.com/KavimugilRajasekar/Koto · release 1.3.1 · 87 tests
git clone --recurse-submodules https://github.com/KavimugilRajasekar/Hibari.git
Hibari/ engine: src/hibari, scripts/engine, tests, Docs
└── models/Koto/ submodule: configs, tokenizer, koto/ data + evaluation,
training/, experiments/, releases/, docs/
dependency: Koto ──uses──▶ Hibari (never the other way)
Architecture
How a reply is produced
Inside the engine
One package per responsibility| Layer | Package | What it does |
|---|---|---|
| Model | hibari.model | Decoder-only Transformer: token embedding, RoPE, multi-head causal attention with KV cache, SwiGLU, pre-RMSNorm, tied output head, residual dropout |
| Tokenizer | hibari.data.tokenizer | Byte-level BPE (4,096 tokens), chat template, escaping of special-token text typed by users |
| Data | hibari.data | Conversation formatting, windowing that never cuts a reply, assistant-only loss masking, length-grouped batching |
| Training | hibari.training | AdamW with warm-up + cosine schedule, token-weighted gradient accumulation, resume, checkpoint provenance |
| Inference | hibari.inference | Batched KV-cache sampling, streaming, chat session with context trimming, rewriting-task router, informal-text normalisation |
| Safety & ranking | safety · reranking | Deterministic safety layer with reviewed responses; a critic that ranks several model-written replies (it never writes text) |
| Export | hibari.export | Native GGUF writer (F32 / F16, then Q8_0 / Q4_K_M via llama.cpp) and a NumPy reference runtime that reads only the GGUF |
| Release | hibari.release | Release profiles that bind version, weights, tokenizer and GGUFs by SHA-256; validator; generated Ollama Modelfile |
Links
Everything in one place| What | Where |
|---|---|
| Engine source | github.com/KavimugilRajasekar/Hibari |
| Model source (submodule) | github.com/KavimugilRajasekar/Koto |
| Model weights (GGUF + PyTorch) | huggingface.co/kavimugil-r/Hibari-Koto |
| Ollama | ollama.com/kavimugil-r/Hibari-Koto1.3.1 · ollama run kavimugil-r/Hibari-Koto1.3.1:29M |
| Release report | docs/34 — Koto 1.3.1 release report |
| Model card | MODEL_CARD.md |
| Engine documentation | Hibari/Docs |
| Author | Hugging Face · Ollama · GitHub |