Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,26 +25,6 @@ torch_device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
25 |
print("Running on device:", torch_device)
|
26 |
print("CPU threads:", torch.get_num_threads())
|
27 |
|
28 |
-
loader = PyPDFLoader("total.pdf")
|
29 |
-
pages = loader.load()
|
30 |
-
|
31 |
-
# ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์์ ํ
์คํธ๋ฅผ ์ผ์ ํ ์๋ก ๋๋๊ณ ๊ตฌ๋ถ์๋ก ์ฐ๊ฒฐํ๋ ์์
|
32 |
-
text_splitter = RecursiveCharacterTextSplitter(chunk_size=300, chunk_overlap=0)
|
33 |
-
texts = text_splitter.split_documents(pages)
|
34 |
-
|
35 |
-
print(f"๋ฌธ์์ {len(texts)}๊ฐ์ ๋ฌธ์๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค.")
|
36 |
-
|
37 |
-
# ์๋ฒ ๋ฉ ๋ชจ๋ธ ๋ก๋
|
38 |
-
embeddings = HuggingFaceEmbeddings(model_name="intfloat/multilingual-e5-large")
|
39 |
-
|
40 |
-
# ๋ฌธ์์ ์๋ ํ
์คํธ๋ฅผ ์๋ฒ ๋ฉํ๊ณ FAISS ์ ์ธ๋ฑ์ค๋ฅผ ๊ตฌ์ถํจ
|
41 |
-
index = FAISS.from_documents(
|
42 |
-
documents=texts,
|
43 |
-
embedding=embeddings,
|
44 |
-
)
|
45 |
-
|
46 |
-
# faiss_db ๋ก ๋ก์ปฌ์ ์ ์ฅํ๊ธฐ
|
47 |
-
index.save_local("")
|
48 |
|
49 |
# faiss_db ๋ก ๋ก์ปฌ์ ๋ก๋ํ๊ธฐ
|
50 |
docsearch = FAISS.load_local("", embeddings)
|
|
|
25 |
print("Running on device:", torch_device)
|
26 |
print("CPU threads:", torch.get_num_threads())
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# faiss_db ๋ก ๋ก์ปฌ์ ๋ก๋ํ๊ธฐ
|
30 |
docsearch = FAISS.load_local("", embeddings)
|