Method

Bằng chứng cấu trúc

Heading gốc Method xuất hiện tại trang PDF vật lý 3 (text layer).

Ghi chú kế thừa (nguyên văn)

Nguồn: ghi chú gốc. Chưa tái xác minh từng claim theo PDF.

1. Hybrid prompt representation

Vanilla prompt classification thường có:

  • Template: biến input thành cloze-style input.
  • Verbalizer: map mỗi label sang một token hoặc cụm token.

CPL bỏ verbalizer. Với câu , head entity và tail entity , template là:

Trong đó:

  • Bốn nhóm là continuous learnable prompt vectors.
  • Entity mentions là phần hard structure cung cấp prior cho RE.
  • [MASK] nằm giữa hai entity và đại diện cho relation giữa chúng.
  • Cấu hình chính dùng 4 nhóm prompt, mỗi nhóm dài 3 token, tức 12 learnable prompt tokens.
  • Prompt vectors được random initialization.

Embedding sequence được đưa qua encoder ; hidden state của [MASK] là relation representation:

Không có verbalizer nghĩa là model không phải dự đoán relation name như một vocabulary token. Nó học geometry của relation embedding, sau đó dùng metric classifier ở inference.

Vì sao hybrid thay vì hard-only hoặc soft-only?

  • Entity marker chỉ cho model biết vị trí entity nhưng không đưa task về masked-language form.
  • Hard prompt có expert prior tốt nhưng phải thiết kế thủ công.
  • Soft-only prompt linh hoạt nhưng random vectors khó hội tụ với vài mẫu.
  • Hybrid prompt giữ entity structure làm anchor và để continuous vectors tự thích nghi.

Figure 3 cho thứ tự kết quả sau task cuối: hybrid > hard > entity marker > soft-only trên cả FewRel và TACRED. Figure không in số trên từng bar nên chỉ nên dùng cho ranking, không suy số chính xác từ chiều cao cột.

2. Margin-based contrastive learning

Với normalized feature :

Trong đó là positive sample cùng relation, còn là negative sample khác relation.

Normalization term:

Similarity-dependent relaxation factors:

Batch loss:

Hyperparameters chính:

  • Margin .
  • Normalization constant .
  • Temperature .

Theo paper, và làm contribution và decision boundary thay đổi theo similarity, giúp model tập trung hơn vào hard pairs. Mục tiêu cuối là:

  • positive samples cùng relation gần nhau;
  • negative samples khác relation tách nhau;
  • feature space đồng đều hơn supervised contrastive learning;
  • giảm nhầm lẫn giữa relation gần nghĩa như child và father.

Feature bucket cho contrastive training

Supervised contrastive learning thường cần batch lớn để có đủ positive và negative pairs. CPL tránh tăng batch bằng một feature bucket :

  1. Encode current training set thành features và lưu vào .
  2. Với mỗi anchor trong batch, sample một tập features từ bucket để tạo .
  3. Tính MCL trên .
  4. Sau backpropagation, refresh các entries tương ứng trong bằng feature mới.

contrastive_sample_number được đặt là 500. Bucket này là auxiliary memory trong current-task optimization, không phải episodic memory dùng qua nhiều task.

3. Ba loại memory trong CPL

Ký hiệu / tênChứa gì?Tồn tại bao lâu?Dùng để làm gì?
/ feature bucketFeatures của current taskTrong khi train task Tạo nhiều contrastive pairs mà không cần batch lớn
/ replay memoryExemplar thật được chọn cho từng relationQua các taskGiữ evidence thật của relation cũ và tạo prototype
/ augmented samplesStructured examples do GPT-3.5 sinhTrong replay trainingMở rộng support set quanh exemplar thật

Việc tách ba memory giúp tránh nhầm rằng CPL chỉ có một replay buffer hoặc generated samples được dùng trực tiếp làm class prototype.

4. Representative memory sampling

Sau current-task training:

  1. Encode samples của từng relation.
  2. Chạy K-means với clusters cho mỗi relation.
  3. Trong mỗi cluster, chọn sample thật gần centroid nhất.
  4. Lưu sample đó vào replay memory.

Thí nghiệm chính dùng , nên mỗi relation chỉ giữ một exemplar thật gần mean embedding nhất.

5. GPT-3.5 memory augmentation

Với mỗi historical relation, prompt generation gồm:

  • mô tả format của một RE example;
  • relation name;
  • semantic relation explanation;
  • một demonstration thật có context, head entity và tail entity;
  • yêu cầu sinh examples mới cùng relation.

Paper dùng GPT-3.5-turbo, temperature 0, sinh:

  • 2 samples/relation cho FewRel;
  • 5 samples/relation cho TACRED.

Output được parse thành structured dataset , rồi ghép với real memory để replay bằng MCL.

Vì sao demonstration quan trọng?

Case study với relation child cho thấy relation name và description chưa chắc đủ để GPT hiểu đúng hướng head-tail. Khi có exemplar, output đúng relation; khi bỏ exemplar, một output mô tả hai entity là siblings nhưng vẫn gắn nhãn child.

Appendix C cũng cho thấy hai failure modes:

  • Generated samples lặp nhiều lexical pattern như mother, father, son, daughter.
  • Có thể tạo câu gần nghĩa về mặt từ vựng nhưng sai relation thật giữa head và tail.

6. Hai lượt training ở mỗi task

Prompt parameters và encoder parameters được khởi tạo từ checkpoint của task trước.

Current-task training
  D_train^k
  -> hybrid prompt
  -> encoder
  -> MCL
 
Memory construction
  -> K-means exemplar selection
  -> GPT-3.5 augmentation
 
Memory replay
  real exemplars + generated samples
  -> hybrid prompt
  -> encoder
  -> MCL lần hai

Lượt đầu học relation mới. Lượt replay củng cố relation cũ và tránh overfit vào một exemplar/relation.

7. Relation prediction bằng Nearest-Class-Mean

Sau contrastive training, prototype của relation được tính từ real memory:

Với test sample :

NCM phù hợp class-incremental setting vì:

  • không có softmax head với output dimension cố định;
  • relation mới chỉ cần thêm prototype;
  • inference tận dụng trực tiếp feature space đã được MCL làm discriminative.

Với , prototype chỉ dựa trên một exemplar thật, vì vậy chất lượng exemplar selection và stability của encoder đặc biệt quan trọng.