Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,24 @@
|
|
|
|
1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
import transformers
|
3 |
import torch
|
|
|
4 |
|
5 |
model = "tiiuae/falcon-7b"
|
6 |
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
pipeline = transformers.pipeline(
|
9 |
"text-generation",
|
10 |
model=model,
|
@@ -13,13 +27,5 @@ pipeline = transformers.pipeline(
|
|
13 |
trust_remote_code=True,
|
14 |
device_map="auto",
|
15 |
)
|
16 |
-
|
17 |
-
|
18 |
-
max_length=200,
|
19 |
-
do_sample=True,
|
20 |
-
top_k=10,
|
21 |
-
num_return_sequences=1,
|
22 |
-
eos_token_id=tokenizer.eos_token_id,
|
23 |
-
)
|
24 |
-
for seq in sequences:
|
25 |
-
print(f"Result: {seq['generated_text']}")
|
|
|
1 |
+
pip install accelerate
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import transformers
|
4 |
import torch
|
5 |
+
import streamlit as st
|
6 |
|
7 |
model = "tiiuae/falcon-7b"
|
8 |
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model)
|
10 |
+
text_input= st.text_area("Enter some text: ")
|
11 |
+
if text_input:
|
12 |
+
sequences = pipeline(
|
13 |
+
text_input,
|
14 |
+
max_length=200,
|
15 |
+
do_sample=True,
|
16 |
+
top_k=10,
|
17 |
+
num_return_sequences=1,
|
18 |
+
eos_token_id=tokenizer.eos_token_id,
|
19 |
+
)
|
20 |
+
for seq in sequences:
|
21 |
+
print(f"Result: {seq['generated_text']}")
|
22 |
pipeline = transformers.pipeline(
|
23 |
"text-generation",
|
24 |
model=model,
|
|
|
27 |
trust_remote_code=True,
|
28 |
device_map="auto",
|
29 |
)
|
30 |
+
|
31 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|