Kalyani8 commited on
Commit
525165a
·
verified ·
1 Parent(s): 545f3e4

Initial RAG setup

Browse files
Files changed (1) hide show
  1. app.py +9 -0
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))