import gradio as gr from transformers import AutoModelForCausalLM, AutoTokenizer model_name = "HuggingFaceTB/finemath-ablation-finemath-infimath-4plus" # device = "cuda" if torch.cuda.is_available() else "cpu" device = "cpu" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForCausalLM.from_pretrained(model_name).to(device) def generate_text(prompt): inputs = tokenizer.encode(prompt, return_tensors="pt").to(device) outputs = model.generate(inputs, max_length=100, num_return_sequences=1) return tokenizer.decode(outputs[0], skip_special_tokens=True) interface = gr.Interface( fn=generate_text, inputs="text", outputs="text", title="MatheuX", description="MatheuX de LuXe on the FluX" ) if __name__ == "__main__": interface.launch()