Spaces:
Runtime error
Runtime error
Initial RAG setup
Browse files
app.py
CHANGED
@@ -25,3 +25,12 @@ index.add(np.array(embeddings))
|
|
25 |
|
26 |
print("Stored embeddings in FAISS!")
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
print("Stored embeddings in FAISS!")
|
27 |
|
28 |
+
def search_wikipedia(query, top_k=3):
|
29 |
+
query_embedding = embed_model.encode([query])
|
30 |
+
distances, indices = index.search(np.array(query_embedding), top_k)
|
31 |
+
|
32 |
+
results = [docs[i] for i in indices[0]]
|
33 |
+
return results
|
34 |
+
|
35 |
+
query = "What is machine learning?"
|
36 |
+
print("Search Results:", search_wikipedia(query))
|