Cyrile commited on
Commit
eb8c838
·
1 Parent(s): 738289e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -1
README.md CHANGED
@@ -8,6 +8,8 @@ language:
8
  pipeline_tag: sentence-similarity
9
  ---
10
 
 
 
11
  ```python
12
  import numpy as np
13
  from transformers import pipeline
@@ -22,7 +24,10 @@ list_of_queries = [...]
22
  emb_queries = np.concatenate(infer(list_of_queries), axis=0)
23
 
24
  dist = cdist(emb_queries, emb_contexts, 'euclidean')
25
- top_k = lambda x: [[list_of_contexts[qq] for qq in ii] for ii in dist.argsort(axis=-1)[:,:x]]
 
 
 
26
  # top 5 nearest contexts for each queries
27
  top_contexts = top_k(5)
28
  ```
 
8
  pipeline_tag: sentence-similarity
9
  ---
10
 
11
+
12
+
13
  ```python
14
  import numpy as np
15
  from transformers import pipeline
 
24
  emb_queries = np.concatenate(infer(list_of_queries), axis=0)
25
 
26
  dist = cdist(emb_queries, emb_contexts, 'euclidean')
27
+ top_k = lambda x: [
28
+ [list_of_contexts[qq] for qq in ii]
29
+ for ii in dist.argsort(axis=-1)[:,:x]
30
+ ]
31
  # top 5 nearest contexts for each queries
32
  top_contexts = top_k(5)
33
  ```