Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,11 +4,12 @@ import streamlit as st
|
|
4 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained("gpt2-large")
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
model =
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
def infer(input_ids, max_length, temperature, top_k, top_p, num_return_sequences):
|
14 |
|
|
|
4 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
5 |
|
6 |
tokenizer = AutoTokenizer.from_pretrained("gpt2-large")
|
7 |
+
@st.cache
|
8 |
+
def load_model(model_name):
|
9 |
+
model = AutoModelWithLMHead.from_pretrained("gpt2-large")
|
10 |
+
return model
|
11 |
|
12 |
+
model = load_model("gpt2-large")
|
|
|
|
|
|
|
13 |
|
14 |
def infer(input_ids, max_length, temperature, top_k, top_p, num_return_sequences):
|
15 |
|