Text Generation
GGUF
Japanese
gpt2
japanese
character-level
no-bpe
base
ollama
llama.cpp
from-scratch

makellm-ja-char-200m

日本語は後半に書いてあります。 English first; Japanese below.

A from-scratch, character-level Japanese language model (~209.5M parameters), pre-trained on consumer AMD hardware. No BPE / no subword tokenizer — every token is a single Unicode character.

This is a base (foundation) language model, not an instruction-tuned chat model. It continues Japanese text. Chat-finetuned variants: JK persona / neutral adult.

  • Author: 内田勉 (Tsutomu Uchida)
  • Type: Decoder-only Transformer (GPT-2 style), character-level
  • Parameters: 209,520,640
  • Language: Japanese (ja)
  • Tokenizer: character-level, vocabulary 7,280 (no BPE)
  • Context length: 512 characters
  • Training: from scratch, fp32, ~90 h on a single Radeon 8060S (ROCm)

TL;DR

This model was trained entirely from scratch — no pretrained weights, no external tokenizer — as a study in how far a small, fully self-built Japanese LM can go on a single consumer APU. It uses character-level tokenization, so the "vocabulary" is just the 7,280 distinct characters that appear in the corpus; there is no BPE/subword merging step at all.


Architecture

A standard GPT-2-style decoder-only Transformer.

Component Value
Architecture Decoder-only Transformer (GPT-2 style)
Parameters 209,520,640 (~210M)
Layers (n_layer) 16
Embedding dim (n_embd) 1024
Attention heads (n_head) 16 (head dim 64)
Context window (block_size) 512 tokens (= 512 characters)
Vocabulary 7,280 (character-level)
Positional encoding learned absolute
Normalization pre-LayerNorm
MLP 4× hidden (1024 → 4096 → 1024), GELU
Weight tying token embedding ↔ output head
Init residual projections scaled by 1/√(2·n_layer)
Precision fp32
Attention impl. eager (math-equivalent to SDPA)

Implementation: a compact ~250-line model.py (nanoGPT-lineage), no external modeling library.

Why character-level (no BPE)?

  • No tokenizer artifacts / no OOV merges. Each token is one character; the model sees raw Japanese exactly as written.
  • Transparency & reproducibility. The "vocabulary" is simply the set of characters in the corpus (kana, kanji, ASCII, common symbols).
  • Trade-off: sequences are longer (1 char = 1 token), so the 512-token context covers ~512 characters, and the model must learn word/phrase structure from characters. This is intentional for the from-scratch study.

Training data

The model was pre-trained on a ~6.17 billion-character Japanese corpus (internally called cleancc3), mixed from three public sources:

Source What it is License / status
Japanese Wikipedia encyclopedic articles CC BY-SA
Aozora Bunko (青空文庫) copyright-expired Japanese literature public domain
CC-100 (Japanese) web text derived from Common Crawl Common Crawl–derived (research corpus)
  • Total: ~6.17B characters → split train ≈ 5.55B / validation ≈ 0.617B characters.
  • Stored as uint16 character-id binaries (*_train.bin / *_val.bin).

Data processing pipeline

  1. Collect raw text from the three sources (Wikipedia dump, Aozora texts, CC-100 Japanese shard).
  2. Clean / denoise (text_clean.py):
    • Unicode NFKC normalization.
    • Strip control / format / private-use / unassigned code points (Unicode categories Cc/Cf/Co/Cn — ~963k code points removed from the map).
    • Remove garbled fragments and boilerplate noise typical of web crawls.
  3. Build the character vocabulary from the cleaned corpus → 7,280 characters.
  4. Character-tokenize the whole corpus with a NumPy lookup table (codepoint → id), skipping any out-of-vocabulary characters, and write the train/val binaries.

Note on quality: a separate quality-classifier pipeline (LLM-labeled sample → lightweight classifier → corpus-wide filtering, FineWeb-Edu style) was also developed to produce a higher-quality "premium" subset of the Japanese web data. This 200M model was trained on the standard cleancc3 mix described above.


Training procedure

Setting Value
Objective next-character prediction (cross-entropy)
Optimizer AdamW, lr = 3e-4 (constant)
Gradient clipping 1.0 (global norm)
Batch size 16 sequences × 512 tokens
Iterations 50,000
Dropout 0.1
Precision fp32
Seed 1337
Hardware AMD Ryzen AI MAX+ 395 / Radeon 8060S iGPU (gfx1151, RDNA 3.5), PyTorch ROCm
Wall-clock ~90 hours
Final validation loss 2.0180 (character-level cross-entropy)

Compute note (honest): training was time-limited. At 50,000 steps × 8,192 tokens/step the model saw only ~0.41B tokens — far below a Chinchilla-optimal budget for 200M params. The model is therefore deliberately under-trained relative to its size; quality reflects the single-APU compute budget, not the architecture's ceiling.


