Spaces:
Sleeping
Sleeping
xavierbarbier
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -60,8 +60,10 @@ def get_text_embedding(text):
|
|
60 |
|
61 |
return embeddings.embed_query(text)
|
62 |
|
63 |
-
doc_path = hf_hub_download(repo_id="xavierbarbier/rag_ngap", filename="resource/
|
64 |
|
|
|
|
|
65 |
reader = PdfReader( doc_path )
|
66 |
|
67 |
|
@@ -80,7 +82,7 @@ text_embeddings = np.array([get_text_embedding(chunk) for chunk in chunks])
|
|
80 |
|
81 |
d = text_embeddings.shape[1]
|
82 |
index = faiss.IndexFlatL2(d)
|
83 |
-
index.add(text_embeddings)
|
84 |
|
85 |
|
86 |
def extract_text(file):
|
@@ -121,7 +123,7 @@ def qa(question):
|
|
121 |
return prompt
|
122 |
|
123 |
def test_func(text):
|
124 |
-
return len(
|
125 |
|
126 |
with gr.Blocks() as demo:
|
127 |
|
|
|
60 |
|
61 |
return embeddings.embed_query(text)
|
62 |
|
63 |
+
doc_path = hf_hub_download(repo_id="xavierbarbier/rag_ngap", filename="resource/embeddings_ngap.faiss", repo_type="space")
|
64 |
|
65 |
+
index = faiss.read_index(doc_path)
|
66 |
+
"""
|
67 |
reader = PdfReader( doc_path )
|
68 |
|
69 |
|
|
|
82 |
|
83 |
d = text_embeddings.shape[1]
|
84 |
index = faiss.IndexFlatL2(d)
|
85 |
+
index.add(text_embeddings)"""
|
86 |
|
87 |
|
88 |
def extract_text(file):
|
|
|
123 |
return prompt
|
124 |
|
125 |
def test_func(text):
|
126 |
+
return len(index)
|
127 |
|
128 |
with gr.Blocks() as demo:
|
129 |
|