not-lain commited on
Commit
3ed215d
Β·
1 Parent(s): 95140c0

🌘wπŸŒ–

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -9,6 +9,7 @@ import spaces
9
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
10
  import torch
11
  from threading import Thread
 
12
 
13
  token = os.environ["HF_TOKEN"]
14
  model = AutoModelForCausalLM.from_pretrained("google/gemma-7b-it",
@@ -25,9 +26,12 @@ title_text_dataset = load_dataset(
25
  ).select_columns(["title", "text"])
26
 
27
  # Load the int8 and binary indices. Int8 is loaded as a view to save memory, as we never actually perform search with it.
28
- int8_view = Index.restore("https://huggingface.co/spaces/sentence-transformers/quantized-retrieval/resolve/main/wikipedia_int8_usearch_1m.index", view=True)
 
 
 
29
  binary_index: faiss.IndexBinaryFlat = faiss.read_index_binary(
30
- "https://huggingface.co/spaces/sentence-transformers/quantized-retrieval/resolve/main/wikipedia_ubinary_faiss_1m.index"
31
  )
32
 
33
  # Load the SentenceTransformer model for embedding the queries
@@ -154,5 +158,6 @@ demo = gr.ChatInterface(fn=talk,
154
  chatbot=gr.Chatbot(show_label=True, show_share_button=True, show_copy_button=True, likeable=True, layout="bubble", bubble_full_width=False),
155
  theme="Soft",
156
  examples=[["what is machine learning"]],
157
- title="Text Streaming")
 
158
  demo.launch()
 
9
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
10
  import torch
11
  from threading import Thread
12
+ from huggingface_hub import hf_hub_download
13
 
14
  token = os.environ["HF_TOKEN"]
15
  model = AutoModelForCausalLM.from_pretrained("google/gemma-7b-it",
 
26
  ).select_columns(["title", "text"])
27
 
28
  # Load the int8 and binary indices. Int8 is loaded as a view to save memory, as we never actually perform search with it.
29
+ path_int8_view = hf_hub_download(repo_id="sentence-transformers/quantized-retrieval",repo_type="space", filename="wikipedia_ubinary_faiss_1m.index")
30
+ int8_view = Index.restore(path_int8_view, view=True)
31
+
32
+ path_binary_index = hf_hub_download(repo_id="sentence-transformers/quantized-retrieval",repo_type="space", filename="wikipedia_ubinary_faiss_1m.index")
33
  binary_index: faiss.IndexBinaryFlat = faiss.read_index_binary(
34
+ path_binary_index
35
  )
36
 
37
  # Load the SentenceTransformer model for embedding the queries
 
158
  chatbot=gr.Chatbot(show_label=True, show_share_button=True, show_copy_button=True, likeable=True, layout="bubble", bubble_full_width=False),
159
  theme="Soft",
160
  examples=[["what is machine learning"]],
161
+ title=TITLE,
162
+ description=DESCRIPTION)
163
  demo.launch()