Intended use & limitations

Intended use

  • Japanese text continuation / next-character generation.
  • A base model to fine-tune (e.g., chat, domain adaptation).
  • Education & research: a fully transparent, reproducible from-scratch small LM.

Limitations

  • Not instruction-tuned: it is not a chat assistant and will not reliably follow instructions.
  • Small & under-trained: limited factual accuracy and long-range coherence; the 512-character context is short.
  • Character-level generation can occasionally produce non-words or drift.
  • Trained on web/encyclopedic/literary Japanese — may reflect biases of those sources.
  • Educational/hobby project; not for production or high-stakes use.

How to use

This repository distributes the F16 GGUF and an Ollama Modelfile. Set the context to 512 (num_ctx 512). This base model completes text; it does not use the chat variants' user/bot template.

hf download Sido/makellm-ja-char-200m \
    makellm-ja-char-200m.f16.gguf Modelfile --local-dir ./makellm-base
cd makellm-base
ollama create makellm-200m-base -f Modelfile
ollama run makellm-200m-base "日本の四季は"

For llama.cpp, load makellm-ja-char-200m.f16.gguf with a 512-token context and use text-completion mode. In LM Studio, import the GGUF and use a raw prompt without a chat template. Training checkpoints, source code, and training corpora are not included in this model repository.


License & data provenance

  • Model weights: CC BY-SA 4.0 (research / educational release; share-alike, consistent with the CC BY-SA Japanese-Wikipedia training data).
  • Training-data provenance & redistribution:
    • Japanese Wikipedia — CC BY-SA.
    • Aozora Bunko (青空文庫) — public domain (copyright-expired works).
    • CC-100 (Japanese) — no explicit license; derived from Common Crawl, governed by the Common Crawl Terms of Use and the copyright of the original source websites.
    • The weights are released under the license above, but no license is granted over the underlying corpora, and the training corpora / tokenized binaries (*_train.bin, *_val.bin) are NOT redistributed here. Non-commercial educational/research artifact; review the source terms before reuse.

Citations (CC-100)

  • Wenzek, G. et al. (2020). CCNet: Extracting High Quality Monolingual Datasets from Web Crawl Data. LREC.
  • Conneau, A. et al. (2020). Unsupervised Cross-lingual Representation Learning at Scale. ACL.

Acknowledgements

Built from scratch by 内田勉 (Tsutomu Uchida). Architecture lineage: nanoGPT-style GPT-2. Trained on AMD Ryzen AI / Radeon hardware via ROCm.



(日本語)makellm-ja-char-200m

AMDのコンシューマ機でフルスクラッチ学習した文字単位(character-level)の日本語言語モデル(約2.095億パラメータ)。BPE・サブワード分割は一切使わず、1トークン=1文字です。

本モデルは「ベース(事前学習)モデル」であり、指示追従のチャットモデルではありません。日本語テキストの続きを生成します。会話版:女子高生ペルソナ/中立な大人。

  • 作者: 内田勉 (Tsutomu Uchida)
  • 種別: デコーダのみTransformer(GPT-2系)・文字単位
  • パラメータ: 209,520,640
  • 言語: 日本語
  • トークナイザ: 文字単位・語彙7,280(BPE不使用)
  • コンテキスト長: 512文字
  • 学習: スクラッチ・fp32・Radeon 8060S 単体で約90時間(ROCm)

特徴

事前学習の重みも外部トークナイザも使わず、完全に自作で「単一のコンシューマAPUでどこまで日本語LMを作れるか」を試したプロジェクトです。文字単位なので語彙は「コーパスに出現した7,280文字」そのもの=サブワード結合の工程がありません。

アーキテクチャ

標準的なGPT-2系のデコーダのみTransformer。

項目 値
構造 デコーダのみTransformer(GPT-2系)
パラメータ 209,520,640(約210M)
層数 (n_layer) 16
埋め込み次元 (n_embd) 1024
ヘッド数 (n_head) 16(ヘッド次元64)
コンテキスト (block_size) 512トークン(=512文字)
語彙 7,280(文字単位)
位置符号 学習型・絶対位置
正規化 pre-LayerNorm
MLP 4倍(1024→4096→1024), GELU
重み共有 入力埋め込み↔出力ヘッド
初期化 残差出力を 1/√(2·n_layer) でスケール
精度 fp32

なぜ文字単位(BPEなし)か

  • トークナイザ由来の癖・未知語結合がなく、生の日本語をそのまま学習。
  • 語彙=コーパスの文字集合のみ=透明で再現容易。
  • 代償:系列が長くなる(1文字=1トークン)ので512トークン=約512文字。単語・句構造を文字から学ぶ必要がある(本研究の意図)。

学習データ

約61.7億文字の日本語コーパス(社内名 cleancc3)。3つの公開ソースの混合:

