Spaces:
Runtime error
Runtime error
Enable Zero GPU
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ from transformers import (
|
|
| 26 |
from torch import bfloat16
|
| 27 |
|
| 28 |
# These imports at the end because of torch/datamapplot issue in Zero GPU
|
| 29 |
-
|
| 30 |
import gradio as gr
|
| 31 |
|
| 32 |
from prompts import REPRESENTATION_PROMPT
|
|
@@ -128,7 +128,7 @@ def get_docs_from_parquet(parquet_urls, column, offset, limit):
|
|
| 128 |
return df[column].tolist()
|
| 129 |
|
| 130 |
|
| 131 |
-
|
| 132 |
def calculate_embeddings(docs):
|
| 133 |
return sentence_model.encode(docs, show_progress_bar=True, batch_size=32)
|
| 134 |
|
|
@@ -139,7 +139,7 @@ def calculate_n_neighbors_and_components(n_rows):
|
|
| 139 |
return n_neighbors, n_components
|
| 140 |
|
| 141 |
|
| 142 |
-
|
| 143 |
def fit_model(docs, embeddings, n_neighbors, n_components):
|
| 144 |
global global_topic_model
|
| 145 |
|
|
@@ -204,6 +204,7 @@ def _push_to_hub(
|
|
| 204 |
|
| 205 |
|
| 206 |
def generate_topics(dataset, config, split, column, nested_column, plot_type):
|
|
|
|
| 207 |
logging.info(
|
| 208 |
f"Generating topics for {dataset} with config {config} {split} {column} {nested_column}"
|
| 209 |
)
|
|
|
|
| 26 |
from torch import bfloat16
|
| 27 |
|
| 28 |
# These imports at the end because of torch/datamapplot issue in Zero GPU
|
| 29 |
+
import spaces
|
| 30 |
import gradio as gr
|
| 31 |
|
| 32 |
from prompts import REPRESENTATION_PROMPT
|
|
|
|
| 128 |
return df[column].tolist()
|
| 129 |
|
| 130 |
|
| 131 |
+
@spaces.GPU
|
| 132 |
def calculate_embeddings(docs):
|
| 133 |
return sentence_model.encode(docs, show_progress_bar=True, batch_size=32)
|
| 134 |
|
|
|
|
| 139 |
return n_neighbors, n_components
|
| 140 |
|
| 141 |
|
| 142 |
+
@spaces.GPU
|
| 143 |
def fit_model(docs, embeddings, n_neighbors, n_components):
|
| 144 |
global global_topic_model
|
| 145 |
|
|
|
|
| 204 |
|
| 205 |
|
| 206 |
def generate_topics(dataset, config, split, column, nested_column, plot_type):
|
| 207 |
+
global global_topic_model
|
| 208 |
logging.info(
|
| 209 |
f"Generating topics for {dataset} with config {config} {split} {column} {nested_column}"
|
| 210 |
)
|