File size: 21,817 Bytes
7695943 3fca9af 7695943 3fca9af 7695943 bc91024 9c2f514 7ba88e4 bc91024 8eaffae 7ba88e4 8eaffae 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af bc91024 8eaffae 293fa8d 8eaffae 3fca9af bc91024 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af bc91024 3fca9af 7ba88e4 3fca9af b7dc9d7 7ba88e4 6c50946 3fca9af 7ba88e4 3fca9af 6c50946 3fca9af b7dc9d7 6c50946 7ba88e4 3fca9af 6c50946 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af bc91024 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af 7ba88e4 35d95c0 6c50946 3fca9af 7ba88e4 3fca9af 7ba88e4 35d95c0 7ba88e4 b7dc9d7 05b268f b7dc9d7 6c50946 3fca9af 7ba88e4 3fca9af 7ba88e4 35d95c0 7ba88e4 b7dc9d7 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af bc91024 7ba88e4 bc91024 3fca9af 7ba88e4 3fca9af bc91024 7ba88e4 b7dc9d7 3fca9af bc91024 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af b7dc9d7 3fca9af 7ba88e4 bc91024 3fca9af bc91024 3fca9af 7ba88e4 3fca9af 000f1d8 6c50946 000f1d8 6c50946 7ba88e4 000f1d8 6c50946 7ba88e4 b7dc9d7 6c50946 b7dc9d7 3fca9af bc91024 3fca9af bc91024 7ba88e4 3fca9af bc91024 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af 7ba88e4 3fca9af 7ba88e4 b7dc9d7 7ba88e4 000f1d8 bc91024 6c50946 000f1d8 b7dc9d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | ---
language:
- ko
- lzh
license: cc-by-sa-4.0
library_name: transformers
tags:
- fill-mask
- text-generation
- sillok
- history
- korean-history
- classical-chinese
pipeline_tag: fill-mask
co2_eq_emissions:
emissions: 1.1662 # kg, 1-epoch sample run extrapolated to 10 epochs.
source: "codecarbon"
training_type: "from_scratch"
geographical_location: "South Korea, Seoul"
hardware_used: "1 x NVIDIA A100-PCIE-40GB"
---
datasets:
- "VERITABLE RECORDS of the JOSEON DYNASTY"
# **SillokBert: ์กฐ์ ์์กฐ์ค๋ก ํนํ ์ธ์ด ๋ชจ๋ธ**
# **SillokBert: A Language Model Specialized for Veritable Records of the Joseon Dynasty**
## **๋ชจ๋ธ ์ค๋ช
(Model Description)**
**SillokBert**์ `bert-base-multilingual-cased` ๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก, ๊ตญ์ฌํธ์ฐฌ์์ํ์์ ์ ๊ณตํ๋ ์กฐ์ ์์กฐ์ค๋ก ์๋ฌธ(ํ๋ฌธ) ์ ์ฒด ๋ฐ์ดํฐ์
์ Masked Language Modeling(MLM) ํ์คํฌ๋ก ์ถ๊ฐ ํ์ธํ๋(further fine-tuned)ํ ์ธ์ด ๋ชจ๋ธ์
๋๋ค. ๋ณธ ๋ชจ๋ธ์ ์กฐ์ ์์กฐ์ค๋ก์ ๋ฑ์ฅํ๋ ๊ณ ์ ํ ์ดํ(์ธ๋ช
, ์ง๋ช
, ๊ด์ง ๋ฑ), ๋ฌธ์ด์ฒด ์คํ์ผ, ๊ทธ๋ฆฌ๊ณ ๋ณต์กํ ๋ฌธ๋งฅ ๊ตฌ์กฐ๋ฅผ ๊น์ด ์๊ฒ ํ์ตํ๋๋ก ์ค๊ณ๋์์ต๋๋ค. ์ด๋ฅผ ํตํด ์ค๋ก ์๋ฌธ์ ๋น์นธ ์ถ๋ก , ์๋ฌธ ๊ต์ด ๋ฐ ๋ณต์, ์๋ฏธ์ ๊ฒ์, ํ
์คํธ ํน์ง ์ถ์ถ ๋ฑ ๋ค์ํ ์ญ์ฌํ ๋ฐ ๋์งํธ ์ธ๋ฌธํ ์ฐ๊ตฌ์ ๊ธฐ๋ฐ(foundational) ๋ชจ๋ธ๋ก ํ์ฉ๋ ์ ์๋ ์ ์ฌ๋ ฅ์ ๊ฐ์ง๋๋ค.
**SillokBert** is a language model based on `bert-base-multilingual-cased`, further fine-tuned on the entire Veritable Records of the Joseon Dynasty (Annals of the Joseon Dynasty) original text (Classical Chinese) dataset provided by the National Institute of Korean History using the Masked Language Modeling (MLM) task. This model is designed to deeply learn the unique vocabulary (personal names, place names, official titles, etc.), literary style, and complex contextual structures found in the Annals. It holds the potential to be utilized as a foundational model for various historical and digital humanities research tasks, such as fill-in-the-blank inference, text correction and restoration, semantic search, and feature extraction from the original Sillok texts.
๋ณธ ๋ชจ๋ธ์ ํ๊ตญํ์ค์์ฐ๊ตฌ์ ๋์งํธ์ธ๋ฌธํ์ฐ๊ตฌ์์ "ํ๊ตญ ๊ณ ์ ๋ฌธํ ๊ธฐ๋ฐ ์ง๋ฅํ ํ๊ตญํ ์ธ์ด๋ชจ๋ธ ๊ฐ๋ฐ" ํ๋ก์ ํธ์ ์ผํ์ผ๋ก ๊ฐ๋ฐ๋์์ต๋๋ค. ๋ณธ ๋ชจ๋ธ์ ํ์ต ํ๊ฒฝ์ ๊ณผํ๊ธฐ์ ์ ๋ณดํต์ ๋ถ ์ ๋ณดํต์ ์ฐ์
์งํฅ์์ 2025๋
๊ณ ์ฑ๋ฅ์ปดํจํ
์ง์(GPU) ์ฌ์
(G2025-0450)์ ์ง์์ ๋ฐ์์ต๋๋ค. ์ฐ๊ตฌ์ ํ์์ ์ธ ๊ณ ์ฑ๋ฅ ์ปดํจํ
ํ๊ฒฝ์ ์ง์ํด์ฃผ์
์ ์ง์ฌ์ผ๋ก ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
This model was developed as part of the "Development of an Intelligent Korean Studies Language Model based on Classical Korean Texts" project at the Digital Humanities Research Institute, The Academy of Korean Studies. The training environment for this model was supported by the 2025 High-Performance Computing Support (GPU) Program of the National IT Industry Promotion Agency (NIPA) (No. G2025-0450). We sincerely appreciate the support for providing the high-performance computing environment essential for our research.
## **ํ์ฉ ๋ฐฉ์ (Intended Use)**
#### **์ง์ ์ฌ์ฉ (Direct Use)**
`fill-mask` ํ์ดํ๋ผ์ธ์ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ์ ์ธ์ด์ ์ดํด๋๋ฅผ ์ง์ ํ
์คํธํ๊ฑฐ๋, ํน์ ๋ฌธ๋งฅ์์ ๊ฐ์ฅ ํ๋ฅ ์ด ๋์ ๋จ์ด๋ฅผ ์์ธกํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค.
You can use the `fill-mask` pipeline to directly test the model's linguistic understanding or to predict the most probable words in a specific context.
```
# !pip install transformers torch # ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ค์น๋์ง ์์ ๊ฒฝ์ฐ ์ฃผ์์ ํด์ ํ๊ณ ์คํํ์ธ์.
# transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ํ์ํ pipeline๊ณผ AutoTokenizer๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
from transformers import pipeline, AutoTokenizer
# ํ๊น
ํ์ด์ค Hub์ ์๋ ๋ชจ๋ธ๊ณผ ํ ํฌ๋์ด์ ์ ๊ฒฝ๋ก๋ฅผ ์ง์ ํฉ๋๋ค.
model_path = "ddokbaro/SillokBert"
# ์ง์ ๋ ๊ฒฝ๋ก์์ ํ ํฌ๋์ด์ ๋ฅผ ๋ถ๋ฌ์ต๋๋ค.
tokenizer = AutoTokenizer.from_pretrained(model_path)
# "fill-mask" ์์
์ ์ํ ํ์ดํ๋ผ์ธ์ ์์ฑํฉ๋๋ค.
# ์ด ๋, ๋ฏธ๋ฆฌ ๋ถ๋ฌ์จ ๋ชจ๋ธ ๊ฒฝ๋ก์ ํ ํฌ๋์ด์ ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
fill_mask = pipeline("fill-mask", model=model_path, tokenizer=tokenizer)
# ์์ ๋ฌธ์ฅ (์กฐ์ ์์กฐ์ค๋ก ์คํ์ผ)
# ไธๆฐ, "ไบ ็ถ ็ก [MASK] ไนๆ." (์๊ธ๊ป์ ๋ง์ํ์๊ธธ, '๋ด๊ฒ๋ [MASK]ํ ๋ป์ด ์๋ค.')
text = "ไธๆฐ, \"ไบ ็ถ ็ก [MASK] ไนๆ.\""
# ํ์ดํ๋ผ์ธ์ ์คํํ์ฌ ๋น์นธ([MASK])์ ๋ค์ด๊ฐ ๋จ์ด๋ฅผ ์ถ๋ก ํฉ๋๋ค.
results = fill_mask(text)
# ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
print(f"'{text}' ๋ฌธ์ฅ์ ๋ํ ์ถ๋ก ๊ฒฐ๊ณผ:")
for item in results:
# 'sequence'๋ [MASK]๊ฐ ์ฑ์์ง ์ ์ฒด ๋ฌธ์ฅ, 'score'๋ ํด๋น ์์ธก์ ์ ๋ขฐ๋ ์ ์์
๋๋ค.
print(f" - ๋ฌธ์ฅ: {item['sequence']}, ์ ์: {item['score']:.4f}, ํ ํฐ: {item['token_str']}")
```
#### **๋ค์ด์คํธ๋ฆผ ํ์คํฌ ํ์ฉ (Downstream Use)**
๋ณธ ๋ชจ๋ธ์ ์กฐ์ ์์กฐ์ค๋ก ํ
์คํธ๋ฅผ ๋์์ผ๋ก ํ๋ ๋ค์ํ ๋ค์ด์คํธ๋ฆผ ํ์คํฌ์ ์ฌ์ ํ์ต ๋ชจ๋ธ๋ก ํ์ฉ๋ ์ ์์ต๋๋ค.
This model can be used as a pre-trained model for various downstream tasks targeting the text of Veritable Records of the Joseon Dynasty.
* ๋ฌธ์ ๋ถ๋ฅ (Text Classification): ํน์ ์ฃผ์ (์: ๊ตฐ์ฌ, ์ธ๊ต, ์๋ก)์ ๋ํ ๊ธฐ์ฌ ๋ถ๋ฅ.
Classification of articles on specific topics (e.g., military, diplomacy, rituals).
* ๊ฐ์ฒด๋ช
์ธ์ (Named Entity Recognition): ์ธ๋ช
, ์ง๋ช
, ๊ด์ง๋ช
๋ฑ ๊ณ ์ ๋ช
์ฌ ์๋ ์ถ์ถ.
Automatic extraction of named entities such as personal names, place names, and official titles.
* ์๋ฏธ ๊ฒ์ (Semantic Search): ํค์๋ ๋งค์นญ์ ๋์ด ์๋ฏธ์ ์ผ๋ก ์ ์ฌํ ๊ธฐ์ฌ ๊ฒ์.
Semantic search for articles that are contextually similar, going beyond simple keyword matching.
## **ํ์ต ๋ฐ์ดํฐ (Training Data)**
#### **๋ฐ์ดํฐ ์ถ์ฒ ๋ฐ ์์ง (Data Source and Collection)**
* ์์ฒ ๋ฐ์ดํฐ (Source Data): ๊ณต๊ณต๋ฐ์ดํฐํฌํธ \- ๊ต์ก๋ถ ๊ตญ์ฌํธ์ฐฌ์์ํ\_์กฐ์ ์์กฐ์ค๋ก ์ ๋ณด\_์ค๋ก์๋ฌธ https://www.data.go.kr/data/15053647/fileData.do. ์ฐ๊ตฌ์ ํ ๋๊ฐ ๋ ๊ท์คํ ์๋ฃ๋ฅผ ์ ๊ณตํด์ฃผ์ ๊ต์ก๋ถ ๊ตญ์ฌํธ์ฐฌ์์ํ ์ธก์ ๊ฐ์ฌ์ ๋ง์์ ์ ํ๋ค.
We express our gratitude to the National Institute of Korean History (Ministry of Education) for providing the invaluable data that formed the foundation of this research.
* ๋ฐ์ดํฐ ๋ฒ์ ๋ฐ ์ฌํ์ฑ (Data Version and Reproducibility): ๋ณธ ์ฐ๊ตฌ๋ 2022๋
11์ 03์ผ์ ๋ฑ๋ก๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค. ๊ณต์ ๋ฐฐํฌ์ฒ์ ๋ฐ์ดํฐ๊ฐ ์
๋ฐ์ดํธ๋ ์ ์์ด, ์๋ฒฝํ ์ฌํ์ฑ์ ๋ณด์ฅํ๊ธฐ ์ํด ํ์ต์ ์ฌ์ฉ๋ ์๋ณธ XML ํ์ผ ์ ์ฒด๋ฅผ `raw_data/sillok_raw_xml.zip` ํ์ผ๋ก ์ ๊ณตํฉ๋๋ค. ๋ํ, ์ฆ์ ํ์ฉ ๊ฐ๋ฅํ ์ ์ฒ๋ฆฌ ์๋ฃ ํ
์คํธ ํ์ผ(`train.txt`, `validation.txt`, `test.txt`)์ `preprocessed_data/` ํด๋์์ ํ์ธํ์ค ์ ์์ต๋๋ค.
This research is based on the data registered on November 3, 2022\. As the data from the official distributor may be updated, we provide the entire original XML files used for training as `raw_data/sillok_raw_xml.zip` in this repository to ensure perfect reproducibility. Additionally, the preprocessed text files (`train.txt`, `validation.txt`, `test.txt`) ready for immediate use can be found in the `preprocessed_data/` folder.
#### **๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ (Data Preprocessing)**
`raw_data`์ ์๋ณธ XML์ ๋ค์๊ณผ ๊ฐ์ ๊ณผ์ ์ ๊ฑฐ์ณ `preprocessed_data`๋ก ๊ฐ๊ณต๋์์ต๋๋ค.
The original XML from `raw_data` was processed into `preprocessed_data` through the following steps:
1. ๊ตฌ์กฐ ๋ถ์ (Structural Parsing): `lxml` ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ์ฌ XML ํ์ผ์ ํ์ฑ.
Parsed XML files using the `lxml` library.
2. ๋ณธ๋ฌธ ์ถ์ถ (Text Extraction): ๊ฐ ๊ธฐ์ฌ(`level5`) ๋ด์ `paragraph` ํ๊ทธ์์ ํ
์คํธ๋ฅผ ์ถ์ถ.
Extracted text from the `paragraph` tags within each article (`level5`).
3. ์ฃผ์ ์ ์ธ (Annotation Exclusion): ์๋ฌธ์ ์๋ฏธ๋ฅผ ํด์น์ง ์์ผ๋ฉด์๋ ๋ชจ๋ธ ํ์ต์ ๋ฐฉํด๊ฐ ๋ ์ ์๋ ํ๋์ธ์ ์ฃผ์(`<annotation\>`) ๋ด์ฉ์ ์ถ์ถ ๊ณผ์ ์์ ๋ชจ๋ ์ ์ธํ์ฌ, ์์ํ ์์ ํ
์คํธ๋ง์ ํ์ต ๋์์ผ๋ก ์ผ์์ต๋๋ค.
To ensure the model learned purely from the original source text, modern annotations (`<annotation\>`) that could interfere with learning while not affecting the meaning of the original text were excluded during extraction.
4. ์ ์ (Normalization): ์ถ์ถ๋ ํ
์คํธ์์ ๋ถํ์ํ ๊ณต๋ฐฑ๊ณผ ์ค๋ฐ๊ฟ ๋ฌธ์๋ฅผ ์ ๊ทํ.
Normalized unnecessary whitespace and line breaks in the extracted text.
5. ํํฐ๋ง (Filtering): ์๋ฏธ ์๋ ๋ฌธ๋งฅ ํ์ต์ ์ํด ์ต์ ๊ธธ์ด 10์ ๋ฏธ๋ง์ ๊ธฐ์ฌ๋ ์ ์ธ.
Filtered out articles shorter than 10 characters to focus on meaningful contextual learning.
์์ธํ ์ ์ฒ๋ฆฌ ๋ก์ง๊ณผ ์ ์ฒด ์ฝ๋๋ ๋ณธ ๋ฆฌํฌ์งํ ๋ฆฌ์ ํจ๊ป ์
๋ก๋๋ `scripts/prepare_data.py` ์คํฌ๋ฆฝํธ์์ ํ์ธํ์ค ์ ์์ต๋๋ค.
The detailed preprocessing logic and the complete code can be found in the `scripts/prepare_data.py` script uploaded to this repository.
#### **๋ฐ์ดํฐ ํต๊ณ (Data Statistics)**
* **์ ์ฒด ๊ธฐ์ฌ ์ (Total Articles)**: 402,339
* **๋ฐ์ดํฐ** ๋ถํ **(Data Split \- 90/5/5)**:
* **ํ์ต (Train)**: 362,107 articles
* **๊ฒ์ฆ (Validation)**: 20,116 articles
* **ํ
์คํธ (Test)**: 20,116 articles
* **์ถ๊ฐ ์ ๋ณด (Additional Information)**:
* **์ด ๊ธ์ ์ (Total Characters)**: 66,322,312
* **์ดํ์ง ํฌ๊ธฐ (Vocabulary Size)**: 119,547
## **ํ์ต ์ ์ฐจ (Training Procedure)**
#### **ํ์ดํผํ๋ผ๋ฏธํฐ ์ต์ ํ (Hyperparameter Optimization \- HPO)**
๋ณธ ๋ชจ๋ธ์ ํ์ ๋ ์ฐ๊ตฌ ์์ ๋ด์์ ์ต์ ์ ์ฑ๋ฅ์ ๋์ถํ๊ธฐ ์ํด, ๋จ๊ณ์ ํ์(Staged Exploration) HPO ์ ๋ต์ ์ฑํํ์ต๋๋ค. ์ด๋ ๋์ ํ์ ๊ณต๊ฐ์์ ์ ์ง์ ์ผ๋ก ์ ๋งํ ํ๋ณด๊ตฐ์ ์ขํ๋๊ฐ๋ ๊น๋๊ธฐ(Funnel) ๋ฐฉ์์ ์ ๊ทผ๋ฒ์ผ๋ก, ์ฐ๊ตฌ์ ํจ์จ์ฑ๊ณผ ์ ๋ขฐ๋๋ฅผ ๋์์ ํ๋ณดํ๊ธฐ ์ํด ์ค๊ณ๋์์ต๋๋ค.
To derive optimal performance within limited research resources, this model adopted a Staged Exploration HPO strategy. This is a funnel-like approach that progressively narrows down promising candidates from a wide search space, designed to ensure both efficiency and reliability in the research.
##### **1๋จ๊ณ: ๊ด๋ฒ์ ํ์ (Stage 1: Broad Exploration)**
* ๋ชฉํ (Objective): ๋์ ํ์ดํผํ๋ผ๋ฏธํฐ ๊ณต๊ฐ์์ ์ฑ๋ฅ์ด ํ์ ํ ๋ฎ์ ์์ญ์ ๋น ๋ฅด๊ฒ ์๋ณํ๊ณ ๋ฐฐ์ .
To quickly identify and exclude underperforming regions from a wide hyperparameter space.
* ๋ฐฉ๋ฒ (Method): ์ ์ฒด ํ์ต ๋ฐ์ดํฐ์ 10%๋ง์ ์ฌ์ฉํ์ฌ ๊ฐ Trial์ ์ต๋ 20 ์คํ
์ด๋ผ๋ ๋งค์ฐ ์งง์ ์๊ฐ ๋์๋ง ํ์ต. ์ด ๋จ๊ณ์์๋ `learning_rate`(`1e-6` \~ `1e-3`), ์ ํจ ๋ฐฐ์น ํฌ๊ธฐ(16 \~ 512), `optimizer` ์ข
๋ฅ(`AdamW`, `Adafactor`) ๋ฑ ๋ชจ๋ธ ์ฑ๋ฅ์ ์ํฅ์ ๋ฏธ์น๋ ์ฃผ์ ํ์ดํผํ๋ผ๋ฏธํฐ์ ๋ํด ๊ฐ๋ฅํ ๋์ ํ์ ๋ฒ์๋ฅผ ์ค์ ํ์ฌ ์ ์ฌ์ ์ฑ๋ฅ ์์ญ์ ํฌ๊ด์ ์ผ๋ก ํ์ธํ์ต๋๋ค.
Each trial was trained for a very short period (max 20 steps) using only 10% of the total training data. A wide search range was set for key hyperparameters influencing model performance, such as `learning_rate` (`1e-6` to `1e-3`), effective batch size (16 to 512), and `optimizer` type (`AdamW`, `Adafactor`), to comprehensively identify potential performance areas.
* ๊ฒฐ๊ณผ (Result): ์ปดํจํ
์์ ๋ญ๋น๋ฅผ ์ต์ํํ๋ฉฐ, ํ์ ํ์์ ์ง์คํ ์ ๋งํ ํ๋ผ๋ฏธํฐ ์์ญ์ ๋ํ ์ด๊ธฐ ํต์ฐฐ ํ๋ณด (์ต์ `eval_loss` \~3.83).
Minimized computational waste and gained initial insights into promising parameter regions for subsequent focused searches (lowest `eval_loss` \~3.83).
##### **2๋จ๊ณ: ์ฌ์ธต ํ์ (Stage 2: Focused Search)**
* ๋ชฉํ (Objective): 1๋จ๊ณ์์ ์๋ณ๋ ์ ๋ง ์์ญ์ ๋์์ผ๋ก, ๋ ๋ง์ ๋ฐ์ดํฐ์ ํ์ต๋์ ํฌ์
ํ์ฌ ์ ๋ขฐ๋ ๋์ ํ๋ณด๊ตฐ์ ์์ถ.
To narrow down a reliable set of candidates by applying more data and training to the promising regions identified in Stage 1\.
* ๋ฐฉ๋ฒ (Method): ๋ฐ์ดํฐ์
์ 40%๋ฅผ ์ฌ์ฉํ์ฌ 2-4 ์ํฌํฌ ๋์ ํ์ต์ ์งํ. 1๋จ๊ณ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ์ผ๋ก ๋ค์๊ณผ ๊ฐ์ด ์ ๋งํ ํ์ดํผํ๋ผ๋ฏธํฐ ๊ณต๊ฐ์ ์ง์ค์ ์ผ๋ก ํ์ํ์ต๋๋ค.
Based on the results from Stage 1, a focused search was conducted in the promising hyperparameter space by training for 2-4 epochs using 40% of the dataset.
* **learning\_rate**: `2e-5` \~ `1e-4` (log-uniform)
* **effective\_batch\_size** (`per_device_train_batch_size` \~ `gradient_accumulation_steps`): 32 \~ 256
* **weight\_decay**: `0.0` \~ `0.1`
* **lr\_scheduler\_type**: `linear`, `cosine`, `constant_with_warmup`
* ๊ฒฐ๊ณผ (Result): `eval_loss`๊ฐ 1.8822๊น์ง ํฌ๊ฒ ํฅ์๋์์ผ๋ฉฐ, ์ต์ข
ํ๊ฐ๋ฅผ ์งํํ ์ต์์ 10๊ฐ์ ์ฐ์ํ ํ์ดํผํ๋ผ๋ฏธํฐ ์กฐํฉ์ ์ฑ๊ณต์ ์ผ๋ก ๋์ถ. ํ๋ผ๋ฏธํฐ ์ค์๋ ๋ถ์ ๊ฒฐ๊ณผ, `learning_rate`์ `weight_decay`๊ฐ ๋ชจ๋ธ ์ฑ๋ฅ์ ๊ฐ์ฅ ๊ฒฐ์ ์ ์ธ ์ํฅ์ ๋ฏธ์น๋ ํ๋ผ๋ฏธํฐ๋ก ํ์ธ๋์์ต๋๋ค. (์์ธ ๋ด์ฉ์ `hpo_visualizations/stage2_param_importances.html` ์ฐธ๊ณ )
The `eval_loss` was significantly improved to 1.8822, successfully identifying the top 10 hyperparameter combinations for final evaluation. Parameter importance analysis revealed that `learning_rate` and `weight_decay` were the most critical parameters affecting model performance. (See `hpo_visualizations/stage2_param_importances.html` for details).
##### **3๋จ๊ณ: ์ต์ข
๊ฒ์ฆ (Stage 3: Final Validation)**
* ๋ชฉํ (Objective): 2๋จ๊ณ์์ ์ ๋ณ๋ ์์ 10๊ฐ ํ๋ณด๋ฅผ ๋์์ผ๋ก ์ ์ฒด ๋ฐ์ดํฐ์
์ ๋ํ ์ค์ ์ฑ๋ฅ๊ณผ ๊ณผ์ ํฉ ์ง์ ์ ์ ๋ฐํ๊ฒ ์ธก์ ํ์ฌ ์ต์ข
๋ชจ๋ธ์ ํ์ .
To precisely measure the actual performance and overfitting points on the entire dataset for the top 10 candidates selected in Stage 2, thereby finalizing the model.
* ๋ฐฉ๋ฒ (Method): ์ ์ฒด ๋ฐ์ดํฐ์
(100%)์ ์ฌ์ฉํ์ฌ ๊ฐ ํ๋ณด๋ฅผ 10 ์ํฌํฌ ๋์ ํ์ต. ๋งค ์ํฌํฌ๋ง๋ค ๊ฒ์ฆ ์์ค์ ๊ธฐ๋กํ์ฌ ์ต์ ์ ์ฑ๋ฅ์ ๋ณด์ธ ์์ ์ ๋ชจ๋ธ์ ์ ์ฅ.
Each candidate was trained for 10 epochs using the entire dataset (100%). The model at the point of best performance was saved by recording the validation loss at each epoch.
* ๊ฒฐ๊ณผ (Result): ์ต์ข
์ ์ผ๋ก `Test Loss` 1.4163, `Perplexity` 4.1219๋ฅผ ๊ธฐ๋กํ Trial 4 ๋ชจ๋ธ์ ์ต์ข
๋ชจ๋ธ๋ก ์ ์ .
The Trial 4 model, which recorded a final `Test Loss` of 1.4163 and a `Perplexity` of 4.1219, was selected as the final model.
#### **์ต์ข
๋ชจ๋ธ ํ์ดํผํ๋ผ๋ฏธํฐ (Final Model Hyperparameters)**
3๋จ๊ณ ์ต์ข
๊ฒ์ฆ์ ํตํด ์ ์ ๋ Trial 4 ๋ชจ๋ธ์ ํ์ดํผํ๋ผ๋ฏธํฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
The hyperparameters for the Trial 4 model, selected through the final validation, are as follows:
* **learning\_rate**: 9.66e-05
* **per\_device\_train\_batch\_size**: 8
* **gradient\_accumulation\_steps**: 4 (Effective batch size: 32\)
* **weight\_decay**: 0.0401
* **lr\_scheduler\_type**: linear
* **adam\_beta1**: 0.8943
* **adam\_beta2**: 0.9923
* **warmup\_ratio**: 0.0983
* **optimizer**: AdamW
* **mlm\_probability**: 0.15
* **max\_seq\_length**: 256
#### **ํ์ต ํ๊ฒฝ (Training Environment)**
* **Hardware**: 1 x NVIDIA A100-PCIE-40GB
* **Software**: For reproducibility, the following versions of major libraries were used in this study.
* `transformers`: v4.47.1
* `datasets`: v3.0.1
* `torch`: v2.6.0a0+ecf3bae40a.nv25.01
* `optuna`: v4.3.0
* `accelerate`: v1.5.2
* `pandas`: v2.2.2
* `lxml`: v5.3.0
* `tqdm`: v4.67.1
* `scikit-learn`: v1.6.1
## **ํ๊ฐ (Evaluation)**
#### **ํ๊ฐ ์งํ (Evaluation Metrics)**
* **Test Loss**: The loss value of the model on the test dataset.
* **Perplexity (PPL)**: A standard metric for evaluating language models, representing uncertainty. **A lower value indicates** that the model predicts the next word better. (Formula: eloss)
#### **ํ๊ฐ ๊ฒฐ๊ณผ (Evaluation Results)**
ํ ๋ฒ๋ ํ์ต์ ์ฌ์ฉ๋์ง ์์ ํ
์คํธ ๋ฐ์ดํฐ์
(`test.txt`)์ผ๋ก ์์ 10๊ฐ ํ๋ณด ๋ชจ๋ธ์ ํ๊ฐํ ์ต์ข
์ฑ๋ฅ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
The final performance of the top 10 candidate models, evaluated on the held-out test dataset (`test.txt`), is as follows:
| ์์(Rank) | Trial ๋ฒํธ(No.) | Test Loss | Perplexity (PPL) | ๊ฒ์ฆ(Val) ์์์์ ์ฐจ์ด(vs. Val Rank) |
| :---- | :---- | :---- | :---- | :---- |
| **1** | **4** | **1.4163** | **4.1219** | \- |
| 2 | 11 | 1.4182 | 4.1296 | โฒ 2 |
| 3 | 10 | 1.4197 | 4.1357 | โฒ 2 |
| 4 | 3 | 1.4198 | 4.1362 | โผ 1 |
| 5 | 2 | 1.4202 | 4.1381 | โผ 3 |
| 6 | 7 | 1.4800 | 4.3931 | \- |
| 7 | 8 | 1.5229 | 4.5853 | \- |
| 8 | 6 | 1.5269 | 4.6040 | \- |
| 9 | 5 | 1.5688 | 4.8010 | \- |
| 10 | 9 | 1.5757 | 4.8339 | \- |
๋ถ์ (Analysis): ๊ฒ์ฆ ๋ฐ์ดํฐ์
์์ 1์๋ฅผ ์ฐจ์งํ๋ Trial 4 ๋ชจ๋ธ์ด ํ
์คํธ ๋ฐ์ดํฐ์
์์๋ ๊ฐ์ฅ ์ฐ์ํ ์ผ๋ฐํ ์ฑ๋ฅ์ ๋ณด์ฌ, ๋ณธ ์ฐ๊ตฌ์์ ์ฑํํ ๋จ๊ณ์ HPO ์ ๋ต์ ์ ํจ์ฑ์ ์
์ฆํ์ต๋๋ค. ๋ํ ๊ฒ์ฆ ์
์์ 4์์๋ Trial 11์ด ์ต์ข
2์๋ฅผ ๊ธฐ๋กํ ๊ฒ์, ์ต์ข
ํ๊ฐ์์ Top 10 ์ ์ฒด๋ฅผ ๊ฒ์ฆํ๋ ๊ณผ์ ์ ์ค์์ฑ์ ์์ฌํฉ๋๋ค.
The Trial 4 model, which ranked first on the validation dataset, also showed the best generalization performance on the test dataset, validating the effectiveness of the staged HPO strategy adopted in this study. Furthermore, the fact that Trial 11, ranked 4th on the validation set, achieved the 2nd position in the final evaluation highlights the importance of validating the entire top 10 candidates.
#### **HPO ๊ฒฐ๊ณผ ๋ถ์ ์๋ฃ (Analysis of HPO Results)**
์ ์ฒด ํ์ดํผํ๋ผ๋ฏธํฐ ์ต์ ํ ๊ณผ์ ์ ๋ํ ์์ธํ ๊ฒฐ๊ณผ๋ ๋ณธ ๋ฆฌํฌ์งํ ๋ฆฌ์ `hpo_visualizations` ๋ฐ `hpo_databases` ํด๋์์ ํ์ธํ์ค ์ ์์ต๋๋ค.
Detailed results of the entire hyperparameter optimization process can be found in the `hpo_visualizations` and `hpo_databases` folders of this repository.
* **์ ์ ์๊ฐํ ๋ณด๊ณ ์ (Static Visualization Reports)**
* **์์น (Location)**: `hpo_visualizations/`
* **์ค๋ช
(Description)**: HTML files containing interactive graphs that visualize the results of each HPO stage. These can be opened directly in a browser for quick exploration. (Visualization for Stage 1 is excluded due to its short training time and low statistical significance.)
* **HPO ์์ ๋ฐ์ดํฐ (Raw HPO Data)**
* **์์น (Location)**: `hpo_databases/`
* **์ค๋ช
(Description)**: Original SQLite database files containing the records of all HPO trials. Other researchers can load these files to perfectly reproduce the results of this study or conduct their own analysis.
* **ํ์ฉ ์์ (Usage Example)**: You can perform the analysis yourself using the provided `scripts/hpo\_result\_analyzer\_universal.py` script and the DB files.
```
# 2๋จ๊ณ ๊ฒฐ๊ณผ ๋ถ์ ์ฌํ
# Reproduce Stage 2 analysis
# (DB and Study names should be adjusted to match the actual uploaded files and settings.)
python scripts/hpo_result_analyzer_universal.py \
--db_path "hpo_databases/hpo_stage2_search.db" \
--study_name "Sillok-LM_MLM_HyperOpt_Heavier_bert_base_multilingual_cased" \
--file_prefix "reproduced_stage2_"
# 3๋จ๊ณ ๊ฒฐ๊ณผ ๋ถ์ ์ฌํ
# Reproduce Stage 3 analysis
python scripts/hpo_result_analyzer_universal.py \
--db_path "hpo_databases/hpo_stage3_validation.db" \
--study_name "Sillok-LM_Final_Top10_Run" \
--file_prefix "reproduced_stage3_"
```
## **์ ํ ์ฌํญ ๋ฐ ํธํฅ์ฑ (Limitations and Bias)**
* ๋ณธ ๋ชจ๋ธ์ ์กฐ์ ์์กฐ์ค๋ก ์๋ฌธ ๋ฐ์ดํฐ๋ก ํ์ต๋์์ผ๋ฏ๋ก, ํ๋ ํ๊ตญ์ด๋ ๋ค๋ฅธ ์๋์ ํ๋ฌธ ํ
์คํธ์ ๋ํด์๋ ์ฑ๋ฅ์ด ์ ํ๋ ์ ์์ต๋๋ค.
Since this model was trained on the original text of Veritable Records of the Joseon Dynasty, its performance may degrade on modern Korean or Classical Chinese texts from other periods.
* ์ค๋ก์ ํน์ ๊ณ์ธต(์, ์ฌ๋๋ถ)์ ๊ด์ ์์ ๊ธฐ๋ก๋ ์ฌ๋ฃ์ด๋ฏ๋ก, ๋ชจ๋ธ์ด ์์ฑํ๊ฑฐ๋ ์์ธกํ๋ ๋ด์ฉ ๋ํ ์ด๋ฌํ ์ญ์ฌ์ , ์ด๋
์ ํธํฅ์ฑ์ ๋ด์ฌํ ์ ์์ต๋๋ค. ์ฌ์ฉ์๋ ๋ชจ๋ธ์ ๊ฒฐ๊ณผ๋ฅผ ๋นํ์ ์ผ๋ก ํด์ํด์ผ ํฉ๋๋ค.
Veritable Records of the Joseon Dynasty were recorded from the perspective of a specific class (kings, scholar-officials), so the content generated or predicted by the model may inherit these historical and ideological biases. Users should interpret the model's outputs critically.
## **์ฐ๊ตฌํ ๋ฐ ์ธ์ฉ (Team and Citation)**
#### **์ฐ๊ตฌํ (Team)**
* **๊น๋ฐ๋ก (Baro Kim)**: ์ฐ๊ตฌ ์ฑ
์์ (Principal Investigator), Digital Humanities Research Institute, The Academy of Korean Studies
#### **์ธ์ฉ ์ ๋ณด (Citation)**
์ด ๋ชจ๋ธ์ ์ฐ๊ตฌ์ ์ฌ์ฉํ์ค ๊ฒฝ์ฐ, ๋ค์๊ณผ ๊ฐ์ด ์ธ์ฉํด ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
If you use this model in your research, please cite it as follows:
```
@misc{kim2025sillokbert,
title={{SillokBert: A Language Model for Veritable Records of the Joseon Dynasty}},
author={Baro, Kim},
year={2025},
publisher={Hugging Face},
journal={Hugging Face repository},
howpublished={url{[https://huggingface.co/ddokbaro/SillokBert](https://huggingface.co/ddokbaro/SillokBert)}}
}
``` |