atrytone's picture
Update app.py
f56c933
raw
history blame
2.16 kB
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification
import gradio as gr
model_name = 'biodatlab/score-claim-identification'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
def inference(abstract):
claims = []
lines = abstract.split('. ')
inputs = tokenizer(lines,return_tensors='pt',truncation=True,padding="longest")
output = model(**inputs).logits
for (i,out) in enumerate(output):
pred = out.argmax().item()
if pred:
claims.append(lines[i])
if claims:
return '.\n'.join(claims)
return 'No claims were made here'
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# Claim Identification")
gr.Markdown("This demo finds claims made by an abstract.")
abst = gr.Textbox(label="Abstract")
greet_btn = gr.Button("Find Claims")
output = gr.Textbox(label="Detected Claims")
greet_btn.click(fn=inference, inputs=abst, outputs=output, api_name="inference")
examples = gr.Examples(examples=["This study adopted a person (actor) by partner perspective to examine how actor personality traits, partner personality traits, and specific actor by partner personality trait interactions predict actor's depressive symptoms across the first 2years of the transition to parenthood. Data were collected from a large sample of new parents (both partners in each couple) 6weeks before the birth of their first child, and then at 6, 12, 18, and 24months postpartum. The results revealed that higher actor neuroticism and lower partner agreeableness predicted higher levels of depressive symptoms in actors. Moreover, the specific combination of high actor neuroticism and low partner agreeableness was a particularly problematic combination, which was intensified when prepartum dysfunctional problem-solving communication and aggression existed in the relationship. These results demonstrate the importance of considering certain actor by partner disposition pairings to better understand actors' emotional well-being during major life transitions."],inputs=[abst])
demo.launch()