토큰
AI와 NLP의 맥락에서 토큰은 처리 및 분석에 사용되는 단어, 단어의 일부 또는 점수 마크와 같은 텍스트의 기본 단위입니다.
토큰화는 텍스트를 이러한 토큰으로 나누는 과정입니다. 이는 텍스트 데이터를 머신 러닝 모델을 위해 준비하는 데 중요한 단계이며, 모델이 텍스트를 이해하고 처리할 수 있도록 합니다. 토큰화에 대한 특정 규칙은 작업 및 사용 중인 모델에 따라 다를 수 있으며, 서로 다른 토크나이저는 서로 다른 결과를 생성합니다.
토큰화 방법은 단순한 공백 분할에서 하위 단어 단위 또는 문자 수준 표현을 고려하는 보다 정교한 기술까지 다양합니다. 토크나이저의 선택은 NLP 모델의 성능에 상당한 영향을 미칩니다. 예를 들어, 단어 기반 토크나이저는 'cat'과 'cats'를 별도의 토큰으로 처리할 수 있지만, 하위 단어 토크나이저는 'cats'를 'cat'과 's'로 나눌 수 있습니다.
graph LR
Center["토큰"]:::main
Pre_cryptography["cryptography"]:::pre --> Center
click Pre_cryptography "/terms/cryptography"
Rel_machine_learning["machine-learning"]:::related -.-> Center
click Rel_machine_learning "/terms/machine-learning"
Rel_token["token"]:::related -.-> Center
click Rel_token "/terms/token"
Rel_tokenizer["tokenizer"]:::related -.-> Center
click Rel_tokenizer "/terms/tokenizer"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 지식 테스트
🧒 5살도 이해할 수 있게 설명
A [token](/ko/terms/token) is like a single Lego brick that makes up a sentence. AI breaks sentences into these bricks (words, parts of words, or punctuation) so it can understand and build new sentences.
🤓 Expert Deep Dive
Tokenization is a critical preprocessing step in NLP pipelines. Subword tokenization algorithms like BPE, WordPiece, and SentencePiece have become dominant because they balance vocabulary size with the ability to represent rare words and morphology. BPE iteratively merges frequent pairs of characters or bytes, while WordPiece uses a likelihood-based approach. SentencePiece treats text as a sequence of Unicode characters and learns subword units directly, making it language-agnostic. The choice of tokenizer impacts downstream tasks: a word-level tokenizer struggles with OOV words, while character-level tokenizers result in very long sequences. Subword tokenizers offer a compromise, allowing models to handle morphology (e.g., 'running' -> 'run', '##ing') and unknown words by composing them from known subwords. The mapping from tokens to numerical IDs and then to dense vector embeddings (e.g., Word2Vec, GloVe, or contextual embeddings from Transformers) is where semantic meaning is encoded for the model.