Sillok-LM 350M: Causal Language Model for the Annals of the Joseon Dynasty

조선왕조실록 인과적 언어모델 (Sillok-LM 350M)

License: Apache-2.0 Parameters Architecture Sillok-100M GitHub Live Web Studio

🌐 English Model Card | 🇰🇷 한국어 모델 설명


🌐 English Model Card

1. Model Summary

Sillok-LM 350M (347.1M parameters) is a decoder-only causal language model trained from random initialization on the complete digital corpus of the Annals of the Joseon Dynasty (Joseon Wangjo Sillok, 1392–1863).

Built with a modern Llama-3-style architecture (RoPE, GQA, SwiGLU, RMSNorm) and sharing the custom 32K Byte-Level BPE tokenizer of Sillok-LM 100M, Sillok-LM 350M scales model capacity to 26 layers and 1,024 hidden dimensions for digital humanities research, historical text imputation, and stylistic generation of Classical Chinese historiography.

Model Architecture & Specs

Property Value
Model Type Llama-3 Style Decoder-only Transformer (LlamaForCausalLM compatible)
Parameters 347,132,928 (~347.1M, tied word embeddings)
Layers / Hidden / Intermediate 26 layers / 1,024 hidden dim / 3,072 intermediate dim
Attention 16 query heads, 4 key-value heads (Grouped-Query Attention, 4:1)
Max Sequence Length 1,024 tokens (rope_theta: 500,000.0, rms_norm_eps: 1e-5)
Tokenizer 32,768 vocab custom Byte-Level BPE (PreTrainedTokenizerFast, Hanja & Hangul)
Exported Weight Format FP16 safetensors (model.safetensors)
Training Checkpoint Step 5,000 (best.pt, final evaluation checkpoint)
Best Validation Loss 3.2509 (Perplexity: 25.81)
Author & Research Gyungmin Jo (조경민 / Academy of Korean Studies, AKS-DHLAB)

Sillok-LM Model Family Comparison

Model Parameters Layers / Hidden / FFN Heads (Q / KV) Training Steps & Tokens Val Loss (PPL) Notes
Sillok-LM 100M 100.7M 12 / 768 / 2,048 12 / 4 4,400 steps (~760M tokens) 2.9128 (18.41) Compact baseline, multi-epoch
Sillok-LM 350M (this repo) 347.1M 26 / 1,024 / 3,072 16 / 4 5,000 steps (40.96M nominal token positions) 3.2509 (25.81) Scaled 350M research checkpoint (Apple Silicon MPS)

Note on Checkpoint Maturity: Sillok-LM 350M is a 5,000-step research checkpoint (40,960,000 nominal token positions, ~0.65 epochs of the 62.87M-token training split). Because it has seen fewer tokens than Sillok-LM 100M, its validation perplexity is higher while demonstrating 3.45× larger parameter capacity for continued pretraining or fine-tuning. Full run settings are recorded in training_metadata.json.


2. Training & Corpus Details

Training Configuration

  • Hardware & Framework: Apple M5 Pro, PyTorch 2.15.0 (MPS backend) with bfloat16 autocast
  • Optimizer & Schedule: AdamW (lr=3e-4, min_lr=3e-5, warmup_steps=300, weight_decay=0.1, seed=42)
  • Batch & Budget: batch_size=1, gradient_accumulation_steps=8, sequence_length=1,024 (8,192 tokens/step × 5,000 steps = 40,960,000 nominal token positions)
  • Evaluation: Every 500 steps (5 batches/eval across the validation split); best checkpoint selected at step 5,000 (best_validation_loss=3.2509, validation_perplexity=25.81)
  • Metadata & Provenance: training_metadata.json (source commit a50c06d)

Source Corpus

  • Corpus: National Institute of Korean History (NIKH) digital Annals of the Joseon Dynasty (673 XML volumes, 30 annals, 67,707,578 Classical Chinese characters)
  • Dataset Split: 381,701 total articles split via deterministic blake2b_streaming (seed=42) into 374,206 training articles (62,873,933 packed tokens) and 7,495 validation articles (1,252,864 packed tokens)
  • License Compliance: Identified in the project as KOGL Type 1 (공공누리 제1유형) and AI-training compliant. See the Sillok repository for full XML parsing and preprocessing pipelines.

