minimaxir commited on
Commit
f8ee625
1 Parent(s): b3269e5
Files changed (5) hide show
  1. .gitignore +1 -0
  2. README.md +25 -0
  3. config.json +38 -0
  4. pytorch_model.bin +3 -0
  5. tokenizer.json +1 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ .DS_Store
README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # magic-the-gathering
2
+
3
+ A small (~1M parameters) GPT-2 model trained on Magic: The Gathering cards from sets up to and including _Strixhaven_ and _Commander 2021_.
4
+
5
+ The model was trained 8 hours on a V100 on about ~22k unique encoded cards, with 10 permutations of each possible card.
6
+
7
+ Examples of encoded cards:
8
+
9
+ ```
10
+ <|toughness|><|text|>Counter target spell unless its controller pays {X}.<|power|><|type|>Instant<|loyalty|><|manaCost|>{X}{U}<|name|>Clash of Wills
11
+ ```
12
+
13
+ ```
14
+ <|loyalty|><|text|>~ enters the battlefield tapped.
15
+ {T}: Add {C}.
16
+ {T}: Add {U} or {R}. ~ deals 1 damage to you.<|toughness|><|name|>Caldera Lake<|power|><|manaCost|><|type|>Land
17
+ ```
18
+
19
+ ```
20
+ <|loyalty|>5<|text|>+1: Scry 1, then draw a card.
21
+ −2: Return target creature to its owner's hand.
22
+ −8: You get an emblem with "Whenever an opponent casts their first spell each turn, counter that spell."<|name|>Jace, Unraveler of Secrets<|toughness|><|type|>Legendary Planeswalker — Jace<|manaCost|>{3}{U}{U}<|power|>
23
+ ```
24
+
25
+ The generated cards follow a similar schema, however because the model learns all possible permutations of the schema, the user can prompt the generation with any combination of schema.
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": ["GPT2LMHeadModel"],
4
+ "attn_pdrop": 0.2,
5
+ "bos_token_id": 0,
6
+ "embd_pdrop": 0.2,
7
+ "eos_token_id": 0,
8
+ "gradient_checkpointing": false,
9
+ "initializer_range": 0.02,
10
+ "layer_norm_epsilon": 1e-5,
11
+ "line_by_line": true,
12
+ "model_type": "gpt2",
13
+ "n_ctx": 256,
14
+ "n_embd": 128,
15
+ "n_head": 8,
16
+ "n_inner": null,
17
+ "n_layer": 8,
18
+ "n_positions": 256,
19
+ "resid_pdrop": 0.2,
20
+ "schema_return": null,
21
+ "schema_tokens": [
22
+ "<|name|>",
23
+ "<|manaCost|>",
24
+ "<|type|>",
25
+ "<|text|>",
26
+ "<|power|>",
27
+ "<|toughness|>",
28
+ "<|loyalty|>"
29
+ ],
30
+ "summary_activation": null,
31
+ "summary_first_dropout": 0.2,
32
+ "summary_proj_to_labels": true,
33
+ "summary_type": "cls_index",
34
+ "summary_use_proj": true,
35
+ "transformers_version": "4.5.1",
36
+ "use_cache": true,
37
+ "vocab_size": 500
38
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7639b9f5af63fbc123255c318b07fae8dd143ed7cadf848f73960111abd27140
3
+ size 7299843
tokenizer.json ADDED
@@ -0,0 +1 @@
 
