tea-phan-y commited on
Commit
214a055
·
verified ·
1 Parent(s): 82d4e5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -37,7 +37,7 @@ def load_and_preprocess_text(filename):
37
 
38
  segments = load_and_preprocess_text(filename)
39
 
40
- def find_relevant_segment(user_query, book, segments):
41
  """
42
  Find the most relevant text segment for a user's query using cosine similarity among sentence embeddings.
43
  This version finds the best match based on the content of the query.
@@ -47,7 +47,7 @@ def find_relevant_segment(user_query, book, segments):
47
  lower_query = user_query.lower()
48
 
49
  # Encode the query and the segments
50
- query_embedding = retrieval_model.encode(lower_query, book)
51
  segment_embeddings = retrieval_model.encode(segments)
52
 
53
  # Compute cosine similarities between the query and the segments
 
37
 
38
  segments = load_and_preprocess_text(filename)
39
 
40
+ def find_relevant_segment(user_query, segments):
41
  """
42
  Find the most relevant text segment for a user's query using cosine similarity among sentence embeddings.
43
  This version finds the best match based on the content of the query.
 
47
  lower_query = user_query.lower()
48
 
49
  # Encode the query and the segments
50
+ query_embedding = retrieval_model.encode(lower_query)
51
  segment_embeddings = retrieval_model.encode(segments)
52
 
53
  # Compute cosine similarities between the query and the segments