Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3# load model
4model_name = 'fuhsiao/BioBART-PMC-EXT-TB-Section'
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7
8# example
9text = """ Suicide is a major challenge for the public health system, accounting for over 800,000 deaths each year worldwide.
10Prisoners constitute such a risk group. Prisoners represent one extreme on the spectrum of delinquency, and are exposed to a particularly high risk of suicide, with suicide rates about 5 to 8 times higher than in the general population.
11First, prisoners show behaviour and personality traits associated with suicide, even before imprisonment; these risk factors are imported into the prison environment.
12The first weeks of imprisonment are particularly important for suicide prevention, since a considerable proportion of suicides in prisons occur during this period.
13Only isolated studies have examined whether these factors are related to early suicide in prison, and these show a connection between drug addiction and early prison suicide.
14To the best of our knowledge, this is the first study that uses a case-control design to investigate whether suicides in the first weeks of imprisonment differ from late prison suicide events in terms of their risk and resilience factors.
15Previous prison sentences are negatively associated with early suicides, as this knowledge of the prison environment facilitates the process of re-adaptation.
16Offences that are closely associated with drug use, such as theft, or offences against the narcotics law, are associated with early suicide events.
17Evidence of mental illness or drug withdrawal is associated with early prison suicides. Assignment of a psychiatrist is protective against suicides during the first days of detention.
18Risk factors change with increasing prison time. """
19
20inputs = tokenizer(text, truncation=True, return_tensors='pt').input_ids
21outputs = model.generate(inputs)
22generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)