Stancld commited on
Commit
ec07e8b
1 Parent(s): d4858c8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +417 -0
README.md ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ datasets:
4
+ - ccdv/pubmed-summarization
5
+
6
+ license: apache-2.0
7
+ ---
8
+
9
+ ## Introduction
10
+
11
+ [Google's LongT5: Efficient Text-To-Text Transformer for Long Sequences](https://arxiv.org/pdf/2112.07916.pdf) introduced as an extension of a successful [T5 model](https://arxiv.org/pdf/1910.10683.pdf).
12
+
13
+ This is an unofficial *longt5-large-16384-pubmed-3k_steps* checkpoint. I.e., this is a large configuration of the LongT5 model with a `transient-global` attention fine-tuned on [pubmed summarization dataset](https://huggingface.co/datasets/ccdv/pubmed-summarization) for 3,000 training steps.
14
+
15
+ ## Results and Fine-tuning Details
16
+
17
+ The fine-tuned model achieves the following results on the evaluation set using `beam_search=3` and without any specific calibration of generation parameters:
18
+
19
+ | Metric | Score |
20
+ | --- | --- |
21
+ | Rouge-1 | 47.44 |
22
+ | Rouge-2 | 22.68 |
23
+ | Rouge-L | 29.83 |
24
+ | Rouge-Lsum | 43.13 |
25
+
26
+ The full training hyper-parameters and logs can be found via the following [W&B run](https://wandb.ai/stancld/LongT5/runs/1lwncl8a?workspace=user-stancld). The model was trained using the [HuggingFace's trainer](https://github.com/huggingface/transformers/blob/main/src/transformers/trainer_seq2seq.py).
27
+
28
+ The only specific adjustment, I made for the training, was dropping very short sequences (less than 16 tokens) as this sequences do not contribute to gradient creation in the *transient-global* attention, which resulted in training crashes when DDP used.
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ LONG_ARTICLE = """"anxiety affects quality of life in those living
34
+ with parkinson 's disease ( pd ) more so than
35
+ overall cognitive status , motor deficits , apathy
36
+ , and depression [ 13 ] . although anxiety and
37
+ depression are often related and coexist in pd
38
+ patients , recent research suggests that anxiety
39
+ rather than depression is the most prominent and
40
+ prevalent mood disorder in pd [ 5 , 6 ] . yet ,
41
+ our current understanding of anxiety and its
42
+ impact on cognition in pd , as well as its neural
43
+ basis and best treatment practices , remains
44
+ meager and lags far behind that of depression .
45
+ overall , neuropsychiatric symptoms in pd have
46
+ been shown to be negatively associated with
47
+ cognitive performance . for example , higher
48
+ depression scores have been correlated with lower
49
+ scores on the mini - mental state exam ( mmse ) [
50
+ 8 , 9 ] as well as tests of memory and executive
51
+ functions ( e.g. , attention ) [ 1014 ] . likewise
52
+ , apathy and anhedonia in pd patients have been
53
+ associated with executive dysfunction [ 10 , 1523
54
+ ] . however , few studies have specifically
55
+ investigated the relationship between anxiety and
56
+ cognition in pd . one study showed a strong
57
+ negative relationship between anxiety ( both state
58
+ and trait ) and overall cognitive performance (
59
+ measured by the total of the repeatable battery
60
+ for the assessment of neuropsychological status
61
+ index ) within a sample of 27 pd patients .
62
+ furthermore , trait anxiety was negatively
63
+ associated with each of the cognitive domains
64
+ assessed by the rbans ( i.e. , immediate memory ,
65
+ visuospatial construction , language , attention ,
66
+ and delayed memory ) . two further studies have
67
+ examined whether anxiety differentially affects
68
+ cognition in patients with left - sided dominant
69
+ pd ( lpd ) versus right - sided dominant pd ( rpd
70
+ ) ; however , their findings were inconsistent .
71
+ the first study found that working memory
72
+ performance was worse in lpd patients with anxiety
73
+ compared to rpd patients with anxiety , whereas
74
+ the second study reported that , in lpd , apathy
75
+ but not anxiety was associated with performance on
76
+ nonverbally mediated executive functions and
77
+ visuospatial tasks ( e.g. , tmt - b , wms - iii
78
+ spatial span ) , while in rpd , anxiety but not
79
+ apathy significantly correlated with performance
80
+ on verbally mediated tasks ( e.g. , clock reading
81
+ test and boston naming test ) . furthermore ,
82
+ anxiety was significantly correlated with
83
+ neuropsychological measures of attention and
84
+ executive and visuospatial functions . taken
85
+ together , it is evident that there are limited
86
+ and inconsistent findings describing the
87
+ relationship between anxiety and cognition in pd
88
+ and more specifically how anxiety might influence
89
+ particular domains of cognition such as attention
90
+ and memory and executive functioning . it is also
91
+ striking that , to date , no study has examined
92
+ the influence of anxiety on cognition in pd by
93
+ directly comparing groups of pd patients with and
94
+ without anxiety while excluding depression . given
95
+ that research on healthy young adults suggests
96
+ that anxiety reduces processing capacity and
97
+ impairs processing efficiency , especially in the
98
+ central executive and attentional systems of
99
+ working memory [ 26 , 27 ] , we hypothesized that
100
+ pd patients with anxiety would show impairments in
101
+ attentional set - shifting and working memory
102
+ compared to pd patients without anxiety .
103
+ furthermore , since previous work , albeit limited
104
+ , has focused on the influence of symptom
105
+ laterality on anxiety and cognition , we also
106
+ explored this relationship . seventeen pd patients
107
+ with anxiety and thirty - three pd patients
108
+ without anxiety were included in this study ( see
109
+ table 1 ) . the cross - sectional data from these
110
+ participants was taken from a patient database
111
+ that has been compiled over the past 8 years (
112
+ since 2008 ) at the parkinson 's disease research
113
+ clinic at the brain and mind centre , university
114
+ of sydney . inclusion criteria involved a
115
+ diagnosis of idiopathic pd according to the united
116
+ kingdom parkinson 's disease society brain bank
117
+ criteria and were confirmed by a neurologist (
118
+ sjgl ) . patients also had to have an adequate
119
+ proficiency in english and have completed a full
120
+ neuropsychological assessment . ten patients in
121
+ this study ( 5 pd with anxiety ; 5 pd without
122
+ anxiety ) were taking psychotropic drugs ( i.e. ,
123
+ benzodiazepine or selective serotonin reuptake
124
+ inhibitor ) . patients were also excluded if they
125
+ had other neurological disorders , psychiatric
126
+ disorders other than affective disorders ( such as
127
+ anxiety ) , or if they reported a score greater
128
+ than six on the depression subscale of the
129
+ hospital anxiety and depression scale ( hads ) .
130
+ thus , all participants who scored within a
131
+ depressed ( hads - d > 6 ) range were excluded
132
+ from this study , in attempt to examine a refined
133
+ sample of pd patients with and without anxiety in
134
+ order to determine the independent effect of
135
+ anxiety on cognition . this research was approved
136
+ by the human research ethics committee of the
137
+ university of sydney , and written informed
138
+ consent was obtained from all participants . self
139
+ - reported hads was used to assess anxiety in pd
140
+ and has been previously shown to be a useful
141
+ measure of clinical anxiety in pd . a cut - off
142
+ score of > 8 on the anxiety subscale of the hads (
143
+ hads - a ) was used to identify pd cases with
144
+ anxiety ( pda+ ) , while a cut - off score of < 6
145
+ on the hads - a was used to identify pd cases
146
+ without anxiety ( pda ) . this criterion was more
147
+ stringent than usual ( > 7 cut - off score ) , in
148
+ effort to create distinct patient groups . the
149
+ neurological evaluation rated participants
150
+ according to hoehn and yahr ( h&y ) stages and
151
+ assessed their motor symptoms using part iii of
152
+ the revised mds task force unified parkinson 's
153
+ disease rating scale ( updrs ) . in a similar way
154
+ this was determined by calculating a total left
155
+ and right score from rigidity items 3035 ,
156
+ voluntary movement items 3643 , and tremor items
157
+ 5057 from the mds - updrs part iii ( see table 1 )
158
+ . processing speed was assessed using the trail
159
+ making test , part a ( tmt - a , z - score ) .
160
+ attentional set - shifting was measured using the
161
+ trail making test , part b ( tmt - b , z - score )
162
+ . working memory was assessed using the digit span
163
+ forward and backward subtest of the wechsler
164
+ memory scale - iii ( raw scores ) . language was
165
+ assessed with semantic and phonemic verbal fluency
166
+ via the controlled oral word associated test (
167
+ cowat animals and letters , z - score ) . the
168
+ ability to retain learned verbal memory was
169
+ assessed using the logical memory subtest from the
170
+ wechsler memory scale - iii ( lm - i z - score ,
171
+ lm - ii z - score , % lm retention z - score ) .
172
+ the mini - mental state examination ( mmse )
173
+ demographic , clinical , and neuropsychological
174
+ variables were compared between the two groups
175
+ with the independent t - test or mann whitney u
176
+ test , depending on whether the variable met
177
+ parametric assumptions . chi - square tests were
178
+ used to examine gender and symptom laterality
179
+ differences between groups . all analyses employed
180
+ an alpha level of p < 0.05 and were two - tailed .
181
+ spearman correlations were performed separately in
182
+ each group to examine associations between anxiety
183
+ and/or depression ratings and cognitive functions
184
+ . as expected , the pda+ group reported
185
+ significant greater levels of anxiety on the hads
186
+ - a ( u = 0 , p < 0.001 ) and higher total score
187
+ on the hads ( u = 1 , p < 0.001 ) compared to the
188
+ pda group ( table 1 ) . groups were matched in age
189
+ ( t(48 ) = 1.31 , p = 0.20 ) , disease duration (
190
+ u = 259 , p = 0.66 ) , updrs - iii score ( u =
191
+ 250.5 , p = 0.65 ) , h&y ( u = 245 , p = 0.43 ) ,
192
+ ledd ( u = 159.5 , p = 0.80 ) , and depression (
193
+ hads - d ) ( u = 190.5 , p = 0.06 ) . additionally
194
+ , all groups were matched in the distribution of
195
+ gender ( = 0.098 , p = 0.75 ) and side - affected
196
+ ( = 0.765 , p = 0.38 ) . there were no group
197
+ differences for tmt - a performance ( u = 256 , p
198
+ = 0.62 ) ( table 2 ) ; however , the pda+ group
199
+ had worse performance on the trail making test
200
+ part b ( t(46 ) = 2.03 , p = 0.048 ) compared to
201
+ the pda group ( figure 1 ) . the pda+ group also
202
+ demonstrated significantly worse performance on
203
+ the digit span forward subtest ( t(48 ) = 2.22 , p
204
+ = 0.031 ) and backward subtest ( u = 190.5 , p =
205
+ 0.016 ) compared to the pda group ( figures 2(a )
206
+ and 2(b ) ) . neither semantic verbal fluency (
207
+ t(47 ) = 0.70 , p = 0.49 ) nor phonemic verbal
208
+ fluency ( t(47 ) = 0.39 , p = 0.70 ) differed
209
+ between groups . logical memory i immediate recall
210
+ test ( u = 176 , p = 0.059 ) showed a trend that
211
+ the pda+ group had worse new verbal learning and
212
+ immediate recall abilities than the pda group .
213
+ however , logical memory ii test performance ( u =
214
+ 219 , p = 0.204 ) and logical memory % retention (
215
+ u = 242.5 , p = 0.434 ) did not differ between
216
+ groups . there were also no differences between
217
+ groups in global cognition ( mmse ) ( u = 222.5 ,
218
+ p = 0.23 ) . participants were split into lpd and
219
+ rpd , and then further group differences were
220
+ examined between pda+ and pda. importantly , the
221
+ groups remained matched in age , disease duration
222
+ , updrs - iii , dde , h&y stage , and depression
223
+ but remained significantly different on self -
224
+ reported anxiety . lpda+ demonstrated worse
225
+ performance on the digit span forward test ( t(19
226
+ ) = 2.29 , p = 0.033 ) compared to lpda , whereas
227
+ rpda+ demonstrated worse performance on the digit
228
+ span backward test ( u = 36.5 , p = 0.006 ) , lm -
229
+ i immediate recall ( u = 37.5 , p = 0.008 ) , and
230
+ lm - ii ( u = 45.0 , p = 0.021 ) but not lm %
231
+ retention ( u = 75.5 , p = 0.39 ) compared to
232
+ rpda. this study is the first to directly compare
233
+ cognition between pd patients with and without
234
+ anxiety . the findings confirmed our hypothesis
235
+ that anxiety negatively influences attentional set
236
+ - shifting and working memory in pd . more
237
+ specifically , we found that pd patients with
238
+ anxiety were more impaired on the trail making
239
+ test part b which assessed attentional set -
240
+ shifting , on both digit span tests which assessed
241
+ working memory and attention , and to a lesser
242
+ extent on the logical memory test which assessed
243
+ memory and new verbal learning compared to pd
244
+ patients without anxiety . taken together , these
245
+ findings suggest that anxiety in pd may reduce
246
+ processing capacity and impair processing
247
+ efficiency , especially in the central executive
248
+ and attentional systems of working memory in a
249
+ similar way as seen in young healthy adults [ 26 ,
250
+ 27 ] . although the neurobiology of anxiety in pd
251
+ remains unknown , many researchers have postulated
252
+ that anxiety disorders are related to
253
+ neurochemical changes that occur during the early
254
+ , premotor stages of pd - related degeneration [
255
+ 37 , 38 ] such as nigrostriatal dopamine depletion
256
+ , as well as cell loss within serotonergic and
257
+ noradrenergic brainstem nuclei ( i.e. , raphe
258
+ nuclei and locus coeruleus , resp . , which
259
+ provide massive inputs to corticolimbic regions )
260
+ . over time , chronic dysregulation of
261
+ adrenocortical and catecholamine functions can
262
+ lead to hippocampal damage as well as
263
+ dysfunctional prefrontal neural circuitries [ 39 ,
264
+ 40 ] , which play a key role in memory and
265
+ attention . recent functional neuroimaging work
266
+ has suggested that enhanced hippocampal activation
267
+ during executive functioning and working memory
268
+ tasks may represent compensatory processes for
269
+ impaired frontostriatal functions in pd patients
270
+ compared to controls . therefore , chronic stress
271
+ from anxiety , for example , may disrupt
272
+ compensatory processes in pd patients and explain
273
+ the cognitive impairments specifically in working
274
+ memory and attention seen in pd patients with
275
+ anxiety . it has also been suggested that
276
+ hyperactivation within the putamen may reflect a
277
+ compensatory striatal mechanism to maintain normal
278
+ working memory performance in pd patients ;
279
+ however , losing this compensatory activation has
280
+ been shown to contribute to poor working memory
281
+ performance . anxiety in mild pd has been linked
282
+ to reduced putamen dopamine uptake which becomes
283
+ more extensive as the disease progresses . this
284
+ further supports the notion that anxiety may
285
+ disrupt compensatory striatal mechanisms as well ,
286
+ providing another possible explanation for the
287
+ cognitive impairments observed in pd patients with
288
+ anxiety in this study . noradrenergic and
289
+ serotonergic systems should also be considered
290
+ when trying to explain the mechanisms by which
291
+ anxiety may influence cognition in pd . although
292
+ these neurotransmitter systems are relatively
293
+ understudied in pd cognition , treating the
294
+ noradrenergic and serotonergic systems has shown
295
+ beneficial effects on cognition in pd . selective
296
+ serotonin reuptake inhibitor , citalopram , was
297
+ shown to improve response inhibition deficits in
298
+ pd , while noradrenaline reuptake blocker ,
299
+ atomoxetine , has been recently reported to have
300
+ promising effects on cognition in pd [ 45 , 46 ] .
301
+ overall , very few neuroimaging studies have been
302
+ conducted in pd in order to understand the neural
303
+ correlates of pd anxiety and its underlying neural
304
+ pathology . future research should focus on
305
+ relating anatomical changes and neurochemical
306
+ changes to neural activation in order to gain a
307
+ clearer understanding on how these pathologies
308
+ affect anxiety in pd . to further understand how
309
+ anxiety and cognitive dysfunction are related ,
310
+ future research should focus on using advanced
311
+ structural and function imaging techniques to
312
+ explain both cognitive and neural breakdowns that
313
+ are associated with anxiety in pd patients .
314
+ research has indicated that those with amnestic
315
+ mild cognitive impairment who have more
316
+ neuropsychiatric symptoms have a greater risk of
317
+ developing dementia compared to those with fewer
318
+ neuropsychiatric symptoms . future studies should
319
+ also examine whether treating neuropsychiatric
320
+ symptoms might impact the progression of cognitive
321
+ decline and improve cognitive impairments in pd
322
+ patients . previous studies have used pd symptom
323
+ laterality as a window to infer asymmetrical
324
+ dysfunction of neural circuits . for example , lpd
325
+ patients have greater inferred right hemisphere
326
+ pathology , whereas rpd patients have greater
327
+ inferred left hemisphere pathology . thus ,
328
+ cognitive domains predominantly subserved by the
329
+ left hemisphere ( e.g. , verbally mediated tasks
330
+ of executive function and verbal memory ) might be
331
+ hypothesized to be more affected in rpd than lpd ;
332
+ however , this remains controversial . it has also
333
+ been suggested that since anxiety is a common
334
+ feature of left hemisphere involvement [ 48 , 49 ]
335
+ , cognitive domains subserved by the left
336
+ hemisphere may also be more strongly related to
337
+ anxiety . results from this study showed selective
338
+ verbal memory deficits in rpd patients with
339
+ anxiety compared to rpd without anxiety , whereas
340
+ lpd patients with anxiety had greater attentional
341
+ / working memory deficits compared to lpd without
342
+ anxiety . although these results align with
343
+ previous research , interpretations of these
344
+ findings should be made with caution due to the
345
+ small sample size in the lpd comparison
346
+ specifically . recent work has suggested that the
347
+ hads questionnaire may underestimate the burden of
348
+ anxiety related symptomology and therefore be a
349
+ less sensitive measure of anxiety in pd [ 30 , 50
350
+ ] . in addition , our small sample size also
351
+ limited the statistical power for detecting
352
+ significant findings . based on these limitations
353
+ , our findings are likely conservative and
354
+ underrepresent the true impact anxiety has on
355
+ cognition in pd . additionally , the current study
356
+ employed a very brief neuropsychological
357
+ assessment including one or two tests for each
358
+ cognitive domain . future studies are encouraged
359
+ to collect a more complex and comprehensive
360
+ battery from a larger sample of pd participants in
361
+ order to better understand the role anxiety plays
362
+ on cognition in pd . another limitation of this
363
+ study was the absence of diagnostic interviews to
364
+ characterize participants ' psychiatric symptoms
365
+ and specify the type of anxiety disorders included
366
+ in this study . future studies should perform
367
+ diagnostic interviews with participants ( e.g. ,
368
+ using dsm - v criteria ) rather than relying on
369
+ self - reported measures to group participants ,
370
+ in order to better understand whether the type of
371
+ anxiety disorder ( e.g. , social anxiety , phobias
372
+ , panic disorders , and generalized anxiety )
373
+ influences cognitive performance differently in pd
374
+ . one advantage the hads questionnaire provided
375
+ over other anxiety scales was that it assessed
376
+ both anxiety and depression simultaneously and
377
+ allowed us to control for coexisting depression .
378
+ although there was a trend that the pda+ group
379
+ self - reported higher levels of depression than
380
+ the pda group , all participants included in the
381
+ study scored < 6 on the depression subscale of the
382
+ hads . controlling for depression while assessing
383
+ anxiety has been identified as a key shortcoming
384
+ in the majority of recent work . considering many
385
+ previous studies have investigated the influence
386
+ of depression on cognition in pd without
387
+ accounting for the presence of anxiety and the
388
+ inconsistent findings reported to date , we
389
+ recommend that future research should try to
390
+ disentangle the influence of anxiety versus
391
+ depression on cognitive impairments in pd .
392
+ considering the growing number of clinical trials
393
+ for treating depression , there are few if any for
394
+ the treatment of anxiety in pd . anxiety is a key
395
+ contributor to decreased quality of life in pd and
396
+ greatly requires better treatment options .
397
+ moreover , anxiety has been suggested to play a
398
+ key role in freezing of gait ( fog ) , which is
399
+ also related to attentional set - shifting [ 52 ,
400
+ 53 ] . future research should examine the link
401
+ between anxiety , set - shifting , and fog , in
402
+ order to determine whether treating anxiety might
403
+ be a potential therapy for improving fog ."""
404
+
405
+ import torch
406
+ from transformers import LongT5ForConditionalGeneration, AutoTokenizer
407
+
408
+ tokenizer = LongT5ForConditionalGeneration.from_pretrained("Stancld/longt5-tglobal-large-16384-pubmed-3k_steps")
409
+
410
+ input_ids = tokenizer(LONG_ARTICLE, return_tensors="pt").input_ids.to("cuda")
411
+
412
+ model = LEDForConditionalGeneration.from_pretrained("Stancld/longt5-tglobal-large-16384-pubmed-3k_steps", return_dict_in_generate=True).to("cuda")
413
+
414
+ sequences = model.generate(input_ids, global_attention_mask=global_attention_mask).sequences
415
+
416
+ summary = tokenizer.batch_decode(sequences)
417
+ ```