Loading…
Loading…
A 125M-parameter language model trained from scratch on about 1 billion tokens of texts written before 1868: classical Japanese, Edo-period Japanese and Literary Chinese. It has never seen modern Japanese, English or anything from the web.
It is a research artifact for studying what a model learns from premodern text alone: its vocabulary, its "world knowledge" and its style. It also gives a period-faithful baseline for working with historical documents. It is a base model: it continues text and does not follow instructions. For a conversational version, see classical-smollm2-sft.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "kuramot6f/classical-smollm2-trunk"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16).eval()
inputs = tok("春はあけぼの", return_tensors="pt")
out = model.generate(**inputs, max_new_tokens=64, do_sample=True, top_p=0.95, temperature=0.8)
print(tok.decode(out[0], skip_special_tokens=True))
trust_remote_code=True is needed only for the small SentencePiece tokenizer wrapper
(classical_tokenizer.py). The model is a standard LlamaForCausalLM.
| architecture | Llama (SmolLM2-135M shape): 30 layers, hidden 576, 9 heads / 3 KV heads, MLP 1536 |
| parameters | 124.6M (tied input/output embeddings) |
| context | 8,192 positions (trained on 2,048-token sequences) |
| vocabulary | 32,000, classical-ja-tokenizer |
| training tokens | 1.00B: NDL 440M, Kanripo 427M, Wikisource 108M, Minna de Honkoku 25M |
training_config.json has the full configuration and
metrics.jsonl the per-step loss and learning rate.Weights and code: Apache-2.0.
Training data note: the model was trained on texts under several licenses. These are public domain (NDL OCR); CC BY-SA 4.0 (Kanripo, Wikisource, Minna de Honkoku); and CC BY-NC-SA 3.0 TW for CBETA-derived Buddhist texts, about 13% of the corpus tokens. See the dataset LICENSES. The license on the weights does not change the licenses of the training texts. If the model reproduces a passage from its training data, that passage stays under its original license.