C.W.K.
Stream
Lesson 03 of 07 · published

Tokenizer

~8 min · keras-nlp

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

Text → integer token ID. byte-pair encoding (BPE), wordpiece (BERT), unigram (T5) 등 알고리즘. 같은 model 에 *반드시 같은 tokenizer*. 안 그럼 vocab id 가 안 맞아 결과 쓰레기.

KerasHub 의 tokenizer: preprocessor = BertClassifier.preprocessor; tokens = preprocessor.tokenizer('hello world'). 또는 model 자체에 string 직접 넘기면 자동 tokenize. 학습 / inference 시 자동.

Code

# Tokenizers are included with model presets
tokenizer = keras_hub.tokenizers.WordPieceTokenizer(
    vocabulary=vocab_data,
)

# Or use the tokenizer that comes with a preset
preprocessor = keras_hub.models.BertPreprocessor.from_preset(
    "bert_base_en",
    sequence_length=128,
)

External links

Exercise

BERT 의 tokenizer 가져와. 'Hello, world! 안녕!' tokenize. token ID + decoded 문자열 출력. 한국어 처리 (BERT-base-en 은 byte 단위로 쪼갤 가능성) 메모.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.