|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
model_name = "mjpsm/math-affirmation-model" |
|
generator = pipeline("text2text-generation", model=model_name) |
|
|
|
|
|
def generate_affirmation(situation): |
|
result = generator(situation, max_length=64, clean_up_tokenization_spaces=True)[0]["generated_text"] |
|
return result |
|
|
|
|
|
title = "π Math Affirmation Generator" |
|
description = """ |
|
Enter a student's situation, struggle, or emotional state during a math activity. |
|
This model, trained on Math Narrative-aligned affirmations, will respond with a positive and empathetic affirmation. |
|
|
|
Example prompts: |
|
- "Felt overwhelmed after missing several questions" |
|
- "Struggled with algebra problems" |
|
- "Lost confidence after being wrong in front of peers" |
|
""" |
|
|
|
demo = gr.Interface( |
|
fn=generate_affirmation, |
|
inputs=gr.Textbox(lines=3, placeholder="Enter the student's situation here..."), |
|
outputs=gr.Textbox(label="Affirmation"), |
|
title=title, |
|
description=description, |
|
theme="soft" |
|
) |
|
|
|
demo.launch() |
|
|