목록 List

SNU Thunder-Tok

개요
Overview

생성형 언어 모델의 추론 비용은 생성해야 할 토큰(token)의 수에 비례합니다. 따라서 동일한 텍스트를 생성하더라도, 이를 더 적은 수의 토큰으로 표현할 수 있다면 모델의 추론 비용을 효과적으로 줄일 수 있습니다.

"Thunder-Tok"은 한국어의 고유한 언어적 특성을 정밀하게 반영하여 설계된 한국어 특화 토크나이저입니다. 기존 GPT-2 스타일의 BPE(Byte Pair Encoding) 방식과 비교했을 때, 더 효율적인 어휘 구성을 통해 텍스트를 표현하는 데 필요한 평균 토큰 수를 줄이는 데 성공했습니다. 같은 데이터셋으로 학습한 BPE 토크나이저와 비교했을 때, Thunder-Tok 은 단어당 토큰 수(Tokens-per-Word) 기준으로 약 10% 낮은 수치를 기록하며, 같은 문장을 더 적은 토큰으로 처리할 수 있음을 보였습니다. 이는 곧 언어 모델의 성능을 유지하면서도 약 10%의 추론 비용 절감 효과를 제공함을 의미합니다. 전력 소모가 큰 언어 모델의 한계가 중요한 문제가 되는 언어 모델 기반 서비스(Google 검색 한 번엔 평균 0.3Wh 전력이 쓰이는데 ChatGPT는 한 번에 2.9Wh를 소모)나 연구 환경에서, 이러한 효율성은 해당 문제를 완화하고 지속 가능한 활용을 가능하게 합니다.

Thunder-Tok은 한국어 생성형 언어 모델을 위한 정확하고 효율적인 토크나이징 솔루션으로, 모델 학습과 추론 과정에서의 경제성과 실용성을 모두 만족시키는 강력한 도구입니다.

The inference cost of generative language models is proportional to the number of tokens they need to generate. Therefore, even when generating the same text, reducing the number of tokens required to represent that text can significantly lower inference costs.

Thunder-Tok is a Korean-specific tokenizer designed with careful consideration of the unique linguistic characteristics of the Korean language. Compared to the traditional GPT-2 style Byte Pair Encoding (BPE) approach, Thunder-Tok achieves a more efficient vocabulary design that reduces the average number of tokens needed to represent text. In fact, using the same dataset, Thunder-Tok achieves approximately 10% fewer tokens per word compared to BPE, demonstrating that it can process the same sentence using fewer tokens. This translates to a 10% reduction in inference cost while maintaining language model performance. In language model-based services—where power consumption is a critical concern due to the high energy demands of large language models (e.g., a single Google search consumes approximately 0.3Wh, whereas one ChatGPT query uses around 2.9Wh)—and in research environments, such efficiency helps mitigate this issue and enables more sustainable use.

Thunder-Tok provides a precise and efficient tokenization solution for Korean generative language models, making it a powerful tool that ensures both economic and practical benefits during training and inference.

토큰화란?
What is Tokenization?

언어 모델이 텍스트 데이터를 처리하기 위해서는 먼저 텍스트를 숫자 형태로 변환하는 과정이 필요합니다. 이때 사용되는 과정이 "토큰화(Tokenization)"이며, 이 과정을 수행하는 도구를 "토크나이저(Tokenizer)"라고 합니다. 일반적으로 토크나이저는 "어휘 집합(Vocabulary)" 이라고 불리는 미리 정의된 토큰 목록을 기반으로, 입력 텍스트를 해당 토큰 단위로 나누고 각 토큰을 고유한 인덱스로 변환합니다. 하지만 텍스트에는 문자, 숫자, 특수기호 등 다양한 구성 요소가 포함되어 있으며, 일부의 경우 간단한 규칙으로 분리할 수 있습니다. 이러한 규칙 기반의 초기 분할 과정을 "사전 토큰화(Pre-Tokenization)"라고 합니다. 즉, 전체적인 토큰화는 두 단계로 이루어지며, 먼저 사전 토큰화를 통해 텍스트를 큰 단위로 분리한 뒤, 각 단위를 어휘 집합을 사용해 더욱 세분화하게 됩니다.

