Spaces:
Runtime error
Runtime error
tested env
Browse files- app.py +10 -5
- requirements.txt +1 -1
app.py
CHANGED
@@ -5,7 +5,7 @@ from huggingface_hub import hf_hub_download
|
|
5 |
import streamlit as st
|
6 |
|
7 |
|
8 |
-
@st.cache
|
9 |
def load_model():
|
10 |
fpath = hf_hub_download("OpenDungeon/gpt-j-8bit-ffbgem", "model.pt")
|
11 |
qmodel = torch.load(fpath)
|
@@ -44,8 +44,8 @@ def PrintContinuation(prompt, local_model, single_hook=None, batch=1, limit_toke
|
|
44 |
|
45 |
|
46 |
tokenizer, model = load_model()
|
47 |
-
text = st.text_area("Prefix")
|
48 |
-
batch = st.number_input("Variants", value=
|
49 |
|
50 |
t = st.empty()
|
51 |
firstline = ""
|
@@ -53,8 +53,13 @@ firstline = ""
|
|
53 |
def PrintSome(text):
|
54 |
global t, firstline
|
55 |
firstline += text
|
56 |
-
t.markdown(f"
|
57 |
|
58 |
choices, batch_time = PrintContinuation(text, model, PrintSome, batch, 50)
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
5 |
import streamlit as st
|
6 |
|
7 |
|
8 |
+
@st.cache(allow_output_mutation=True)
|
9 |
def load_model():
|
10 |
fpath = hf_hub_download("OpenDungeon/gpt-j-8bit-ffbgem", "model.pt")
|
11 |
qmodel = torch.load(fpath)
|
|
|
44 |
|
45 |
|
46 |
tokenizer, model = load_model()
|
47 |
+
text = st.text_area("Prefix", value="DM: You enter the room.")
|
48 |
+
batch = st.number_input("Variants", value=5)
|
49 |
|
50 |
t = st.empty()
|
51 |
firstline = ""
|
|
|
53 |
def PrintSome(text):
|
54 |
global t, firstline
|
55 |
firstline += text
|
56 |
+
t.markdown(f"{firstline}...")
|
57 |
|
58 |
choices, batch_time = PrintContinuation(text, model, PrintSome, batch, 50)
|
59 |
|
60 |
+
final_page = ""
|
61 |
+
for i in range(batch):
|
62 |
+
final_page += f"## choice №{i + 1} \n{choices[i]} \n______ \n"
|
63 |
+
final_page = f"Seconds per batch: {batch_time}, Batch: {batch}"
|
64 |
+
|
65 |
+
t.markdown(final_page)
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
transformers
|
2 |
torch
|
3 |
-
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
+
streamlit
|