|
Download README.md from OpenBlade/Katana-1B: direct link, hf CLI and curl.
- Browser
- Download file 9.17 kB
-
https://huggingface.co/OpenBlade/Katana-1B/resolve/main/README.md
- Command line
-
hf download hf://OpenBlade/Katana-1B/README.md
-
curl -L -o README.md https://huggingface.co/OpenBlade/Katana-1B/resolve/main/README.md
9.17 kB
| license: apache-2.0 | |
| language: | |
| - en | |
| pipeline_tag: text-generation | |
| tags: | |
| - fuser | |
| - katana | |
| - base-model | |
| - pretrained | |
| - text-generation | |
| - safetensors | |
| - pytorch | |
| - gaussian-modulation | |
| - math | |
| - code | |
|  | |
| --------------------------------------------------------------- | |
| KATANA 1B - User Guide (v.0.1.0) | |
| --------------------------------------------------------------- | |
| What is Katana? | |
| Katana is a custom engineered tranformer, paired with a custom tokenizer that has a custom vocab. The data mix consists of roughly 52% math/code and 48% science/general web text. The hypothesis of training Katana is to measure that guassian modulation, guassians and other similar (new) AI foundations will improve intelligence and learning. | |
| What makes Katana impressive? | |
| The sheer scale makes Katana impressive, because compared to most AI models it is absolutely tiny and heavily undertrained. Katana has only processed roughly 12B tokens throughout its 700k steps so far. That makes it sit at half-chinchilla point, with benchmarks proving it is growing in intelligence as it continues training. | |
| At 12B tokens seen, a 1B transformer should usually only learn english/spelling/grammar/punctuation (generally), but due to the custom data, architecture and training pipeline, we achieved this with half the data seen (roughly around 5b). At around 9B tokens seen, it could nearly always tell the area of a circle (πr²). | |
| We also developed Avalanche (drop-in pytorch optimizer), which cut down the gradient/optimizer memory usage by upto 99.99% (99.8% in this specific case on a single RTX 3060 12GB). Katana also proves that Avalanche can reliably train an AI model, even allowing for way larger contexts/batch sizes during training time. | |
| What Katana can do (This release): | |
| - Base model (no distillation or finetuning yet), it has seen mild reasoning/thinking traces so far. | |
| - generate basic text (it can be trained/finetuned to output any kind of text from math, code, languages, to anything else. | |
| - Some basic facts/formulae (πr², what a dog is, what a star is) | |
| Core Drawbacks (Currently): | |
| - NO SFT/DISTILLATION YET (This is a base model, which acts as an autocompletion engine rather than an AI). | |
| - Hallucinations and loose fact binding (can give wrong answers, hallucinate or enter a different domain (language --> code). | |
| - Mainly trained on ENGLISH text (loose binding with most languages, although multilingual capabilities do exist). | |
| What it can't do yet: | |
| - Agentic work | |
| - Coding/Debugging | |
| - Holding large context | |
| - Answering and responding with only facts/rag (correct answers) | |
| Why is it worth pursuing? and the future of Katana/OpenBlade: | |
| 1. Avalanche Optimizer - One of the most important innovations that was developed in order to even fit Katana's training on a single 12GB card. The optimizer was only possible because of a bottleneck/problem, but it proved itself by pretraining Katana. | |
| 2. Guassians/custom mechanisms - Currently, Katana is objectively unique in its architecture, meaning that no other AI (that we know of) has used all the same mechanisms/trainer. This sets it apart from the industry because we aren't building on what's already there. | |
| 3. Future of Local AI - As companies add watermarks, restrictions, mechanisms to limit the user experience regarding AI, we want to go the opposite route and give power back to the people. From finetuning/pretraining on owned hardware, to running and deploying capable SLMs. | |
| 4. Research and Development - As discussed before, Avalanche was one of the creations due to the research on this project. We would like to continue to develop and release more solutions, and training/testing is where we find those issues/roadblocks. All the research is free and open source at our homepage. | |
| 5. iRun Studio - A local app for iOS and MacOS running SLMs/LLMs on device (using metal compilation), which speeds up and frees up memory. It is blazing fast inference and loading, combined with full customizability and privacy. Releasing Katana for iRun Studio (in the near future) means we can have a capable SLM trained to run on a phone or ipad. | |
| --------------------------------------------------------------- | |
| Architecture: | |
| Katana-1.1B (`VortexV4` / `fuser`) is a 1.12B-parameter dense decoder-only transformer trained from scratch with three custom architectural mechanisms: | |
| | Specification | Value | | |
| | :--- | :--- | | |
| | Weights File | `model.safetensors` (`2.28 GiB`, 473 finite tensors, BF16 + FP32 `GaussianMod`) | | |
| | Total Parameters | `1,122,571,848` (`1,021,910,088` non-embedding) | | |
| | Depth / Hidden Size | `36` transformer layers, `d_model = 1,536` | | |
| | Attention | `24` heads (`head_dim = 64`), fused QKV projection, causal SDPA | | |
| | MLP / FFN | SwiGLU (`ff = 4,096`, bias-free `w1`, `w3`, `w2`) | | |
| | Normalization | Pre-LayerNorm (`ln1`, `ln2`, `ln_f`) with bias (`eps = 1e-5`) | | |
| | Positional Encoding | NTK-scaled RoPE (`theta = 1,000,000`, `4,096` token context) + Kaprekar phase modulation | | |
| | Tokenizer & Embeddings | Custom `65,535`-token byte-level BPE (`uint16`-safe), tied `tok_emb` / `lm_head` | | |
| | Optimizer | `GPUFactorizedAdamV2` (pretraining) & `Avalanche4Bit` (context extension) | | |
| Key architectural components per forward pass: | |
| 1. Embedding Context Gate (`ctx_gate`): `x = emb * sigmoid(ctx_gate @ emb)` gates each token embedding dimension before Block 0. | |
| 2. Per-Block `GaussianMod`: computes a learned diagonal Mahalanobis radius from `ln1(x)` in FP32 (`r^2 = mean(((ln1(x) - mu) / sigma)^2)`) and scales attention output before the residual add (`a = a * (beta + alpha * exp(-0.5 * r^2))`). | |
| 3. Kaprekar RoPE Phase Offsets: derives a 4-digit signature from quarter-channel activation statistics, steps through the Kaprekar (`6174`) orbit, and maps the trajectory to deterministic per-(layer, head) rotary phase offsets. | |
| For full implementation details, see `integrations/LLAMACPP_INTEGRATION.md` and `integrations/Integrationpatchspots.txt`. | |
| Benchmark Graph: | |
|  | |
| Zero-shot normalized accuracy (`acc_norm`, %) across EleutherAI `lm-evaluation-harness` (`n=200`) and full `ArithMark-3` (`n=1,000`): | |
| | Model | ARC-Easy | ARC-Challenge | HellaSwag | PIQA | ArithMark-3 | | |
| | :--- | ---: | ---: | ---: | ---: | ---: | | |
| | **Katana 700k (Ctx4k 1k)** | **38.00** | **24.00** | **37.00** | **60.00** | **35.40** | | |
| | **Katana 492k** | 39.50 | 21.00 | 37.00 | 59.50 | 34.60 | | |
| | GPT-X3-150M *(ref)* | 59.64 | 31.31 | 46.16 | 71.33 | 50.90 | | |
| | SmolLM2-135M *(ref)* | 58.63 | 29.69 | 43.22 | 68.44 | 39.20 | | |
| | LFM-2.5-230M-Base *(ref)* | 59.72 | 34.98 | 39.29 | 63.38 | 36.60 | | |
| | void.1 *(ref)* | 49.32 | 29.35 | 39.46 | 67.19 | 43.70 | | |
| Training Graph: | |
|  | |
| Measured checkpoint progression (`180k -> 700k` at `1024` ctx pretraining, followed by `Step 701k / Ctx4k step 1,000` at `4096` ctx): | |
| | Milestone | Total Steps | Tokens Seen | Validation Loss | Perplexity | Top-1 Acc | | |
| | :--- | ---: | ---: | ---: | ---: | ---: | | |
| | `180k` (1024 ctx) | 180,692 | 3.26 B | 3.8763 | 48.25 | 32.60% | | |
| | `404k` (1024 ctx) | 404,057 | 6.91 B | 3.0975 | 22.14 | 42.53% | | |
| | `492k` (1024 ctx) | 492,000 | 8.35 B | 2.6891 | 14.72 | 49.67% | | |
| | `520k` (1024 ctx) | 519,500 | 8.80 B | 2.6812 | 14.60 | 49.76% | | |
| | `554k` (1024 ctx) | 554,000 | 9.37 B | 2.6518 | 14.18 | 50.31% | | |
| | `609k` (1024 ctx) | 609,000 | 10.27 B | 2.6383 | 13.99 | 50.52% | | |
| | `674k` (1024 ctx) | 674,000 | 11.33 B | 2.6323 | 13.91 | 50.70% | | |
| | `700k` (1024 ctx) | 700,000 | 11.76 B | 2.6323 | 13.91 | 50.70% | | |
| | **`701k` (`Ctx4k step 1,000`, 4096 ctx)** | **701,000** | **12.02 B** | **2.2459** | **9.45** | **57.70%** | | |
| Running using llamacpp: | |
| Katana uses custom ops (`fuser` architecture: `ctx_gate`, `GaussianMod`, optional `GGML_OP_FUSER_PHASE_ROT`, `theta^2` RoPE base, and BPE prefix-space handling) implemented in our custom `llama.cpp` fork. Full patch spots and porting instructions live in `integrations/Integrationpatchspots.txt` and `integrations/LLAMACPP_INTEGRATION.md`. | |
| 1. Build the custom `llama.cpp` with CUDA: | |
| ```bash | |
| cmake -B build -DGGML_CUDA=ON -DCMAKE_BUILD_TYPE=Release | |
| cmake --build build --config Release -j $(nproc) | |
| ``` | |
| 2. Run inference using a converted `.gguf` build (`fuser.kaprekar.mode = "none"` recommended for exact training parity): | |
| ```bash | |
| ./build/bin/llama-cli \ | |
| -m katana-1b.gguf \ | |
| -c 4096 -ngl 99 \ | |
| -p "The area of a circle is" \ | |
| -n 128 --temp 0.6 --top-k 40 | |
| ``` | |
| 3. Or launch an OpenAI-compatible local endpoint: | |
| ```bash | |
| ./build/bin/llama-server \ | |
| -m katana-1b.gguf \ | |
| -c 4096 -ngl 99 --host 127.0.0.1 --port 8080 | |
| ``` | |
| --------------------------------------------------------------- | |
| License: | |
| Apache License 2.0 (see LICENSE) — individuals and commercial companies are free to use, modify, edit, train, and finetune Katana-1.1B. | |
| Links: | |
| OpenBlade - www.openblade.org | |
| iRunStudio - www.irun.studio | |
| Credits: | |
| Lead engineer: Jassim Ibrahim Farooqi | |
| Organizations: iRun Studio, OpenBlade, | |
| --------------------------------------------------------------- | |