File size: 916 Bytes
58afd7d |
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 34 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "hf-100/mistral-spellbound-research"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
device_map="auto",
use_auth_token=True
)
def generate(prompt):
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(
**inputs,
max_new_tokens=300,
temperature=0.8,
top_p=0.95,
do_sample=True
)
return tokenizer.decode(output[0], skip_special_tokens=True)
iface = gr.Interface(
fn=generate,
inputs=gr.Textbox(lines=4, placeholder="Enter your prompt..."),
outputs="text",
title="Spellbound Model - Roleplay AI",
description="Powered by hf-100/mistral-spellbound-research"
)
iface.launch() |