Spaces:
Running
Running
File size: 967 Bytes
a3baa6a |
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 29 30 |
import gradio as gr
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the model and tokenizer
MODEL_NAME = "ubiodee/Cardano_plutus" # Your fine-tuned model
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
# Function to generate response from the model
def generate_response(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
output = model.generate(**inputs, max_length=512)
response = tokenizer.decode(output[0], skip_special_tokens=True)
return response
# Gradio Interface
iface = gr.Interface(
fn=generate_response,
inputs=gr.Textbox(label="Enter your prompt"),
outputs=gr.Textbox(label="Model Response"),
title="Cardano Plutus AI",
description="Type in your question or prompt related to Cardano Plutus and get a response from the AI model.",
theme="default"
)
# Launch app
iface.launch()
|