هذا هو مستودع الكود المستخدم في الورقة:
يرجى الاستشهاد بالورقة على النحو التالي:
@article { din2023jump ,
title = { Jump to Conclusions: Short-Cutting Transformers With Linear Transformations } ,
author = { Yom Din, Alexander and Karidi, Taelin and Choshen, Leshem and Geva, Mor } ,
journal = { arXiv preprint arXiv:2303.09435 } ,
year = { 2023 } ,
} لإنتاج مخططات لجمل gpt2 و Wikipedia ، قم بتشغيل ما يلي ، بالترتيب المكتوب:
get_wikipedia_sentences.py
(ينتج ./experiment/sentences/wikipedia_20K-sentences.pickle
add_tokenization.py
./experiment/gpt2/wikipedia_tokenized_val.pickle تنتج ./experiment/gpt2/wikipedia_tokenized_train.pickle
add_linreg.py
(تنتج ./linreg/gpt2/wikipedia/i_j.pickle حيث
add_plot_r2.py
(تنتج ./experiment/gpt2/wikipedia_r2_scores.pickle المحتوى ./experiments/gpt2/plots/wikipedia/r2_scores_12.pdf
add_linreg_submodules.py
(تنتج ./linreg/gpt2/wikipedia/pi_a_b.pickle حيث
add_results.py
(ينتج ./experiment/gpt2/wikipedia_results.pickle
plot_results.py
(ينتج بعض المؤامرات في ./experiment/gpt2/plots/wikipedia/ بناءً على النتائج في إخراج الملف السابق)
لإنتاج مخططات لجمل bert-base-uncased و Wikipedia ، قم بتشغيل ما يلي ، بالترتيب المكتوب:
get_wikipedia_sentences.py
(كما هو الحال بالنسبة gpt2 أعلاه ، لا حاجة لإعادة تشغيل)
bert_add_reps.py
./experiment/bert-base-uncased_mask/wikipedia_val.pickle ينتج ./experiment/bert-base-uncased_mask/wikipedia_train.pickle مواقف الرمز المميز وتمثيل الرمز العشوائي المقنع في جميع الطبقات للجمل 3000 التالية)
bert_add_linreg.py
./linreg/bert-base-uncased_mask/wikipedia/i_j.pickle ينتج
BERT_ADD_PLOT_R2.PY
(ينتج ./experiment/bert-base-uncased_mask/wikipedia_r2_scores.pickle ./experiments/bert-base-uncased_mask/plots/wikipedia/r2_scores_12.pdf
bert_add_results.py
(المنتج ./experiment/bert-base-uncased_mask/wikipedia_results.pickle
plot_results.py (تغيير model_folder_name='bert-base-uncased_mask' و plot_parts = False )
(ينتج بعض المؤامرات في ./experiment/bert-base-uncased_mask/plots/wikipedia/
أنتجنا أيضًا مخططات لـ gpt2-medium و gpt2-large و gpt2-xl و bert-large-uncased . للقيام بذلك ، ينبغي للمرء أن يعدل ، بطريقة متطورة نسبيا ، المتغيرات الموجودة على رأس كل نص في التسلسل.
تم تشغيل الرمز مع Python 3.10.4 وإصدارات الحزمة التالية:
torch.__version__ = 1.13.1+cu117
transformers.__version__ = 4.20.1
sklearn.__version__ = 1.2.0
pickle.format_version = 4.0
datasets.__version__ = 2.5.2 # used only to fetch Wikipedia sentences
spacy.__version__ = 3.5.0 # used only to fetch Wikipedia sentences
يمكن العثور على بعض المصفوفات المدربة على https://huggingface.co/Sashay/linear-hortcut.