3. Historiographical Foundations & Innovations

① Cross-Lingual Bi-Directional Modeling

  • The Nature of Article Titles: Original woodblock prints of the Annals contained no headlines. All article titles (<mainTitle>) in the corpus were curated by modern historians at the National Institute of Korean History (NIKH).
  • Consequently, Sillok-LM acts as a neural cross-lingual bridge between 15th–19th century Classical Chinese annals and modern Korean scholarly summaries:
    • Forward Drafting (<|title|>... ➔ <|hanja|>...): Given a monarch, date, and modern Korean title, drafts a Classical Chinese chronological entry.
    • Reverse Summarization (<|hanja|>... ➔ <|title|>...): Given raw Classical Chinese text, extracts an archival-grade modern Korean title.

② Historiographer Editorial Commentary (Saron, 史論)

  • Following Confucian historiography (Chunqiu-pilbeop, 春秋筆法), royal chroniclers appended moral and political verdicts (【史臣曰: "..."】).
  • Exactly 5,873 instances of official <postScript type="史論"> tags were extracted from NIKH XML standards and modeled via the dedicated <|postscript|> control token.

③ Chronological Date Context Hierarchy (Tree Inheritance)

  • Reflecting authentic Annals conventions (where the 60-Ganji cyclical day marker appears only on a day's first entry), our XML parser enforces strict DOM tree inheritance (level2(Year) ➔ level3(Month) ➔ level4(Day) ➔ level5(Article)), preventing cross-day date contamination.

4. Quickstart with Hugging Face Transformers

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "darkstar-11e/sillok-350m"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto",
)

# Forward Annals Generation: King Sejong promulgating Hunminjeongeum (Hangul)
prompt = (
    "<|bos|><|king|>세종실록(世宗實錄)"
    "<|date|>세종 28년 9월 29일 | 庚戌"
    "<|subject|>문화-출판/인쇄"
    "<|title|>어제 훈민정음 서책을 완성하여 인쇄하게 하다"
    "<|hanja|>"
)

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
    outputs = model.generate(
        **inputs,
        max_new_tokens=80,
        temperature=0.6,
        top_p=0.9,
        repetition_penalty=1.15,
        do_sample=True,
    )

print(tokenizer.decode(outputs[0], skip_special_tokens=False))

5. Prompt Control Tokens

The model follows the structured bibliographic schema of the Annals:

<|bos|><|king|>King<|date|>Date<|subject|>Subject<|title|>Title<|hanja|>Body<|postscript|>Commentary<|eos|>
Token Description Example
`< king >`
`< date >`
`< subject >`
`< title >`
`< hanja >`
`< postscript >`

