Field Log · Entry
Dense Retrieval 학습 계보: DPR에서 E5까지 (5/14)
이번 글의 결론
- Dense retrieval의 발전은 backbone 크기만의 역사가 아니라 negative 범위, label 정제, pretraining task, data scale을 확장한 역사입니다.
- DPR은 간단한 dual encoder와 in-batch negative가 강한 출발점임을 보였고, ANCE는 학습 중 corpus 전체의 hard negative를 갱신하는 문제를 전면에 놓았습니다.
- RocketQA는 cross-batch negative가 커질수록 false negative 정제가 중요함을 보여 주었습니다.
- Contriever·RetroMAE는 labeled query-document pair가 적어도 retrieval-oriented pretraining으로 transfer를 높이는 서로 다른 길을 제안했습니다.
- E5의 multi-stage recipe는 대규모 weak pair로 넓게 pretrain한 뒤 작은 고품질 supervised mixture로 정렬하는 현대 embedding 학습의 기본형이 됐습니다.
앞 글에서 data pipeline을 설계했습니다. 이번 글은 주요 연구를 “누가 먼저였나”가 아니라 “어떤 bottleneck을 해결했나”로 읽습니다.
1. 공통 골격: Dual Encoder
query q → encoder_q → zq ─┐
├─ dot/cosine → score
document d → encoder_d → zd ─┘
Query와 document encoder는 weight를 공유할 수도 있고 분리할 수도 있습니다. Corpus vector를 미리 계산하므로 수백만 문서에 ANN 검색할 수 있습니다.
기본 loss:
L = -log exp(sim(q,d+)/τ)
/ [exp(sim(q,d+)/τ) + Σ_j exp(sim(q,d_j-)/τ)]
차이는 좋은 (d^-)를 어디서 얻고, encoder가 retrieval을 언제 배우는가에 있습니다.
2. DPR · 간단한 Supervised Dual Encoder
Dense Passage Retrieval, DPR은 open-domain QA에서 question encoder와 passage encoder를 학습하고 inner product로 검색했습니다.
주요 구조:
- BERT 기반 두 encoder
- question-positive passage pair
- in-batch negatives
- BM25 hard negative 선택지
- Maximum Inner Product Search
question batch: q1 q2 ... qB
passage batch: p1 p2 ... pB
positive: (qi, pi)
negative for qi: pj, j ≠ i
DPR의 지속적인 교훈은 거대한 custom objective 없이도 적절한 supervised pair와 batch negatives로 강한 dense retriever를 만들 수 있다는 것입니다.
한계:
- QA answer-containing passage가 항상 semantic evidence는 아님
- in-batch negative 범위가 작음
- BM25가 못 찾는 dense-specific hard case 부족
- in-domain 성능과 zero-shot generalization 간 차이
3. ANCE · Corpus 전체에서 Negative를 찾는다
Model이 강해지면 random/in-batch negative 대부분은 너무 쉽습니다. ANCE는 current model로 corpus의 ANN index를 만들고 hard negatives를 mining하며 학습합니다.
checkpoint θ_t
→ encode whole corpus
→ ANN index
→ retrieve hard negatives
→ train θ_{t+1}
→ refresh index
이를 통해 local batch가 아니라 global corpus의 decision boundary를 학습합니다.
Staleness
Mining index는 과거 checkpoint로 만들었기 때문에 현재 model과 어긋납니다.
negative distribution ~ model θ_t
training model = model θ_t+k
Refresh가 잦으면 비싸고, 늦으면 stale합니다. 오늘날 offline iterative mining도 같은 trade-off를 가집니다.
4. RocketQA · 더 많은 Negative에는 더 많은 정제가 필요하다
RocketQA는 세 요소를 강조했습니다.
- cross-batch negatives
- denoised hard negatives
- data augmentation
Cross-batch memory로 더 많은 negative를 쓰면 representation discrimination은 좋아질 수 있지만 unlabeled positive도 더 많이 섞입니다. Cross-Encoder 같은 stronger teacher로 hard negative를 정제합니다.
retriever candidate
→ cross-encoder relevance
├─ likely positive → remove/relabel
└─ confident negative → train
RocketQA의 설계는 4편의 positive-aware mining으로 이어집니다.
5. RocketQAv2 · Retriever와 Reranker를 함께 본다
RocketQAv2는 dense retriever와 passage reranker의 dynamic listwise distillation을 통해 두 단계를 공동 학습하려 했습니다.
dense retriever candidates
↔ cross-encoder reranker scores
→ retriever learns better global retrieval
→ reranker sees retriever's changing candidates
Teacher가 fixed offline label만 주는 것보다 changing student distribution에 맞출 수 있습니다. 반면 training complexity와 reproducibility cost가 커집니다.
6. Contriever · Label 없이 Retrieval Space를 만든다
Contriever는 unlabeled text에서 contrastive learning으로 unsupervised dense retriever를 학습합니다. Text crop·augmentation과 large negative pool로 representation을 만들고, zero-shot retrieval과 supervised fine-tuning을 평가했습니다.
가치:
- human qrel이 없는 domain의 initialization
- multilingual/low-resource transfer 확장 가능성
- task-specific label에 과도하게 맞지 않은 base
한계:
Self-supervised positive가 실제 user relevance와 같지는 않습니다. 같은 문서의 두 crop은 topic은 공유하지만 query intent는 없습니다.
7. RetroMAE · 한 Vector로 원문을 복원하게 한다
RetroMAE는 retrieval-oriented masked auto-encoder pretraining을 제안했습니다.
corrupted input
→ full encoder
→ single sentence embedding
→ shallow decoder + heavily masked input
→ reconstruct original tokens
Decoder가 강하면 embedding을 무시하고 masked context만으로 복원할 수 있습니다. 그래서 shallow decoder와 높은 decoder masking ratio로 single vector에 정보를 싣도록 압박합니다.
Contrastive pretraining과 다른 질문:
contrastive: 어떤 입력이 서로 가까워야 하는가?
reconstruction: 한 vector가 입력 정보를 얼마나 담아야 하는가?
둘은 결합할 수 있습니다.
8. E5 · Weak Pair Scale과 High-quality Fine-tuning
E5의 이름은 embedding을 하나의 범용 text encoder로 다루는 흐름을 상징합니다. 논문은 대규모 heterogeneous text pair를 weak supervision으로 contrastive pretrain하고, labeled task mixture로 fine-tune합니다.
Stage 1: weakly supervised contrastive pretraining
web pairs / QA / title-body / dialogue / etc.
→ broad alignment
Stage 2: supervised fine-tuning
retrieval / NLI / similarity datasets
+ hard negatives
→ task quality and transfer
query:와 passage: prefix는 input role을 명시합니다.
query: 환불 기간은?
passage: 구매 후 14일 이내에 반품할 수 있습니다.
Prefix를 누락하면 training distribution과 serving input이 달라집니다.
9. Multilingual E5 · Scale만이 아니라 Sampling 문제
Multilingual E5 보고서는 10억 규모 multilingual text pair의 contrastive pretraining과 labeled mixture fine-tuning을 설명합니다.
Multilingual mixture의 어려움:
- 언어별 data 규모 불균형
- 같은 batch 내 false negatives
- cross-lingual positive 부족
- tokenizer fertility 차이
- 번역체와 실제 query style 차이
- high-resource language의 gradient domination
Language-balanced sampling과 monolingual/cross-lingual batch를 별도 ablation합니다.
10. BGE-M3 · Representation Function을 함께 학습한다
BGE-M3는 multilingual, multi-functionality, multi-granularity를 목표로 dense·sparse·multi-vector retrieval을 한 model에서 지원합니다. 서로 다른 retrieval score를 self-knowledge distillation teacher signal로 합칩니다.
same backbone
├─ dense score
├─ sparse lexical score
└─ multi-vector score
↓ self-distillation / joint learning
장점은 hybrid signal의 일관된 기반입니다. 운영에서는 각 head의 index·storage·latency가 여전히 다르므로 “model 하나”와 “system 하나”를 혼동하지 않습니다.
11. 하나의 현대적 Training Recipe로 합치기
Stage 0 base LM/encoder initialization
Stage 1 unlabeled corpus adaptation or reconstruction
Stage 2 large weak/synthetic pair contrastive pretraining
Stage 3 supervised multi-task fine-tuning
Stage 4 corpus ANN hard-negative mining + teacher denoising
Stage 5 in-domain calibration / distillation / compression
모든 stage가 필요한 것은 아닙니다.
| 상황 | 먼저 시도할 단계 |
|---|---|
| Label 5천, domain corpus 있음 | strong base → supervised + mined negatives |
| Label 없음, corpus 큼 | self-supervised/corpus adaptation → synthetic pairs |
| Generalist model 연구 | weak multi-task scale → curated supervised mixture |
| 작은 student 배포 | teacher distillation → MRL/quantization-aware eval |
12. Stage별 검증을 분리한다
stage_metrics:
pretraining:
- held_out_pair_retrieval
- representation_collapse
supervised:
- in_domain_ndcg
- mteb_task_slices
hard_negative:
- boundary_pair_accuracy
- false_negative_rate
deployment:
- exact_to_ann_recall
- latency
- storage
마지막 점수만 보면 어느 stage가 실제 gain을 냈는지 알 수 없습니다.
13. 재현할 때 놓치기 쉬운 차이
- Base checkpoint revision
- Query/document encoder weight sharing
- Pooling과 normalization
- Max length와 truncation side
- Temperature
- Per-device와 global effective batch
- Cross-device negative gather
- Hard-negative miner checkpoint
- Dataset mixture·sampling temperature
- Evaluation corpus preprocessing
“DPR loss를 썼다”만으로 recipe가 정의되지 않습니다.
14. 선택 가이드
작은 In-domain 개선
강한 공개 embedding을 고정 baseline으로 두고 human qrel + BM25/dense negatives로 fine-tune합니다. Pretraining을 처음부터 하지 않습니다.
새로운 언어·도메인 Base 연구
Corpus adaptation과 weak/synthetic pair pretraining을 비교하고, unseen source·time split으로 transfer를 봅니다.
범용 Model 연구
Dataset mixture, instruction, contamination audit, task balance가 architecture보다 먼저입니다.
스스로 확인하기
- ANCE의 global negative mining이 in-batch negative보다 해결하려는 문제는 무엇인가?
- Cross-batch negative 수를 늘릴 때 RocketQA식 denoising이 중요한 이유는 무엇인가?
- Contriever와 RetroMAE의 self-supervision은 무엇을 각각 학습시키는가?
- E5의 두 단계 학습에서 weak pretraining과 supervised fine-tuning의 역할은 무엇인가?
- BGE-M3가 model 하나여도 system cost가 하나가 아닌 이유는 무엇인가?
다음 글에서는 instruction-tuned embedding과 decoder-only LLM backbone의 pooling·attention·prompt contract를 분석합니다.