In order for a language model to process text data, the text must first be converted into a numerical format. This process is known as "tokenization", and the tool that performs this operation is called a "tokenizer". Typically, a tokenizer relies on a predefined list of tokens called a "vocabulary", which it uses to segment the input text into token units and convert each token into a unique index. However, text often contains a mix of characters, numbers, and special symbols, some of which can be separated using simple rules. This rule-based initial segmentation step is referred to as "pre-tokenization". In other words, tokenization generally involves two stages: first, the text is segmented into larger units through pre-tokenization; then, each segment is further broken down into smaller units using the vocabulary.

토크화 과정 토크화 과정

생성형 언어 모델에서는 한 번의 추론(Forward Step)마다 하나의 토큰을 생성합니다. 따라서 특정 텍스트를 생성하는 데 필요한 추론 비용은 해당 텍스트를 구성하는 토큰의 수에 비례합니다. 이로 인해 같은 문장이라도 더 적은 수의 토큰으로 표현할 수 있다면, 모델이 텍스트를 생성하는 데 드는 계산 비용과 시간이 줄어드는 장점이 있습니다.

In generative language models, a single forward step generates one token. Therefore, the computational cost of generating a given text is proportional to the number of tokens required to represent that text. As a result, if the same sentence can be expressed using fewer tokens, the model can generate the text with reduced computation time and cost.

토큰수와 추론 비용 토큰수와 추론 비용

앞서 설명한 것처럼, 토큰화는 사전 토큰화를 기반으로 이루어지며, 최종적으로 생성되는 토큰의 수는 일반적으로 사전 토큰화에 의해 나뉜 단위보다 더 많아집니다. 따라서 전체 토큰 수를 줄이기 위해서는 먼저 사전 토큰화 과정에서 텍스트가 과도하게 나뉘지 않도록 조정하는 것이 중요합니다.

As previously explained, tokenization is based on a pre-tokenization step. In most cases, the number of final tokens is greater than the number of segments produced during pre-tokenization. Therefore, to reduce the total number of tokens, it is important to minimize unnecessary splits during the pre-tokenization process.

Thunder-Tok
Thunder-Tok

Thunder-Tok은 기존의 사전 토큰화 방식과는 달리, 한국어의 언어적 특성을 반영하여 사전 토큰화 결과로 나뉘는 텍스트 수를 줄이는 데 중점을 둔 토크나이저입니다. 기존 방식은 일반적으로 공백, 문자, 특수기호 등을 항상 분리하는 규칙을 따르기 때문에, 한국어처럼 띄어쓰기가 선택적으로 사용되거나 종결어미와 문장부호가 함께 결합되는 경우에는 비효율적인 분할이 발생할 수 있습니다. Thunder-Tok은 이러한 한국어의 특징을 고려하여 불필요한 분할을 최소화하였고, 음소, 음절, 단어 등 다양한 언어 단위와 의미 단위가 뚜렷하게 나타나는 경계를 인식하기 위해 사용되는 지표인 Branching Entropy를 활용한 어휘 집합을 구성하였습니다. 이를 통해 Thunder-Tok은 더 적은 수의 토큰으로 텍스트를 표현할 수 있어 모델의 추론 비용을 줄이는 동시에, 사람의 해석과도 잘 맞는 자연스러운 토큰화를 실현하였습니다. 보다 구체적인 구현 방식과 실험 결과는 관련 논문을 참고해주시기 바랍니다.

