DistilBERT 아키텍처와 설정 — 사양 읽기

DistilBERT 아키텍처와 설정

DistilBERT를 실제로 다루려면 설정 클래스가 어떤 기본값을 쓰는지 아는 게 좋아요. DistilBertConfig는 모델 아키텍처를 정의하고, 대부분 환경이 이 기본값 그대로 동작해요.

출처: https://huggingface.co/docs/transformers/model_doc/distilbert

주요 설정값

아래 값들이 DistilBERT의 기본 구성이에요. 코드상 타입은 원문 그대로 보존했어요.

  • vocab_size: 30522
  • max_position_embeddings: 512
  • n_layers: 6 (인코더 히든 레이어)
  • n_heads: 12
  • dim: 768 (인코더·풀러 레이어 차원)
  • hidden_dim: 3072
  • dropout: 0.1
  • attention_dropout: 0.1
  • activation: 'gelu'
  • initializer_range: 0.02
  • pad_token_id: 0

토크나이저 특징

  • DistilBERT에는 token_type_ids가 없어요 — 세그먼트를 구분할 필요가 없어요. 세그먼트는 분리 토큰 tokenizer.sep_token(즉 [SEP])으로 구분해요.
  • 입력 위치를 고르는 position_ids 옵션도 없어요.

설정 인스턴스화 예시

from transformers import DistilBertConfig, DistilBertModel

# DistilBERT 설정 초기화
configuration = DistilBertConfig()

# 랜덤 가중치 모델 초기화
model = DistilBertModel(configuration)

더 알아보기