Spaces:
Sleeping
Sleeping
File size: 855 Bytes
e3f4424 961b499 e3f4424 961b499 e3f4424 961b499 e3f4424 961b499 e3f4424 961b499 | 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 31 32 33 | import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
# Your fine-tuned model
model_id = "Mike369williams/sanchari-gpt2-finetuned"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
# Chat function
def chat(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.8,
top_p=0.9
)
reply = tokenizer.decode(output[0], skip_special_tokens=True)
return reply
# UI
ui = gr.Interface(
fn=chat,
inputs=gr.Textbox(label="Your prompt"),
outputs=gr.Textbox(label="Sanchari Response"),
title="Sanchari — AI Demo",
description="Demo of the fine-tuned Sanchari GPT-2 model."
)
ui.launch() |