tea-phan-y
commited on
Update app.py
Browse files
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,
|
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
|
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
|