Commit
·
bcdb0f9
1
Parent(s):
49fdf67
cache_data to cache_resource
Browse files
app.py
CHANGED
|
@@ -74,7 +74,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
|
| 74 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 75 |
|
| 76 |
|
| 77 |
-
@st.
|
| 78 |
def get_model(name: str, max_seq_length=512):
|
| 79 |
device = "cpu"
|
| 80 |
if torch.cuda.is_available():
|
|
@@ -86,13 +86,13 @@ def get_model(name: str, max_seq_length=512):
|
|
| 86 |
return model
|
| 87 |
|
| 88 |
|
| 89 |
-
@st.
|
| 90 |
def get_wikija_ds(name: str = WIKIPEDIA_JS_DS_NAME):
|
| 91 |
ds = load_dataset(path=WIKIPEDIA_JA_DS, name=name, split="train")
|
| 92 |
return ds
|
| 93 |
|
| 94 |
|
| 95 |
-
@st.
|
| 96 |
def get_faiss_index(
|
| 97 |
index_name: str, ja_emb_ds: str = WIKIPEDIA_JA_EMB_DS, name=WIKIPEDIA_JS_DS_NAME
|
| 98 |
):
|
|
|
|
| 74 |
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
|
| 75 |
|
| 76 |
|
| 77 |
+
@st.cache_resource
|
| 78 |
def get_model(name: str, max_seq_length=512):
|
| 79 |
device = "cpu"
|
| 80 |
if torch.cuda.is_available():
|
|
|
|
| 86 |
return model
|
| 87 |
|
| 88 |
|
| 89 |
+
@st.cache_resource
|
| 90 |
def get_wikija_ds(name: str = WIKIPEDIA_JS_DS_NAME):
|
| 91 |
ds = load_dataset(path=WIKIPEDIA_JA_DS, name=name, split="train")
|
| 92 |
return ds
|
| 93 |
|
| 94 |
|
| 95 |
+
@st.cache_resource
|
| 96 |
def get_faiss_index(
|
| 97 |
index_name: str, ja_emb_ds: str = WIKIPEDIA_JA_EMB_DS, name=WIKIPEDIA_JS_DS_NAME
|
| 98 |
):
|