1
+ {"version":"1.0","truncation":null,"padding":null,"added_tokens":[{"id":0,"special":true,"content":"<|endoftext|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":1,"special":true,"content":"<|name|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":2,"special":true,"content":"<|manaCost|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":3,"special":true,"content":"<|type|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":4,"special":true,"content":"<|text|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":5,"special":true,"content":"<|power|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":6,"special":true,"content":"<|toughness|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false},{"id":7,"special":true,"content":"<|loyalty|>","single_word":false,"lstrip":false,"rstrip":false,"normalized":false}],"normalizer":null,"pre_tokenizer":{"type":"ByteLevel","add_prefix_space":false,"trim_offsets":true},"post_processor":{"type":"ByteLevel","add_prefix_space":true,"trim_offsets":true},"decoder":{"type":"ByteLevel","add_prefix_space":true,"trim_offsets":true},"model":{"type":"BPE","dropout":null,"unk_token":null,"continuing_subword_prefix":null,"end_of_word_suffix":null,"fuse_unk":false,"vocab":{"<|endoftext|>":0,"<|name|>":1,"<|manaCost|>":2,"<|type|>":3,"<|text|>":4,"<|power|>":5,"<|toughness|>":6,"<|loyalty|>":7,"!":8,"\"":9,"#":10,"$":11,"%":12,"&":13,"'":14,"(":15,")":16,"*":17,"+":18,",":19,"-":20,".":21,"/":22,"0":23,"1":24,"2":25,"3":26,"4":27,"5":28,"6":29,"7":30,"8":31,"9":32,":":33,";":34,"<":35,"=":36,">":37,"?":38,"@":39,"A":40,"B":41,"C":42,"D":43,"E":44,"F":45,"G":46,"H":47,"I":48,"J":49,"K":50,"L":51,"M":52,"N":53,"O":54,"P":55,"Q":56,"R":57,"S":58,"T":59,"U":60,"V":61,"W":62,"X":63,"Y":64,"Z":65,"[":66,"\\":67,"]":68,"^":69,"_":70,"`":71,"a":72,"b":73,"c":74,"d":75,"e":76,"f":77,"g":78,"h":79,"i":80,"j":81,"k":82,"l":83,"m":84,"n":85,"o":86,"p":87,"q":88,"r":89,"s":90,"t":91,"u":92,"v":93,"w":94,"x":95,"y":96,"z":97,"{":98,"|":99,"}":100,"~":101,"¡":102,"¢":103,"£":104,"¤":105,"¥":106,"¦":107,"§":108,"¨":109,"©":110,"ª":111,"«":112,"¬":113,"®":114,"¯":115,"°":116,"±":117,"²":118,"³":119,"´":120,"µ":121,"¶":122,"·":123,"¸":124,"¹":125,"º":126,"»":127,"¼":128,"½":129,"¾":130,"¿":131,"À":132,"Á":133,"Â":134,"Ã":135,"Ä":136,"Å":137,"Æ":138,"Ç":139,"È":140,"É":141,"Ê":142,"Ë":143,"Ì":144,"Í":145,"Î":146,"Ï":147,"Ð":148,"Ñ":149,"Ò":150,"Ó":151,"Ô":152,"Õ":153,"Ö":154,"×":155,"Ø":156,"Ù":157,"Ú":158,"Û":159,"Ü":160,"Ý":161,"Þ":162,"ß":163,"à":164,"á":165,"â":166,"ã":167,"ä":168,"å":169,"æ":170,"ç":171,"è":172,"é":173,"ê":174,"ë":175,"ì":176,"í":177,"î":178,"ï":179,"ð":180,"ñ":181,"ò":182,"ó":183,"ô":184,"õ":185,"ö":186,"÷":187,"ø":188,"ù":189,"ú":190,"û":191,"ü":192,"ý":193,"þ":194,"ÿ":195,"Ā":196,"ā":197,"Ă":198,"ă":199,"Ą":200,"ą":201,"Ć":202,"ć":203,"Ĉ":204,"ĉ":205,"Ċ":206,"ċ":207,"Č":208,"č":209,"Ď":210,"ď":211,"Đ":212,"đ":213,"Ē":214,"ē":215,"Ĕ":216,"ĕ":217,"Ė":218,"ė":219,"Ę":220,"ę":221,"Ě":222,"ě":223,"Ĝ":224,"ĝ":225,"Ğ":226,"ğ":227,"Ġ":228,"ġ":229,"Ģ":230,"ģ":231,"Ĥ":232,"ĥ":233,"Ħ":234,"ħ":235,"Ĩ":236,"ĩ":237,"Ī":238,"ī":239,"Ĭ":240,"ĭ":241,"Į":242,"į":243,"İ":244,"ı":245,"IJ":246,"ij":247,"Ĵ":248,"ĵ":249,"Ķ":250,"ķ":251,"ĸ":252,"Ĺ":253,"ĺ":254,"Ļ":255,"ļ":256,"Ľ":257,"ľ":258,"Ŀ":259,"ŀ":260,"Ł":261,"ł":262,"Ń":263,"<|":264,"|>":265,"re":266,"Ġt":267,"an":268,"er":269,"Ġc":270,"ou":271,"at":272,"ty":273,"st":274,"en":275,"ar":276,"al":277,"|><|":278,"Ġth":279,"Ġo":280,"reat":281,"es":282,"ure":283,"reature":284,"am":285,"lo":286,"man":287,"pe":288,"}{":289,"in":290,"po":291,"te":292,"ess":293,"ost":294,"gh":295,"mana":296,"|>{":297,"wer":298,"ame":299,"xt":300,"power":301,"you":302,"Ġyou":303,"ough":304,"Ġa":305,"ness":306,"name":307,"oughness":308,"yal":309,"yalty":310,"loyalty":311,"type":312,"Cost":313,"čĊ":314,"text":315,"toughness":316,"manaCost":317,"nt":318,"ge":319,"Ġthe":320,"Ġcreature":321,"it":322,"Ġb":323,"ac":324,"}<|":325,"\"<|":326,"ard":327,"Ġd":328,"ro":329,"âĢ":330,"Ġof":331,"le":332,"âĢĶ":333,"ĠâĢĶ":334,".<|":335,"ent":336,"is":337,"Ġp":338,"and":339,"get":340,"if":341,"Ġto":342,"ay":343,"or":344,"ur":345,"Ġco":346,"Creature":347,"Ġf":348,"Ġcard":349,"Ġ~":350,"ing":351,"Ġit":352,"Ġs":353,"Ġu":354,"arget":355,"Ġyour":356,"ld":357,"att":358,"Ġw":359,"Ġl":360,"on":361,"urn":362,"rol":363,"ĠS":364,"ant":365,"ch":366,"hen":367,"Ġcont":368,"Ġcontrol":369,"When":370,"Ġe":371,"ie":372,"ra":373,"Ġtarget":374,"end":375,"il":376,"ve":377,"Ġh":378,"Ġon":379,"Ġg":380,"Ġm":381,"Ġ{":382,"ers":383,"Ġthis":384,"ĠA":385,"Ġturn":386,"ic":387,"Ġan":388,"ast":389,"ield":390,"attle":391,"field":392,"attlefield":393,"Ġbattlefield":394,"Ġor":395,"Ġde":396,"Ġpl":397,".)":398,"Ġbe":399,"Ġ(":400,"Ġand":401,"ll":402,"Ġthat":403,"'s":404,"ut":405,"ach":406,"ith":407,"Ġin":408,"Ġunt":409,"age":410,"Ġ+":411,"ke":412,"/+":413,"ount":414,"ver":415,"Ġplay":416,"}:":417,"Ġwith":418,"ly":419,"|>\"":420,"En":421,"Ġend":422,"amage":423,"ment":424,"as":425,"ary":426,"Ġplayer":427,"ĠT":428,"Ġn":429,"ĠD":430,"Ġmay":431,"ir":432,"Ġdamage":433,"Ench":434,"pell":435,"Ġre":436,"Ġent":437,"Ġcount":438,"mb":439,"act":440,"tif":441,"rom":442,"Ġdeal":443,"Ġenters":444,"ĠH":445,"Ġspell":446,"Ġfrom":447,"ap":448,"ĠI":449,"tifact":450,"ain":451,"ever":452,"ĠC":453,"Whenever":454,"Ġuntil":455,"ĠE":456,"Ġget":457,"Ġcast":458,"},":459,"ack":460,"Ġeach":461,"ep":462,"ĠW":463,"Enchant":464,"'t":465,"Ġfor":466,"cer":467,"Ġput":468,"th":469,"Ġcards":470,"Ġcreatures":471,"orcer":472,"orcery":473,"lying":474,"Ġas":475,"Ġhand":476,"stant":477,"ice":478,"Ġits":479,"ib":480,"ĠP":481,"se":482,"Ġcan":483,"ĠR":484,"rif":485,"Ġgain":486,"ife":487,"Ġdeals":488,"In":489,"ion":490,"acrif":491,"You":492,"Ġgets":493,"ho":494,"Ġlife":495,"rave":496,"ĠHu":497,"loc":498,"yard":499},"merges":["< |","| >","r e","Ġ t","a n","e r","Ġ c","o u","a t","t y","s t","e n","a r","a l","|> <|","Ġt h","Ġ o","re at","e s","u re","reat ure","a m","l o","m an","p e","} {","i n","p o","t e","es s","o st","g h","man a","|> {","w er","am e","x t","po wer","y ou","Ġ you","ou gh","Ġ a","n ess","n ame","ough ness","y al","yal ty","lo yalty","ty pe","C ost","č Ċ","te xt","t oughness","mana Cost","n t","g e","Ġth e","Ġc reature","i t","Ġ b","a c","} <|","\" <|","ar d","Ġ d","r o","â Ģ","Ġo f","l e","âĢ Ķ","Ġ âĢĶ",". <|","en t","i s","Ġ p","an d","ge t","i f","Ġt o","a y","o r","u r","Ġc o","C reature","Ġ f","Ġc ard","Ġ ~","in g","Ġ it","Ġ s","Ġ u","ar get","Ġyou r","l d","at t","Ġ w","Ġ l","o n","ur n","ro l","Ġ S","an t","c h","h en","Ġco nt","Ġcont rol","W hen","Ġ e","i e","r a","Ġt arget","en d","i l","v e","Ġ h","Ġo n","Ġ g","Ġ m","Ġ {","er s","Ġth is","Ġ A","Ġt urn","i c","Ġ an","a st","ie ld","att le","f ield","attle field","Ġb attlefield","Ġo r","Ġd e","Ġp l",". )","Ġb e","Ġ (","Ġ and","l l","Ġth at","' s","u t","ac h","it h","Ġ in","Ġu nt","a ge","Ġ +","k e","/ +","ou nt","v er","Ġpl ay","} :","Ġw ith","l y","|> \"","E n","Ġ end","am age","m ent","a s","ar y","Ġplay er","Ġ T","Ġ n","Ġ D","Ġm ay","i r","Ġd amage","En ch","pe ll","Ġ re","Ġ ent","Ġc ount","m b","ac t","t if","ro m","Ġde al","Ġent ers","Ġ H","Ġs pell","Ġf rom","a p","Ġ I","tif act","a in","e ver","Ġ C","When ever","Ġunt il","Ġ E","Ġ get","Ġc ast","} ,","ac k","Ġe ach","e p","Ġ W","Ench ant","' t","Ġf or","c er","Ġp ut","t h","Ġcard s","Ġcreature s","or cer","orcer y","ly ing","Ġa s","Ġh and","st ant","ic e","Ġit s","i b","Ġ P","s e","Ġc an","Ġ R","r if","Ġg ain","if e","Ġdeal s","I n","i on","ac rif","Y ou","Ġget s","h o","Ġl ife","ra ve","ĠH u","lo c","y ard"]}}