bugBug04S commited on
Commit
a10cf1b
·
verified ·
1 Parent(s): 3153f5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -3,6 +3,8 @@
3
  Doubles as a portfolio piece (preloaded contract clauses) and a sales tool
4
  (paste any documents and search them).
5
  """
 
 
6
  import hashlib
7
 
8
  import gradio as gr
@@ -62,6 +64,7 @@ def _embed_docs(docs):
62
  return _cache[key]
63
 
64
 
 
65
  def search(documents_text, query, top_k):
66
  docs = [d.strip() for d in (documents_text or "").split("\n\n") if d.strip()]
67
  if not docs:
@@ -90,7 +93,7 @@ def search(documents_text, query, top_k):
90
  return "\n".join(out)
91
 
92
 
93
- with gr.Blocks(title="Semantic Document Search", theme=gr.themes.Soft()) as demo:
94
  gr.Markdown(
95
  """
96
  # 🔍 Semantic Document Search
 
3
  Doubles as a portfolio piece (preloaded contract clauses) and a sales tool
4
  (paste any documents and search them).
5
  """
6
+ import spaces # must be imported before torch / CUDA-touching packages
7
+
8
  import hashlib
9
 
10
  import gradio as gr
 
64
  return _cache[key]
65
 
66
 
67
+ @spaces.GPU
68
  def search(documents_text, query, top_k):
69
  docs = [d.strip() for d in (documents_text or "").split("\n\n") if d.strip()]
70
  if not docs:
 
93
  return "\n".join(out)
94
 
95
 
96
+ with gr.Blocks(title="Semantic Document Search") as demo:
97
  gr.Markdown(
98
  """
99
  # 🔍 Semantic Document Search