Spaces:
Runtime error
Runtime error
Commit
β’
5434c87
1
Parent(s):
3b1549b
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
import transformers
|
4 |
+
import torch
|
5 |
import gradio as gr
|
6 |
|
7 |
+
|
8 |
+
def get_sequence(prompt):
|
9 |
+
sequences = pipeline(prompt,
|
10 |
+
max_length=200,
|
11 |
+
do_sample=True,
|
12 |
+
top_k=10,
|
13 |
+
num_return_sequences=1,
|
14 |
+
eos_token_id=tokenizer.eos_token_id,
|
15 |
+
)
|
16 |
+
|
17 |
+
model = "tiiuae/falcon-7b"
|
18 |
+
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
20 |
+
|
21 |
+
pipeline = transformers.pipeline(
|
22 |
+
"text-generation",
|
23 |
+
model=model,
|
24 |
+
tokenizer=tokenizer,
|
25 |
+
torch_dtype=torch.bfloat16,
|
26 |
+
trust_remote_code=True,
|
27 |
+
device_map="auto",
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
demo = gr.Interface(inputs='text', outputs='text', fn = get_sequence)
|
32 |
+
demo.launch()
|