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

Pretrained model

~8 min · keras-nlp

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

architecture 로 줄 세우기

NLP model 은 결국 세 family 로 갈려, 근데 실전에선 두 개가 거의 다야: (1) encoder (BERT, RoBERTa) — 분류 / NER / 추출형 QA, 텍스트의 representation 을 학습. (2) decoder (GPT-2, Llama, Gemma) — 다음 token 예측해서 텍스트 생성. (T5 같은 encoder-decoder 는 세 번째지만 2026 년엔 드물어.) 브랜드 이름보다 Type 이 그 모델 쓸모를 결정해 — 그게 핵심.

size variant 도 있어. 작은 (base / 2b) 부터 큰 (large / 70b) 까지, GPU memory 따라 골라. 같은 family 면 코드는 똑같고 preset 이름만 바뀌어.

loader 는 하나

Code 보면 — classifier 도 generator 도 똑같은 from_preset() 로 로드돼. class 이름이랑 preset 문자열만 달라. 이게 hub 의 진짜 이득이야: 모델마다 API 새로 안 외워도 돼. task 에 맞는 class 고르고 preset 이름 넘기면 weight + 짝 tokenizer 가 한 방에 와. classifier 의 num_classes 만 task 별로 손대는 knob — pretrained backbone 은 그대로 두고 output head 만 새로 깔아줘.

Code

classifier 와 generator 를 같은 from_preset 으로 로드·python
import keras_hub

# Load a pretrained classifier
classifier = keras_hub.models.BertClassifier.from_preset(
    "bert_base_en",
    num_classes=4,
)

# Load a text generator
gpt2 = keras_hub.models.GPT2CausalLM.from_preset("gpt2_base_en")

External links

Exercise

BertBackbone (small) + GemmaCausalLM (small) 로드. parameter 수 출력. 같은 text input 으로 inference. BERT 는 embedding 내고, Gemma 는 token logit 내는 거 메모.

Progress

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

댓글 0

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

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