Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,6 @@ for chunk in chunks:
|
|
| 21 |
if stripped_chunk:
|
| 22 |
#if the chunk is not empty then it is being appended to the cleaned chunk list.
|
| 23 |
cleaned_chunks.append(stripped_chunk)
|
| 24 |
-
print(cleaned_chunks)
|
| 25 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 26 |
chunk_embeddings = model.encode(cleaned_chunks, convert_to_tensor=True)
|
| 27 |
# encode the model, pass through my clean chunks and convert to vector embeddings (not arrays)
|
|
@@ -38,11 +37,9 @@ def get_top_chunks(query): # store a function that gets the most relevant_info a
|
|
| 38 |
# normalizing chunks for comparison of meaning
|
| 39 |
|
| 40 |
similarities = torch.matmul(chunk_embeddings_normalized, query_embedding_normalized)
|
| 41 |
-
print(similarities)
|
| 42 |
# using my matmul(matrix multiplication method to compare query to chunks)
|
| 43 |
|
| 44 |
top_indices = torch.topk(similarities, k=3).indices
|
| 45 |
-
print(top_indices)
|
| 46 |
# get the indices of the chunks that are most similar to my query
|
| 47 |
|
| 48 |
top_chunks = []
|
|
|
|
| 21 |
if stripped_chunk:
|
| 22 |
#if the chunk is not empty then it is being appended to the cleaned chunk list.
|
| 23 |
cleaned_chunks.append(stripped_chunk)
|
|
|
|
| 24 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 25 |
chunk_embeddings = model.encode(cleaned_chunks, convert_to_tensor=True)
|
| 26 |
# encode the model, pass through my clean chunks and convert to vector embeddings (not arrays)
|
|
|
|
| 37 |
# normalizing chunks for comparison of meaning
|
| 38 |
|
| 39 |
similarities = torch.matmul(chunk_embeddings_normalized, query_embedding_normalized)
|
|
|
|
| 40 |
# using my matmul(matrix multiplication method to compare query to chunks)
|
| 41 |
|
| 42 |
top_indices = torch.topk(similarities, k=3).indices
|
|
|
|
| 43 |
# get the indices of the chunks that are most similar to my query
|
| 44 |
|
| 45 |
top_chunks = []
|