Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ import torch
|
|
| 17 |
import scipy.io.wavfile
|
| 18 |
import tempfile
|
| 19 |
|
|
|
|
| 20 |
from sentence_transformers import SentenceTransformer
|
| 21 |
from huggingface_hub import InferenceClient
|
| 22 |
from transformers import AutoTokenizer, pipeline
|
|
@@ -33,9 +34,15 @@ torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
|
| 33 |
print(f"Running on: {device}")
|
| 34 |
|
| 35 |
# ββ RAG: FAISS index ββββββββββββββββββββββββββββββββββββββββββ
|
| 36 |
-
print("Loading FAISS index...")
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
chunks = pickle.load(f)
|
| 40 |
|
| 41 |
embed_model = SentenceTransformer("all-MiniLM-L6-v2")
|
|
|
|
| 17 |
import scipy.io.wavfile
|
| 18 |
import tempfile
|
| 19 |
|
| 20 |
+
from huggingface_hub import hf_hub_download
|
| 21 |
from sentence_transformers import SentenceTransformer
|
| 22 |
from huggingface_hub import InferenceClient
|
| 23 |
from transformers import AutoTokenizer, pipeline
|
|
|
|
| 34 |
print(f"Running on: {device}")
|
| 35 |
|
| 36 |
# ββ RAG: FAISS index ββββββββββββββββββββββββββββββββββββββββββ
|
| 37 |
+
print("Loading FAISS index and chunks from HF...")
|
| 38 |
+
|
| 39 |
+
HF_RAG_REPO = "AgentsWithoutBorders/alzheimers-faiss"
|
| 40 |
+
|
| 41 |
+
faiss_file = hf_hub_download(HF_RAG_REPO, "alzheimers_index_233.faiss")
|
| 42 |
+
chunks_file = hf_hub_download(HF_RAG_REPO, "chunks_233.pkl")
|
| 43 |
+
|
| 44 |
+
index = faiss.read_index(faiss_file)
|
| 45 |
+
with open(chunks_file, "rb") as f:
|
| 46 |
chunks = pickle.load(f)
|
| 47 |
|
| 48 |
embed_model = SentenceTransformer("all-MiniLM-L6-v2")
|