ソース 内容 ライセンス/状態
日本語Wikipedia 百科事典記事 CC BY-SA
青空文庫 著作権満了の文学作品 パブリックドメイン
CC-100(日本語) Common Crawl由来のWebテキスト Common Crawl由来(研究用コーパス)
  • 合計 約61.7億文字 → train 約55.5億 / val 約6.17億 に分割。uint16 の文字ID列として保存。

データ加工パイプライン

  1. 収集:3ソースから生テキストを取得。
  2. ノイズ除去(text_clean.py):NFKC正規化/制御・書式・私用・未割当のコードポイント(Unicodeカテゴリ Cc/Cf/Co/Cn 約963k点)を除去/Web由来の文字化け・定型ノイズを除去。
  3. 文字語彙の構築:クリーン後コーパスから 7,280文字。
  4. 文字トークナイズ:codepoint→id のNumPy LUTで全文を変換(語彙外文字はスキップ)→ train/val バイナリを出力。

補足:別途、品質分類器パイプライン(LLMで少量採点→軽量分類器→全コーパスをフィルタ。FineWeb-Edu方式)も開発し、日本語Webデータの高品質「premium」サブセットを作成済みです。ただし本200Mモデルは上記の標準 cleancc3 混合で学習しています。

学習手順

設定 値
目的関数 次文字予測(交差エントロピー)
最適化 AdamW, lr=3e-4(定数)
勾配クリップ 1.0(全体ノルム)
バッチ 16系列 × 512トークン
反復 50,000
ドロップアウト 0.1
精度 fp32
シード 1337
ハード AMD Ryzen AI MAX+ 395 / Radeon 8060S(gfx1151, RDNA3.5), PyTorch ROCm
実時間 約90時間
最終val損失 2.0180(文字単位の交差エントロピー)

計算量について(正直な注記):時間制約付きの学習で、50,000ステップ×8,192トークン=約4.1億トークンしか見ていません(200Mに対しChinchilla最適より大幅に少ない)。よってサイズの割に意図的に過小学習で、品質は単一APUの計算予算を反映したものです。

想定用途と制約

想定用途:日本語の続き生成/fine-tuneの土台/教育・研究(透明で再現可能な自作小型LM)。

制約:

  • 指示追従なし(チャット非対応)。
  • 小型・過小学習:事実性・長距離一貫性に限界。512文字と短い。
  • 文字単位生成のため、たまに非単語や脱線が出る。
  • Web/百科/文学の日本語で学習=それらの偏りを反映しうる。
  • 教育・趣味プロジェクト。本番・高リスク用途には非推奨。

使い方

このリポジトリには F16 GGUF と Ollama 用の Modelfile を同梱しています。実行時はコンテキストを 512(num_ctx 512)にします。ベースモデルなので、会話版の user/bot テンプレートは使いません。

hf download Sido/makellm-ja-char-200m \
    makellm-ja-char-200m.f16.gguf Modelfile --local-dir ./makellm-base
cd makellm-base
ollama create makellm-200m-base -f Modelfile
ollama run makellm-200m-base "日本の四季は"

llama.cpp では文脈長512・テキスト補完として使います。LM Studio ではGGUFを読み込み、チャットテンプレートなしの生のプロンプトを使用してください。このモデルリポジトリには、学習チェックポイント・ソースコード・学習コーパスは含めていません。

ライセンスとデータ来歴

  • モデル重み: CC BY-SA 4.0(研究・教育目的。継承(ShareAlike)=CC BY-SAの日本語Wikipedia学習データと整合)。
  • 学習データ来歴と再配布:
    • 日本語Wikipedia — CC BY-SA。
    • 青空文庫 — パブリックドメイン(著作権満了作品)。
    • CC-100(日本語) — 明示ライセンスなし。Common Crawl由来で、Common Crawl 利用規約と各ソースサイトの著作権に従う。
    • モデル重みは上記ライセンスで公開するが、元コーパスにライセンスを付与するものではなく、本公開には学習コーパス/トークナイズ済みバイナリ(*_train.bin・*_val.bin)を同梱・再配布しない。非商用の教育・研究成果物。再利用前に各ソースの条件を確認すること。

引用(CC-100)

  • Wenzek, G. et al. (2020). CCNet: Extracting High Quality Monolingual Datasets from Web Crawl Data. LREC.
  • Conneau, A. et al. (2020). Unsupervised Cross-lingual Representation Learning at Scale. ACL.

謝辞

内田勉 (Tsutomu Uchida) によるフルスクラッチ実装。アーキテクチャ系譜:nanoGPT系GPT-2。AMD Ryzen AI / Radeon(ROCm)で学習。

Downloads last month
24
GGUF
Model size
0.2B params
Architecture
gpt2
Hardware compatibility
Log In to add your hardware

16-bit

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

Datasets used to train Sido/makellm-ja-char-200m