
我们已经在拥抱脸上添加了检查站,以便于复制!
我们已经添加了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的宝贵评论和观点