
我們已經在擁抱臉上添加了檢查站,以便於復制!
我們已經添加了continual_pretrain.ipynb,作為軟覆蓋方案的獨立示例。它運行良好,沒有GPU!
軟掩模也可以在常規的持續微調中起作用。查看我們最新的EMNLP23紙!
想知道您是否可以在不擔心其參數更新的情況下調整Black-Box LLM ?在此處查看我們有關檢索的最新報紙(RAG)!
在2021年,我們引入了Pycontinual,這是一個直接而靈活的框架,用於持續學習。我們的研究從這個框架中受益匪淺。如今,我們很高興分享連續性的持續學習框架,旨在維持該領域的持續學習(CL)的好處(LMS)。
LMS的持續學習與傳統CL不同,因為
我們的存儲庫包括使用相同的培訓和評估管道的Pytorch實施(SOTA)方法集合(SOTA)。該存儲庫致力於推進LMS持續學習的領域。包括的方法是:
來自我們的小組:
來自其他團體(未來更多) :
廣泛使用的基準持續學習:
我們已經添加了continual_pretrain.ipynb ,作為軟覆蓋方案的獨立示例。它運行良好,沒有GPU!
當涉及語言模型(LMS)的持續學習時,找到合適的數據集至關重要。我們提供的數據集遵守以下原則:
我們發布包括6個不同域的數據集,每個域都伴隨其相應的端任務。數據集可以在此處找到。以下是每個領域的一些統計數據:
| 域語料庫 | 尺寸 | 端任務 | 任務 | #訓練 | #Testing | #Classes |
|---|---|---|---|---|---|---|
| Yelp餐廳 | 758MB | 餐廳 | 方面情感分類(ASC) | 3,452 | 1,120 | 3 |
| 亞馬遜電話 | 724MB | 電話 | 方面情感分類(ASC) | 239 | 553 | 2 |
| 亞馬遜相機 | 319MB | 相機 | 方面情感分類(ASC) | 230 | 626 | 2 |
| ACL論文 | 867MB | ACL | 引用意圖分類 | 1,520 | 421 | 6 |
| AI論文 | 507MB | 人工智慧 | 關係分類 | 2,260 | 2,388 | 7 |
| PubMed論文 | 989MB | PubMed | 化學蛋白相互作用預測 | 2,667 | 7,398 | 13 |
連續性的架構在很大程度上遵循了Pycontinual,CPT和DGA的結構。
conda create --name continuallm --file requirements.txt
transformers==4.17.0 ,並且adapter-transformers==3.0.1 。我們建議使用這些特定版本,因為使用其他版本可能會導致意外的錯誤。
這是不斷學習的地方。我們將學習一個域的信息。
max_samples=640000
for idrandom in 0
do
for pt_task in 0 1 2 3 4 5
do
python -m torch.distributed.launch --nproc_per_node 4 --use_env posttrain.py
--per_device_train_batch_size 62
--fp16
--max_seq_length 164
--max_samples ${max_samples}
--idrandom ${idrandom}
--ntasks 6
--pt_task ${pt_task}
--baseline ' das '
done
done --idrandom :選擇任務序列。有關更多詳細信息,請參見./sequences 。--baseline :有關可用基線模型的簡介(請參閱config.py中的choices )。 經過LMS的孔子學習後,現在我們能夠通過單獨運行端任務微調來評估性能。
max_samples=640000
seed=(2021 111 222 333 444 555 666 777 888 999)
for round in 0 ; do
for idrandom in 0 ;
do
for pt_task in 0 1 2 3 4 5
do
for ft_task in $( seq 0 ${pt_task} ) ;
do
python finetune.py
--max_seq_length 164
--pt_task ${pt_task}
--ft_task ${ft_task}
--idrandom ${idrandom}
--ntasks 6
--max_samples ${max_samples}
--seed ${seed[$round]}
--baseline ' das '
done
done
done
done 對於那些僅對最終模型感興趣或想繼續使用自己的數據進行訓練的人,我們有個好消息!我們通過擁抱的臉提供檢查站。
您可以輕鬆地使用HuggingFace的transformers導入我們持續的訓練後模型!
import torch
from transformers import AutoTokenizer , AutoModelForSequenceClassification
# Import our model. The package will take care of downloading the models automatically
tokenizer = AutoTokenizer . from_pretrained ( "UIC-Liu-Lab/DAS-Rest2Cam" )
model = AutoModelForSequenceClassification . from_pretrained ( "UIC-Liu-Lab/DAS-Rest2Cam" , trust_remote_code = True )
# Tokenize input texts
texts = [
"There's a kid on a skateboard." ,
"A kid is skateboarding." ,
"A kid is inside the house."
]
inputs = tokenizer ( texts , padding = True , truncation = True , return_tensors = "pt" )
# Get the model output!
res = model ( ** inputs )如果您通過HuggingFace的API直接加載模型時遇到任何問題,也可以手動從存儲庫手動下載模型,並使用model = AutoModel.from_pretrained({PATH TO THE DOWNLOAD MODEL}) 。
持續的訓練序列是./sequences/posttrain (從餐廳到相機)的第一個序列,您可以使用下載的權重來調整相應的端任務。
如果您對重要性文件感興趣,請參閱before_distill0和after_mlm{domain_id} 。在預先培訓之前計算出的重要性before ,這僅在第一個領域之前進行一次以供一般培訓的知識進行。 after指示domain_id預訓練後計算的重要性。
我們非常感謝您凝視和引用的行為。您對細節和認可的關注非常重視。
@inproceedings { ke2022dgs ,
title = { Continual Learning of Language Models } , author = { Ke, Zixuan and Shao, Yijia and Lin, Haowei and Konishi, Tatsuya and Kim, Gyuhak and Liu, Bing } , booktitle = { International Conference on Learning Representations (ICLR) } , year = { 2023 } }
@inproceedings { ke2022dga ,
title = { Adapting a Language Model While Preserving its General Knowledge } , author = { Ke, Zixuan and Shao, Yijia and Lin, Haowei and Xu, Hu and Shu, Lei, and Liu, Bing } , booktitle = { Empirical Methods in Natural Language Processing (EMNLP) } , year = { 2022 } }
@inproceedings { ke2022continual ,
title = { Continual Training of Language Models for Few-Shot Learning } , author = { Ke, Zixuan and Lin, Haowei and Shao, Yijia and Xu, Hu and Shu, Lei, and Liu, Bing } , booktitle = { Empirical Methods in Natural Language Processing (EMNLP) } , year = { 2022 } } 如果您對代碼有任何疑問,請隨時向Zixuan KE,Yijia Shao或Haowei Lin發送電子郵件。另外,您可能會打開一個問題。我們要感謝Bing Liu,Hu Xu和Lei Shu的寶貴評論和觀點