№005 reranker-engineering · 03
Cross-Encoder Reranker: Joint Attention부터 실전 추론까지 (3/14)
Query와 document를 한 Transformer에 넣는 Cross-Encoder의 joint attention과 score를 이해하고, batching·truncation·긴 문서 windowing 및 재현 가능한 baseline을 구현합니다.
Tag index
Query와 document를 한 Transformer에 넣는 Cross-Encoder의 joint attention과 score를 이해하고, batching·truncation·긴 문서 windowing 및 재현 가능한 baseline을 구현합니다.
Transformer가 attention 하나가 아니라 token·position embedding, multi-head attention, residual, LayerNorm, FFN을 반복한 구조임을 설명하고 encoder와 decoder의 RAG 역할까지 비교합니다.
Transformer의 핵심인 query·key·value를 검색 비유와 행렬 shape로 설명하고, score·scale·mask·softmax·weighted sum을 작은 숫자로 직접 계산해 multi-head와 RAG context까지 연결합니다.
Transformer 추론을 GEMM, normalization, RoPE, attention, sampling 커널로 분해합니다. Prefill·decode shape와 HBM 이동, FlashAttention·fusion·fallback을 측정해 serving 성능을 검증합니다.
현대 decoder-only LLM block을 pre-norm·RMSNorm, RoPE, SwiGLU, MHA·MQA·GQA, KV cache, dense·MoE로 분해하고 각 구조가 학습 안정성, 메모리, 통신, latency에 미치는 영향을 계산합니다.