ldhldh commited on
Commit
ecf1f13
ยท
1 Parent(s): 21315fc

Update app.py

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