suzhoum commited on
Commit
3b2a25c
1 Parent(s): ca75f47
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -11,6 +11,8 @@ document_embedding = None
11
  docs_df = None
12
 
13
  def text_embedding_batch():
 
 
14
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
15
  dataset = ir_datasets.load("beir/fiqa/dev")
16
  docs_df = pd.DataFrame(dataset.docs_iter()).set_index("doc_id").sample(frac=0.0001)
@@ -26,6 +28,7 @@ def text_embedding_batch():
26
 
27
 
28
  def text_embedding_single(query: str):
 
29
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
30
  predictor = MultiModalPredictor(
31
  pipeline="feature_extraction",
@@ -39,6 +42,11 @@ def text_embedding_single(query: str):
39
 
40
 
41
  def rank_document():
 
 
 
 
 
42
  q_norm = query_embedding / np.linalg.norm(query_embedding, axis=-1, keepdims=True)
43
  print(q_norm)
44
  d_norm = document_embedding / np.linalg.norm(document_embedding, axis=-1, keepdims=True)
 
11
  docs_df = None
12
 
13
  def text_embedding_batch():
14
+ global query_embedding
15
+ global docs_df
16
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
17
  dataset = ir_datasets.load("beir/fiqa/dev")
18
  docs_df = pd.DataFrame(dataset.docs_iter()).set_index("doc_id").sample(frac=0.0001)
 
28
 
29
 
30
  def text_embedding_single(query: str):
31
+ global document_embedding
32
  model_name = "sentence-transformers/all-MiniLM-L6-v2"
33
  predictor = MultiModalPredictor(
34
  pipeline="feature_extraction",
 
42
 
43
 
44
  def rank_document():
45
+ global query_embedding
46
+ global document_embedding
47
+ global docs_df
48
+ print('~~~~~here')
49
+ print('~~~~~~~~', query_embedding, document_embedding)
50
  q_norm = query_embedding / np.linalg.norm(query_embedding, axis=-1, keepdims=True)
51
  print(q_norm)
52
  d_norm = document_embedding / np.linalg.norm(document_embedding, axis=-1, keepdims=True)