Thunder-Tok is a tokenizer that differs from conventional methods by focusing on reducing the number of segments generated during pre-tokenization, specifically by considering the linguistic characteristics of Korean. Traditional approaches typically follow rules that always separate spaces, letters, and special characters. However, in Korean, spacing is often optional (especially in single-syllable words or compound nouns), and sentence-final endings are frequently attached directly to punctuation. These characteristics can result in inefficient splitting when using standard rules. Thunder-Tok addresses this by minimizing unnecessary splits through a better understanding of Korean syntax and morphology. It constructs its vocabulary based on various linguistic units such as phonemes, syllables, and words, and leverages a metric called Branching Entropy to detect boundaries where semantic units naturally occur. Through this approach, Thunder-Tok enables text to be represented with fewer tokens, reducing inference costs while maintaining a tokenization scheme that aligns closely with how humans intuitively read and understand sentences. For further details on implementation and experimental results, please refer to the associated research paper.

아래는 Thunder-Tok과 다른 토크나이저들을 비교한 예시입니다. BPE와 Unigram 토크나이저에는 GPT-2의 사전 토큰화 규칙이 적용되었으며, BPE Mecab-ko는 사전 토큰화 과정에 Mecab-ko를 사용하여 형태소 단위로 텍스트가 분할되도록 구성되었습니다. 결과를 보면 Thunder-Tok은 사람이 문장을 읽는 단위와 유사한 방식으로 토큰화를 수행하며, 다른 토크나이저에 비해 더 적은 수의 토큰으로 문장을 표현할 수 있음을 확인할 수 있습니다.

The following is a comparison between Thunder-Tok and other tokenizers. The BPE and Unigram tokenizers use the GPT-2 pre-tokenization rules, while BPE Mecab-ko incorporates Mecab-ko during the pre-tokenization stage, resulting in morpheme-level segmentation of the text. As shown in the results, Thunder-Tok performs tokenization in a way that closely resembles how humans naturally read sentences, and it represents text using fewer tokens compared to the other tokenizers.

토크나이저 비교 Tokenizer Comparison
생성형 언어 모델에서의 Thunder-Tok 적용 효과
Effectiveness of Thunder-Tok in Generative Language Models

Thunder-Tok의 효율성은 실제 생성형 언어 모델에 적용했을 때 더욱 명확하게 드러납니다. 이를 확인하기 위해 Llama-3.1, EXAONE-3.5, Llama-Thunder-LLM을 비교하였습니다. Llama-3.1은 영어 중심의 BPE 토크나이저를 사용하며, 한국어 토큰은 거의 포함되어 있지 않습니다. 반면 EXAONE-3.5는 한국어와 영어가 모두 포함된 BPE 토크나이저를 사용하지만, 형태소 단위로 어휘 집합이 구성되어 있어 BPE Mecab-Ko와 유사한 방식으로 토큰화가 수행됩니다. Llama-Thunder-LLM은 기존 Llama-3.1 토크나이저에 92K 규모의 한국어 특화 토큰을 추가한 Thunder-Tok 을 사용합니다.

Thunder-Tok의 효율성을 평가하고자, 4개의 대표적인 한국어 벤치마크를 대상으로 단어당 평균 토큰 수(Tokens per Word)를 비교 분석하였습니다. 그 결과, Llama-Thunder-LLM은 한국어의 특성을 고려하지 않은 Llama-3.1 대비 약 44%, 한국어 형태소 위주 토큰들로 구성된 EXAONE-3.5 대비 약 29% 더 적은 단어당 토큰 수를 기록하였습니다. 이는 곧 같은 Llama-Thunder-LLM이 다른 모델에 비해 문장을 생성하는 데 필요한 추론 스텝 수가 적음을 의미하며, 결과적으로 모델의 추론 속도는 향상되고 전체 추론 비용 또한 크게 절감될 수 있음을 시사합니다. 물론 각 토크나이저가 훈련된 데이터셋과 사전 크기에 차이가 있기 때문에, 이 수치가 순수하게 토크나이저만의 효과라고 보기는 어렵습니다. 그럼에도 불구하고, 유사한 조건 하에서 Thunder-Tok이 더 간결하고 효율적인 토큰화를 달성했음을 보여주는 강력한 정량적 지표라 할 수 있습니다.

