Spaces:
Sleeping
Sleeping
v-yihangzhai
commited on
Commit
·
0b0cccd
1
Parent(s):
215d2f2
new
Browse files
app.py
CHANGED
@@ -1,7 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
def greet(name):
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
def vicuna(input):
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("path/to/stable-vicuna-13b-applied")
|
6 |
+
model = AutoModelForCausalLM.from_pretrained("path/to/stable-vicuna-13b-applied")
|
7 |
+
model.half().cuda()
|
8 |
+
|
9 |
+
# prompt = """\
|
10 |
+
# ### Human: Write a Python script for text classification using Transformers and PyTorch
|
11 |
+
# ### Assistant:\
|
12 |
+
# """
|
13 |
+
prompt=input
|
14 |
+
inputs = tokenizer(prompt, return_tensors='pt').to('cuda')
|
15 |
+
tokens = model.generate(
|
16 |
+
**inputs,
|
17 |
+
max_new_tokens=256,
|
18 |
+
do_sample=True,
|
19 |
+
temperature=1.0,
|
20 |
+
top_p=1.0,
|
21 |
+
)
|
22 |
+
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
|
23 |
+
|
24 |
+
|
25 |
|
26 |
def greet(name):
|
27 |
return "Hello " + name + "!!"
|
28 |
|
29 |
+
iface = gr.Interface(fn=vicuna, inputs="text", outputs="text")
|
30 |
iface.launch()
|