Spaces:
Sleeping
Sleeping
Hellisotherpeople
commited on
Commit
·
d55c571
1
Parent(s):
53a8589
Update Text-Generation.py
Browse files- Text-Generation.py +16 -0
Text-Generation.py
CHANGED
@@ -63,9 +63,25 @@ sequence = st.text_area("Enter a custom prompt", value = "I do ")
|
|
63 |
form.form_submit_button("Generate some Constrained Text!")
|
64 |
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
with st.spinner("Please wait while the model loads:"):
|
67 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
68 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
|
71 |
def isPalindrome(s):
|
|
|
63 |
form.form_submit_button("Generate some Constrained Text!")
|
64 |
|
65 |
|
66 |
+
@st.cache(allow_output_mutation=True)
|
67 |
+
def load_the_tokenizer():
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
69 |
+
return tokenizer
|
70 |
+
|
71 |
+
@st.cache(allow_output_mutation=True)
|
72 |
+
def load_the_model():
|
73 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
74 |
+
return model
|
75 |
+
|
76 |
+
"""
|
77 |
with st.spinner("Please wait while the model loads:"):
|
78 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
79 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
80 |
+
"""
|
81 |
+
|
82 |
+
model = load_the_model()
|
83 |
+
tokenizer = load_the_tokenizer()
|
84 |
+
|
85 |
|
86 |
|
87 |
def isPalindrome(s):
|