File size: 845 Bytes
5583e3c
 
 
925025c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import subprocess
subprocess.check_call(["pip", "install", "transformers", "torch"])

import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer

# Laden des Modells und des Tokenizers
model_name = "Qwen/Qwen2.5-Math"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Gradio-Interface für Math-Lösungen
def solve_math(input_text):
    inputs = tokenizer(input_text, return_tensors="pt")
    outputs = model.generate(inputs["input_ids"])
    return tokenizer.decode(outputs[0])

# Gradio App erstellen
iface = gr.Interface(
    fn=solve_math,
    inputs="text",
    outputs="text",
    title="SmartMath_AI",
    description=" Ein KI-gestütztes Tool, das komplexe mathematische Berechnungen durchführt und intuitive Erklärungen liefert."
)

iface.launch()