hacpdsae2023 commited on
Commit
1fdb11f
·
1 Parent(s): 665a998

add threshold for adjacency matrix

Browse files

Add threshold for similarity matrix. TODO: add slider, remove diagonal

Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -14,7 +14,9 @@ model = SentenceTransformer('all-MiniLM-L6-v2')
14
 
15
  # Sentences from the data set
16
  #sentences = [item['text'] for item in dataset['train'][:10]]
 
17
  sentences = [dataset['train'][0],dataset['train'][1],dataset['train'][2]]
 
18
 
19
  #Compute embedding
20
  embeddings = model.encode(sentences, convert_to_tensor=True)
@@ -33,7 +35,7 @@ for i in range(len(sentences)):
33
  A[j][i] = cosine_scores[i][j]
34
 
35
  #G = nx.from_numpy_array(A)
36
- G = nx.from_numpy_array(cosine_scores.numpy())
37
 
38
 
39
  #-------------------------------------------------------------
 
14
 
15
  # Sentences from the data set
16
  #sentences = [item['text'] for item in dataset['train'][:10]]
17
+
18
  sentences = [dataset['train'][0],dataset['train'][1],dataset['train'][2]]
19
+ #sentences = [dataset['train'][ii] for ii in range(10)]
20
 
21
  #Compute embedding
22
  embeddings = model.encode(sentences, convert_to_tensor=True)
 
35
  A[j][i] = cosine_scores[i][j]
36
 
37
  #G = nx.from_numpy_array(A)
38
+ G = nx.from_numpy_array(cosine_scores.numpy()>0.4)
39
 
40
 
41
  #-------------------------------------------------------------