KAWK50M-Project / scripts /build_model_card.py
Infinity08's picture
Add files using upload-large-folder tool
91ac3cc verified
Raw History Blame Contribute Delete
6.22 kB
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any
from kawk50m.cli import configure_utf8_stdio
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Build the final KAWK-1.5-50M Korean model card."
)
parser.add_argument("--checkpoint", required=True)
parser.add_argument("--base-checkpoint", required=True)
parser.add_argument("--base-evaluation", required=True)
parser.add_argument("--base-byte-evaluation", required=True)
parser.add_argument("--evaluation", required=True)
parser.add_argument("--byte-evaluation", required=True)
parser.add_argument("--base-manifest", required=True)
parser.add_argument("--cpt-manifest", required=True)
parser.add_argument("--rag-state", required=True)
parser.add_argument("--chat-state", required=True)
parser.add_argument("--output", required=True)
return parser.parse_args()
def read_json(path: str) -> dict[str, Any]:
value = json.loads(Path(path).read_text(encoding="utf-8"))
if not isinstance(value, dict):
raise TypeError(f"Expected a JSON object: {path}")
return value
def metric(value: Any, digits: int = 6) -> str:
if isinstance(value, (int, float)):
return f"{float(value):.{digits}f}"
return "n/a"
def main() -> None:
configure_utf8_stdio()
args = parse_args()
checkpoint = Path(args.checkpoint).resolve()
base_checkpoint = Path(args.base_checkpoint).resolve()
base_eval = read_json(args.base_evaluation)
base_byte = read_json(args.base_byte_evaluation)
final_eval = read_json(args.evaluation)
final_byte = read_json(args.byte_evaluation)
base_manifest = read_json(args.base_manifest)
cpt_manifest = read_json(args.cpt_manifest)
rag_state = read_json(args.rag_state)
chat_state = read_json(args.chat_state)
text = f"""---
language:
- ko
pipeline_tag: text-generation
library_name: transformers
tags:
- llama
- korean
- base-model
- long-context
---
# KAWK-1.5-50M Korean Base
KAWK-1.5-50M은 한국어 중심 문서로 처음부터 학습한 51,542,528
파라미터의 decoder-only Llama 계열 BASE 모델입니다. 1,024 토큰
컨텍스트에서 20B 토큰 사전학습을 수행한 뒤, 같은 가중치를 5,120 토큰
컨텍스트로 확장하여 3B 토큰을 추가 학습했습니다.
이 모델은 지시 튜닝 모델이 아닙니다. 입력 뒤의 텍스트를 이어 쓰는 BASE
모델이며, 질문에 정확히 답하거나 안전한 대화를 보장하지 않습니다.
## Architecture
| Item | Value |
|---|---:|
| Parameters | 51,542,528 |
| Vocabulary | 20,000 |
| Layers | 14 |
| Hidden / MLP | 512 / 1,408 |
| Attention / KV heads | 8 / 4 |
| Head dimension | 64 |
| Context | 5,120 |
| Position encoding | RoPE, linear factor 5 |
| Activation / norm | SwiGLU(SiLU) / RMSNorm |
| Tied embeddings | yes |
The tokenizer is a Korean-focused SentencePiece Unigram tokenizer with NFC
input normalization and byte fallback. Dedicated English, source-code, and
mathematics corpora were not used. Latin letters and numbers naturally
embedded in Korean documents were retained.
## Training
- Base checkpoint: `{base_checkpoint}`
- Final checkpoint: `{checkpoint}`
- Base corpus tokens: {int(base_manifest.get("total_tokens", 0)):,}
- Base pretraining budget: 20,000,000,000 tokens at context 1,024
- Long-context CPT mix: {int(cpt_manifest.get("total_train_tokens", 0)):,} tokens
- Long-context CPT budget: 3,000,000,000 tokens at context 5,120
- Precision: BF16
- Hardware: one NVIDIA GeForce RTX 5090
The long-context mix contains 2.9B Korean web/document tokens and 100M
strictly filtered structured Korean tokens:
- Korean RAG: {int(rag_state.get("tokens_written", 0)):,} tokens,
accepted rows {int(rag_state.get("counts", {}).get("accepted", 0)):,}
- Korean chat: {int(chat_state.get("tokens_written", 0)):,} tokens,
accepted rows {int(chat_state.get("counts", {}).get("accepted", 0)):,}
ChatML markers were converted to plain Korean role labels. Rows containing
code fences, LaTeX patterns, code/math-heavy text, disallowed licenses, or
English-heavy content were rejected.
## Data lineage and attribution
- `HuggingFaceFW/fineweb-2`, subset `kor_Hang`, revision
`af9c13333eb981300149d5ca60a8e9d659b276b9`
(ODC-By 1.0; Common Crawl terms also apply)
- `mkd-chanwoo/keural-rag-chatml-ko`, revision
`aa9023d231a3451d25135d5aa84b12b48ca06450`
(accepted rows: CC-BY-4.0)
- `Mkd-Yonas/keural-SFT-chatml-ko-v1`, revision
`c56d7885efb37799deb1ecba471e4f6bf263852e`
(only rows with explicitly allowed permissive licenses were accepted)
Users distributing the model should preserve these attributions and review
the upstream dataset terms. The project source code license and the model
weight release license should be stated separately at publication time.
## Evaluation
| Checkpoint | Context | Validation loss | Perplexity | Bits / UTF-8 byte |
|---|---:|---:|---:|---:|
| 20B base | 1,024 | {metric(base_eval.get("validation_loss"))} | {metric(base_eval.get("validation_perplexity"))} | {metric(base_byte.get("bits_per_utf8_byte"))} |
| 3B long CPT | 5,120 | {metric(final_eval.get("validation_loss"))} | {metric(final_eval.get("validation_perplexity"))} | {metric(final_byte.get("bits_per_utf8_byte"))} |
`bits / UTF-8 byte` is reported on the fixed ordered Korean validation
documents. Generation samples are BASE-model continuations, not instruction
following scores.
## Limitations
- At 50M parameters, factual coverage and multi-step reasoning are limited.
- The model may generate incorrect, repetitive, biased, private, or unsafe text.
- Web data can contain errors and cultural or temporal bias despite filtering.
- A 5,120-token configuration does not guarantee reliable retrieval across the
entire context; task-specific long-context evaluation is still required.
- Do not use the model as an authority for medical, legal, financial, or safety
decisions.
"""
output = Path(args.output)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(text, encoding="utf-8")
print(output.resolve())
if __name__ == "__main__":
main()