Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update auditqa/doc_process.py
Browse files- auditqa/doc_process.py +3 -1
auditqa/doc_process.py
CHANGED
@@ -2,9 +2,11 @@ import glob
|
|
2 |
import os
|
3 |
from langchain.text_splitter import RecursiveCharacterTextSplitter, SentenceTransformersTokenTextSplitter
|
4 |
from transformers import AutoTokenizer
|
|
|
5 |
from langchain_community.document_loaders import PyMuPDFLoader
|
6 |
from langchain_community.embeddings import HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
|
7 |
from langchain_community.vectorstores import Qdrant
|
|
|
8 |
#from dotenv import load_dotenv
|
9 |
#load_dotenv()
|
10 |
|
@@ -55,7 +57,7 @@ def process_pdf():
|
|
55 |
|
56 |
|
57 |
embeddings = HuggingFaceEmbeddings(
|
58 |
-
model_kwargs = {'device':
|
59 |
encode_kwargs = {'normalize_embeddings': True},
|
60 |
model_name="BAAI/bge-small-en-v1.5"
|
61 |
)
|
|
|
2 |
import os
|
3 |
from langchain.text_splitter import RecursiveCharacterTextSplitter, SentenceTransformersTokenTextSplitter
|
4 |
from transformers import AutoTokenizer
|
5 |
+
from torch import cuda
|
6 |
from langchain_community.document_loaders import PyMuPDFLoader
|
7 |
from langchain_community.embeddings import HuggingFaceEmbeddings, HuggingFaceInferenceAPIEmbeddings
|
8 |
from langchain_community.vectorstores import Qdrant
|
9 |
+
device = 'cuda' if cuda.is_available() else 'cpu'
|
10 |
#from dotenv import load_dotenv
|
11 |
#load_dotenv()
|
12 |
|
|
|
57 |
|
58 |
|
59 |
embeddings = HuggingFaceEmbeddings(
|
60 |
+
model_kwargs = {'device': device},
|
61 |
encode_kwargs = {'normalize_embeddings': True},
|
62 |
model_name="BAAI/bge-small-en-v1.5"
|
63 |
)
|