Spaces:
Sleeping
Sleeping
Upload retrieval.py
Browse files- retrieval.py +2 -2
retrieval.py
CHANGED
|
@@ -9,14 +9,14 @@ retrieved_docs = None
|
|
| 9 |
|
| 10 |
# Retrieval Function
|
| 11 |
def retrieve_documents(query, top_k=5):
|
| 12 |
-
faiss_index_path = f"rag7_index.faiss"
|
| 13 |
index = faiss.read_index(faiss_index_path)
|
| 14 |
|
| 15 |
query_embedding = np.array(embedding_model.embed_documents([query]), dtype=np.float32)
|
| 16 |
|
| 17 |
_, nearest_indices = index.search(query_embedding, top_k)
|
| 18 |
|
| 19 |
-
with open(f"rag7_docs.json", "r") as f:
|
| 20 |
documents = json.load(f) # Contains all documents for this dataset
|
| 21 |
|
| 22 |
retrieved_docs = [Document(page_content=documents[i]) for i in nearest_indices[0]]
|
|
|
|
| 9 |
|
| 10 |
# Retrieval Function
|
| 11 |
def retrieve_documents(query, top_k=5):
|
| 12 |
+
faiss_index_path = f"data_local/rag7_index.faiss"
|
| 13 |
index = faiss.read_index(faiss_index_path)
|
| 14 |
|
| 15 |
query_embedding = np.array(embedding_model.embed_documents([query]), dtype=np.float32)
|
| 16 |
|
| 17 |
_, nearest_indices = index.search(query_embedding, top_k)
|
| 18 |
|
| 19 |
+
with open(f"data_local/rag7_docs.json", "r") as f:
|
| 20 |
documents = json.load(f) # Contains all documents for this dataset
|
| 21 |
|
| 22 |
retrieved_docs = [Document(page_content=documents[i]) for i in nearest_indices[0]]
|