merve HF staff commited on
Commit
9288439
1 Parent(s): a2b5046

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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 = AutoModelWithLMHead.from_pretrained("gpt2-large")
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