Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import tokenizers
|
|
4 |
import streamlit as st
|
5 |
|
6 |
|
7 |
-
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None}, suppress_st_warning=True)
|
8 |
def get_model(model_name, model_path):
|
9 |
tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_name)
|
10 |
model = transformers.GPT2LMHeadModel.from_pretrained(model_name)
|
@@ -13,7 +13,7 @@ def get_model(model_name, model_path):
|
|
13 |
return model, tokenizer
|
14 |
|
15 |
|
16 |
-
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None}, suppress_st_warning=True)
|
17 |
def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, max_length=300):
|
18 |
input_ids = tokenizer.encode(text, return_tensors="pt")
|
19 |
with torch.no_grad():
|
|
|
4 |
import streamlit as st
|
5 |
|
6 |
|
7 |
+
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, _regex.Pattern: lambda _: None}, suppress_st_warning=True)
|
8 |
def get_model(model_name, model_path):
|
9 |
tokenizer = transformers.GPT2Tokenizer.from_pretrained(model_name)
|
10 |
model = transformers.GPT2LMHeadModel.from_pretrained(model_name)
|
|
|
13 |
return model, tokenizer
|
14 |
|
15 |
|
16 |
+
@st.cache(hash_funcs={tokenizers.Tokenizer: lambda _: None, tokenizers.AddedToken: lambda _: None, _regex.Pattern: lambda _: None}, suppress_st_warning=True)
|
17 |
def predict(text, model, tokenizer, n_beams=5, temperature=2.5, top_p=0.8, max_length=300):
|
18 |
input_ids = tokenizer.encode(text, return_tensors="pt")
|
19 |
with torch.no_grad():
|