You are on page 1of 54

CONDENSER: a Pre-training

Architecture for Dense Retrieval

Giảng viên:
Nguyễn Tiến Huy Nhóm 5:
Nguyễn Trường Sơn 21C11029 Hoàng Minh Thanh
21C11005 Trần Hữu Nghĩa
1. Introduction

2. Related Work

Contents 3. Main

4. Experiments

5. Conclusion

6. Q & A
1. Giới thiệu
Giới thiệu

• Pre-trainning Language model mang lại nhiều


hiệu quả leaning text encoders
• Nhận thấy LM như BERT sau khi pre-training có
cấu trúc attention không tối ưu
• Bi-encoder fine-tuning không thực sự hiệu quả
do thiếu sẵn sàng về cấu trúc(structural
readiness)
Giới thiệu

• Condenser
• Condenser pre-train hướng tới cấu trúc bi-encoder
• Với dữ liệu ít
• Condenser mang lại sự cải thiện so với LM
• Có thể so sánh hiệu suất với các model pre-
trained có các tác vụ cụ thể
• Với dữ liệu lớn
• Condenser tối ưu hóa dễ hơn, vượt trội hơn so với pre
-trained trước sử dụng kỹ thuật phức tạp
2. Related work
2. Related work

❑ Bi-Encoders để tính
độ tương đồng giữa
queries và data trong
không gian vector.
Model này được biểu
diễn dữ liệu ( văn
bản,hình ảnh,
video,…) dưới dạng
vector
2. Related work

❑ Cross-Encoder không
tạo ra các embeddings
vector cho dữ liệu mà
thay vào đó sử dụng cơ
chế phân loại cho các
cặp dữ liệu. Đầu vào của
mô hình luôn bao gồm
một cặp dữ liệu, ví dụ
hai câu và xuất ra một
giá trị từ 0 đến 1 cho
thấy sự tương đồng giữa
hai câu này .
2. Related work
2. Related work
2. Related work

• Dense retrieval so sánh encoded query vectors


với corpus document vectors sử dụng inner
product
• Pre-train Bi-encoder cho thấy hiệu quả
Transformer với dense retrieval
• Inverse Cloze Task (ICT)
3. Condenser: a Pre-training
Architecture for Dense Retrieval
What is Condenser?

❑ Condenser giúp việc fine-tune tốt hơn


Dense Retrieval là gì?

❑ Bài toán: Open-domain Question Answering

Corpus

Tổng thống đầu Ranked


Stage Re-Ranker
tiên của Mỹ là ai ?
Retrieval Cross-Encoder hits

Donal Trump George​ Washington​


Pipeline cho Question Answering
Cơ chế Attention
𝑥1 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5
Apple is good in its design Apple is good for your health

0.6 0.2 0.9 0.3 0.4 0.5


0.6 0.2 0.8
0.2 0.3 0.1 0.1 0.1 0.3

Query Q 0.8 0.1 0.8 0.4 0.3 0.7


Hệ số chuẩn hóa
Keys K
Apple is for good your health
0.6 0.6 0.2 0.9 0.3 0.4 0.5

0.2 0.2 0.3 0.1 0.1 0.1 0.3

0.8 0.8 0.1 0.8 0.4 0.3 0.7

Values V Hệ số chuẩn
hóa

16
Cơ chế Attention
Attention mechanism
Attention mechanism
Attention mechanism
Attention mechanism
Attention mechanism

v2 v3
v1
Pipeline cho Question Answering
BERT – Cross Encoder
Cross-Encoder và Bi-Encoder
Dense Retrieval

❑ Encode chuỗi văn bản thành các vector


❑ Tìm cặp phù hợp bằng cách tính inner product
search
❑ Effective và efficient
● Dễ dàng tương tác trong dense embedding space
● Có thể xử lý trước các đoạn văn bản

Tổng thống đầu tiên của Mỹ là ai ?


Dense Retrieval with Transformer

❑ Đưa text sequence qua Transformer encoder


❑ Sử lớp layer cuối cùng [CLS] biểu diễn
embedding
Dense Retrieval with Transformer
Pre-trained Language Model for Dense
Retrieval
❑ Encoder được khởi tạo bằng pre-trained LM
như BERT
● Fine-tune CLS token representation
❑ Tuy nhiên, BERT được training để hướng
tới level token
● Masked Language Model học để biểu diễn token-
level ngữ cảnh
CLS Representation and attention in
BERT
❑ CLS không được training để tổng hợp thông tin
từ toàn bộ input sequence
❑ CLS Attention Pattern (Clark et al., 2019)
● CLS gần như đứng im ở những layer ở giữa
● CLS chỉ kích hoạt trở lại ở layer cuối cùng cho Next
Sentence Prediction
Condenser

