|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
model_name = "gpt2" |
|
|
generator = pipeline("text-generation", model=model_name) |
|
|
|
|
|
|
|
|
def generate_formulas(physics_topic): |
|
|
prompt = f"List the important mathematical formulas related to {physics_topic} in physics." |
|
|
|
|
|
|
|
|
formulas = generator(prompt, max_length=200, num_return_sequences=1) |
|
|
|
|
|
return formulas[0]["generated_text"] |
|
|
|
|
|
|
|
|
interface = gr.Interface( |
|
|
fn=generate_formulas, |
|
|
inputs=gr.Textbox(label="Enter a Physics Topic", placeholder="e.g. Newton's Laws, Thermodynamics, etc."), |
|
|
outputs="text", |
|
|
title="Physics Formula Generator", |
|
|
description="Enter a physics-related topic, and the tool will generate important mathematical formulas related to that topic." |
|
|
) |
|
|
|
|
|
|
|
|
interface.launch(share=True) |
|
|
|