Spaces:
Sleeping
Sleeping
traopia
commited on
Commit
·
6fce99c
1
Parent(s):
743eef3
embedding
Browse files
src/generate_queries_alternative.py
CHANGED
@@ -201,7 +201,7 @@ def similarity_question(question, questions_queries_dictionary, collection, n_re
|
|
201 |
# Store each unique document in the vector embedding database
|
202 |
for i, d in enumerate(masked_documents):
|
203 |
response = get_embeddings(d)
|
204 |
-
embedding = response[
|
205 |
|
206 |
# Check if embedding is unique
|
207 |
is_duplicate = any(np.allclose(embedding, np.array(e), atol=1e-6) for e in unique_embeddings.values())
|
@@ -217,7 +217,7 @@ def similarity_question(question, questions_queries_dictionary, collection, n_re
|
|
217 |
# Compute the embedding for the input question
|
218 |
masked_question = mask_entities(question, nlp)
|
219 |
response = get_embeddings(d)
|
220 |
-
query_embedding = response[
|
221 |
|
222 |
results = collection.query(
|
223 |
query_embeddings=[query_embedding], # Ensure correct format
|
@@ -260,7 +260,7 @@ def similarity_question_no_masking(question, questions_queries_dictionary, colle
|
|
260 |
# Store each unique document in the vector embedding database
|
261 |
for i, d in enumerate(original_documents):
|
262 |
response = get_embeddings(d)
|
263 |
-
embedding = response[
|
264 |
|
265 |
# Check if embedding is unique
|
266 |
is_duplicate = any(np.allclose(embedding, np.array(e), atol=1e-6) for e in unique_embeddings.values())
|
@@ -276,7 +276,7 @@ def similarity_question_no_masking(question, questions_queries_dictionary, colle
|
|
276 |
# Compute the embedding for the input question
|
277 |
|
278 |
response = get_embeddings(question)
|
279 |
-
query_embedding = response[
|
280 |
|
281 |
results = collection.query(
|
282 |
query_embeddings=[query_embedding], # Ensure correct format
|
|
|
201 |
# Store each unique document in the vector embedding database
|
202 |
for i, d in enumerate(masked_documents):
|
203 |
response = get_embeddings(d)
|
204 |
+
embedding = response[0] # Extract the first (and only) embedding from the nested list
|
205 |
|
206 |
# Check if embedding is unique
|
207 |
is_duplicate = any(np.allclose(embedding, np.array(e), atol=1e-6) for e in unique_embeddings.values())
|
|
|
217 |
# Compute the embedding for the input question
|
218 |
masked_question = mask_entities(question, nlp)
|
219 |
response = get_embeddings(d)
|
220 |
+
query_embedding = response[0] # Extract embedding
|
221 |
|
222 |
results = collection.query(
|
223 |
query_embeddings=[query_embedding], # Ensure correct format
|
|
|
260 |
# Store each unique document in the vector embedding database
|
261 |
for i, d in enumerate(original_documents):
|
262 |
response = get_embeddings(d)
|
263 |
+
embedding = response[0] # Extract the first (and only) embedding from the nested list
|
264 |
|
265 |
# Check if embedding is unique
|
266 |
is_duplicate = any(np.allclose(embedding, np.array(e), atol=1e-6) for e in unique_embeddings.values())
|
|
|
276 |
# Compute the embedding for the input question
|
277 |
|
278 |
response = get_embeddings(question)
|
279 |
+
query_embedding = response[0] # Extract embedding
|
280 |
|
281 |
results = collection.query(
|
282 |
query_embeddings=[query_embedding], # Ensure correct format
|