6. Interactive Web Studio (https://sillok.tsar.kr)

Explore the Annals archive and Sillok-LM ecosystem directly in your browser:

  • Zero-Hallucination Archive Explorer: Full-text SQLite FTS5 / BM25 search across all 381,701 authentic Annals articles with direct NIKH cross-verification links.
  • Native <ruby> Phonetic Viewer: Renders phonetic Hangul readings above Classical Chinese characters with one-click toggle.
  • Historiographical Verdict Card: Dedicated viewer for the 5,873 official Confucian Saron commentaries.
  • Joseon Government Glossary: Instant definitions for premodern offices and terminology (Uijeongbu, Seungjeongwon, Uigeumbu).

7. Limitations & Historical Disclaimer

  • Research Checkpoint: Trained for 5,000 steps (40.96M nominal token positions) and released as an open research checkpoint and base model for continued pretraining or downstream fine-tuning.
  • Not a Historical Authority: Generated Classical Chinese text and historical statements may be inaccurate or fabricated (hallucinated). Always verify historical claims against official primary sources at the National Institute of Korean History (sillok.history.go.kr).
  • Base Causal LM: This model is not instruction-tuned or aligned for general chat; prompt it using the structured control token schema above.

🇰🇷 한국어 모델 설명

Sillok-LM 350M은 국사편찬위원회 조선왕조실록 전수 원문 XML(30종 실록, 381,701개 기사, 한문 6,770만 자)을 기반으로 무작위 초기화(From-Scratch)부터 학습한 3.47억(347.1M) 파라미터 규모의 고문헌 특화 Decoder-only 언어모델입니다. Sillok-LM 100M과 동일한 32K 한자·한글 특화 Byte-Level BPE 토크나이저를 공유하며, 26층·1,024 히든 차원의 Llama-3 스타일 아키텍처로 모델 용량을 확장했습니다.

모델 사양 및 학습 요약

항목 세부 내용
아키텍처 Llama-3 Style Decoder-only Transformer (LlamaForCausalLM 호환, RoPE · GQA · SwiGLU · RMSNorm)
파라미터 수 347,132,928 (~347.1M)
레이어 / 히든 / FFN 26층 / 1,024 히든 차원 / 3,072 중간 차원 (Attention 16 Q-Heads / 4 KV-Heads)
컨텍스트 / 토크나이저 최대 1,024 토큰 / 32,768 어휘 고문헌 특화 한자·한글 Byte-Level BPE
학습 환경 Apple M5 Pro, PyTorch 2.15.0 MPS, BF16 Autocast, AdamW (lr=3e-4 → 3e-5, warmup 300)
학습 스텝 및 토큰 5,000 steps (batch 1 × grad_accum 8 × seq 1,024 = 40,960,000 nominal token positions)
최적 검증 성능 Validation Loss 3.2509 / Perplexity 25.81 (best.pt, Step 5,000)
학습 데이터 분할 전체 381,701건 (374,206 학습 / 7,495 검증, 학습 스플릿 62,873,933 토큰)
배포 가중치 FP16 safetensors (training_metadata.json에 전체 메타데이터 수록)
연구 / 개발 조경민 (Gyungmin Jo / 한국학중앙연구원 디지털인문학연구소 AKS-DHLAB)

참고: Sillok-LM 350M은 Apple Silicon MPS 환경에서 5,000 스텝(4,096만 토큰) 학습된 연구용 체크포인트입니다. 더 많은 에포크를 학습한 경량 기준 모델이 필요하다면 Sillok-LM 100M(Val Loss 2.9128, PPL 18.41)을, 더 큰 표현력을 바탕으로 추가 사전학습·파인튜닝을 진행하려면 본 350M 모델을 활용하실 수 있습니다.

주요 연구 및 활용 목적

  1. 사료 결락 복원 (Historical Text Imputation): 훼손되거나 망실된 실록 기사의 원문 문맥 추정
  2. 연대·왕명별 양식 모사 (Stylistic Generation): 태조~순종 30대 국왕별 문체 및 시대별 간지(干支) 표기 생성
  3. 디지털 사관 사론 생성 (Historiographical Commentary): 실록 기사 말미 사관의 논평(<|postscript|>, 원전 5,873건 학습) 생성
  4. 역방향 국역 요약 (Reverse Title Extraction): 한문 사초 입력 시 국사편찬위원회 스타일의 한글 1줄 요약 제목 추출

한계 및 유의사항

  • 본 모델은 5,000 스텝 학습된 연구용 베이스 체크포인트이며, 역사적 사실을 보증하는 권위 있는 출처가 아닙니다.
  • 생성된 한문 기사나 인명·연대 정보에는 환각(Hallucination)이 포함될 수 있으므로, 역사적 사실 확인은 반드시 국사편찬위원회 공식 실록 원문(sillok.history.go.kr)을 통해 교차 검증해야 합니다.
  • 별도의 지시 튜닝(Instruction Tuning)이 적용되지 않은 인과적 언어모델이므로, 상단의 제어 토큰 스키마(<|bos|><|king|>...<|hanja|>) 형식에 맞춰 프롬프트를 입력하는 것을 권장합니다.

📜 License, Data Terms & Citation (라이선스 및 인용)

@misc{sillok-lm-350m,
  title  = {Sillok-LM 350M: Causal Language Model for the Annals of the Joseon Dynasty},
  author = {Jo, Gyungmin},
  year   = {2026},
  url    = {https://huggingface.co/darkstar-11e/sillok-350m}
}
Downloads last month
59
Safetensors
Model size
0.4B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support