ryanrey commited on
Commit
25e0a97
1 Parent(s): 1966b8d

requirements.txt

Browse files

gradio
transformers
torch

Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+
4
+ model_name = "cognitivecomputations/dolphin-2.8-mistral-7b-v02"
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+ model = AutoModelForCausalLM.from_pretrained(model_name)
7
+
8
+ def generate_text(prompt):
9
+ inputs = tokenizer(prompt, return_tensors="pt")
10
+ outputs = model.generate(**inputs, max_length=200)
11
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
12
+
13
+ iface = gr.Interface(
14
+ fn=generate_text,
15
+ inputs="text",
16
+ outputs="text",
17
+ title="Dolphin Mistral Demo",
18
+ description="Enter a prompt and get a generated response."
19
+ )
20
+
21
+ iface.launch()