![مفتوح- GPT-2-3](https://habrastorage.org/webt/1k/58/ea/1k58ea5w9egy2dc5z3jtsiip3sc.png)
في عام 2019 ، شهدنا الاستخدام الرائع للتعلم الآلي. أظهر نموذج OpenAI GPT-2 قدرة رائعة على كتابة نصوص متماسكة وعاطفية متفوقة على فهمنا لما يمكن أن تولده نماذج اللغة الحديثة. إن GPT-2 ليست بنية معمارية جديدة على وجه الخصوص - فهي تذكرنا جدًا بـ Transformer-Decoder (Transoder-only Transformer). الفرق بين GPT-2 هو أنه نموذج لغوي ضخم حقًا يعتمد على Transformer ، تم تدريبه على مجموعة بيانات رائعة. في هذه المقالة ، سنلقي نظرة على بنية النموذج ، مما يسمح لنا بتحقيق مثل هذه النتائج: نعتبر بالتفصيل طبقة الانتباه الذاتي واستخدام محول فك التشفير للمهام التي تتجاوز نمذجة اللغة.
المحتوى
1: GPT-2
?
Word2vec , – , , . – , .
![لوحة مفاتيح سريعة](https://habrastorage.org/webt/98/yv/br/98yvbr3q4hpjs8hfsg1rajz3n9m.png)
, GPT-2 , , , . GPT-2 40 (WebText), OpenAI . , , SwiftKey, 78 , GPT-2 500 , GPT-2 – 13 ( 6,5 ).
![أحجام gpt2](https://habrastorage.org/webt/md/qg/ve/mdqgveo0tsyxqapfzqpomuu5nzo.png)
GPT-2 AllenAI GPT-2 Explorer. GPT-2 ( ), .
, – .. . – , - .
![محول - ترميز - فك](https://habrastorage.org/webt/sv/tx/hm/svtxhmcbpksa7rjn0wb0o2jj_wc.png)
, , , , ( AlphaStar).
![gpt-2-transformer-xl-bert-3](https://habrastorage.org/webt/j4/sb/4r/j4sb4rysituzcqsafgktspu0pa8.png)
? , GPT-2 :
![gpt2-size-hyperparameters-3](https://habrastorage.org/webt/gg/og/nr/ggognri38aojdzkkzazvnetxfvy.png)
BERT'
:
, .
GPT-2 . BERT , , . . , GPT-2, , . , GPT-2 :
![gpt-2-output](https://habrastorage.org/webt/so/pv/tj/sopvtjhr-crr3rgtf_zaoqomgck.gif)
: , , . . «» (auto-regression) RNN .
![gpt-2-autoregression-2](https://habrastorage.org/webt/un/7x/ir/un7xirwndekafrdeixsce0ocmmm.gif)
GPT-2 TransformerXL XLNet . BERT . . , BERT . XLNet , .
.
– :
![محول ترميز كتلة 2](https://habrastorage.org/webt/f_/ym/xb/f_ymxbcpvszucrhogiurzwqypzk.png)
(, 512 ). , .
– , . :
![محول - مفكك - بلوك - 2](https://habrastorage.org/webt/gh/so/u6/ghsou6icfirnjbj1abkj7ouqohg.png)
, [mask] , BERT', , , .
, , #4, , :
![المحول - وحدة فك الترميز - الانتباه الذاتي - 2](https://habrastorage.org/webt/ta/9r/td/ta9rtdiimdxkwmwpmdxy2ig-0h8.png)
, BERT, GPT-2. . :
![الانتباه الذاتي والملثمين والاهتمام الذاتي](https://habrastorage.org/webt/43/cq/pd/43cqpdiypmyuccr1gznrhr4tioo.png)
, «Generating Wikipedia by Summarizing Long Sequences» , : . «-». 6 :
![محول - فك - مقدمة](https://habrastorage.org/webt/rd/l7/k-/rdl7k--_z3kg4ajejaycksxqpt0.png)
. , . , 4000 – 512 .
, , . « », / .
GPT-2 OpenAI .
- : GPT-2
, , . , , , , . (Budgie)
GPT-2 , .
![gpt-2-طبقات -2](https://habrastorage.org/webt/he/ig/hj/heighjb23joyolbax5b7__fvj6a.png)
GPT-2 1024 . .
GPT-2 – ( ) (), (.. ). , ( <|endoftext|>; <|s|>).
![gpt2-simple-output-2](https://habrastorage.org/webt/ho/yz/o0/hoyzo0yvmbi3gf-1awm__udx0fi.gif)
, . , (score) – , (50 GPT-2). – «the». - – , , , , – . . GPT-2 top-k, , , (, , top-k = 1).
:
![gpt-2-simple-output-3](https://habrastorage.org/webt/hg/2x/ps/hg2xpsd1kuverowaqcd4z_w--ki.gif)
, . GPT-2 ( ). GPT-2 .
. . NLP-, , – , .
![gpt2-token-embeddings-wte-2](https://habrastorage.org/webt/qo/ml/jl/qomljlikh-rqxyud6otmaxrtyum.png)
– , - . GPT-2. 768 /.
, <|s|> . , – , . , 1024 .
![الترميز الموضعي gpt2](https://habrastorage.org/webt/zp/mu/cg/zpmucgftth4mabqo60oolwdohey.png)
. , GPT-2.
![gpt2-input-embedding-pososition-encoding-3 (إدخال-تضمين-تضمين-ترميز -3)](https://habrastorage.org/webt/me/r8/bx/mer8bx3ofjqcpydqnfsvo1fk4ok.png)
#1.
, , . , . , , .
![gpt2-transformer-block-vectors-2](https://habrastorage.org/webt/ij/9e/3a/ij9e3alc1pc5ihgpd8njpbh2-vy.png)
. , :
, , , .
, . , . , , :
: , , ( ). , , .
, «a robot» «it». , , , .
![gpt2-self-attention-example-2](https://habrastorage.org/webt/yx/vw/ou/yxvwoujcadhlalw2xgq3dnoezjq.png)
. :
- – , ( ). , ;
- – . ;
- – ; , , .
![self-attention-example-folders-3](https://habrastorage.org/webt/ds/30/gu/ds30gubjhv2r7ubicxiq-idgdlg.png)
. – , . . , – . , .
(: ).
![self-attention-example-folders-scores-3](https://habrastorage.org/webt/br/mp/xd/brmpxdc2ngiqgrkmrgn1wb5aud4.png)
, .
![gpt2-value-vector-sum](https://habrastorage.org/webt/xv/7n/ez/xv7nezgfhygrknpndfsptjwucpe.png)
, 50% «robot», 30% «a» 19% – «it». . .
( ), .
![gpt2-output-projection-2](https://habrastorage.org/webt/vz/tt/mf/vzttmfwinmu2z7v3m0hkxijm5o8.png)
, . .
![gpt2-output-scores-2](https://habrastorage.org/webt/fg/ib/yq/fgibyqwocamlo1cax73ck1qxrwg.png)
(top_k = 1). , . , , ( ). – top_k 40: 40 .
![gpt2-output](https://habrastorage.org/webt/ji/zl/mk/jizlmk0ywrvlljh6ynxq_eqacjs.png)
, . , (1024 ) .
: GPT-2,
, , GPT-2. , , . , ( TransformerXL XLNet).
, :
- «» «» ; GPT-2 (Byte Pair Encoding) . , .
- GPT-2 / (inference/evaluation mode). . . (512), 1, .
- / . .
- , . Transformer , .
- . «zoom in», :
![zoom-in](https://habrastorage.org/webt/q_/kq/35/q_kq35nsjwiycnwcafi8ctxl_tm.png)
2:
, «it»:
![gpt2-self-attention-1-2](https://habrastorage.org/webt/ss/7h/dk/ss7hdk8hwx43lbghil2t3os95bm.png)
, . , , . , , .
( )
, . , 4 .
:
- , ;
- ;
- .
![self-attention-summary](https://habrastorage.org/webt/ab/l8/ax/abl8ax5sj4nuqdq8jihtayycpvc.png)
1 – ,
. . . ( «» ):
![self-attention-1](https://habrastorage.org/webt/qc/7c/0l/qc7c0ll_eqaebzsk5jqluip1j7k.png)
, WQ, WK, WV
2 –
, , №2: .
![self-attention-2](https://habrastorage.org/webt/47/tl/vm/47tlvmotgdunt0od7rzfptulwxi.png)
( ) ,
3 –
. , .
![self-attention-3-2](https://habrastorage.org/webt/nz/aa/sl/nzaaslrrr6etmrs-qlkhlb9o6oc.png)
, – , .
, , . ( ).
, , , . №2. , . . , :
![masked-self-attention-2](https://habrastorage.org/webt/di/h6/vx/dih6vxt0pa-5ipj_qtruxbmbcae.png)
, (attention mask). , , («robot must obey orders»). 4 : ( , – ). .. , 4 , ( 4 ) .
![transformer-decoder-attention-mask-dataset](https://habrastorage.org/webt/ot/_d/k9/ot_dk95ismt5lcax-xeomlzxigu.png)
, . , , ( ), :
![queries-keys-attention-mask](https://habrastorage.org/webt/2_/kz/ws/2_kzws5vewj2dvdy-rtcgwjxdd8.png)
«» . , , – (-inf) (, -1 GPT-2):
![transformer-attention-mask](https://habrastorage.org/webt/86/aw/oh/86awoh2nlrcsdh3_hveet0rh3vw.png)
, , , :
![transformer-attention-masked-scores-softmax](https://habrastorage.org/webt/cr/-o/ku/cr-okuz6tuuuaeht--j8mjblnqo.png)
:
- ( №1), («robot»), 100% .
- ( №2), («robot must»), «must» 48% «robot» 52% «must».
- ..
GPT-2
GPT-2.
:
, GPT-2 , . , , , .
( <|s|>).
![gpt2-self-attention-qkv-1-2](https://habrastorage.org/webt/oc/r2/ps/ocr2ps037_1vvr2uajz1idbe76g.png)
GPT-2 «a». :
![gpt2-self-attention-qkv-2-2](https://habrastorage.org/webt/0e/wf/vx/0ewfvx7snx6azpvwietxqfd9zzg.png)
, «robot», , «a» – , :
![gpt2-self-attention-qkv-3-2](https://habrastorage.org/webt/re/qe/ff/reqeffjn9neoql-qqpiqp8hwmjq.png)
GPT-2: 1 – ,
, «it». , «it» + #9:
![gpt2-self-attention-1](https://habrastorage.org/webt/k1/ol/ee/k1oleegivyrvsvcx-glsjjxdt14.png)
( ), , .
![gpt2-self-attention-2](https://habrastorage.org/webt/ws/nc/1k/wsnc1kowztsdydbbgkevy7ycene.png)
(bias vector),
, , «it».
![gpt2-self-attention-3](https://habrastorage.org/webt/od/oc/ag/odocagmiv-m420l-3wy8sdila4w.png)
( ) ,
GPT-2: 1.5 – «»
, «» . . (Q), (K) (V). «» – . GPT-2 12 «» , :
![gpt2-self-attention-split-attention-heads-1](https://habrastorage.org/webt/zt/qf/wr/ztqfwr4l3kaoq243xhlleg4ro2i.png)
, «» . «» , ( 12 «» ):
![gpt2-self-attention-split-attention-heads-2](https://habrastorage.org/webt/lu/8a/5c/lu8a5cqdztpnonylf6jfxpopngg.png)
GPT-2: 2 –
( , «» ):
![gpt2-self-attention-scoring](https://habrastorage.org/webt/ab/0b/nm/ab0bnmrgkb-3knzrtitk2e64opi.png)
( «» #1 ):
![gpt2-self-attention-scoring-2](https://habrastorage.org/webt/zc/ll/nt/zcllnthmdvddhniljejpbgke8is.png)
GPT-2: 3 –
, , , «» #1:
![gpt2-self-attention-multihead-sum-1](https://habrastorage.org/webt/dv/rf/-i/dvrf-ik3yxkidhzgihbuuqv4sww.png)
GPT-2: 3.5 – «»
«» , , :
![gpt2-self-attention-merge-heads-1](https://habrastorage.org/webt/p9/jg/bg/p9jgbgr9-c8lzl-zjnqfdortvxe.png)
. .
GPT-2: 4 –
, , . , «» :
![gpt2-self-attention-project-1](https://habrastorage.org/webt/mc/mz/qq/mcmzqqb80hq14cyooubulhh3hhu.png)
, , :
![مشروع gpt2- الاهتمام الذاتي- 2](https://habrastorage.org/webt/af/tl/0o/aftl0oqxhho-m6uph1uqer2a4_c.png)
GPT-2: #1
– , , . . 4 ( GPT-2 768, 768*4 = 3072 ). ? ( 512 #1 – 2048). , , .
![gpt2-mlp1](https://habrastorage.org/webt/gu/4d/ci/gu4dciafj9oa7wcbnt1pwtpfcu8.gif)
( )
GPT-2:
(768 GPT-2). .
![gpt2-mlp-2](https://habrastorage.org/webt/x-/eh/kj/x-ehkj3y5dyunh4nf3v7aykhp70.gif)
( )
!
, - . , . , , :
![الأوزان gpt2 المحول كتلة 2](https://habrastorage.org/webt/yz/n7/20/yzn720lcfsuwwky-r3kanjys3w0.png)
. , :
![gpt2- الأوزان -2](https://habrastorage.org/webt/xl/22/mc/xl22mctq_nzefihu84kxryqj5be.png)
, :
![معلمات gpt2-117](https://habrastorage.org/webt/vk/it/nh/vkitnhrnvo0djn0gn1_e0fpzhp0.png)
- 124 117. , , (, ).
3:
, . , . .
. :
![فك ترميز المحول فقط](https://habrastorage.org/webt/ni/vt/bw/nivtbwcuuxla5cx5p2srhoohfgm.png)
, . , ( , ) . :
![ويكيبيديا تلخيص](https://habrastorage.org/webt/gd/3u/h5/gd3uh5vlhfzoarket8i2eeudj_4.png)
.
![تلخيص وحدة فك الترميز فقط](https://habrastorage.org/webt/f2/-z/8v/f2-z8vum88usd2nyshvwwpesjq8.png)
Sample Efficient Text Summarization Using a Single Pre-Trained Transformer , . , , - .
GPT-2 .
. « » – (, « »).
, . , (), ( ). (, , ) «» – , .
![ترميز أداء الموسيقى - المحول - 3](https://habrastorage.org/webt/en/x-/g2/enx-g2e1om4ctwjcuvnsspcjzcm.png)
– one-hot . midi . :
![مثال على تمثيل الموسيقى](https://habrastorage.org/webt/q2/0s/vv/q20svvnlw_1ji4s_fjejnlnrckc.png)
one-hot :
![الموسيقى - المحولات - المدخلات - التمثيل - 2](https://habrastorage.org/webt/gh/av/o5/ghavo5srziiagcrg-zqzg0vbnjg.png)
:
![الموسيقى-المحولات-الانتباه الذاتي -2](https://habrastorage.org/webt/gg/up/ou/ggupou0idkyeu2oc-dtgvxayxsa.png)
, . .
GPT-2 – . , , , , .
المؤلفون