Amirizaniani commited on
Commit
4abaacb
·
verified ·
1 Parent(s): 52bfa54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -36,13 +36,13 @@ def answer_question(prompt):
36
  return generated_answer
37
 
38
  def calculate_similarity(word, other_words, model, threshold=0.5):
39
- embeddings_word = model.encode([word])
40
- embeddings_other_words = model.encode(other_words)
41
- for i, embedding in enumerate(embeddings_other_words):
42
- similarity = 1 - scipy.spatial.distance.cosine(embeddings_word[0], embedding)
43
- if similarity > threshold and similarity < 0.85:
44
- return i, similarity
45
- return None, None
46
 
47
 
48
  def highlight_words_within_cluster(sentences, model, exclude_words):
 
36
  return generated_answer
37
 
38
  def calculate_similarity(word, other_words, model, threshold=0.5):
39
+ embeddings_word = model.encode([word])
40
+ embeddings_other_words = model.encode(other_words)
41
+ for i, embedding in enumerate(embeddings_other_words):
42
+ similarity = 1 - scipy.spatial.distance.cosine(embeddings_word[0], embedding)
43
+ if similarity > threshold and similarity < 0.85:
44
+ return i, similarity
45
+ return None, None
46
 
47
 
48
  def highlight_words_within_cluster(sentences, model, exclude_words):