❑ Condenser ý tưởng
● Bi-directional attention (Transformer Encoder)
● Bi-direction language modeling task (MLM)
● Language model prediction cần phải phụ thuộc vào
CLS biểu diễn đặc
Condenser

❑ Pre-training CONditions on DENSE


Representation
❑ A Transformer Encoder với kiến trúc "đối xứng"
Architecture
Condenser

❑ Ba nhóm của Transformer Encoder Layer


● Early Backbone Layer
● Late Backbone Layer
● Condenser Head Layers
Condenser

❑ Early Backbone:
● Input: Embeddings
❑ Late Backbone:
● Input: Output từ early layers
Condenser: Head Layers

❑ Input:
● CLS vector từ late layers
● Token vectors từ early layers
❑ A "Short Circuit"
Condenser: Masked Language
Modeling Pre-training
❑ Pre-training với MLM Objective
❑ Dựa trên head layer output
Condenser: CLS in Late Backbone
Layers
❑ Layer cuối tiếp tục được refine token biểu diễn
❑ Tuy nhiên chỉ CLS token được pass vào thông tin
mới
❑ CLS chủ động tổng hợp input sequence
information
Condenser: Related Architectures

❑ Funnel Transformer (Dai et al,. 2020)


❑ U-net (Ronneberger et al., 2015)
Condenser: Fine-tuning

❑ Drop head Condenser


● Condenser head dùng để phụ trợ trước khi training
❑ Train CLS từ late backbone Condenser
● Recall CLS thông tin đã học được tổng hợp từ input
sequence
4. Experiment result
Colab resul

❑ Condenser:
https://colab.research.google.com/drive/1ZtxZI8
8hB1jGl00y2eixsmvNG-5Zc9SL?usp=sharing

❑ Legal Text Retrieval:


https://colab.research.google.com/drive/1YVrk9
yfq7PgF8Ug2NYyI8UMSeMkSqcSH?usp=sharing
Experiment

❑ Retrieval
● Open QA
 Natural Question
 Trivia QA
● Large Scale Supervised IR
 MS-MARCO
● Attention Analysis
 Condenser có dễ dàng training hơn không?
Ranking
Experiment: Open QA

❑ Kết quả training

Improved Fine-tuning

Condenser Pre-training
Experiment: Supervised IR

❑ Hiệu suất của mô hình với kỹ thuật fine-tuning


Attention Analysis: Is
Condenser actually easier to train?
❑ Vanilla BERT's Attention thay đổi rất lớn
❑ Further pre-trained Models (ICT and condenser)
thay đổi rất nhỏ
Conclusion

❑ Trong mô hình BERT


● Pre-training tập trung vào token-level representation
● CLS không học được thông tin tổng hợp
● Token CLS chỉ học ở cuối mô hình và gần như đứng
im ở các layer ở giữa
❑ Mô hình Condenser để xuất:
● A Transformer LM học thông tin được tổng hợp
● MLM pre-training conditions dựa trên các CLS vector
❑ Condenser giúp fine-tuning dễ dàng hơn
Q&A
Thanks
(Previous) Pre-training Methods for
Dense Retrieval
❑ (Pseudo) Data Driven
● Create pseudo query passage pairs
● Inverse Cloze Task (ICT)
● Body First Selection and Wiki Link Prediction
❑ "Warm up" the CLS representation
❑ Large training batch với Contrastive Loss
Attention Analysis: Is Condenser
actually easier to train?
❑ So sánh CLS Attention
● Pre-trained Model without Fine-tuning
● Fine-tuned Model
❑ Find out change in attention patterns
❑ Measure CLS attention entropy at each layer
● Characterize CLS attention pattern
Better Pre-training?

❑ Goal
● Make fine-tuning easier
❑ ICT and related methods
● Tasks may be too simple
● Better task is desired
Direct Fine-tuning for Dense Retrieval

❑ The dense passage retrieval (DPR) setup


● Careful fine-tuning yields better results than earlier
pre-training methods
❑ Best results requires sophisticated methods
(RocketQA)
● Large training batch
● Negative selection and filtering
● Data augmentation
❑ Fine-tuning không hề dễ dàng
● Model không thực sự sẵn sàng cho dense fine-tuning

You might also like