該存儲庫包含實驗守則,以通過合併語言模型的權重來重現數據知識融合的結果,該論文將在2023年5月1日至5日在2023年在盧旺達的基加利舉行,將在第十一國際學習代表國際會議(ICLR 2023)會議上發表。
@inproceedings{
jin2023dataless,
title={Dataless Knowledge Fusion by Merging Weights of Language Models},
author={Xisen Jin and Xiang Ren and Daniel Preotiuc-Pietro and Pengxiang Cheng},
booktitle={The Eleventh International Conference on Learning Representations},
year={2023},
url={https://openreview.net/forum?id=FCnohuR6AnM}
}
我們使用了Pytorch 1.13.1。有關其他要求,請參見要求。
如果您只是對回歸平均值(Regmean)算法感興趣,請檢查regmean_demo.ipynb。
這是一個獨立的jupyter筆記本電腦,融合了兩個在膠水上進行微調的擁抱臉型變壓器模型。該文件不在src/下導入文件。
請在此存儲庫中下載統一的情緒數據集。這些文件應在以下結構中放置在PROJECT_ROOT/resources/emotion_splits下。
.
├── crowdflower
│ ├── dev.jsonl
│ ├── full.jsonl
│ ├── test.jsonl
│ └── train.jsonl
├── dailydialog
│ ├── dev.jsonl
│ ├── full.jsonl
│ ├── test.jsonl
│ └── train.jsonl
├── electoraltweets
│ ├── dev.jsonl
│ ├── full.jsonl
│ ├── test.jsonl
│ └── train.jsonl
├── emobank
│ ├── dev.jsonl
│ ├── full.jsonl
│ ├── test.jsonl
│ └── train.jsonl
...
請準備Conll2003,Ontonotes和Twitter NER數據集,並將其放在PROJECT_ROOT/resources/ner下。
.
├── conll2003
│ ├── dev.conll
│ ├── test.conll
│ └── train.conll
├── ontonotes
│ ├── onto.development.bc.ner
│ ├── onto.development.bn.ner
│ ├── onto.development.mz.ner
│ ├── onto.development.nw.ner
│ ├── onto.development.tc.ner
│ ├── onto.development.wb.ner
│ ├── onto.test.bc.ner
│ ├── onto.test.bn.ner
│ ├── onto.test.mz.ner
│ ├── onto.test.nw.ner
│ ├── onto.test.tc.ner
│ ├── onto.test.wb.ner
│ ├── onto.train.bc.ner
│ ├── onto.train.bn.ner
│ ├── onto.train.mz.ner
│ ├── onto.train.nw.ner
│ ├── onto.train.tc.ner
│ └── onto.train.wb.ner
└── twitter
├── annotated.twitter-ner-20-21-tweet-dev-withcleaned.json
├── annotated.twitter-ner-20-21-tweet-test-withcleaned.json
└── annotated.twitter-ner-20-21-tweet-train-withcleaned.json
在這裡,Conll和Ontonotes數據集包含孔格式的條目。
CRICKET O Conll
- O Conll
LEICESTERSHIRE B-ORG Conll
TAKE O Conll
OVER O Conll
AT O Conll
TOP O Conll
AFTER O Conll
INNINGS O Conll
VICTORY O Conll
. O Conll
LONDON B-LOC Conll
1996-08-30 O Conll
...
Twitter NER每行包含1個JSON。
{"text": "Spectacular skies over #Clonmel tonight http://t.co/OxclQkuyTp /via @niallodonovan #lastdayofautumn", "id": "539106999980797952", "entities": [{"startCharOffset": 24, "endOffset": 31, "endCharOffset": 31, "surface": "Clonmel", "startOffset": 24, "type": "LOC"}, {"startCharOffset": 69, "endOffset": 82, "endCharOffset": 82, "surface": "niallodonovan", "startOffset": 69, "type": "PER"}], "labels": ["O", "O", "O", "O", "B-LOC", "O", "O", "O", "O", "B-PER", "O", "O"], "tokens": ["Spectacular", "skies", "over", "#", "Clonmel", "tonight", "http://t.co/OxclQkuyTp", "/", "via", "@niallodonovan", "#", "lastdayofautumn"], "domain": "TWT"}
膠水數據集將下載並加載擁抱Face的datasets集庫。
請從擁抱的面部模型存儲庫中下載預估計的型號(例如,Roberta-Base),並將其放在PROJECT_ROOT/resources (例如PROJECT_ROOT/resources/roberta-base )下。
--config_files :請參閱src/configs下的下方。訓練模塊( src.run_experiments )需要三個配置文件定義默認參數( src/defaults.yaml ),數據配置(在src/configs/datasets下)和exp confiel(在src/configs/exps下)。
--filter_model :僅合併數據配置中指定的單個模型的子集時很有用--filter_model model0 model1將執行Model0和Model1的成型合併(請參閱數據配置中的Model0,Model1,Model0,Model1的定義)。
--templates :配置文件可能包含{seed}之類的模板。模板的值應在命令行中指定(例如--templates seed=1 )。
單個模型(在合併之前)將在配置中指定的local_zoo_dir下進行訓練和存儲。如果動物園中的單個模型都不匹配給定的模型類型和配置中的zoo_filter參數,則該程序將自動訓練新的單個模型並將其存儲在local_zoo_dir下。如果在local_zoo_dir中找到各個模型,則將加載它們而不會重新訓練。
示例:雷格曼,情感,同一頭初始化,合併Model0(每日模型)和Model1(Crowdflower)
HF_DATASETS_OFFLINE=1 CUDA_VISIBLE_DEVICES=0 python -m src.run_experiments --config src/configs/defaults.yaml src/configs/datasets/emotion.yaml src/configs/exps/roberta-base/roberta-base-emotion.yaml --templates seed=1 --filter_model model0 model1
合併在不同數據集(域)上訓練的兩個情緒分類模型。
scripts/roberta/pairwise_emotion.pyscripts/t5/pairwise_emotion.pyscripts/t5/pairwise_emotion.py合併了在不同的膠水任務上訓練的兩個型號。特定於任務的分類頭不合併。
scripts/distilbert/pairwise_glue_difftask.pyscripts/roberta/pairwise_glue_difftask.py合併兩個在同一膠水任務的兩個非IID分區訓練的型號
scripts/distilbert/pairwise_glue_subset.pyscripts/roberta/pairwise_glue_subset.py 貪婪地合併了多個模型的多個模型(兩個)模型。
scripts/roberta/incremental_emotion.pyscripts/t5/incremental_emotion.pyscripts/deberta/incrementale_emotion.pyscripts/roberta/incremental_ner.pyscripts/deberta/incremental_ner.py請注意,這些腳本在內域和室外測試集上都進行推斷。
上面的每個腳本將運行簡單,費舍爾和雷格曼平均。他們還運行多任務學習(MTL),模型集合以及單個模型(合併)作為比較器的性能。您可以在這些腳本中評論線條,只需運行每個腳本的一部分即可。
該項目是根據Apache 2.0許可證獲得許可的。有關詳細信息,請參見許可證文件。
該項目採用了行為準則。如果您對項目中經歷的代碼或行為有任何疑問,請通過[email protected]與我們聯繫。
如果您認為自己已經確定了該項目中的安全漏洞,請通過[email protected]向項目團隊發送電子郵件,詳細介紹了可疑問題以及您發現複製它的任何方法。
請不要在GitHub存儲庫中打開一個問題,因為我們希望將脆弱性報告保密,直到我們有機會進行審查和解決它們。