Shobhank-iiitdwd commited on
Commit
f7359a2
1 Parent(s): 0af0677

Upload 17 files

Browse files
README.md ADDED
@@ -0,0 +1,603 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - summarization
4
+ - summary
5
+ - booksum
6
+ - long-document
7
+ - long-form
8
+ license:
9
+ - apache-2.0
10
+ - bsd-3-clause
11
+ datasets:
12
+ - kmfoda/booksum
13
+ metrics:
14
+ - rouge
15
+ widget:
16
+ - text: large earthquakes along a given fault segment do not occur at random intervals
17
+ because it takes time to accumulate the strain energy for the rupture. The rates
18
+ at which tectonic plates move and accumulate strain at their boundaries are approximately
19
+ uniform. Therefore, in first approximation, one may expect that large ruptures
20
+ of the same fault segment will occur at approximately constant time intervals.
21
+ If subsequent main shocks have different amounts of slip across the fault, then
22
+ the recurrence time may vary, and the basic idea of periodic mainshocks must be
23
+ modified. For great plate boundary ruptures the length and slip often vary by
24
+ a factor of 2. Along the southern segment of the San Andreas fault the recurrence
25
+ interval is 145 years with variations of several decades. The smaller the standard
26
+ deviation of the average recurrence interval, the more specific could be the long
27
+ term prediction of a future mainshock.
28
+ example_title: earthquakes
29
+ - text: " A typical feed-forward neural field algorithm. Spatiotemporal coordinates\
30
+ \ are fed into a neural network that predicts values in the reconstructed domain.\
31
+ \ Then, this domain is mapped to the sensor domain where sensor measurements are\
32
+ \ available as supervision. Class and Section Problems Addressed Generalization\
33
+ \ (Section 2) Inverse problems, ill-posed problems, editability; symmetries. Hybrid\
34
+ \ Representations (Section 3) Computation & memory efficiency, representation\
35
+ \ capacity, editability: Forward Maps (Section 4) Inverse problems Network Architecture\
36
+ \ (Section 5) Spectral bias, integration & derivatives. Manipulating Neural Fields\
37
+ \ (Section 6) Edit ability, constraints, regularization. Table 2: The five classes\
38
+ \ of techniques in the neural field toolbox each addresses problems that arise\
39
+ \ in learning, inference, and control. (Section 3). We can supervise reconstruction\
40
+ \ via differentiable forward maps that transform Or project our domain (e.g, 3D\
41
+ \ reconstruction via 2D images; Section 4) With appropriate network architecture\
42
+ \ choices, we can overcome neural network spectral biases (blurriness) and efficiently\
43
+ \ compute derivatives and integrals (Section 5). Finally, we can manipulate neural\
44
+ \ fields to add constraints and regularizations, and to achieve editable representations\
45
+ \ (Section 6). Collectively, these classes constitute a 'toolbox' of techniques\
46
+ \ to help solve problems with neural fields There are three components in a conditional\
47
+ \ neural field: (1) An encoder or inference function \u20AC that outputs the conditioning\
48
+ \ latent variable 2 given an observation 0 E(0) =2. 2 is typically a low-dimensional\
49
+ \ vector, and is often referred to aS a latent code Or feature code_ (2) A mapping\
50
+ \ function 4 between Z and neural field parameters O: Y(z) = O; (3) The neural\
51
+ \ field itself $. The encoder \u20AC finds the most probable z given the observations\
52
+ \ O: argmaxz P(2/0). The decoder maximizes the inverse conditional probability\
53
+ \ to find the most probable 0 given Z: arg- max P(Olz). We discuss different encoding\
54
+ \ schemes with different optimality guarantees (Section 2.1.1), both global and\
55
+ \ local conditioning (Section 2.1.2), and different mapping functions Y (Section\
56
+ \ 2.1.3) 2. Generalization Suppose we wish to estimate a plausible 3D surface\
57
+ \ shape given a partial or noisy point cloud. We need a suitable prior over the\
58
+ \ sur- face in its reconstruction domain to generalize to the partial observations.\
59
+ \ A neural network expresses a prior via the function space of its architecture\
60
+ \ and parameters 0, and generalization is influenced by the inductive bias of\
61
+ \ this function space (Section 5)."
62
+ example_title: scientific paper
63
+ - text: 'Is a else or outside the cob and tree written being of early client rope
64
+ and you have is for good reasons. On to the ocean in Orange for time. By''s the
65
+ aggregate we can bed it yet. Why this please pick up on a sort is do and also
66
+ M Getoi''s nerocos and do rain become you to let so is his brother is made in
67
+ use and Mjulia''s''s the lay major is aging Masastup coin present sea only of
68
+ Oosii rooms set to you We do er do we easy this private oliiishs lonthen might
69
+ be okay. Good afternoon everybody. Welcome to this lecture of Computational Statistics.
70
+ As you can see, I''m not socially my name is Michael Zelinger. I''m one of the
71
+ task for this class and you might have already seen me in the first lecture where
72
+ I made a quick appearance. I''m also going to give the tortillas in the last third
73
+ of this course. So to give you a little bit about me, I''m a old student here
74
+ with better Bulman and my research centres on casual inference applied to biomedical
75
+ disasters, so that could be genomics or that could be hospital data. If any of
76
+ you is interested in writing a bachelor thesis, a semester paper may be mastathesis
77
+ about this topic feel for reach out to me. you have my name on models and my email
78
+ address you can find in the directory I''d Be very happy to talk about it. you
79
+ do not need to be sure about it, we can just have a chat. So with that said, let''s
80
+ get on with the lecture. There''s an exciting topic today I''m going to start
81
+ by sharing some slides with you and later on during the lecture we''ll move to
82
+ the paper. So bear with me for a few seconds. Well, the projector is starting
83
+ up. Okay, so let''s get started. Today''s topic is a very important one. It''s
84
+ about a technique which really forms one of the fundamentals of data science,
85
+ machine learning, and any sort of modern statistics. It''s called cross validation.
86
+ I know you really want to understand this topic I Want you to understand this
87
+ and frankly, nobody''s gonna leave Professor Mineshousen''s class without understanding
88
+ cross validation. So to set the stage for this, I Want to introduce you to the
89
+ validation problem in computational statistics. So the problem is the following:
90
+ You trained a model on available data. You fitted your model, but you know the
91
+ training data you got could always have been different and some data from the
92
+ environment. Maybe it''s a random process. You do not really know what it is,
93
+ but you know that somebody else who gets a different batch of data from the same
94
+ environment they would get slightly different training data and you do not care
95
+ that your method performs as well. On this training data. you want to to perform
96
+ well on other data that you have not seen other data from the same environment.
97
+ So in other words, the validation problem is you want to quantify the performance
98
+ of your model on data that you have not seen. So how is this even possible? How
99
+ could you possibly measure the performance on data that you do not know The solution
100
+ to? This is the following realization is that given that you have a bunch of data,
101
+ you were in charge. You get to control how much that your model sees. It works
102
+ in the following way: You can hide data firms model. Let''s say you have a training
103
+ data set which is a bunch of doubtless so X eyes are the features those are typically
104
+ hide and national vector. It''s got more than one dimension for sure. And the
105
+ why why eyes. Those are the labels for supervised learning. As you''ve seen before,
106
+ it''s the same set up as we have in regression. And so you have this training
107
+ data and now you choose that you only use some of those data to fit your model.
108
+ You''re not going to use everything, you only use some of it the other part you
109
+ hide from your model. And then you can use this hidden data to do validation from
110
+ the point of you of your model. This hidden data is complete by unseen. In other
111
+ words, we solve our problem of validation.'
112
+ example_title: transcribed audio - lecture
113
+ - text: "Transformer-based models have shown to be very useful for many NLP tasks.\
114
+ \ However, a major limitation of transformers-based models is its O(n^2)O(n 2)\
115
+ \ time & memory complexity (where nn is sequence length). Hence, it's computationally\
116
+ \ very expensive to apply transformer-based models on long sequences n > 512n>512.\
117
+ \ Several recent papers, e.g. Longformer, Performer, Reformer, Clustered attention\
118
+ \ try to remedy this problem by approximating the full attention matrix. You can\
119
+ \ checkout \U0001F917's recent blog post in case you are unfamiliar with these\
120
+ \ models.\nBigBird (introduced in paper) is one of such recent models to address\
121
+ \ this issue. BigBird relies on block sparse attention instead of normal attention\
122
+ \ (i.e. BERT's attention) and can handle sequences up to a length of 4096 at a\
123
+ \ much lower computational cost compared to BERT. It has achieved SOTA on various\
124
+ \ tasks involving very long sequences such as long documents summarization, question-answering\
125
+ \ with long contexts.\nBigBird RoBERTa-like model is now available in \U0001F917\
126
+ Transformers. The goal of this post is to give the reader an in-depth understanding\
127
+ \ of big bird implementation & ease one's life in using BigBird with \U0001F917\
128
+ Transformers. But, before going into more depth, it is important to remember that\
129
+ \ the BigBird's attention is an approximation of BERT's full attention and therefore\
130
+ \ does not strive to be better than BERT's full attention, but rather to be more\
131
+ \ efficient. It simply allows to apply transformer-based models to much longer\
132
+ \ sequences since BERT's quadratic memory requirement quickly becomes unbearable.\
133
+ \ Simply put, if we would have \u221E compute & \u221E time, BERT's attention\
134
+ \ would be preferred over block sparse attention (which we are going to discuss\
135
+ \ in this post).\nIf you wonder why we need more compute when working with longer\
136
+ \ sequences, this blog post is just right for you!\nSome of the main questions\
137
+ \ one might have when working with standard BERT-like attention include:\nDo all\
138
+ \ tokens really have to attend to all other tokens? Why not compute attention\
139
+ \ only over important tokens? How to decide what tokens are important? How to\
140
+ \ attend to just a few tokens in a very efficient way? In this blog post, we will\
141
+ \ try to answer those questions.\nWhat tokens should be attended to? We will give\
142
+ \ a practical example of how attention works by considering the sentence 'BigBird\
143
+ \ is now available in HuggingFace for extractive question answering'. In BERT-like\
144
+ \ attention, every word would simply attend to all other tokens.\nLet's think\
145
+ \ about a sensible choice of key tokens that a queried token actually only should\
146
+ \ attend to by writing some pseudo-code. Will will assume that the token available\
147
+ \ is queried and build a sensible list of key tokens to attend to.\n>>> # let's\
148
+ \ consider following sentence as an example >>> example = ['BigBird', 'is', 'now',\
149
+ \ 'available', 'in', 'HuggingFace', 'for', 'extractive', 'question', 'answering']\n\
150
+ >>> # further let's assume, we're trying to understand the representation of 'available'\
151
+ \ i.e. >>> query_token = 'available' >>> # We will initialize an empty `set` and\
152
+ \ fill up the tokens of our interest as we proceed in this section. >>> key_tokens\
153
+ \ = [] # => currently 'available' token doesn't have anything to attend Nearby\
154
+ \ tokens should be important because, in a sentence (sequence of words), the current\
155
+ \ word is highly dependent on neighboring past & future tokens. This intuition\
156
+ \ is the idea behind the concept of sliding attention."
157
+ example_title: bigbird blog intro
158
+ - text: "To be fair, you have to have a very high IQ to understand Rick and Morty.\
159
+ \ The humour is extremely subtle, and without a solid grasp of theoretical physics\
160
+ \ most of the jokes will go over a typical viewer's head. There's also Rick's\
161
+ \ nihilistic outlook, which is deftly woven into his characterisation- his personal\
162
+ \ philosophy draws heavily from Narodnaya Volya literature, for instance. The\
163
+ \ fans understand this stuff; they have the intellectual capacity to truly appreciate\
164
+ \ the depths of these jokes, to realise that they're not just funny- they say\
165
+ \ something deep about LIFE. As a consequence people who dislike Rick & Morty\
166
+ \ truly ARE idiots- of course they wouldn't appreciate, for instance, the humour\
167
+ \ in Rick's existential catchphrase 'Wubba Lubba Dub Dub,' which itself is a cryptic\
168
+ \ reference to Turgenev's Russian epic Fathers and Sons. I'm smirking right now\
169
+ \ just imagining one of those addlepated simpletons scratching their heads in\
170
+ \ confusion as Dan Harmon's genius wit unfolds itself on their television screens.\
171
+ \ What fools.. how I pity them. \U0001F602\nAnd yes, by the way, i DO have a Rick\
172
+ \ & Morty tattoo. And no, you cannot see it. It's for the ladies' eyes only- and\
173
+ \ even then they have to demonstrate that they're within 5 IQ points of my own\
174
+ \ (preferably lower) beforehand. Nothin personnel kid \U0001F60E"
175
+ example_title: Richard & Mortimer
176
+ - text: "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct."
177
+ example_title: eiffel
178
+ parameters:
179
+ max_length: 64
180
+ min_length: 8
181
+ no_repeat_ngram_size: 3
182
+ early_stopping: true
183
+ repetition_penalty: 3.5
184
+ length_penalty: 0.3
185
+ encoder_no_repeat_ngram_size: 3
186
+ num_beams: 4
187
+ model-index:
188
+ - name: pszemraj/long-t5-tglobal-base-16384-book-summary
189
+ results:
190
+ - task:
191
+ type: summarization
192
+ name: Summarization
193
+ dataset:
194
+ name: kmfoda/booksum
195
+ type: kmfoda/booksum
196
+ config: kmfoda--booksum
197
+ split: test
198
+ metrics:
199
+ - name: ROUGE-1
200
+ type: rouge
201
+ value: 36.4085
202
+ verified: true
203
+ - name: ROUGE-2
204
+ type: rouge
205
+ value: 6.0646
206
+ verified: true
207
+ - name: ROUGE-L
208
+ type: rouge
209
+ value: 16.7209
210
+ verified: true
211
+ - name: ROUGE-LSUM
212
+ type: rouge
213
+ value: 33.3405
214
+ verified: true
215
+ - name: loss
216
+ type: loss
217
+ value: .nan
218
+ verified: true
219
+ - name: gen_len
220
+ type: gen_len
221
+ value: 252.8099
222
+ verified: true
223
+ - task:
224
+ type: summarization
225
+ name: Summarization
226
+ dataset:
227
+ name: samsum
228
+ type: samsum
229
+ config: samsum
230
+ split: test
231
+ metrics:
232
+ - name: ROUGE-1
233
+ type: rouge
234
+ value: 30.9047
235
+ verified: true
236
+ - name: ROUGE-2
237
+ type: rouge
238
+ value: 7.4715
239
+ verified: true
240
+ - name: ROUGE-L
241
+ type: rouge
242
+ value: 22.3962
243
+ verified: true
244
+ - name: ROUGE-LSUM
245
+ type: rouge
246
+ value: 26.9094
247
+ verified: true
248
+ - name: loss
249
+ type: loss
250
+ value: .nan
251
+ verified: true
252
+ - name: gen_len
253
+ type: gen_len
254
+ value: 46.7973
255
+ verified: true
256
+ - task:
257
+ type: summarization
258
+ name: Summarization
259
+ dataset:
260
+ name: cnn_dailymail
261
+ type: cnn_dailymail
262
+ config: 3.0.0
263
+ split: test
264
+ metrics:
265
+ - name: ROUGE-1
266
+ type: rouge
267
+ value: 30.5942
268
+ verified: true
269
+ - name: ROUGE-2
270
+ type: rouge
271
+ value: 7.252
272
+ verified: true
273
+ - name: ROUGE-L
274
+ type: rouge
275
+ value: 17.7156
276
+ verified: true
277
+ - name: ROUGE-LSUM
278
+ type: rouge
279
+ value: 27.2881
280
+ verified: true
281
+ - name: loss
282
+ type: loss
283
+ value: .nan
284
+ verified: true
285
+ - name: gen_len
286
+ type: gen_len
287
+ value: 125.2507
288
+ verified: true
289
+ - task:
290
+ type: summarization
291
+ name: Summarization
292
+ dataset:
293
+ name: xsum
294
+ type: xsum
295
+ config: default
296
+ split: test
297
+ metrics:
298
+ - name: ROUGE-1
299
+ type: rouge
300
+ value: 20.3648
301
+ verified: true
302
+ - name: ROUGE-2
303
+ type: rouge
304
+ value: 3.4126
305
+ verified: true
306
+ - name: ROUGE-L
307
+ type: rouge
308
+ value: 13.6168
309
+ verified: true
310
+ - name: ROUGE-LSUM
311
+ type: rouge
312
+ value: 15.8313
313
+ verified: true
314
+ - name: loss
315
+ type: loss
316
+ value: .nan
317
+ verified: true
318
+ - name: gen_len
319
+ type: gen_len
320
+ value: 82.2177
321
+ verified: true
322
+ - task:
323
+ type: summarization
324
+ name: Summarization
325
+ dataset:
326
+ name: billsum
327
+ type: billsum
328
+ config: default
329
+ split: test
330
+ metrics:
331
+ - name: ROUGE-1
332
+ type: rouge
333
+ value: 39.6378
334
+ verified: true
335
+ - name: ROUGE-2
336
+ type: rouge
337
+ value: 13.0017
338
+ verified: true
339
+ - name: ROUGE-L
340
+ type: rouge
341
+ value: 23.0255
342
+ verified: true
343
+ - name: ROUGE-LSUM
344
+ type: rouge
345
+ value: 32.9943
346
+ verified: true
347
+ - name: loss
348
+ type: loss
349
+ value: 1.9428048133850098
350
+ verified: true
351
+ - name: gen_len
352
+ type: gen_len
353
+ value: 162.3588
354
+ verified: true
355
+ - task:
356
+ type: summarization
357
+ name: Summarization
358
+ dataset:
359
+ name: big_patent
360
+ type: big_patent
361
+ config: y
362
+ split: test
363
+ metrics:
364
+ - name: ROUGE-1
365
+ type: rouge
366
+ value: 34.7641
367
+ verified: true
368
+ - name: ROUGE-2
369
+ type: rouge
370
+ value: 7.8744
371
+ verified: true
372
+ - name: ROUGE-L
373
+ type: rouge
374
+ value: 19.9826
375
+ verified: true
376
+ - name: ROUGE-LSUM
377
+ type: rouge
378
+ value: 29.208
379
+ verified: true
380
+ - name: loss
381
+ type: loss
382
+ value: 2.8316469192504883
383
+ verified: true
384
+ - name: gen_len
385
+ type: gen_len
386
+ value: 132.7475
387
+ verified: true
388
+ - task:
389
+ type: summarization
390
+ name: Summarization
391
+ dataset:
392
+ name: launch/gov_report
393
+ type: launch/gov_report
394
+ config: plain_text
395
+ split: validation
396
+ metrics:
397
+ - name: ROUGE-1
398
+ type: rouge
399
+ value: 37.9246
400
+ verified: true
401
+ - name: ROUGE-2
402
+ type: rouge
403
+ value: 8.5837
404
+ verified: true
405
+ - name: ROUGE-L
406
+ type: rouge
407
+ value: 18.0274
408
+ verified: true
409
+ - name: ROUGE-LSUM
410
+ type: rouge
411
+ value: 34.0816
412
+ verified: true
413
+ - name: loss
414
+ type: loss
415
+ value: 2.56695818901062
416
+ verified: true
417
+ - name: gen_len
418
+ type: gen_len
419
+ value: 220.3747
420
+ verified: true
421
+ - task:
422
+ type: summarization
423
+ name: Summarization
424
+ dataset:
425
+ name: launch/gov_report
426
+ type: launch/gov_report
427
+ config: plain_text
428
+ split: test
429
+ metrics:
430
+ - name: ROUGE-1
431
+ type: rouge
432
+ value: 37.4438
433
+ verified: true
434
+ - name: ROUGE-2
435
+ type: rouge
436
+ value: 8.2907
437
+ verified: true
438
+ - name: ROUGE-L
439
+ type: rouge
440
+ value: 17.6893
441
+ verified: true
442
+ - name: ROUGE-LSUM
443
+ type: rouge
444
+ value: 33.7141
445
+ verified: true
446
+ - name: loss
447
+ type: loss
448
+ value: 2.5776000022888184
449
+ verified: true
450
+ - name: gen_len
451
+ type: gen_len
452
+ value: 214.9692
453
+ verified: true
454
+ ---
455
+
456
+ # long-t5-tglobal-base-16384 + BookSum
457
+
458
+ <a href="https://colab.research.google.com/gist/pszemraj/d9a0495861776168fd5cdcd7731bc4ee/example-long-t5-tglobal-base-16384-book-summary.ipynb">
459
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
460
+ </a>
461
+
462
+ Summarize long text and get a SparkNotes-esque summary of arbitrary topics!
463
+
464
+ - generalizes reasonably well to academic & narrative text.
465
+ - A simple example/use case on ASR is [here](https://longt5-booksum-example.netlify.app/).
466
+ - Example notebook in Colab (_click on the icon above_).
467
+
468
+ ## Cheeky Proof-of-Concept
469
+
470
+ A summary of the [infamous navy seals copypasta](https://knowyourmeme.com/memes/navy-seal-copypasta):
471
+
472
+ > The narrator tells us that he's graduated from the Navy seals and has been involved in many secret raids. He's also one of the best snipers in the entire U.S. military. He promises to "wipe you out with precision" when they meet again.
473
+
474
+ * * *
475
+
476
+ **Contents**
477
+
478
+ <!-- TOC -->
479
+
480
+ - [Model description](#model-description)
481
+ - [How-To in Python](#how-to-in-python)
482
+ - [Intended uses & limitations](#intended-uses--limitations)
483
+ - [Training and evaluation data](#training-and-evaluation-data)
484
+ - [FAQ](#faq)
485
+ - [Inference over long documents in batches](#how-to-run-inference-over-a-very-long-30k-tokens-document-in-batches)
486
+ - [How to fine-tune further](#how-to-fine-tune-further)
487
+ - [Training procedure](#training-procedure)
488
+ - [Updates](#updates)
489
+ - [Training hyperparameters](#training-hyperparameters)
490
+ - [Framework versions](#framework-versions)
491
+ - [Citation info](#citation-info)
492
+
493
+ <!-- /TOC -->
494
+
495
+ * * *
496
+
497
+ ## Model description
498
+
499
+ A fine-tuned version of [google/long-t5-tglobal-base](https://huggingface.co/google/long-t5-tglobal-base) on the `kmfoda/booksum` dataset:
500
+
501
+ - 30+ epochs of fine-tuning from the base model on V100/A100 GPUs
502
+ - Training used 16384 token input / 1024 max output
503
+
504
+ Read the paper by Guo et al. here: [LongT5: Efficient Text-To-Text Transformer for Long Sequences](https://arxiv.org/pdf/2112.07916.pdf)
505
+
506
+ ## How-To in Python
507
+
508
+ Install/update transformers `pip install -U transformers`
509
+
510
+ Summarize text with pipeline:
511
+
512
+ ```python
513
+ import torch
514
+ from transformers import pipeline
515
+
516
+ summarizer = pipeline(
517
+ "summarization",
518
+ "pszemraj/long-t5-tglobal-base-16384-book-summary",
519
+ device=0 if torch.cuda.is_available() else -1,
520
+ )
521
+ long_text = "Here is a lot of text I don't want to read. Replace me"
522
+
523
+ result = summarizer(long_text)
524
+ print(result[0]["summary_text"])
525
+ ```
526
+
527
+ Pass [other parameters related to beam search textgen](https://huggingface.co/blog/how-to-generate) when calling `summarizer` to get even higher quality results.
528
+
529
+ ## Intended uses & limitations
530
+
531
+ - The current checkpoint is fairly well converged but will be updated if further improvements can be made.
532
+ - Compare performance to [LED-base](https://huggingface.co/pszemraj/led-base-book-summary) trained on the same dataset (API gen parameters are the same).
533
+ - while this model seems to improve upon factual consistency, **do not take summaries to be foolproof and check things that seem odd**.
534
+
535
+ ## Training and evaluation data
536
+
537
+ `kmfoda/booksum` dataset on HuggingFace - read [the original paper here](https://arxiv.org/abs/2105.08209). Summaries longer than 1024 LongT5 tokens were filtered out to prevent the model from learning to generate "partial" summaries.
538
+
539
+
540
+ * * *
541
+
542
+ ## FAQ
543
+
544
+ ### How to run inference over a very long (30k+ tokens) document in batches?
545
+
546
+ See `summarize.py` in [the code for my hf space Document Summarization](https://huggingface.co/spaces/pszemraj/document-summarization/blob/main/summarize.py) :)
547
+
548
+ You can also use the same code to split a document into batches of 4096, etc., and run over those with the model. This is useful in situations where CUDA memory is limited.
549
+
550
+ ### How to fine-tune further?
551
+
552
+ See [train with a script](https://huggingface.co/docs/transformers/run_scripts) and [the summarization scripts](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization).
553
+
554
+ This model was originally tuned on Google Colab with a heavily modified variant of the [longformer training notebook](https://github.com/patrickvonplaten/notebooks/blob/master/Fine_tune_Longformer_Encoder_Decoder_(LED)_for_Summarization_on_pubmed.ipynb), key enabler being deepspeed. You can try this as an alternate route to fine-tuning the model without using the command line.
555
+
556
+ * * *
557
+
558
+ ## Training procedure
559
+
560
+ ### Updates:
561
+
562
+ - July 22, 2022: updated to a fairly converged checkpoint
563
+ - July 3, 2022: Added a new version with several epochs of additional general training that is more performant.
564
+
565
+ ### Training hyperparameters
566
+
567
+ _NOTE: early checkpoints of this model were trained on a "smaller" subsection of the dataset as it was filtered for summaries of **1024 characters**. This was subsequently caught and adjusted to **1024 tokens** and then trained further for 10+ epochs._
568
+
569
+ The following hyperparameters were used during the **most recent** training round\*:
570
+
571
+ - learning_rate: 0.0005
572
+ - train_batch_size: 1
573
+ - eval_batch_size: 1
574
+ - seed: 42
575
+ - distributed_type: multi-GPU
576
+ - gradient_accumulation_steps: 128
577
+ - total_train_batch_size: 128
578
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
579
+ - lr_scheduler_type: cosine
580
+ - lr_scheduler_warmup_ratio: 0.01
581
+ - num_epochs: 2
582
+
583
+ \* Prior training sessions used roughly similar parameters; multiple sessions were required as this takes eons to train
584
+
585
+ ### Framework versions
586
+
587
+ - Transformers 4.20.1
588
+ - Pytorch 1.10.0+cu113
589
+ - Datasets 2.3.2
590
+ - Tokenizers 0.12.1
591
+
592
+ ## Citation info
593
+
594
+ If you find `pszemraj/long-t5-tglobal-base-16384-book-summary` useful in your work, please consider citing this model :)
595
+
596
+ @misc {peter_szemraj_2022,
597
+ author = { {Peter Szemraj} },
598
+ title = { long-t5-tglobal-base-16384-book-summary (Revision 4b12bce) },
599
+ year = 2022,
600
+ url = { https://huggingface.co/pszemraj/long-t5-tglobal-base-16384-book-summary },
601
+ doi = { 10.57967/hf/0100 },
602
+ publisher = { Hugging Face }
603
+ }
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "pszemraj/long-t5-tglobal-base-16384-booksum-V10",
3
+ "architectures": [
4
+ "LongT5ForConditionalGeneration"
5
+ ],
6
+ "d_ff": 2048,
7
+ "d_kv": 64,
8
+ "d_model": 768,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "early_stopping": true,
13
+ "encoder_attention_type": "transient-global",
14
+ "encoder_no_repeat_ngram_size": 4,
15
+ "eos_token_id": 1,
16
+ "feed_forward_proj": "gated-gelu",
17
+ "global_block_size": 16,
18
+ "initializer_factor": 1.0,
19
+ "is_encoder_decoder": true,
20
+ "is_gated_act": true,
21
+ "layer_norm_epsilon": 1e-06,
22
+ "length_penalty": 0.8,
23
+ "local_radius": 127,
24
+ "max_length": 512,
25
+ "min_length": 8,
26
+ "model_type": "longt5",
27
+ "n_positions": 4096,
28
+ "no_repeat_ngram_size": 3,
29
+ "num_beams": 2,
30
+ "num_decoder_layers": 12,
31
+ "num_heads": 12,
32
+ "num_layers": 12,
33
+ "output_past": true,
34
+ "pad_token_id": 0,
35
+ "relative_attention_max_distance": 128,
36
+ "relative_attention_num_buckets": 32,
37
+ "repetition_penalty": 3.5,
38
+ "tie_word_embeddings": false,
39
+ "torch_dtype": "float32",
40
+ "transformers_version": "4.20.1",
41
+ "use_cache": false,
42
+ "vocab_size": 32128
43
+ }
index.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
index.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ checkpoint-*/
latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step330
long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum_training_metadata.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"output_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum", "overwrite_output_dir": true, "do_train": false, "do_eval": false, "do_predict": false, "evaluation_strategy": "no", "prediction_loss_only": false, "per_device_train_batch_size": 2, "per_device_eval_batch_size": 1, "per_gpu_train_batch_size": "None", "per_gpu_eval_batch_size": "None", "gradient_accumulation_steps": 64, "eval_accumulation_steps": "None", "eval_delay": 0, "learning_rate": 0.0004, "weight_decay": 0.05, "adam_beta1": 0.9, "adam_beta2": 0.999, "adam_epsilon": 1e-08, "max_grad_norm": 0.2, "num_train_epochs": 2, "max_steps": -1, "lr_scheduler_type": "cosine_with_restarts", "warmup_ratio": 0.02, "warmup_steps": 0, "log_level": -1, "log_level_replica": -1, "log_on_each_node": true, "logging_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum/logs", "logging_strategy": "steps", "logging_first_step": false, "logging_steps": 3, "logging_nan_inf_filter": true, "save_strategy": "epoch", "save_steps": 500, "save_total_limit": 1, "save_on_each_node": false, "no_cuda": false, "seed": 42, "data_seed": "None", "jit_mode_eval": false, "use_ipex": false, "bf16": false, "fp16": false, "fp16_opt_level": "O1", "half_precision_backend": "auto", "bf16_full_eval": false, "fp16_full_eval": false, "tf32": "None", "local_rank": 0, "xpu_backend": "None", "tpu_num_cores": "None", "tpu_metrics_debug": false, "debug": "[]", "dataloader_drop_last": false, "eval_steps": "None", "dataloader_num_workers": 0, "past_index": -1, "run_name": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum", "disable_tqdm": false, "remove_unused_columns": true, "label_names": "None", "load_best_model_at_end": false, "metric_for_best_model": "None", "greater_is_better": "None", "ignore_data_skip": false, "sharded_ddp": "[]", "fsdp": "[]", "fsdp_min_num_params": 0, "deepspeed": "/content/ds_config_zero2_bf16.json", "label_smoothing_factor": 0.0, "optim": "adamw_hf", "adafactor": false, "group_by_length": false, "length_column_name": "length", "report_to": "['tensorboard']", "ddp_find_unused_parameters": "None", "ddp_bucket_cap_mb": "None", "dataloader_pin_memory": true, "skip_memory_metrics": true, "use_legacy_prediction_loop": false, "push_to_hub": true, "resume_from_checkpoint": "None", "hub_model_id": "long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum", "hub_strategy": "end", "hub_token": "<HUB_TOKEN>", "hub_private_repo": true, "gradient_checkpointing": true, "include_inputs_for_metrics": false, "fp16_backend": "auto", "push_to_hub_model_id": "None", "push_to_hub_organization": "None", "push_to_hub_token": "<PUSH_TO_HUB_TOKEN>", "_n_gpu": 1, "mp_parameters": "", "auto_find_batch_size": false, "full_determinism": false, "torchdynamo": "None", "ray_scope": "last", "sortish_sampler": false, "predict_with_generate": false, "generation_max_length": "None", "generation_num_beams": "None", "train_batch_size": 2, "eval_batch_size": 1, "configs_src": "long-t5-tglobal-base-16384-booksum-V6-partial-ft3-booksum"}
long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum_training_metadata.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"output_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum", "overwrite_output_dir": true, "do_train": false, "do_eval": false, "do_predict": false, "evaluation_strategy": "no", "prediction_loss_only": false, "per_device_train_batch_size": 1, "per_device_eval_batch_size": 1, "per_gpu_train_batch_size": "None", "per_gpu_eval_batch_size": "None", "gradient_accumulation_steps": 64, "eval_accumulation_steps": "None", "eval_delay": 0, "learning_rate": 0.001, "weight_decay": 0.05, "adam_beta1": 0.9, "adam_beta2": 0.999, "adam_epsilon": 1e-08, "max_grad_norm": 0.5, "num_train_epochs": 2, "max_steps": -1, "lr_scheduler_type": "cosine", "warmup_ratio": 0.01, "warmup_steps": 0, "log_level": -1, "log_level_replica": -1, "log_on_each_node": true, "logging_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum/logs", "logging_strategy": "steps", "logging_first_step": false, "logging_steps": 2, "logging_nan_inf_filter": true, "save_strategy": "epoch", "save_steps": 500, "save_total_limit": 1, "save_on_each_node": false, "no_cuda": false, "seed": 42, "data_seed": "None", "jit_mode_eval": false, "use_ipex": false, "bf16": false, "fp16": true, "fp16_opt_level": "O1", "half_precision_backend": "cuda_amp", "bf16_full_eval": false, "fp16_full_eval": false, "tf32": "None", "local_rank": 0, "xpu_backend": "None", "tpu_num_cores": "None", "tpu_metrics_debug": false, "debug": "[]", "dataloader_drop_last": false, "eval_steps": "None", "dataloader_num_workers": 0, "past_index": -1, "run_name": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum", "disable_tqdm": false, "remove_unused_columns": true, "label_names": "None", "load_best_model_at_end": false, "metric_for_best_model": "None", "greater_is_better": "None", "ignore_data_skip": false, "sharded_ddp": "[]", "fsdp": "[]", "fsdp_min_num_params": 0, "deepspeed": "/content/ds_config_zero2.json", "label_smoothing_factor": 0.0, "optim": "adamw_hf", "adafactor": false, "group_by_length": false, "length_column_name": "length", "report_to": "['tensorboard']", "ddp_find_unused_parameters": "None", "ddp_bucket_cap_mb": "None", "dataloader_pin_memory": true, "skip_memory_metrics": true, "use_legacy_prediction_loop": false, "push_to_hub": true, "resume_from_checkpoint": "None", "hub_model_id": "long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum", "hub_strategy": "end", "hub_token": "<HUB_TOKEN>", "hub_private_repo": true, "gradient_checkpointing": true, "include_inputs_for_metrics": false, "fp16_backend": "auto", "push_to_hub_model_id": "None", "push_to_hub_organization": "None", "push_to_hub_token": "<PUSH_TO_HUB_TOKEN>", "_n_gpu": 1, "mp_parameters": "", "auto_find_batch_size": false, "full_determinism": false, "torchdynamo": "None", "ray_scope": "last", "sortish_sampler": false, "predict_with_generate": false, "generation_max_length": "None", "generation_num_beams": "None", "train_batch_size": 1, "eval_batch_size": 1, "configs_src": "long-t5-tglobal-base-16384-booksum-V7.9-ft1-booksum"}
long-t5-tglobal-base-16384-booksum-V9-ft1-booksum_training_metadata.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"output_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V9-ft1-booksum", "overwrite_output_dir": true, "do_train": false, "do_eval": false, "do_predict": false, "evaluation_strategy": "no", "prediction_loss_only": false, "per_device_train_batch_size": 1, "per_device_eval_batch_size": 1, "per_gpu_train_batch_size": "None", "per_gpu_eval_batch_size": "None", "gradient_accumulation_steps": 64, "eval_accumulation_steps": "None", "eval_delay": 0, "learning_rate": 0.0006, "weight_decay": 0.01, "adam_beta1": 0.9, "adam_beta2": 0.999, "adam_epsilon": 1e-08, "max_grad_norm": 0.3, "num_train_epochs": 2, "max_steps": -1, "lr_scheduler_type": "cosine", "warmup_ratio": 0.01, "warmup_steps": 0, "log_level": -1, "log_level_replica": -1, "log_on_each_node": true, "logging_dir": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V9-ft1-booksum/logs", "logging_strategy": "steps", "logging_first_step": false, "logging_steps": 2, "logging_nan_inf_filter": true, "save_strategy": "steps", "save_steps": 25, "save_total_limit": 1, "save_on_each_node": false, "no_cuda": false, "seed": 42, "data_seed": "None", "jit_mode_eval": false, "use_ipex": false, "bf16": false, "fp16": true, "fp16_opt_level": "O1", "half_precision_backend": "cuda_amp", "bf16_full_eval": false, "fp16_full_eval": false, "tf32": "None", "local_rank": 0, "xpu_backend": "None", "tpu_num_cores": "None", "tpu_metrics_debug": false, "debug": "[]", "dataloader_drop_last": false, "eval_steps": "None", "dataloader_num_workers": 0, "past_index": -1, "run_name": "/content/drive/MyDrive/Programming/hf-trainer/long-t5-tglobal-base-16384-booksum-V9-ft1-booksum", "disable_tqdm": false, "remove_unused_columns": true, "label_names": "None", "load_best_model_at_end": false, "metric_for_best_model": "None", "greater_is_better": "None", "ignore_data_skip": false, "sharded_ddp": "[]", "fsdp": "[]", "fsdp_min_num_params": 0, "deepspeed": "/content/ds_config_zero2.json", "label_smoothing_factor": 0.0, "optim": "adamw_hf", "adafactor": false, "group_by_length": false, "length_column_name": "length", "report_to": "['tensorboard']", "ddp_find_unused_parameters": "None", "ddp_bucket_cap_mb": "None", "dataloader_pin_memory": true, "skip_memory_metrics": true, "use_legacy_prediction_loop": false, "push_to_hub": true, "resume_from_checkpoint": "None", "hub_model_id": "long-t5-tglobal-base-16384-booksum-V9-ft1-booksum", "hub_strategy": "end", "hub_token": "<HUB_TOKEN>", "hub_private_repo": true, "gradient_checkpointing": true, "include_inputs_for_metrics": false, "fp16_backend": "auto", "push_to_hub_model_id": "None", "push_to_hub_organization": "None", "push_to_hub_token": "<PUSH_TO_HUB_TOKEN>", "_n_gpu": 1, "mp_parameters": "", "auto_find_batch_size": false, "full_determinism": false, "torchdynamo": "None", "ray_scope": "last", "sortish_sampler": false, "predict_with_generate": false, "generation_max_length": "None", "generation_num_beams": "None", "train_batch_size": 1, "eval_batch_size": 1, "configs_src": "long-t5-tglobal-base-16384-booksum-V9-ft1-booksum"}
model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:851dbab14fe12a66c8b5f8efa4a2135061db5ef54ef87b609afb3b27519c2b85
3
+ size 992593930
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:134d0d187b6cde13e94f8ae3dca1aecdc26ecafe075410af4880e5ec9cf0c23d
3
+ size 990446387
special_tokens_map.json ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<extra_id_0>",
4
+ "<extra_id_1>",
5
+ "<extra_id_2>",
6
+ "<extra_id_3>",
7
+ "<extra_id_4>",
8
+ "<extra_id_5>",
9
+ "<extra_id_6>",
10
+ "<extra_id_7>",
11
+ "<extra_id_8>",
12
+ "<extra_id_9>",
13
+ "<extra_id_10>",
14
+ "<extra_id_11>",
15
+ "<extra_id_12>",
16
+ "<extra_id_13>",
17
+ "<extra_id_14>",
18
+ "<extra_id_15>",
19
+ "<extra_id_16>",
20
+ "<extra_id_17>",
21
+ "<extra_id_18>",
22
+ "<extra_id_19>",
23
+ "<extra_id_20>",
24
+ "<extra_id_21>",
25
+ "<extra_id_22>",
26
+ "<extra_id_23>",
27
+ "<extra_id_24>",
28
+ "<extra_id_25>",
29
+ "<extra_id_26>",
30
+ "<extra_id_27>",
31
+ "<extra_id_28>",
32
+ "<extra_id_29>",
33
+ "<extra_id_30>",
34
+ "<extra_id_31>",
35
+ "<extra_id_32>",
36
+ "<extra_id_33>",
37
+ "<extra_id_34>",
38
+ "<extra_id_35>",
39
+ "<extra_id_36>",
40
+ "<extra_id_37>",
41
+ "<extra_id_38>",
42
+ "<extra_id_39>",
43
+ "<extra_id_40>",
44
+ "<extra_id_41>",
45
+ "<extra_id_42>",
46
+ "<extra_id_43>",
47
+ "<extra_id_44>",
48
+ "<extra_id_45>",
49
+ "<extra_id_46>",
50
+ "<extra_id_47>",
51
+ "<extra_id_48>",
52
+ "<extra_id_49>",
53
+ "<extra_id_50>",
54
+ "<extra_id_51>",
55
+ "<extra_id_52>",
56
+ "<extra_id_53>",
57
+ "<extra_id_54>",
58
+ "<extra_id_55>",
59
+ "<extra_id_56>",
60
+ "<extra_id_57>",
61
+ "<extra_id_58>",
62
+ "<extra_id_59>",
63
+ "<extra_id_60>",
64
+ "<extra_id_61>",
65
+ "<extra_id_62>",
66
+ "<extra_id_63>",
67
+ "<extra_id_64>",
68
+ "<extra_id_65>",
69
+ "<extra_id_66>",
70
+ "<extra_id_67>",
71
+ "<extra_id_68>",
72
+ "<extra_id_69>",
73
+ "<extra_id_70>",
74
+ "<extra_id_71>",
75
+ "<extra_id_72>",
76
+ "<extra_id_73>",
77
+ "<extra_id_74>",
78
+ "<extra_id_75>",
79
+ "<extra_id_76>",
80
+ "<extra_id_77>",
81
+ "<extra_id_78>",
82
+ "<extra_id_79>",
83
+ "<extra_id_80>",
84
+ "<extra_id_81>",
85
+ "<extra_id_82>",
86
+ "<extra_id_83>",
87
+ "<extra_id_84>",
88
+ "<extra_id_85>",
89
+ "<extra_id_86>",
90
+ "<extra_id_87>",
91
+ "<extra_id_88>",
92
+ "<extra_id_89>",
93
+ "<extra_id_90>",
94
+ "<extra_id_91>",
95
+ "<extra_id_92>",
96
+ "<extra_id_93>",
97
+ "<extra_id_94>",
98
+ "<extra_id_95>",
99
+ "<extra_id_96>",
100
+ "<extra_id_97>",
101
+ "<extra_id_98>",
102
+ "<extra_id_99>"
103
+ ],
104
+ "eos_token": "</s>",
105
+ "pad_token": "<pad>",
106
+ "unk_token": "<unk>"
107
+ }
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d60acb128cf7b7f2536e8f38a5b18a05535c9e14c7a355904270e15b0945ea86
3
+ size 791656
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<extra_id_0>",
4
+ "<extra_id_1>",
5
+ "<extra_id_2>",
6
+ "<extra_id_3>",
7
+ "<extra_id_4>",
8
+ "<extra_id_5>",
9
+ "<extra_id_6>",
10
+ "<extra_id_7>",
11
+ "<extra_id_8>",
12
+ "<extra_id_9>",
13
+ "<extra_id_10>",
14
+ "<extra_id_11>",
15
+ "<extra_id_12>",
16
+ "<extra_id_13>",
17
+ "<extra_id_14>",
18
+ "<extra_id_15>",
19
+ "<extra_id_16>",
20
+ "<extra_id_17>",
21
+ "<extra_id_18>",
22
+ "<extra_id_19>",
23
+ "<extra_id_20>",
24
+ "<extra_id_21>",
25
+ "<extra_id_22>",
26
+ "<extra_id_23>",
27
+ "<extra_id_24>",
28
+ "<extra_id_25>",
29
+ "<extra_id_26>",
30
+ "<extra_id_27>",
31
+ "<extra_id_28>",
32
+ "<extra_id_29>",
33
+ "<extra_id_30>",
34
+ "<extra_id_31>",
35
+ "<extra_id_32>",
36
+ "<extra_id_33>",
37
+ "<extra_id_34>",
38
+ "<extra_id_35>",
39
+ "<extra_id_36>",
40
+ "<extra_id_37>",
41
+ "<extra_id_38>",
42
+ "<extra_id_39>",
43
+ "<extra_id_40>",
44
+ "<extra_id_41>",
45
+ "<extra_id_42>",
46
+ "<extra_id_43>",
47
+ "<extra_id_44>",
48
+ "<extra_id_45>",
49
+ "<extra_id_46>",
50
+ "<extra_id_47>",
51
+ "<extra_id_48>",
52
+ "<extra_id_49>",
53
+ "<extra_id_50>",
54
+ "<extra_id_51>",
55
+ "<extra_id_52>",
56
+ "<extra_id_53>",
57
+ "<extra_id_54>",
58
+ "<extra_id_55>",
59
+ "<extra_id_56>",
60
+ "<extra_id_57>",
61
+ "<extra_id_58>",
62
+ "<extra_id_59>",
63
+ "<extra_id_60>",
64
+ "<extra_id_61>",
65
+ "<extra_id_62>",
66
+ "<extra_id_63>",
67
+ "<extra_id_64>",
68
+ "<extra_id_65>",
69
+ "<extra_id_66>",
70
+ "<extra_id_67>",
71
+ "<extra_id_68>",
72
+ "<extra_id_69>",
73
+ "<extra_id_70>",
74
+ "<extra_id_71>",
75
+ "<extra_id_72>",
76
+ "<extra_id_73>",
77
+ "<extra_id_74>",
78
+ "<extra_id_75>",
79
+ "<extra_id_76>",
80
+ "<extra_id_77>",
81
+ "<extra_id_78>",
82
+ "<extra_id_79>",
83
+ "<extra_id_80>",
84
+ "<extra_id_81>",
85
+ "<extra_id_82>",
86
+ "<extra_id_83>",
87
+ "<extra_id_84>",
88
+ "<extra_id_85>",
89
+ "<extra_id_86>",
90
+ "<extra_id_87>",
91
+ "<extra_id_88>",
92
+ "<extra_id_89>",
93
+ "<extra_id_90>",
94
+ "<extra_id_91>",
95
+ "<extra_id_92>",
96
+ "<extra_id_93>",
97
+ "<extra_id_94>",
98
+ "<extra_id_95>",
99
+ "<extra_id_96>",
100
+ "<extra_id_97>",
101
+ "<extra_id_98>",
102
+ "<extra_id_99>"
103
+ ],
104
+ "eos_token": "</s>",
105
+ "extra_ids": 100,
106
+ "name_or_path": "pszemraj/long-t5-tglobal-base-16384-booksum-V10",
107
+ "pad_token": "<pad>",
108
+ "special_tokens_map_file": null,
109
+ "tokenizer_class": "T5Tokenizer",
110
+ "unk_token": "<unk>"
111
+ }
trainer_state.json ADDED
@@ -0,0 +1,1015 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": null,
3
+ "best_model_checkpoint": null,
4
+ "epoch": 1.9971671388101981,
5
+ "global_step": 330,
6
+ "is_hyper_param_search": false,
7
+ "is_local_process_zero": true,
8
+ "is_world_process_zero": true,
9
+ "log_history": [
10
+ {
11
+ "epoch": 0.01,
12
+ "learning_rate": 0.0003,
13
+ "loss": 2.0736,
14
+ "step": 2
15
+ },
16
+ {
17
+ "epoch": 0.02,
18
+ "learning_rate": 0.0006,
19
+ "loss": 2.0741,
20
+ "step": 4
21
+ },
22
+ {
23
+ "epoch": 0.04,
24
+ "learning_rate": 0.0005999442811234004,
25
+ "loss": 2.098,
26
+ "step": 6
27
+ },
28
+ {
29
+ "epoch": 0.05,
30
+ "learning_rate": 0.0005997771451908898,
31
+ "loss": 2.0627,
32
+ "step": 8
33
+ },
34
+ {
35
+ "epoch": 0.06,
36
+ "learning_rate": 0.0005994986542866444,
37
+ "loss": 2.0418,
38
+ "step": 10
39
+ },
40
+ {
41
+ "epoch": 0.07,
42
+ "learning_rate": 0.0005991089118586658,
43
+ "loss": 2.0717,
44
+ "step": 12
45
+ },
46
+ {
47
+ "epoch": 0.08,
48
+ "learning_rate": 0.0005986080626803564,
49
+ "loss": 2.0504,
50
+ "step": 14
51
+ },
52
+ {
53
+ "epoch": 0.1,
54
+ "learning_rate": 0.0005979962927967394,
55
+ "loss": 2.0314,
56
+ "step": 16
57
+ },
58
+ {
59
+ "epoch": 0.11,
60
+ "learning_rate": 0.0005972738294553527,
61
+ "loss": 2.0568,
62
+ "step": 18
63
+ },
64
+ {
65
+ "epoch": 0.12,
66
+ "learning_rate": 0.0005964409410218346,
67
+ "loss": 2.073,
68
+ "step": 20
69
+ },
70
+ {
71
+ "epoch": 0.13,
72
+ "learning_rate": 0.0005954979368802377,
73
+ "loss": 2.0737,
74
+ "step": 22
75
+ },
76
+ {
77
+ "epoch": 0.15,
78
+ "learning_rate": 0.0005944451673181043,
79
+ "loss": 2.0936,
80
+ "step": 24
81
+ },
82
+ {
83
+ "epoch": 0.16,
84
+ "learning_rate": 0.0005932830233963502,
85
+ "loss": 2.0846,
86
+ "step": 26
87
+ },
88
+ {
89
+ "epoch": 0.17,
90
+ "learning_rate": 0.0005920119368040003,
91
+ "loss": 2.1374,
92
+ "step": 28
93
+ },
94
+ {
95
+ "epoch": 0.18,
96
+ "learning_rate": 0.0005906323796978346,
97
+ "loss": 2.0828,
98
+ "step": 30
99
+ },
100
+ {
101
+ "epoch": 0.19,
102
+ "learning_rate": 0.0005891448645270008,
103
+ "loss": 2.0802,
104
+ "step": 32
105
+ },
106
+ {
107
+ "epoch": 0.21,
108
+ "learning_rate": 0.0005875499438426604,
109
+ "loss": 2.147,
110
+ "step": 34
111
+ },
112
+ {
113
+ "epoch": 0.22,
114
+ "learning_rate": 0.0005858482100927391,
115
+ "loss": 2.0904,
116
+ "step": 36
117
+ },
118
+ {
119
+ "epoch": 0.23,
120
+ "learning_rate": 0.0005840402954018554,
121
+ "loss": 2.0823,
122
+ "step": 38
123
+ },
124
+ {
125
+ "epoch": 0.24,
126
+ "learning_rate": 0.0005821268713365129,
127
+ "loss": 2.0792,
128
+ "step": 40
129
+ },
130
+ {
131
+ "epoch": 0.25,
132
+ "learning_rate": 0.0005801086486556411,
133
+ "loss": 2.0716,
134
+ "step": 42
135
+ },
136
+ {
137
+ "epoch": 0.27,
138
+ "learning_rate": 0.0005779863770465765,
139
+ "loss": 2.2061,
140
+ "step": 44
141
+ },
142
+ {
143
+ "epoch": 0.28,
144
+ "learning_rate": 0.0005757608448465853,
145
+ "loss": 2.1735,
146
+ "step": 46
147
+ },
148
+ {
149
+ "epoch": 0.29,
150
+ "learning_rate": 0.0005734328787500274,
151
+ "loss": 2.098,
152
+ "step": 48
153
+ },
154
+ {
155
+ "epoch": 0.3,
156
+ "learning_rate": 0.000571003343501274,
157
+ "loss": 2.0977,
158
+ "step": 50
159
+ },
160
+ {
161
+ "epoch": 0.31,
162
+ "learning_rate": 0.0005684731415734899,
163
+ "loss": 2.1076,
164
+ "step": 52
165
+ },
166
+ {
167
+ "epoch": 0.33,
168
+ "learning_rate": 0.0005658432128334017,
169
+ "loss": 2.0476,
170
+ "step": 54
171
+ },
172
+ {
173
+ "epoch": 0.34,
174
+ "learning_rate": 0.0005631145341921755,
175
+ "loss": 2.0728,
176
+ "step": 56
177
+ },
178
+ {
179
+ "epoch": 0.35,
180
+ "learning_rate": 0.0005602881192425346,
181
+ "loss": 2.0477,
182
+ "step": 58
183
+ },
184
+ {
185
+ "epoch": 0.36,
186
+ "learning_rate": 0.000557365017882251,
187
+ "loss": 2.1102,
188
+ "step": 60
189
+ },
190
+ {
191
+ "epoch": 0.37,
192
+ "learning_rate": 0.0005543463159241515,
193
+ "loss": 2.0754,
194
+ "step": 62
195
+ },
196
+ {
197
+ "epoch": 0.39,
198
+ "learning_rate": 0.0005512331346927817,
199
+ "loss": 2.1029,
200
+ "step": 64
201
+ },
202
+ {
203
+ "epoch": 0.4,
204
+ "learning_rate": 0.0005480266306078807,
205
+ "loss": 1.9922,
206
+ "step": 66
207
+ },
208
+ {
209
+ "epoch": 0.41,
210
+ "learning_rate": 0.0005447279947548182,
211
+ "loss": 2.1599,
212
+ "step": 68
213
+ },
214
+ {
215
+ "epoch": 0.42,
216
+ "learning_rate": 0.0005413384524421545,
217
+ "loss": 2.1388,
218
+ "step": 70
219
+ },
220
+ {
221
+ "epoch": 0.44,
222
+ "learning_rate": 0.0005378592627464883,
223
+ "loss": 2.131,
224
+ "step": 72
225
+ },
226
+ {
227
+ "epoch": 0.45,
228
+ "learning_rate": 0.0005342917180447621,
229
+ "loss": 2.0658,
230
+ "step": 74
231
+ },
232
+ {
233
+ "epoch": 0.46,
234
+ "learning_rate": 0.0005306371435341955,
235
+ "loss": 2.1437,
236
+ "step": 76
237
+ },
238
+ {
239
+ "epoch": 0.47,
240
+ "learning_rate": 0.0005268968967400301,
241
+ "loss": 2.1145,
242
+ "step": 78
243
+ },
244
+ {
245
+ "epoch": 0.48,
246
+ "learning_rate": 0.0005230723670112627,
247
+ "loss": 2.1263,
248
+ "step": 80
249
+ },
250
+ {
251
+ "epoch": 0.5,
252
+ "learning_rate": 0.0005191649750045603,
253
+ "loss": 2.0513,
254
+ "step": 82
255
+ },
256
+ {
257
+ "epoch": 0.51,
258
+ "learning_rate": 0.000515176172156543,
259
+ "loss": 2.0723,
260
+ "step": 84
261
+ },
262
+ {
263
+ "epoch": 0.52,
264
+ "learning_rate": 0.0005111074401446355,
265
+ "loss": 2.0744,
266
+ "step": 86
267
+ },
268
+ {
269
+ "epoch": 0.53,
270
+ "learning_rate": 0.0005069602903366834,
271
+ "loss": 2.131,
272
+ "step": 88
273
+ },
274
+ {
275
+ "epoch": 0.54,
276
+ "learning_rate": 0.0005027362632295429,
277
+ "loss": 2.094,
278
+ "step": 90
279
+ },
280
+ {
281
+ "epoch": 0.56,
282
+ "learning_rate": 0.0004984369278768482,
283
+ "loss": 2.0633,
284
+ "step": 92
285
+ },
286
+ {
287
+ "epoch": 0.57,
288
+ "learning_rate": 0.0004940638813061723,
289
+ "loss": 2.1182,
290
+ "step": 94
291
+ },
292
+ {
293
+ "epoch": 0.58,
294
+ "learning_rate": 0.0004896187479257971,
295
+ "loss": 2.1664,
296
+ "step": 96
297
+ },
298
+ {
299
+ "epoch": 0.59,
300
+ "learning_rate": 0.0004851031789213108,
301
+ "loss": 2.1365,
302
+ "step": 98
303
+ },
304
+ {
305
+ "epoch": 0.6,
306
+ "learning_rate": 0.0004805188516422613,
307
+ "loss": 2.1204,
308
+ "step": 100
309
+ },
310
+ {
311
+ "epoch": 0.62,
312
+ "learning_rate": 0.00047586746897908803,
313
+ "loss": 2.0677,
314
+ "step": 102
315
+ },
316
+ {
317
+ "epoch": 0.63,
318
+ "learning_rate": 0.00047115075873056876,
319
+ "loss": 2.1588,
320
+ "step": 104
321
+ },
322
+ {
323
+ "epoch": 0.64,
324
+ "learning_rate": 0.0004663704729620119,
325
+ "loss": 2.0746,
326
+ "step": 106
327
+ },
328
+ {
329
+ "epoch": 0.65,
330
+ "learning_rate": 0.0004615283873544366,
331
+ "loss": 2.126,
332
+ "step": 108
333
+ },
334
+ {
335
+ "epoch": 0.66,
336
+ "learning_rate": 0.0004566263005449791,
337
+ "loss": 2.0786,
338
+ "step": 110
339
+ },
340
+ {
341
+ "epoch": 0.68,
342
+ "learning_rate": 0.0004516660334587729,
343
+ "loss": 2.1019,
344
+ "step": 112
345
+ },
346
+ {
347
+ "epoch": 0.69,
348
+ "learning_rate": 0.00044664942863254913,
349
+ "loss": 2.0605,
350
+ "step": 114
351
+ },
352
+ {
353
+ "epoch": 0.7,
354
+ "learning_rate": 0.0004415783495302096,
355
+ "loss": 2.0879,
356
+ "step": 116
357
+ },
358
+ {
359
+ "epoch": 0.71,
360
+ "learning_rate": 0.0004364546798506258,
361
+ "loss": 2.1516,
362
+ "step": 118
363
+ },
364
+ {
365
+ "epoch": 0.73,
366
+ "learning_rate": 0.0004312803228279218,
367
+ "loss": 2.1287,
368
+ "step": 120
369
+ },
370
+ {
371
+ "epoch": 0.74,
372
+ "learning_rate": 0.0004260572005245005,
373
+ "loss": 2.1054,
374
+ "step": 122
375
+ },
376
+ {
377
+ "epoch": 0.75,
378
+ "learning_rate": 0.00042078725311707585,
379
+ "loss": 2.0905,
380
+ "step": 124
381
+ },
382
+ {
383
+ "epoch": 0.76,
384
+ "learning_rate": 0.0004154724381759763,
385
+ "loss": 2.0875,
386
+ "step": 126
387
+ },
388
+ {
389
+ "epoch": 0.77,
390
+ "learning_rate": 0.0004101147299379876,
391
+ "loss": 2.0948,
392
+ "step": 128
393
+ },
394
+ {
395
+ "epoch": 0.79,
396
+ "learning_rate": 0.00040471611857300423,
397
+ "loss": 2.1521,
398
+ "step": 130
399
+ },
400
+ {
401
+ "epoch": 0.8,
402
+ "learning_rate": 0.0003992786094447625,
403
+ "loss": 2.0645,
404
+ "step": 132
405
+ },
406
+ {
407
+ "epoch": 0.81,
408
+ "learning_rate": 0.0003938042223659299,
409
+ "loss": 2.0953,
410
+ "step": 134
411
+ },
412
+ {
413
+ "epoch": 0.82,
414
+ "learning_rate": 0.0003882949908478272,
415
+ "loss": 2.1046,
416
+ "step": 136
417
+ },
418
+ {
419
+ "epoch": 0.83,
420
+ "learning_rate": 0.0003827529613450617,
421
+ "loss": 2.1814,
422
+ "step": 138
423
+ },
424
+ {
425
+ "epoch": 0.85,
426
+ "learning_rate": 0.0003771801924953534,
427
+ "loss": 2.1147,
428
+ "step": 140
429
+ },
430
+ {
431
+ "epoch": 0.86,
432
+ "learning_rate": 0.0003715787543548345,
433
+ "loss": 2.1226,
434
+ "step": 142
435
+ },
436
+ {
437
+ "epoch": 0.87,
438
+ "learning_rate": 0.0003659507276291087,
439
+ "loss": 2.1093,
440
+ "step": 144
441
+ },
442
+ {
443
+ "epoch": 0.88,
444
+ "learning_rate": 0.00036029820290035347,
445
+ "loss": 2.1038,
446
+ "step": 146
447
+ },
448
+ {
449
+ "epoch": 0.89,
450
+ "learning_rate": 0.0003546232798507543,
451
+ "loss": 2.0581,
452
+ "step": 148
453
+ },
454
+ {
455
+ "epoch": 0.91,
456
+ "learning_rate": 0.00034892806648255875,
457
+ "loss": 2.0076,
458
+ "step": 150
459
+ },
460
+ {
461
+ "epoch": 0.92,
462
+ "learning_rate": 0.0003432146783350393,
463
+ "loss": 2.1017,
464
+ "step": 152
465
+ },
466
+ {
467
+ "epoch": 0.93,
468
+ "learning_rate": 0.0003374852376986568,
469
+ "loss": 2.1353,
470
+ "step": 154
471
+ },
472
+ {
473
+ "epoch": 0.94,
474
+ "learning_rate": 0.00033174187282671686,
475
+ "loss": 2.0836,
476
+ "step": 156
477
+ },
478
+ {
479
+ "epoch": 0.95,
480
+ "learning_rate": 0.0003259867171448097,
481
+ "loss": 2.098,
482
+ "step": 158
483
+ },
484
+ {
485
+ "epoch": 0.97,
486
+ "learning_rate": 0.00032022190845833035,
487
+ "loss": 2.1308,
488
+ "step": 160
489
+ },
490
+ {
491
+ "epoch": 0.98,
492
+ "learning_rate": 0.0003144495881583712,
493
+ "loss": 2.1204,
494
+ "step": 162
495
+ },
496
+ {
497
+ "epoch": 0.99,
498
+ "learning_rate": 0.00030867190042628177,
499
+ "loss": 2.0564,
500
+ "step": 164
501
+ },
502
+ {
503
+ "epoch": 1.01,
504
+ "learning_rate": 0.0003028909914371942,
505
+ "loss": 2.5573,
506
+ "step": 166
507
+ },
508
+ {
509
+ "epoch": 1.02,
510
+ "learning_rate": 0.0002971090085628058,
511
+ "loss": 1.9576,
512
+ "step": 168
513
+ },
514
+ {
515
+ "epoch": 1.03,
516
+ "learning_rate": 0.00029132809957371823,
517
+ "loss": 1.9274,
518
+ "step": 170
519
+ },
520
+ {
521
+ "epoch": 1.04,
522
+ "learning_rate": 0.0002855504118416288,
523
+ "loss": 1.9637,
524
+ "step": 172
525
+ },
526
+ {
527
+ "epoch": 1.05,
528
+ "learning_rate": 0.0002797780915416696,
529
+ "loss": 1.9729,
530
+ "step": 174
531
+ },
532
+ {
533
+ "epoch": 1.07,
534
+ "learning_rate": 0.0002740132828551904,
535
+ "loss": 2.0254,
536
+ "step": 176
537
+ },
538
+ {
539
+ "epoch": 1.08,
540
+ "learning_rate": 0.00026825812717328314,
541
+ "loss": 1.9427,
542
+ "step": 178
543
+ },
544
+ {
545
+ "epoch": 1.09,
546
+ "learning_rate": 0.00026251476230134313,
547
+ "loss": 1.97,
548
+ "step": 180
549
+ },
550
+ {
551
+ "epoch": 1.1,
552
+ "learning_rate": 0.00025678532166496077,
553
+ "loss": 2.042,
554
+ "step": 182
555
+ },
556
+ {
557
+ "epoch": 1.11,
558
+ "learning_rate": 0.00025107193351744115,
559
+ "loss": 2.0033,
560
+ "step": 184
561
+ },
562
+ {
563
+ "epoch": 1.13,
564
+ "learning_rate": 0.0002453767201492457,
565
+ "loss": 1.9466,
566
+ "step": 186
567
+ },
568
+ {
569
+ "epoch": 1.14,
570
+ "learning_rate": 0.00023970179709964656,
571
+ "loss": 2.0294,
572
+ "step": 188
573
+ },
574
+ {
575
+ "epoch": 1.15,
576
+ "learning_rate": 0.0002340492723708912,
577
+ "loss": 2.0002,
578
+ "step": 190
579
+ },
580
+ {
581
+ "epoch": 1.16,
582
+ "learning_rate": 0.00022842124564516548,
583
+ "loss": 1.9686,
584
+ "step": 192
585
+ },
586
+ {
587
+ "epoch": 1.18,
588
+ "learning_rate": 0.0002228198075046467,
589
+ "loss": 2.0857,
590
+ "step": 194
591
+ },
592
+ {
593
+ "epoch": 1.19,
594
+ "learning_rate": 0.00021724703865493827,
595
+ "loss": 2.0111,
596
+ "step": 196
597
+ },
598
+ {
599
+ "epoch": 1.2,
600
+ "learning_rate": 0.00021170500915217283,
601
+ "loss": 2.0058,
602
+ "step": 198
603
+ },
604
+ {
605
+ "epoch": 1.21,
606
+ "learning_rate": 0.00020619577763407015,
607
+ "loss": 1.9725,
608
+ "step": 200
609
+ },
610
+ {
611
+ "epoch": 1.22,
612
+ "learning_rate": 0.0002007213905552375,
613
+ "loss": 2.0542,
614
+ "step": 202
615
+ },
616
+ {
617
+ "epoch": 1.24,
618
+ "learning_rate": 0.0001952838814269958,
619
+ "loss": 2.0265,
620
+ "step": 204
621
+ },
622
+ {
623
+ "epoch": 1.25,
624
+ "learning_rate": 0.00018988527006201237,
625
+ "loss": 2.1143,
626
+ "step": 206
627
+ },
628
+ {
629
+ "epoch": 1.26,
630
+ "learning_rate": 0.00018452756182402364,
631
+ "loss": 1.96,
632
+ "step": 208
633
+ },
634
+ {
635
+ "epoch": 1.27,
636
+ "learning_rate": 0.00017921274688292415,
637
+ "loss": 2.0181,
638
+ "step": 210
639
+ },
640
+ {
641
+ "epoch": 1.28,
642
+ "learning_rate": 0.00017394279947549948,
643
+ "loss": 1.9909,
644
+ "step": 212
645
+ },
646
+ {
647
+ "epoch": 1.3,
648
+ "learning_rate": 0.00016871967717207824,
649
+ "loss": 2.0021,
650
+ "step": 214
651
+ },
652
+ {
653
+ "epoch": 1.31,
654
+ "learning_rate": 0.00016354532014937418,
655
+ "loss": 1.9598,
656
+ "step": 216
657
+ },
658
+ {
659
+ "epoch": 1.32,
660
+ "learning_rate": 0.00015842165046979042,
661
+ "loss": 1.9433,
662
+ "step": 218
663
+ },
664
+ {
665
+ "epoch": 1.33,
666
+ "learning_rate": 0.0001533505713674509,
667
+ "loss": 2.0222,
668
+ "step": 220
669
+ },
670
+ {
671
+ "epoch": 1.34,
672
+ "learning_rate": 0.0001483339665412271,
673
+ "loss": 1.9898,
674
+ "step": 222
675
+ },
676
+ {
677
+ "epoch": 1.36,
678
+ "learning_rate": 0.00014337369945502084,
679
+ "loss": 2.0555,
680
+ "step": 224
681
+ },
682
+ {
683
+ "epoch": 1.37,
684
+ "learning_rate": 0.00013847161264556339,
685
+ "loss": 2.0082,
686
+ "step": 226
687
+ },
688
+ {
689
+ "epoch": 1.38,
690
+ "learning_rate": 0.000133629527037988,
691
+ "loss": 2.0081,
692
+ "step": 228
693
+ },
694
+ {
695
+ "epoch": 1.39,
696
+ "learning_rate": 0.00012884924126943122,
697
+ "loss": 2.0028,
698
+ "step": 230
699
+ },
700
+ {
701
+ "epoch": 1.4,
702
+ "learning_rate": 0.00012413253102091197,
703
+ "loss": 2.0535,
704
+ "step": 232
705
+ },
706
+ {
707
+ "epoch": 1.42,
708
+ "learning_rate": 0.00011948114835773868,
709
+ "loss": 1.9512,
710
+ "step": 234
711
+ },
712
+ {
713
+ "epoch": 1.43,
714
+ "learning_rate": 0.00011489682107868918,
715
+ "loss": 1.9141,
716
+ "step": 236
717
+ },
718
+ {
719
+ "epoch": 1.44,
720
+ "learning_rate": 0.00011038125207420298,
721
+ "loss": 2.0705,
722
+ "step": 238
723
+ },
724
+ {
725
+ "epoch": 1.45,
726
+ "learning_rate": 0.00010593611869382759,
727
+ "loss": 1.9869,
728
+ "step": 240
729
+ },
730
+ {
731
+ "epoch": 1.47,
732
+ "learning_rate": 0.0001015630721231517,
733
+ "loss": 1.9448,
734
+ "step": 242
735
+ },
736
+ {
737
+ "epoch": 1.48,
738
+ "learning_rate": 9.7263736770457e-05,
739
+ "loss": 1.9565,
740
+ "step": 244
741
+ },
742
+ {
743
+ "epoch": 1.49,
744
+ "learning_rate": 9.303970966331645e-05,
745
+ "loss": 1.9925,
746
+ "step": 246
747
+ },
748
+ {
749
+ "epoch": 1.5,
750
+ "learning_rate": 8.88925598553645e-05,
751
+ "loss": 1.995,
752
+ "step": 248
753
+ },
754
+ {
755
+ "epoch": 1.51,
756
+ "learning_rate": 8.482382784345695e-05,
757
+ "loss": 1.9627,
758
+ "step": 250
759
+ },
760
+ {
761
+ "epoch": 1.53,
762
+ "learning_rate": 8.083502499543967e-05,
763
+ "loss": 2.0096,
764
+ "step": 252
765
+ },
766
+ {
767
+ "epoch": 1.54,
768
+ "learning_rate": 7.692763298873725e-05,
769
+ "loss": 2.0731,
770
+ "step": 254
771
+ },
772
+ {
773
+ "epoch": 1.55,
774
+ "learning_rate": 7.310310325996986e-05,
775
+ "loss": 2.0134,
776
+ "step": 256
777
+ },
778
+ {
779
+ "epoch": 1.56,
780
+ "learning_rate": 6.936285646580441e-05,
781
+ "loss": 2.0516,
782
+ "step": 258
783
+ },
784
+ {
785
+ "epoch": 1.57,
786
+ "learning_rate": 6.570828195523786e-05,
787
+ "loss": 2.0061,
788
+ "step": 260
789
+ },
790
+ {
791
+ "epoch": 1.59,
792
+ "learning_rate": 6.214073725351162e-05,
793
+ "loss": 1.9709,
794
+ "step": 262
795
+ },
796
+ {
797
+ "epoch": 1.6,
798
+ "learning_rate": 5.8661547557845534e-05,
799
+ "loss": 2.03,
800
+ "step": 264
801
+ },
802
+ {
803
+ "epoch": 1.61,
804
+ "learning_rate": 5.5272005245181705e-05,
805
+ "loss": 1.9751,
806
+ "step": 266
807
+ },
808
+ {
809
+ "epoch": 1.62,
810
+ "learning_rate": 5.197336939211925e-05,
811
+ "loss": 2.0363,
812
+ "step": 268
813
+ },
814
+ {
815
+ "epoch": 1.63,
816
+ "learning_rate": 4.87668653072184e-05,
817
+ "loss": 2.0713,
818
+ "step": 270
819
+ },
820
+ {
821
+ "epoch": 1.65,
822
+ "learning_rate": 4.565368407584855e-05,
823
+ "loss": 2.021,
824
+ "step": 272
825
+ },
826
+ {
827
+ "epoch": 1.66,
828
+ "learning_rate": 4.2634982117748854e-05,
829
+ "loss": 1.9747,
830
+ "step": 274
831
+ },
832
+ {
833
+ "epoch": 1.67,
834
+ "learning_rate": 3.971188075746535e-05,
835
+ "loss": 2.0548,
836
+ "step": 276
837
+ },
838
+ {
839
+ "epoch": 1.68,
840
+ "learning_rate": 3.688546580782448e-05,
841
+ "loss": 1.9953,
842
+ "step": 278
843
+ },
844
+ {
845
+ "epoch": 1.69,
846
+ "learning_rate": 3.415678716659831e-05,
847
+ "loss": 1.9769,
848
+ "step": 280
849
+ },
850
+ {
851
+ "epoch": 1.71,
852
+ "learning_rate": 3.152685842651004e-05,
853
+ "loss": 2.0558,
854
+ "step": 282
855
+ },
856
+ {
857
+ "epoch": 1.72,
858
+ "learning_rate": 2.899665649872589e-05,
859
+ "loss": 2.047,
860
+ "step": 284
861
+ },
862
+ {
863
+ "epoch": 1.73,
864
+ "learning_rate": 2.6567121249972544e-05,
865
+ "loss": 2.0231,
866
+ "step": 286
867
+ },
868
+ {
869
+ "epoch": 1.74,
870
+ "learning_rate": 2.423915515341467e-05,
871
+ "loss": 2.0504,
872
+ "step": 288
873
+ },
874
+ {
875
+ "epoch": 1.76,
876
+ "learning_rate": 2.2013622953423405e-05,
877
+ "loss": 2.0075,
878
+ "step": 290
879
+ },
880
+ {
881
+ "epoch": 1.77,
882
+ "learning_rate": 1.9891351344358853e-05,
883
+ "loss": 2.0219,
884
+ "step": 292
885
+ },
886
+ {
887
+ "epoch": 1.78,
888
+ "learning_rate": 1.7873128663487047e-05,
889
+ "loss": 1.9923,
890
+ "step": 294
891
+ },
892
+ {
893
+ "epoch": 1.79,
894
+ "learning_rate": 1.5959704598144628e-05,
895
+ "loss": 2.0081,
896
+ "step": 296
897
+ },
898
+ {
899
+ "epoch": 1.8,
900
+ "learning_rate": 1.4151789907260846e-05,
901
+ "loss": 1.9971,
902
+ "step": 298
903
+ },
904
+ {
905
+ "epoch": 1.82,
906
+ "learning_rate": 1.2450056157339439e-05,
907
+ "loss": 1.9923,
908
+ "step": 300
909
+ },
910
+ {
911
+ "epoch": 1.83,
912
+ "learning_rate": 1.0855135472999155e-05,
913
+ "loss": 2.003,
914
+ "step": 302
915
+ },
916
+ {
917
+ "epoch": 1.84,
918
+ "learning_rate": 9.36762030216538e-06,
919
+ "loss": 2.0014,
920
+ "step": 304
921
+ },
922
+ {
923
+ "epoch": 1.85,
924
+ "learning_rate": 7.988063195999639e-06,
925
+ "loss": 2.0675,
926
+ "step": 306
927
+ },
928
+ {
929
+ "epoch": 1.86,
930
+ "learning_rate": 6.716976603649782e-06,
931
+ "loss": 1.9773,
932
+ "step": 308
933
+ },
934
+ {
935
+ "epoch": 1.88,
936
+ "learning_rate": 5.554832681895582e-06,
937
+ "loss": 1.997,
938
+ "step": 310
939
+ },
940
+ {
941
+ "epoch": 1.89,
942
+ "learning_rate": 4.5020631197623e-06,
943
+ "loss": 2.0323,
944
+ "step": 312
945
+ },
946
+ {
947
+ "epoch": 1.9,
948
+ "learning_rate": 3.559058978165319e-06,
949
+ "loss": 2.0221,
950
+ "step": 314
951
+ },
952
+ {
953
+ "epoch": 1.91,
954
+ "learning_rate": 2.7261705446473103e-06,
955
+ "loss": 1.9734,
956
+ "step": 316
957
+ },
958
+ {
959
+ "epoch": 1.92,
960
+ "learning_rate": 2.003707203260585e-06,
961
+ "loss": 1.9529,
962
+ "step": 318
963
+ },
964
+ {
965
+ "epoch": 1.94,
966
+ "learning_rate": 1.3919373196436213e-06,
967
+ "loss": 1.982,
968
+ "step": 320
969
+ },
970
+ {
971
+ "epoch": 1.95,
972
+ "learning_rate": 8.910881413340398e-07,
973
+ "loss": 2.0501,
974
+ "step": 322
975
+ },
976
+ {
977
+ "epoch": 1.96,
978
+ "learning_rate": 5.013457133556276e-07,
979
+ "loss": 2.0041,
980
+ "step": 324
981
+ },
982
+ {
983
+ "epoch": 1.97,
984
+ "learning_rate": 2.2285480911008457e-07,
985
+ "loss": 1.983,
986
+ "step": 326
987
+ },
988
+ {
989
+ "epoch": 1.99,
990
+ "learning_rate": 5.5718876599541995e-08,
991
+ "loss": 2.0002,
992
+ "step": 328
993
+ },
994
+ {
995
+ "epoch": 2.0,
996
+ "learning_rate": 0.0,
997
+ "loss": 2.0595,
998
+ "step": 330
999
+ },
1000
+ {
1001
+ "epoch": 2.0,
1002
+ "step": 330,
1003
+ "total_flos": 4.634629372945367e+17,
1004
+ "train_loss": 2.053801321260857,
1005
+ "train_runtime": 80029.5559,
1006
+ "train_samples_per_second": 0.265,
1007
+ "train_steps_per_second": 0.004
1008
+ }
1009
+ ],
1010
+ "max_steps": 330,
1011
+ "num_train_epochs": 2,
1012
+ "total_flos": 4.634629372945367e+17,
1013
+ "trial_name": null,
1014
+ "trial_params": null
1015
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7590081405196835a42cca00f60db01b8ca901bae8a197f0becb2fcfa0999a94
3
+ size 4527
zero_to_fp32.py ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # This script extracts fp32 consolidated weights from a zero 2 and 3 DeepSpeed checkpoints. It gets
4
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
5
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
6
+ # application.
7
+ #
8
+ # example: python zero_to_fp32.py . pytorch_model.bin
9
+
10
+ import argparse
11
+ import torch
12
+ import glob
13
+ import math
14
+ import os
15
+ import re
16
+ from collections import OrderedDict
17
+
18
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
19
+ # DeepSpeed data structures it has to be available in the current python environment.
20
+ import deepspeed
21
+ from deepspeed.utils import logger
22
+ from deepspeed.checkpoint.constants import (DS_VERSION,
23
+ OPTIMIZER_STATE_DICT,
24
+ PARAM_SHAPES,
25
+ SINGLE_PARTITION_OF_FP32_GROUPS,
26
+ FP32_FLAT_GROUPS,
27
+ ZERO_STAGE,
28
+ PARTITION_COUNT,
29
+ PARAM_SHAPES,
30
+ BUFFER_NAMES)
31
+
32
+ debug = 0
33
+
34
+ # load to cpu
35
+ device = torch.device('cpu')
36
+
37
+
38
+ def atoi(text):
39
+ return int(text) if text.isdigit() else text
40
+
41
+
42
+ def natural_keys(text):
43
+ '''
44
+ alist.sort(key=natural_keys) sorts in human order
45
+ http://nedbatchelder.com/blog/200712/human_sorting.html
46
+ (See Toothy's implementation in the comments)
47
+ '''
48
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
49
+
50
+
51
+ def get_model_state_file(checkpoint_dir, zero_stage):
52
+ if not os.path.isdir(checkpoint_dir):
53
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
54
+
55
+ # there should be only one file
56
+ if zero_stage == 2:
57
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
58
+ elif zero_stage == 3:
59
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
60
+
61
+ if not os.path.exists(file):
62
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
63
+
64
+ return file
65
+
66
+
67
+ def get_optim_files(checkpoint_dir):
68
+ # XXX: need to test that this simple glob rule works for multi-node setup too
69
+ optim_files = sorted(glob.glob(os.path.join(checkpoint_dir,
70
+ "*_optim_states.pt")),
71
+ key=natural_keys)
72
+
73
+ if len(optim_files) == 0:
74
+ raise FileNotFoundError(
75
+ f"can't find '*_optim_states.pt' files in directory '{checkpoint_dir}'")
76
+
77
+ return optim_files
78
+
79
+
80
+ def parse_model_state(file):
81
+ state_dict = torch.load(file, map_location=device)
82
+
83
+ if BUFFER_NAMES not in state_dict:
84
+ raise ValueError(f"{file} is not a model state checkpoint")
85
+ buffer_names = state_dict[BUFFER_NAMES]
86
+ if debug:
87
+ print("Found buffers:", buffer_names)
88
+
89
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
90
+ buffers = {
91
+ k: v.float()
92
+ for k,
93
+ v in state_dict["module"].items() if k in buffer_names
94
+ }
95
+ param_shapes = state_dict[PARAM_SHAPES]
96
+
97
+ ds_version = state_dict.get(DS_VERSION, None)
98
+
99
+ return buffers, param_shapes, ds_version
100
+
101
+
102
+ def parse_optim_states(files, ds_checkpoint_dir):
103
+
104
+ total_files = len(files)
105
+ state_dicts = []
106
+ for f in files:
107
+ state_dicts.append(torch.load(f, map_location=device))
108
+
109
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
110
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
111
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
112
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
113
+
114
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
115
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
116
+ # use the max of the partition_count to get the dp world_size.
117
+
118
+ if type(world_size) is list:
119
+ world_size = max(world_size)
120
+
121
+ if world_size != total_files:
122
+ raise ValueError(
123
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
124
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
125
+ )
126
+
127
+ # the groups are named differently in each stage
128
+ if zero_stage == 2:
129
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
130
+ elif zero_stage == 3:
131
+ fp32_groups_key = FP32_FLAT_GROUPS
132
+ else:
133
+ raise ValueError(f"unknown zero stage {zero_stage}")
134
+
135
+ if zero_stage == 2:
136
+ fp32_flat_groups = [
137
+ state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key]
138
+ for i in range(len(state_dicts))
139
+ ]
140
+ elif zero_stage == 3:
141
+ # if there is more than one param group, there will be multiple flattened tensors - one
142
+ # flattened tensor per group - for simplicity merge them into a single tensor
143
+ #
144
+ # XXX: could make the script more memory efficient for when there are multiple groups - it
145
+ # will require matching the sub-lists of param_shapes for each param group flattened tensor
146
+
147
+ fp32_flat_groups = [
148
+ torch.cat(state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key],
149
+ 0) for i in range(len(state_dicts))
150
+ ]
151
+
152
+ return zero_stage, world_size, fp32_flat_groups
153
+
154
+
155
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir):
156
+ """
157
+ Returns fp32 state_dict reconstructed from ds checkpoint
158
+
159
+ Args:
160
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
161
+
162
+ """
163
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
164
+
165
+ optim_files = get_optim_files(ds_checkpoint_dir)
166
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
167
+ print(
168
+ f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
169
+
170
+ model_file = get_model_state_file(ds_checkpoint_dir, zero_stage)
171
+ buffers, param_shapes, ds_version = parse_model_state(model_file)
172
+ print(f'Parsing checkpoint created by deepspeed=={ds_version}')
173
+
174
+ if zero_stage == 2:
175
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size,
176
+ param_shapes,
177
+ fp32_flat_groups,
178
+ buffers)
179
+ elif zero_stage == 3:
180
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size,
181
+ param_shapes,
182
+ fp32_flat_groups,
183
+ buffers)
184
+
185
+
186
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size,
187
+ param_shapes,
188
+ fp32_flat_groups,
189
+ buffers):
190
+
191
+ # Reconstruction protocol:
192
+ #
193
+ # XXX: document this
194
+
195
+ if debug:
196
+ for i in range(world_size):
197
+ for j in range(len(fp32_flat_groups[0])):
198
+ print(
199
+ f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
200
+
201
+ # XXX: memory usage doubles here (zero2)
202
+ num_param_groups = len(fp32_flat_groups[0])
203
+ merged_single_partition_of_fp32_groups = []
204
+ for i in range(num_param_groups):
205
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
206
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
207
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
208
+ avail_numel = sum([
209
+ full_single_fp32_vector.numel()
210
+ for full_single_fp32_vector in merged_single_partition_of_fp32_groups
211
+ ])
212
+
213
+ if debug:
214
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
215
+ wanted_numel = sum(
216
+ [sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
217
+ # not asserting if there is a mismatch due to possible padding
218
+ print(f"Have {avail_numel} numels to process.")
219
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
220
+
221
+ state_dict = OrderedDict()
222
+
223
+ # buffers
224
+ state_dict.update(buffers)
225
+ if debug:
226
+ print(f"added {len(buffers)} buffers")
227
+
228
+ # params
229
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
230
+ # out-of-core computing solution
231
+ total_numel = 0
232
+ total_params = 0
233
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
234
+ offset = 0
235
+ avail_numel = full_single_fp32_vector.numel()
236
+ for name, shape in shapes.items():
237
+
238
+ unpartitioned_numel = shape.numel()
239
+ total_numel += unpartitioned_numel
240
+ total_params += 1
241
+
242
+ if debug:
243
+ print(
244
+ f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} "
245
+ )
246
+ state_dict[name] = full_single_fp32_vector.narrow(
247
+ 0,
248
+ offset,
249
+ unpartitioned_numel).view(shape)
250
+ offset += unpartitioned_numel
251
+
252
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
253
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
254
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
255
+ # live optimizer object, so we are checking that the numbers are within the right range
256
+ align_to = 2 * world_size
257
+
258
+ def zero2_align(x):
259
+ return align_to * math.ceil(x / align_to)
260
+
261
+ if debug:
262
+ print(f"original offset={offset}, avail_numel={avail_numel}")
263
+
264
+ offset = zero2_align(offset)
265
+ avail_numel = zero2_align(avail_numel)
266
+
267
+ if debug:
268
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
269
+
270
+ # Sanity check
271
+ if offset != avail_numel:
272
+ raise ValueError(
273
+ f"consumed {offset} numels out of {avail_numel} - something is wrong")
274
+
275
+ print(
276
+ f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements"
277
+ )
278
+
279
+ return state_dict
280
+
281
+
282
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
283
+ remainder = unpartitioned_numel % world_size
284
+ padding_numel = (world_size - remainder) if remainder else 0
285
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
286
+ return partitioned_numel, padding_numel
287
+
288
+
289
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size,
290
+ param_shapes,
291
+ fp32_flat_groups,
292
+ buffers):
293
+
294
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
295
+ # param, re-consolidating each param, while dealing with padding if any
296
+
297
+ avail_numel = fp32_flat_groups[0].numel() * world_size
298
+ # merge list of dicts, preserving order
299
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
300
+
301
+ if debug:
302
+ for i in range(world_size):
303
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
304
+
305
+ wanted_params = len(param_shapes)
306
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
307
+ # not asserting if there is a mismatch due to possible padding
308
+ print(f"Have {avail_numel} numels to process.")
309
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
310
+
311
+ state_dict = OrderedDict()
312
+
313
+ # buffers
314
+ state_dict.update(buffers)
315
+ if debug:
316
+ print(f"added {len(buffers)} buffers")
317
+
318
+ # params
319
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
320
+ # out-of-core computing solution
321
+ offset = 0
322
+ total_numel = 0
323
+ total_params = 0
324
+ for name, shape in param_shapes.items():
325
+
326
+ unpartitioned_numel = shape.numel()
327
+ total_numel += unpartitioned_numel
328
+ total_params += 1
329
+
330
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
331
+
332
+ if debug:
333
+ print(
334
+ f"{total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
335
+ )
336
+
337
+ # XXX: memory usage doubles here
338
+ state_dict[name] = torch.cat(
339
+ tuple(fp32_flat_groups[i].narrow(0,
340
+ offset,
341
+ partitioned_numel)
342
+ for i in range(world_size)),
343
+ 0).narrow(0,
344
+ 0,
345
+ unpartitioned_numel).view(shape)
346
+ offset += partitioned_numel
347
+
348
+ offset *= world_size
349
+
350
+ # Sanity check
351
+ if offset != avail_numel:
352
+ raise ValueError(
353
+ f"consumed {offset} numels out of {avail_numel} - something is wrong")
354
+
355
+ print(
356
+ f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements"
357
+ )
358
+
359
+ return state_dict
360
+
361
+
362
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag=None):
363
+ """
364
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
365
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
366
+ via a model hub.
367
+
368
+ Args:
369
+ - ``checkpoint_dir``: path to the desired checkpoint folder
370
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
371
+
372
+ Returns:
373
+ - pytorch ``state_dict``
374
+
375
+ Note: this approach may not work if your application doesn't have sufficient free CPU memory and
376
+ you may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
377
+ the checkpoint.
378
+
379
+ A typical usage might be ::
380
+
381
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
382
+ # do the training and checkpoint saving
383
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
384
+ model = model.cpu() # move to cpu
385
+ model.load_state_dict(state_dict)
386
+ # submit to model hub or save the model to share with others
387
+
388
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
389
+ application. i.e. you will need to re-initialize the deepspeed engine, since
390
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
391
+
392
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
393
+
394
+ """
395
+ if tag is None:
396
+ latest_path = os.path.join(checkpoint_dir, 'latest')
397
+ if os.path.isfile(latest_path):
398
+ with open(latest_path, 'r') as fd:
399
+ tag = fd.read().strip()
400
+ else:
401
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
402
+
403
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
404
+
405
+ if not os.path.isdir(ds_checkpoint_dir):
406
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
407
+
408
+ return _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir)
409
+
410
+
411
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir, output_file, tag=None):
412
+ """
413
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
414
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
415
+
416
+ Args:
417
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
418
+ - ``output_file``: path to the pytorch fp32 state_dict output file (e.g. path/pytorch_model.bin)
419
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
420
+ """
421
+
422
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
423
+ print(f"Saving fp32 state dict to {output_file}")
424
+ torch.save(state_dict, output_file)
425
+
426
+
427
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
428
+ """
429
+ 1. Put the provided model to cpu
430
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
431
+ 3. Load it into the provided model
432
+
433
+ Args:
434
+ - ``model``: the model object to update
435
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
436
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
437
+
438
+ Returns:
439
+ - ``model`: modified model
440
+
441
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
442
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
443
+ conveniently placed for you in the checkpoint folder.
444
+
445
+ A typical usage might be ::
446
+
447
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
448
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
449
+ # submit to model hub or save the model to share with others
450
+
451
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
452
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
453
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
454
+
455
+ """
456
+ logger.info(f"Extracting fp32 weights")
457
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
458
+
459
+ logger.info(f"Overwriting model with fp32 weights")
460
+ model = model.cpu()
461
+ model.load_state_dict(state_dict, strict=False)
462
+
463
+ return model
464
+
465
+
466
+ if __name__ == "__main__":
467
+
468
+ parser = argparse.ArgumentParser()
469
+ parser.add_argument(
470
+ "checkpoint_dir",
471
+ type=str,
472
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
473
+ parser.add_argument(
474
+ "output_file",
475
+ type=str,
476
+ help=
477
+ "path to the pytorch fp32 state_dict output file (e.g. path/checkpoint-12/pytorch_model.bin)"
478
+ )
479
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
480
+ args = parser.parse_args()
481
+
482
+ debug = args.debug
483
+
484
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir, args.output_file)