Spaces:
Runtime error
Runtime error
import gradio as gr | |
from gradio.components import Textbox | |
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline | |
model_name = "deepset/roberta-base-squad2" | |
nlp = pipeline("question-answering", model=model_name, tokenizer=model_name) | |
def predict(abstract, question, ground_truth): | |
res = nlp({"question": question, "context": abstract}) | |
return res["answer"], res["score"] | |
title = "Question Answering on Research Abstracts" | |
description = "Instructions: Enter a research abstract and a related question in the respective text boxes, then click [Submit] to get the model's answer and confidence score. Alternatively, you can select examples at the bottom, then click [Submit]." | |
examples = [ | |
["INTRODUCTION: in Burkina Faso, the tuberculosis (TB) treatment failure rate increased from 2.5% in 2000 to 8.3% in 2006. The risk factors for TB treatment failure in the country are not well known. The study aims to determine the risk factors for treatment failure among pulmonary tuberculosis patients in four health region of Burkina Faso and to recommend appropriate interventions.", | |
"What disease or condition is the focus of this article?", | |
"Tuberculosis"], | |
["In the title compound, C12H10ClNO3, the asymmetric unit comprises two independent molecules, and the dihedral angle between the least-square planes of the quinoline ring systems of these molecules is 73.30 (5)°. In the crystal, N—H...O hydrogen bonds between the independent molecules lead to supramolecular layers parallel to (-1-10); both N—H H atoms are bifurcated.", | |
"Is this a psychology article?", | |
"No"], | |
["It is widely acknowledged that libraries play a positive and important role in the lives of prisoners, just as they do with other people. They do not only provide resources to support various educational, recreational and welfare programs, but they also create opportunities for prisoners to acquire new skills, skills that they may need once they leave prison. In addition, prison libraries also help address various psychological issues, attitude problems, as well as other difficulties in coping with prison life. According to the Ministry of Law and Human Rights of Indonesia, as of 2013, there are 4,622 children in 16 different prisons in Indonesia. Such statistics show that there is a great need for well-resourced and well-staffed libraries inside these prisons in order to support the educational, recreational, and psychological needs of imprisoned children. It is evident that the existence of prison libraries and its library collections, facilities, as well as other services could serve as effective rehabilitation for the prisoners and the detainees – to help them develop awareness of their own actions, as well as associated risks and consequences. The purpose of this study is to examine the practical, social, recreational, educational, psychological, and spiritual needs of detained juvenile delinquents in regards to using the collections, facilities and services at the Tangerang Juvenile Detention Center Library and the Salemba Detention Center Library. This study is based on informational interviews conducted with the Head Librarians at the Tangerang Juvenile Detention Center Library (JDC) and the Salemba Detention Center Library. During these interviews, various problems and challenges related to ethics, professionalism, and other professional issues associated to working as a prison librarian, were discussed. Other issues related to staffing, organizational structure, facilities and the resource situation of the Tangerang Juvenile Detention Center Library and the Salemba Detention Center Library were also addressed.", | |
"What data collection method was used in this study?", | |
"Interviews"], | |
["IntroductionPhysical activity (PA) is important for healthy ageing. Better insight into objectively measured PA levels in older adults is needed, since most previous studies employed self-report measures for PA assessment, which are associated with overestimation of PA.AimThis study aimed to provide insight in objectively measured indoor and outdoor PA of older adults, and in PA differences by frailty levels.MethodsData were collected among non-frail (N = 74) and frail (N = 10) subjects, aged 65 to 89 years. PA, measured for seven days with accelerometers and GPS-devices, was categorized into three levels of intensity (sedentary, light, and moderate-to-vigorous PA).ResultsOlder adults spent most time in sedentary and light PA. Subjects spent 84.7%, 15.1% and 0.2% per day in sedentary, light and moderate-to-vigorous PA respectively. On average, older adults spent 9.8 (SD 23.7) minutes per week in moderate-to-vigorous activity, and 747.0 (SD 389.6) minutes per week in light activity. None of the subjects met the WHO recommendations of 150 weekly minutes of moderate-to-vigorous PA. Age-, sex- and health status-adjusted results revealed no differences in PA between non-frail and frail older adults. Subjects spent significantly more sedentary time at home, than not at home. Non-frail subjects spent significantly more time not at home during moderate-to-vigorous activities, than at home.ConclusionsObjective assessment of PA in older adults revealed that most PA was of light intensity, and time spent in moderate-to-vigorous PA was very low. None of the older adults met the World Health Organization recommendations for PA. These levels of MVPA are much lower than generally reported based on self-reported PA. Future studies should employ objective methods, and age specific thresholds for healthy PA levels in older adults are needed. These results emphasize the need for effective strategies for healthy PA levels for the growing proportion of older adults.", | |
"Does this study include adolescent participants?", | |
"No"], | |
["It is unclear what the contribution of prenatal versus childhood development is for adult cognitive and sensory function and age-related decline in function. We examined hearing, vision and cognitive function in adulthood according to self-reported birth weight (an index of prenatal development) and adult height (an index of early childhood development). Subsets (N = 37,505 to 433,390) of the UK Biobank resource were analysed according to visual and hearing acuity, reaction time and fluid IQ. Sensory and cognitive performance was reassessed after ~4 years (N = 2,438 to 17,659). In statistical modelling including age, sex, socioeconomic status, educational level, smoking, maternal smoking and comorbid disease, adult height was positively associated with sensory and cognitive function (partial correlations; pr 0.05 to 0.12, p < 0.001). Within the normal range of birth weight (10th to 90th percentile), there was a positive association between birth weight and sensory and cognitive function (pr 0.06 to 0.14, p < 0.001). Neither adult height nor birth weight was associated with change in sensory or cognitive function. These results suggest that adverse prenatal and childhood experiences are a risk for poorer sensory and cognitive function and earlier development of sensory and cognitive impairment in adulthood. This finding could have significant implications for preventing sensory and cognitive impairment in older age.", | |
"Does this study include correlations?", | |
"Yes"], | |
] | |
demo = gr.Interface( | |
predict, | |
inputs=[ | |
Textbox(label="Abstract",lines = 8), | |
Textbox(label="Question"), | |
Textbox(label="Ground Truth"), | |
], | |
outputs=[Textbox(label="Answer"), Textbox(label="Score")], | |
title=title, | |
description=description, | |
examples=examples, | |
interpretation="default", | |
theme="freddyaboulton/dracula_revamped", | |
) | |
demo.launch() | |