The efficiency of Thunder-Tok becomes even more evident when applied to actual generative language models. To validate this, a comparison was conducted between Llama-3.1, EXAONE-3.5, and Llama-Thunder-LLM. Llama-3.1 uses an English-centric BPE tokenizer with minimal support for Korean tokens. In contrast, EXAONE-3.5 utilizes a BPE tokenizer that encompasses both Korean and English tokens. However, its vocabulary is primarily composed of morpheme-level Korean tokens, resulting in tokenization behavior similar to BPE Mecab-Ko. Llama-Thunder-LLM, on the other hand, utilizes Thunder-Tok, which extends the original Llama-3.1 tokenizer by incorporating a Korean-specialized vocabulary of 92k tokens.

To evaluate the efficiency of Thunder-Tok, the average number of tokens per word was measured across four representative Korean benchmark datasets. The results showed that Llama-Thunder-LLM required approximately 44% fewer tokens per word than Llama-3.1 which was not optimized for Korean, and about 29% fewer than EXAONE-3.5 which was primarily composed of morpheme-level Korean tokens. This indicates that Llama-Thunder-LLM requires significantly fewer inference steps to generate the same sentence compared to the other models, leading to faster inference and substantially reduced overall computational costs. While differences in training datasets and vocabulary size across tokenizers mean that these numbers may not purely reflect tokenizer performance alone, the results nevertheless provide strong evidence that Thunder-Tok achieves more compact and efficient tokenization.

Model Tokens per Word (lower is better)
Kobest-Hellaswag Kobest-COPA Ko-LAMBADA Ko-Arc-e Average
Llama-3.1 2.686 2.916 2.538 2.576 2.679
EXONE-3.5 2.052 2.272 2.135 1.991 2.113
Llama-Thunder-LLM 1.416 1.548 1.624 1.438 1.507
Acknowledgements
Acknowledgements

본 연구는 과학기술정보통신부 선도연구센터사업(ERC)의 지원을 받아 수행된 연구입니다 (과제번호: RS-2023-00222663, 초거대 AI 모델 및 플랫폼 최적화 센터). 또한, GPU 장비는 과학기술정보통신부·광주광역시가 공동 지원한 '인공지능 중심 산업융합 집적단지 조성사업'의 지원을 받았습니다.

This work was supported by the National Research Foundation of Korea (NRF) under Grant No. RS-2023-00222663 (Center for Optimizing Hyperscale AI Models and Platforms, ERC). This research was also supported by Artificial intelligence industrial convergence cluster development project funded by the Ministry of Science and ICT(MSIT, Korea)&Gwangju Metropolitan City.

Patents
Patents
  • [국내 출원] Branching Entropy 기반 토크나이저 학습 방법: 10-2025-0078029 (출원일: 2025.06.13)
  • [국내 출원] 언어 단위 기반 토크나이저 학습 방법: 10-2025-0078028 (출원일: 2025.06.13)
  • [Domestic Filing] Branching Entropy based Tokenizer Training Method: 10-2025-0078029 (Application Date: 2025.06.13)
  • [Domestic Filing] Linguistic Unit based Tokenizer Training Method: 10-2025-0078028 (Application Date: 2025.06.13)
Contributors
Contributors

조경제+, 소연경+, 박찬우*, 이상민*, 정성목+, 이재진*+

* 서울대학교 컴퓨터공학부
+ 서울대학교 데이터사이언스대학원

Gyeongje Cho+, Yeonkyung So+ Chanwoo Park*, Sangmin Lee*, Sungmok Jung+, Jaejin Lee*+

*Department of Computer Science and Engineering, Seoul National University
+Graduate School of Data Science, Seoul National University