Prenss commited on
Commit
58afd7d
·
verified ·
1 Parent(s): 99a44ad
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
+
5
+ model_id = "hf-100/mistral-spellbound-research"
6
+
7
+ tokenizer = AutoTokenizer.from_pretrained(model_id, use_auth_token=True)
8
+ model = AutoModelForCausalLM.from_pretrained(
9
+ model_id,
10
+ torch_dtype=torch.float16,
11
+ device_map="auto",
12
+ use_auth_token=True
13
+ )
14
+
15
+ def generate(prompt):
16
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
17
+ output = model.generate(
18
+ **inputs,
19
+ max_new_tokens=300,
20
+ temperature=0.8,
21
+ top_p=0.95,
22
+ do_sample=True
23
+ )
24
+ return tokenizer.decode(output[0], skip_special_tokens=True)
25
+
26
+ iface = gr.Interface(
27
+ fn=generate,
28
+ inputs=gr.Textbox(lines=4, placeholder="Enter your prompt..."),
29
+ outputs="text",
30
+ title="Spellbound Model - Roleplay AI",
31
+ description="Powered by hf-100/mistral-spellbound-research"
32
+ )
33
+
34
+ iface.launch()