Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- build_index.py +8 -6
build_index.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
import os
|
| 2 |
-
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, StorageContext
|
| 3 |
-
from llama_index.core import Settings
|
| 4 |
from llama_index.embeddings.fastembed import FastEmbedEmbedding
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
-
#
|
|
|
|
| 9 |
files_to_index = [
|
| 10 |
"./Lebenslauf_SuhasKamuni.pdf",
|
| 11 |
"./about_me.txt",
|
|
@@ -21,7 +21,8 @@ except FileNotFoundError:
|
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
-
#
|
|
|
|
| 25 |
try:
|
| 26 |
embed_model = FastEmbedEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
| 27 |
Settings.embed_model = embed_model
|
|
@@ -32,8 +33,9 @@ except Exception as e:
|
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
-
#
|
|
|
|
| 36 |
index = VectorStoreIndex.from_documents(documents, show_progress=True)
|
| 37 |
index.storage_context.persist(persist_dir="./index_storage")
|
| 38 |
|
| 39 |
-
print("\n✅ Portfolio index built
|
|
|
|
| 1 |
import os
|
| 2 |
+
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex, StorageContext, Settings
|
|
|
|
| 3 |
from llama_index.embeddings.fastembed import FastEmbedEmbedding
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
+
# ----- 1) Load Data -----
|
| 8 |
+
|
| 9 |
files_to_index = [
|
| 10 |
"./Lebenslauf_SuhasKamuni.pdf",
|
| 11 |
"./about_me.txt",
|
|
|
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
+
# ----- 2) Configure Embedding Model -----
|
| 25 |
+
|
| 26 |
try:
|
| 27 |
embed_model = FastEmbedEmbedding(model_name="BAAI/bge-small-en-v1.5")
|
| 28 |
Settings.embed_model = embed_model
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
+
# ----- 3) Build and Store Index -----
|
| 37 |
+
|
| 38 |
index = VectorStoreIndex.from_documents(documents, show_progress=True)
|
| 39 |
index.storage_context.persist(persist_dir="./index_storage")
|
| 40 |
|
| 41 |
+
print("\n✅ Portfolio index built.")
|